line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geoffrey::Role::Converter; |
2
|
|
|
|
|
|
|
|
3
|
19
|
|
|
19
|
|
30757
|
use utf8; |
|
19
|
|
|
|
|
54
|
|
|
19
|
|
|
|
|
97
|
|
4
|
19
|
|
|
19
|
|
634
|
use Carp qw/croak/; |
|
19
|
|
|
|
|
37
|
|
|
19
|
|
|
|
|
911
|
|
5
|
19
|
|
|
19
|
|
106
|
use strict; |
|
19
|
|
|
|
|
36
|
|
|
19
|
|
|
|
|
375
|
|
6
|
19
|
|
|
19
|
|
117
|
use warnings; |
|
19
|
|
|
|
|
36
|
|
|
19
|
|
|
|
|
603
|
|
7
|
19
|
|
|
19
|
|
8697
|
use Perl::Version; |
|
19
|
|
|
|
|
59988
|
|
|
19
|
|
|
|
|
27869
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$Geoffrey::Role::Converter::VERSION = '0.000205'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
33
|
|
|
33
|
1
|
10625
|
my $class = shift; |
13
|
33
|
|
|
|
|
100
|
my $self = {@_}; |
14
|
33
|
|
|
|
|
127
|
return bless $self, $class; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub changelog_table { |
18
|
26
|
|
100
|
26
|
1
|
93
|
$_[0]->{changelog_table} //= 'geoffrey_changelogs'; |
19
|
26
|
|
|
|
|
91
|
return $_[0]->{changelog_table}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub changelog_columns { |
23
|
|
|
|
|
|
|
return [{ |
24
|
3
|
|
|
3
|
1
|
69
|
name => 'id', |
25
|
|
|
|
|
|
|
type => 'varchar', |
26
|
|
|
|
|
|
|
lenght => 64, |
27
|
|
|
|
|
|
|
primarykey => 1, |
28
|
|
|
|
|
|
|
notnull => 1, |
29
|
|
|
|
|
|
|
default => '\'\'' |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
{name => 'created_by', type => 'varchar', lenght => 128, notnull => 1, default => '\'\'',}, |
32
|
|
|
|
|
|
|
{name => 'filename', type => 'varchar', lenght => 255,}, |
33
|
|
|
|
|
|
|
{name => 'md5sum', type => 'varchar', lenght => 64,}, |
34
|
|
|
|
|
|
|
{name => 'description', type => 'varchar', lenght => 255,}, |
35
|
|
|
|
|
|
|
{name => 'comment', type => 'varchar', lenght => 128,}, |
36
|
|
|
|
|
|
|
{ |
37
|
|
|
|
|
|
|
name => 'geoffrey_version', |
38
|
|
|
|
|
|
|
type => 'varchar', |
39
|
|
|
|
|
|
|
lenght => 16, |
40
|
|
|
|
|
|
|
notnull => 1, |
41
|
|
|
|
|
|
|
default => '\'\'' |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
{name => 'created', type => 'timestamp', default => 'current_timestamp', notnull => 1,}, |
44
|
|
|
|
|
|
|
]; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub origin_types { |
48
|
|
|
|
|
|
|
return [ |
49
|
83
|
|
|
83
|
1
|
868
|
'abstime', 'aclitem', #Al |
50
|
|
|
|
|
|
|
'bigint', 'bigserial', 'bit', 'varbit', 'blob', 'bool', 'box', 'bytea', #B |
51
|
|
|
|
|
|
|
'char', 'character', 'varchar', 'cid', 'cidr', 'circle', #C |
52
|
|
|
|
|
|
|
'date', 'daterange', 'double', 'double_precision', 'decimal', #D |
53
|
|
|
|
|
|
|
#E |
54
|
|
|
|
|
|
|
#F |
55
|
|
|
|
|
|
|
'gtsvector', #G |
56
|
|
|
|
|
|
|
#H |
57
|
|
|
|
|
|
|
'inet', 'int2vector', 'int4range', 'int8range', 'integer', 'interval', #I |
58
|
|
|
|
|
|
|
'json', #J |
59
|
|
|
|
|
|
|
#K |
60
|
|
|
|
|
|
|
'line', 'lseg', #L |
61
|
|
|
|
|
|
|
'macaddr', 'money', #M |
62
|
|
|
|
|
|
|
'name', 'numeric', 'numrange', #N |
63
|
|
|
|
|
|
|
'oid', 'oidvector', #O |
64
|
|
|
|
|
|
|
'path', 'pg_node_tree', 'point', 'polygon', #P |
65
|
|
|
|
|
|
|
#Q |
66
|
|
|
|
|
|
|
'real', 'refcursor', 'regclass', 'regconfig', 'regdictionary', 'regoper', 'regoperator', |
67
|
|
|
|
|
|
|
'regproc', 'regprocedure', 'regtype', 'reltime', #R |
68
|
|
|
|
|
|
|
'serial', 'smallint', 'smallserial', 'smgr', #S |
69
|
|
|
|
|
|
|
'text', 'tid', 'timestamp', 'timestamp_tz', 'time', 'time_tz', 'tinterval', 'tsquery', |
70
|
|
|
|
|
|
|
'tsrange', 'tstzrange', 'tsvector', 'txid_snapshot', #T |
71
|
|
|
|
|
|
|
'uuid', #U |
72
|
|
|
|
|
|
|
#V |
73
|
|
|
|
|
|
|
#W |
74
|
|
|
|
|
|
|
'xid', #X |
75
|
|
|
|
|
|
|
#Y |
76
|
|
|
|
|
|
|
#Z |
77
|
|
|
|
|
|
|
]; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
9
|
|
|
9
|
1
|
44
|
sub min_version { return shift->{min_version} } |
81
|
|
|
|
|
|
|
|
82
|
9
|
|
|
9
|
1
|
46
|
sub max_version { return shift->{max_version} } |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub can_create_empty_table; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub check_version { |
87
|
9
|
|
|
9
|
1
|
7282
|
my ($self, $s_version) = @_; |
88
|
9
|
|
|
|
|
53
|
$s_version = Perl::Version->new($s_version); |
89
|
9
|
|
|
|
|
1051
|
my ($s_max_version, $s_min_version) = undef; |
90
|
9
|
50
|
|
|
|
28
|
eval { $s_min_version = $self->min_version; } or do { }; |
|
9
|
|
|
|
|
66
|
|
91
|
9
|
100
|
|
|
|
17
|
eval { $s_max_version = $self->max_version; } or do { }; |
|
9
|
|
|
|
|
29
|
|
92
|
9
|
|
|
|
|
29
|
$s_min_version = Perl::Version->new($s_min_version); |
93
|
9
|
100
|
|
|
|
710
|
if ($s_max_version) { |
|
|
100
|
|
|
|
|
|
94
|
3
|
|
|
|
|
7
|
$s_max_version = Perl::Version->new($s_max_version); |
95
|
3
|
100
|
100
|
|
|
231
|
return 1 if ($s_min_version <= $s_version && $s_version <= $s_max_version); |
96
|
2
|
|
|
|
|
85
|
require Geoffrey::Exception::NotSupportedException; |
97
|
2
|
|
|
|
|
11
|
Geoffrey::Exception::NotSupportedException::throw_version($self, $s_min_version, |
98
|
|
|
|
|
|
|
$s_version, $s_max_version); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
elsif ($s_min_version <= $s_version) { |
101
|
5
|
|
|
|
|
188
|
return 1; |
102
|
|
|
|
|
|
|
} |
103
|
1
|
|
|
|
|
39
|
require Geoffrey::Exception::NotSupportedException; |
104
|
1
|
|
|
|
|
4
|
return Geoffrey::Exception::NotSupportedException::throw_version($self, $s_min_version, |
105
|
|
|
|
|
|
|
$s_version); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub type { |
109
|
85
|
|
|
85
|
1
|
262
|
my ($self, $hr_column_params) = @_; |
110
|
85
|
100
|
|
|
|
210
|
if (!$hr_column_params->{type}) { |
111
|
2
|
|
|
|
|
509
|
require Geoffrey::Exception::RequiredValue; |
112
|
2
|
|
|
|
|
16
|
Geoffrey::Exception::RequiredValue::throw_column_type($self); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
my $s_column_type |
115
|
5893
|
|
|
|
|
14103
|
= (grep {/^$hr_column_params->{type}$/sxm} @{$self->origin_types()}) |
|
83
|
|
|
|
|
238
|
|
116
|
|
|
|
|
|
|
? $self->types()->{$hr_column_params->{type}} |
117
|
83
|
100
|
|
|
|
127
|
: undef; |
118
|
83
|
100
|
|
|
|
461
|
if (!$s_column_type) { |
119
|
1
|
|
|
|
|
7
|
require Geoffrey::Exception::NotSupportedException; |
120
|
|
|
|
|
|
|
Geoffrey::Exception::NotSupportedException::throw_column_type($hr_column_params->{type}, |
121
|
1
|
|
|
|
|
5
|
$self); |
122
|
|
|
|
|
|
|
} |
123
|
82
|
50
|
|
|
|
192
|
$s_column_type .= $hr_column_params->{strict} ? '(strict)' : q//; |
124
|
|
|
|
|
|
|
$s_column_type |
125
|
82
|
100
|
|
|
|
188
|
.= defined $hr_column_params->{lenght} ? qq~($hr_column_params->{lenght})~ : q//; |
126
|
82
|
|
|
|
|
313
|
return $s_column_type; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub _get_table_hashref { |
130
|
3
|
|
|
3
|
|
10
|
my ($self, $dbh, $s_name, $ar_columns, $s_schema) = @_; |
131
|
3
|
|
|
|
|
14
|
my $s_select_get_table = $self->select_get_table; |
132
|
3
|
|
|
|
|
22
|
my $sth = $dbh->prepare($s_select_get_table); |
133
|
3
|
50
|
|
|
|
1286
|
if ($s_schema) { |
134
|
0
|
0
|
|
|
|
0
|
$sth->execute($s_schema, $s_name) or Carp::confess $!; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
else { |
137
|
3
|
50
|
|
|
|
196
|
$sth->execute($s_name) or Carp::confess $!; |
138
|
|
|
|
|
|
|
} |
139
|
3
|
|
|
|
|
105
|
my $hr_table = $sth->fetchrow_hashref(); |
140
|
3
|
100
|
|
|
|
38
|
return if defined $hr_table; |
141
|
2
|
|
|
|
|
45
|
return {name => $s_name, columns => $ar_columns,}; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub get_changelog_table_hashref { |
145
|
3
|
|
|
3
|
1
|
10
|
my ($self, $o_dbh, $s_schema) = @_; |
146
|
3
|
|
|
|
|
18
|
return $self->_get_table_hashref( |
147
|
|
|
|
|
|
|
$o_dbh, |
148
|
|
|
|
|
|
|
$self->changelog_table(), |
149
|
|
|
|
|
|
|
$self->changelog_columns(), $s_schema |
150
|
|
|
|
|
|
|
); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub constraints { |
154
|
1
|
|
|
1
|
1
|
58
|
require Geoffrey::Exception::NotSupportedException; |
155
|
1
|
|
|
|
|
5
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub index { |
159
|
1
|
|
|
1
|
1
|
1700
|
require Geoffrey::Exception::NotSupportedException; |
160
|
1
|
|
|
|
|
5
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub table { |
164
|
1
|
|
|
1
|
1
|
1527
|
require Geoffrey::Exception::NotSupportedException; |
165
|
1
|
|
|
|
|
26
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub view { |
169
|
1
|
|
|
1
|
1
|
1611
|
require Geoffrey::Exception::NotSupportedException; |
170
|
1
|
|
|
|
|
5
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub foreign_key { |
174
|
1
|
|
|
1
|
1
|
1517
|
require Geoffrey::Exception::NotSupportedException; |
175
|
1
|
|
|
|
|
5
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub trigger { |
179
|
1
|
|
|
1
|
1
|
1511
|
require Geoffrey::Exception::NotSupportedException; |
180
|
1
|
|
|
|
|
5
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub primary_key { |
184
|
1
|
|
|
1
|
1
|
1579
|
require Geoffrey::Exception::NotSupportedException; |
185
|
1
|
|
|
|
|
7
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub sequence { |
189
|
7
|
|
|
7
|
1
|
1541
|
require Geoffrey::Exception::NotSupportedException; |
190
|
7
|
|
|
|
|
32
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub function { |
194
|
6
|
|
|
6
|
1
|
1628
|
require Geoffrey::Exception::NotSupportedException; |
195
|
6
|
|
|
|
|
28
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub unique { |
199
|
1
|
|
|
1
|
1
|
1528
|
require Geoffrey::Exception::NotSupportedException; |
200
|
1
|
|
|
|
|
5
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
sub colums_information { |
204
|
2
|
|
|
2
|
1
|
1514
|
require Geoffrey::Exception::NotSupportedException; |
205
|
2
|
|
|
|
|
14
|
return Geoffrey::Exception::NotSupportedException::throw_list_information('colums_information', |
206
|
|
|
|
|
|
|
shift); |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub index_information { |
210
|
2
|
|
|
2
|
1
|
1590
|
require Geoffrey::Exception::NotSupportedException; |
211
|
2
|
|
|
|
|
12
|
return Geoffrey::Exception::NotSupportedException::throw_list_information('index_information', |
212
|
|
|
|
|
|
|
shift); |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub view_information { |
216
|
2
|
|
|
2
|
1
|
1546
|
require Geoffrey::Exception::NotSupportedException; |
217
|
2
|
|
|
|
|
14
|
return Geoffrey::Exception::NotSupportedException::throw_list_information('view_information', |
218
|
|
|
|
|
|
|
shift); |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub sequence_information { |
222
|
1
|
|
|
1
|
1
|
1581
|
require Geoffrey::Exception::NotSupportedException; |
223
|
1
|
|
|
|
|
5
|
return Geoffrey::Exception::NotSupportedException::throw_list_information( |
224
|
|
|
|
|
|
|
'sequence_information', shift); |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
sub primary_key_information { |
228
|
1
|
|
|
1
|
1
|
1512
|
require Geoffrey::Exception::NotSupportedException; |
229
|
1
|
|
|
|
|
5
|
return Geoffrey::Exception::NotSupportedException::throw_list_information( |
230
|
|
|
|
|
|
|
'primary_key_information', shift); |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub function_information { |
234
|
2
|
|
|
2
|
1
|
3188
|
require Geoffrey::Exception::NotSupportedException; |
235
|
2
|
|
|
|
|
10
|
return Geoffrey::Exception::NotSupportedException::throw_list_information( |
236
|
|
|
|
|
|
|
'function_information', shift); |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
sub unique_information { |
240
|
1
|
|
|
1
|
1
|
1572
|
require Geoffrey::Exception::NotSupportedException; |
241
|
1
|
|
|
|
|
5
|
return Geoffrey::Exception::NotSupportedException::throw_list_information('unique_information', |
242
|
|
|
|
|
|
|
shift); |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
sub trigger_information { |
246
|
1
|
|
|
1
|
1
|
1554
|
require Geoffrey::Exception::NotSupportedException; |
247
|
1
|
|
|
|
|
7
|
return Geoffrey::Exception::NotSupportedException::throw_list_information( |
248
|
|
|
|
|
|
|
'trigger_information', shift); |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
1; # End of Geoffrey::converter |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
__END__ |