line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geoffrey::Role::Converter; |
2
|
|
|
|
|
|
|
|
3
|
19
|
|
|
19
|
|
31109
|
use utf8; |
|
19
|
|
|
|
|
59
|
|
|
19
|
|
|
|
|
97
|
|
4
|
19
|
|
|
19
|
|
684
|
use Carp qw/croak/; |
|
19
|
|
|
|
|
45
|
|
|
19
|
|
|
|
|
921
|
|
5
|
19
|
|
|
19
|
|
108
|
use strict; |
|
19
|
|
|
|
|
33
|
|
|
19
|
|
|
|
|
443
|
|
6
|
19
|
|
|
19
|
|
141
|
use warnings; |
|
19
|
|
|
|
|
31
|
|
|
19
|
|
|
|
|
587
|
|
7
|
19
|
|
|
19
|
|
8255
|
use Perl::Version; |
|
19
|
|
|
|
|
58689
|
|
|
19
|
|
|
|
|
26111
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$Geoffrey::Role::Converter::VERSION = '0.000203'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
33
|
|
|
33
|
1
|
10526
|
my $class = shift; |
13
|
33
|
|
|
|
|
113
|
my $self = {@_}; |
14
|
33
|
|
|
|
|
156
|
return bless $self, $class; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub changelog_table { |
18
|
26
|
|
100
|
26
|
1
|
123
|
$_[0]->{changelog_table} //= 'geoffrey_changelogs'; |
19
|
26
|
|
|
|
|
107
|
return $_[0]->{changelog_table}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub changelog_columns { |
23
|
|
|
|
|
|
|
return [{ |
24
|
3
|
|
|
3
|
1
|
118
|
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
|
908
|
'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
|
59
|
sub min_version { return shift->{min_version} } |
81
|
|
|
|
|
|
|
|
82
|
9
|
|
|
9
|
1
|
49
|
sub max_version { return shift->{max_version} } |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub can_create_empty_table; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub check_version { |
87
|
9
|
|
|
9
|
1
|
7174
|
my ($self, $s_version) = @_; |
88
|
9
|
|
|
|
|
64
|
$s_version = Perl::Version->new($s_version); |
89
|
9
|
|
|
|
|
1128
|
my ($s_max_version, $s_min_version) = undef; |
90
|
9
|
50
|
|
|
|
21
|
eval { $s_min_version = $self->min_version; } or do { }; |
|
9
|
|
|
|
|
66
|
|
91
|
9
|
100
|
|
|
|
22
|
eval { $s_max_version = $self->max_version; } or do { }; |
|
9
|
|
|
|
|
37
|
|
92
|
9
|
|
|
|
|
33
|
$s_min_version = Perl::Version->new($s_min_version); |
93
|
9
|
100
|
|
|
|
712
|
if ($s_max_version) { |
|
|
100
|
|
|
|
|
|
94
|
3
|
|
|
|
|
9
|
$s_max_version = Perl::Version->new($s_max_version); |
95
|
3
|
100
|
100
|
|
|
226
|
return 1 if ($s_min_version <= $s_version && $s_version <= $s_max_version); |
96
|
2
|
|
|
|
|
84
|
require Geoffrey::Exception::NotSupportedException; |
97
|
2
|
|
|
|
|
15
|
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
|
|
|
|
|
207
|
return 1; |
102
|
|
|
|
|
|
|
} |
103
|
1
|
|
|
|
|
44
|
require Geoffrey::Exception::NotSupportedException; |
104
|
1
|
|
|
|
|
5
|
return Geoffrey::Exception::NotSupportedException::throw_version($self, $s_min_version, |
105
|
|
|
|
|
|
|
$s_version); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub type { |
109
|
85
|
|
|
85
|
1
|
279
|
my ($self, $hr_column_params) = @_; |
110
|
85
|
100
|
|
|
|
198
|
if (!$hr_column_params->{type}) { |
111
|
2
|
|
|
|
|
547
|
require Geoffrey::Exception::RequiredValue; |
112
|
2
|
|
|
|
|
13
|
Geoffrey::Exception::RequiredValue::throw_column_type($self); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
my $s_column_type |
115
|
5893
|
|
|
|
|
14615
|
= (grep {/^$hr_column_params->{type}$/sxm} @{$self->origin_types()}) |
|
83
|
|
|
|
|
248
|
|
116
|
|
|
|
|
|
|
? $self->types()->{$hr_column_params->{type}} |
117
|
83
|
100
|
|
|
|
125
|
: undef; |
118
|
83
|
100
|
|
|
|
470
|
if (!$s_column_type) { |
119
|
1
|
|
|
|
|
8
|
require Geoffrey::Exception::NotSupportedException; |
120
|
|
|
|
|
|
|
Geoffrey::Exception::NotSupportedException::throw_column_type($hr_column_params->{type}, |
121
|
1
|
|
|
|
|
7
|
$self); |
122
|
|
|
|
|
|
|
} |
123
|
82
|
50
|
|
|
|
217
|
$s_column_type .= $hr_column_params->{strict} ? '(strict)' : q//; |
124
|
|
|
|
|
|
|
$s_column_type |
125
|
82
|
100
|
|
|
|
217
|
.= defined $hr_column_params->{lenght} ? qq~($hr_column_params->{lenght})~ : q//; |
126
|
82
|
|
|
|
|
309
|
return $s_column_type; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub _get_table_hashref { |
130
|
3
|
|
|
3
|
|
13
|
my ($self, $dbh, $s_name, $ar_columns, $s_schema) = @_; |
131
|
3
|
|
|
|
|
15
|
my $s_select_get_table = $self->select_get_table; |
132
|
3
|
|
|
|
|
39
|
my $sth = $dbh->prepare($s_select_get_table); |
133
|
3
|
50
|
|
|
|
1387
|
if ($s_schema) { |
134
|
0
|
0
|
|
|
|
0
|
$sth->execute($s_schema, $s_name) or Carp::confess $!; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
else { |
137
|
3
|
50
|
|
|
|
201
|
$sth->execute($s_name) or Carp::confess $!; |
138
|
|
|
|
|
|
|
} |
139
|
3
|
|
|
|
|
140
|
my $hr_table = $sth->fetchrow_hashref(); |
140
|
3
|
100
|
|
|
|
46
|
return if defined $hr_table; |
141
|
2
|
|
|
|
|
48
|
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
|
|
|
|
|
22
|
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
|
60
|
require Geoffrey::Exception::NotSupportedException; |
155
|
1
|
|
|
|
|
5
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub index { |
159
|
1
|
|
|
1
|
1
|
1662
|
require Geoffrey::Exception::NotSupportedException; |
160
|
1
|
|
|
|
|
5
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub table { |
164
|
1
|
|
|
1
|
1
|
1600
|
require Geoffrey::Exception::NotSupportedException; |
165
|
1
|
|
|
|
|
24
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub view { |
169
|
1
|
|
|
1
|
1
|
1553
|
require Geoffrey::Exception::NotSupportedException; |
170
|
1
|
|
|
|
|
5
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub foreign_key { |
174
|
1
|
|
|
1
|
1
|
1571
|
require Geoffrey::Exception::NotSupportedException; |
175
|
1
|
|
|
|
|
5
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub trigger { |
179
|
1
|
|
|
1
|
1
|
1523
|
require Geoffrey::Exception::NotSupportedException; |
180
|
1
|
|
|
|
|
5
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub primary_key { |
184
|
1
|
|
|
1
|
1
|
1532
|
require Geoffrey::Exception::NotSupportedException; |
185
|
1
|
|
|
|
|
5
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub sequence { |
189
|
7
|
|
|
7
|
1
|
1598
|
require Geoffrey::Exception::NotSupportedException; |
190
|
7
|
|
|
|
|
31
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub function { |
194
|
6
|
|
|
6
|
1
|
1586
|
require Geoffrey::Exception::NotSupportedException; |
195
|
6
|
|
|
|
|
26
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub unique { |
199
|
1
|
|
|
1
|
1
|
1567
|
require Geoffrey::Exception::NotSupportedException; |
200
|
1
|
|
|
|
|
5
|
return Geoffrey::Exception::NotSupportedException::throw_converter(); |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
sub colums_information { |
204
|
2
|
|
|
2
|
1
|
1524
|
require Geoffrey::Exception::NotSupportedException; |
205
|
2
|
|
|
|
|
11
|
return Geoffrey::Exception::NotSupportedException::throw_list_information('colums_information', |
206
|
|
|
|
|
|
|
shift); |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub index_information { |
210
|
2
|
|
|
2
|
1
|
1573
|
require Geoffrey::Exception::NotSupportedException; |
211
|
2
|
|
|
|
|
11
|
return Geoffrey::Exception::NotSupportedException::throw_list_information('index_information', |
212
|
|
|
|
|
|
|
shift); |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub view_information { |
216
|
2
|
|
|
2
|
1
|
1589
|
require Geoffrey::Exception::NotSupportedException; |
217
|
2
|
|
|
|
|
12
|
return Geoffrey::Exception::NotSupportedException::throw_list_information('view_information', |
218
|
|
|
|
|
|
|
shift); |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub sequence_information { |
222
|
1
|
|
|
1
|
1
|
1538
|
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
|
1587
|
require Geoffrey::Exception::NotSupportedException; |
229
|
1
|
|
|
|
|
6
|
return Geoffrey::Exception::NotSupportedException::throw_list_information( |
230
|
|
|
|
|
|
|
'primary_key_information', shift); |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub function_information { |
234
|
2
|
|
|
2
|
1
|
3201
|
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
|
1534
|
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
|
1580
|
require Geoffrey::Exception::NotSupportedException; |
247
|
1
|
|
|
|
|
6
|
return Geoffrey::Exception::NotSupportedException::throw_list_information( |
248
|
|
|
|
|
|
|
'trigger_information', shift); |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
1; # End of Geoffrey::converter |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
__END__ |