line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package SQL::Admin::Driver::Base::Producer; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
1390
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
83
|
|
5
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
118
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = v0.5.0; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
###################################################################### |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
602
|
use SQL::Admin::Utils qw( refarray refhash ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
6785
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
###################################################################### |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $AUTOLOAD; |
16
|
|
|
|
|
|
|
our $STATEMENT_SEPARATOR = ";\n\n"; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
###################################################################### |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my %numbers = ( |
21
|
|
|
|
|
|
|
int2 => 1, |
22
|
|
|
|
|
|
|
int4 => 1, |
23
|
|
|
|
|
|
|
int8 => 1, |
24
|
|
|
|
|
|
|
real => 1, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
###################################################################### |
28
|
|
|
|
|
|
|
###################################################################### |
29
|
|
|
|
|
|
|
sub new { # ; |
30
|
1
|
|
|
1
|
0
|
1025
|
my ($class, %param) = @_; |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
33
|
|
|
13
|
bless \ %param, ref $class || $class; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
###################################################################### |
37
|
|
|
|
|
|
|
###################################################################### |
38
|
|
|
|
|
|
|
sub produce { # ; |
39
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
40
|
0
|
|
|
|
|
0
|
local $, = ' '; |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
0
|
join '', ( |
43
|
|
|
|
|
|
|
map +($_, $STATEMENT_SEPARATOR), |
44
|
|
|
|
|
|
|
map $self->__process ($_), |
45
|
|
|
|
|
|
|
map refarray ($_) ? @$_ : $_, |
46
|
|
|
|
|
|
|
@_ |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
###################################################################### |
52
|
|
|
|
|
|
|
###################################################################### |
53
|
|
|
|
|
|
|
sub __process { # ; |
54
|
0
|
|
|
0
|
|
0
|
my ($self, $def) = @_; |
55
|
|
|
|
|
|
|
|
56
|
0
|
0
|
|
|
|
0
|
return $def |
57
|
|
|
|
|
|
|
unless ref $def; |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
0
|
return map $self->__apply (%$_), @$def |
60
|
|
|
|
|
|
|
if refarray $def; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
0
|
return map $self->__call ($_, $def), keys %$def |
63
|
|
|
|
|
|
|
if refhash $def; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
###################################################################### |
68
|
|
|
|
|
|
|
###################################################################### |
69
|
|
|
|
|
|
|
sub __apply { # ; |
70
|
61
|
|
|
61
|
|
110
|
my ($self, $method, $def, @param) = @_; |
71
|
|
|
|
|
|
|
|
72
|
61
|
|
|
|
|
62
|
my $retval = join $,, do { |
73
|
61
|
|
|
|
|
70
|
local $, = ' '; |
74
|
61
|
|
|
|
|
66
|
local $_ = $def; |
75
|
61
|
|
|
|
|
312
|
$self->$method ($def, @param) |
76
|
|
|
|
|
|
|
}; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
################################################################## |
79
|
|
|
|
|
|
|
|
80
|
61
|
100
|
|
|
|
165
|
return $retval unless wantarray; |
81
|
45
|
|
|
|
|
335
|
grep length $_, $retval; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
###################################################################### |
86
|
|
|
|
|
|
|
###################################################################### |
87
|
|
|
|
|
|
|
sub __call { # ; |
88
|
364
|
|
|
364
|
|
119027
|
my ($self, $method, $def, @param) = @_; |
89
|
|
|
|
|
|
|
|
90
|
364
|
50
|
|
|
|
911
|
return unless refhash $def; |
91
|
364
|
100
|
|
|
|
1067
|
return unless exists $def->{$method}; |
92
|
|
|
|
|
|
|
|
93
|
249
|
|
|
|
|
254
|
my $retval = join $,, do { |
94
|
249
|
|
|
|
|
312
|
local $, = ' '; |
95
|
249
|
|
|
|
|
362
|
local $_ = $def->{$method}; |
96
|
249
|
|
|
|
|
881
|
$self->$method ($def->{$method}, $def) |
97
|
|
|
|
|
|
|
}; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
################################################################## |
100
|
|
|
|
|
|
|
|
101
|
249
|
100
|
|
|
|
790
|
return $retval unless wantarray; |
102
|
156
|
|
|
|
|
640
|
grep length $_, $retval; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
###################################################################### |
107
|
|
|
|
|
|
|
###################################################################### |
108
|
|
|
|
|
|
|
sub __values { # ; |
109
|
0
|
|
|
0
|
|
0
|
my ($self, $def) = @_; |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
0
|
|
|
0
|
join $,, sort $self->__process ($def || {}); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
###################################################################### |
116
|
|
|
|
|
|
|
###################################################################### |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub _escape_identifier { # ; |
119
|
0
|
|
|
0
|
|
0
|
$_[1]; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
###################################################################### |
124
|
|
|
|
|
|
|
###################################################################### |
125
|
|
|
|
|
|
|
sub identifier { # ; |
126
|
124
|
|
|
124
|
0
|
343
|
shift->_escape_identifier (@_); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
###################################################################### |
131
|
|
|
|
|
|
|
###################################################################### |
132
|
|
|
|
|
|
|
sub integer { # ; |
133
|
5
|
|
|
5
|
0
|
92
|
$_[1]; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
###################################################################### |
138
|
|
|
|
|
|
|
###################################################################### |
139
|
|
|
|
|
|
|
sub numeric_constant { # ; |
140
|
10
|
|
|
10
|
0
|
26
|
$_[1]; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
###################################################################### |
145
|
|
|
|
|
|
|
###################################################################### |
146
|
|
|
|
|
|
|
sub string { # ; |
147
|
2
|
|
|
2
|
0
|
148
|
my ($self, $def) = @_; |
148
|
|
|
|
|
|
|
|
149
|
2
|
|
|
|
|
5
|
$def =~ s/(?=\')/\'/; |
150
|
2
|
|
|
|
|
9
|
'\'' . $def . '\''; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
###################################################################### |
155
|
|
|
|
|
|
|
###################################################################### |
156
|
|
|
|
|
|
|
sub data_type { # ; |
157
|
26
|
|
|
26
|
0
|
34
|
my ($self, $type, $parent) = @_; |
158
|
|
|
|
|
|
|
|
159
|
26
|
100
|
100
|
|
|
53
|
if (refhash $parent and $parent->{size}) { |
160
|
7
|
|
|
|
|
17
|
$type .= '(' . $parent->{size}; |
161
|
7
|
100
|
|
|
|
21
|
$type .= ',' . $parent->{scale} if defined $parent->{scale}; |
162
|
7
|
|
|
|
|
12
|
$type .= ')'; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
26
|
|
|
|
|
88
|
$type; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
###################################################################### |
170
|
|
|
|
|
|
|
###################################################################### |
171
|
|
|
|
|
|
|
sub column_name { # ; |
172
|
57
|
|
|
57
|
0
|
128
|
shift->identifier (@_); |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
###################################################################### |
177
|
|
|
|
|
|
|
###################################################################### |
178
|
|
|
|
|
|
|
sub column_order { # ; |
179
|
12
|
|
|
12
|
0
|
51
|
map uc, grep defined $_, $_[1]; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
###################################################################### |
184
|
|
|
|
|
|
|
###################################################################### |
185
|
|
|
|
|
|
|
sub ordered_column_name { # ; |
186
|
24
|
|
|
24
|
0
|
35
|
my ($self, $def) = @_; |
187
|
|
|
|
|
|
|
|
188
|
24
|
|
|
|
|
51
|
join ' ', grep $_, ( |
189
|
|
|
|
|
|
|
$self->__call (column_name => $def), |
190
|
|
|
|
|
|
|
$self->__call (column_order => $def), |
191
|
|
|
|
|
|
|
) |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
###################################################################### |
196
|
|
|
|
|
|
|
###################################################################### |
197
|
|
|
|
|
|
|
sub ordered_column_names { # ; |
198
|
13
|
|
|
13
|
0
|
16
|
my ($self, $def) = @_; |
199
|
|
|
|
|
|
|
|
200
|
13
|
|
|
|
|
38
|
join ', ', map $self->ordered_column_name ($_), @$def; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
###################################################################### |
205
|
|
|
|
|
|
|
###################################################################### |
206
|
|
|
|
|
|
|
sub schema_qualified_name { # ; |
207
|
33
|
|
|
33
|
0
|
49
|
my ($self, $def) = @_; |
208
|
|
|
|
|
|
|
|
209
|
33
|
|
|
|
|
123
|
join '.', |
210
|
|
|
|
|
|
|
map $self->identifier ($_), |
211
|
|
|
|
|
|
|
grep $_, |
212
|
|
|
|
|
|
|
@$def{qw{ schema name }}; |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
###################################################################### |
217
|
|
|
|
|
|
|
###################################################################### |
218
|
|
|
|
|
|
|
sub index_name { # ; alias: schema_qualified_name |
219
|
6
|
|
|
6
|
0
|
14
|
shift->schema_qualified_name (@_); |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
###################################################################### |
224
|
|
|
|
|
|
|
###################################################################### |
225
|
|
|
|
|
|
|
sub sequence_name { # ; alias: schema_qualified_name |
226
|
10
|
|
|
10
|
0
|
24
|
shift->schema_qualified_name (@_); |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
###################################################################### |
231
|
|
|
|
|
|
|
###################################################################### |
232
|
|
|
|
|
|
|
sub table_name { # ; alias: schema_qualified_name |
233
|
11
|
|
|
11
|
0
|
29
|
shift->schema_qualified_name (@_); |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
###################################################################### |
238
|
|
|
|
|
|
|
###################################################################### |
239
|
|
|
|
|
|
|
sub view_name { # ; alias: schema_qualified_name |
240
|
3
|
|
|
3
|
0
|
10
|
shift->schema_qualified_name (@_); |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
###################################################################### |
245
|
|
|
|
|
|
|
###################################################################### |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
sub index_unique { # ; |
248
|
2
|
|
|
2
|
0
|
11
|
grep $_[1], 'UNIQUE'; |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
###################################################################### |
253
|
|
|
|
|
|
|
###################################################################### |
254
|
|
|
|
|
|
|
sub index_column_list { # ; |
255
|
8
|
|
|
8
|
0
|
10
|
my ($self, $def) = @_; |
256
|
|
|
|
|
|
|
|
257
|
8
|
|
|
|
|
17
|
'(' . $self->__apply (ordered_column_names => $def) . ')'; |
258
|
|
|
|
|
|
|
} |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
###################################################################### |
261
|
|
|
|
|
|
|
###################################################################### |
262
|
|
|
|
|
|
|
sub index_options { # ; |
263
|
0
|
|
|
0
|
0
|
0
|
shift->__values (@_); |
264
|
|
|
|
|
|
|
} |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
###################################################################### |
268
|
|
|
|
|
|
|
###################################################################### |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
sub not_null { # ; |
271
|
9
|
|
|
9
|
0
|
28
|
grep $_[1], ('NOT', 'NULL'); |
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
###################################################################### |
276
|
|
|
|
|
|
|
###################################################################### |
277
|
|
|
|
|
|
|
sub column_not_null { # ; alias: not_null |
278
|
9
|
|
|
9
|
0
|
24
|
shift->not_null (@_); |
279
|
|
|
|
|
|
|
} |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
###################################################################### |
283
|
|
|
|
|
|
|
###################################################################### |
284
|
|
|
|
|
|
|
sub column_definition { # ; |
285
|
13
|
|
|
13
|
0
|
16
|
my ($self, $def) = @_; |
286
|
|
|
|
|
|
|
|
287
|
13
|
|
|
|
|
34
|
my @retval = ( |
288
|
|
|
|
|
|
|
' ', |
289
|
|
|
|
|
|
|
(map $self->__call ($_ => $def, $def), ( |
290
|
|
|
|
|
|
|
'column_name', |
291
|
|
|
|
|
|
|
'data_type', |
292
|
|
|
|
|
|
|
'column_not_null', |
293
|
|
|
|
|
|
|
'column_primary_key', |
294
|
|
|
|
|
|
|
'column_unique', |
295
|
|
|
|
|
|
|
'default_clause', |
296
|
|
|
|
|
|
|
'autoincrement', |
297
|
|
|
|
|
|
|
)) |
298
|
|
|
|
|
|
|
); |
299
|
|
|
|
|
|
|
|
300
|
13
|
50
|
|
|
|
47
|
$retval[1] .= ' ' x (22 - length $retval[1]) if @retval > 2; |
301
|
13
|
100
|
|
|
|
32
|
$retval[2] .= ' ' x (15 - length $retval[2]) if @retval > 3; |
302
|
|
|
|
|
|
|
|
303
|
13
|
|
|
|
|
48
|
@retval; |
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
###################################################################### |
308
|
|
|
|
|
|
|
###################################################################### |
309
|
|
|
|
|
|
|
sub column_primary_key { # ; |
310
|
0
|
|
|
0
|
0
|
0
|
grep $_[1], ('PRIMARY', 'KEY'); |
311
|
|
|
|
|
|
|
} |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
###################################################################### |
315
|
|
|
|
|
|
|
###################################################################### |
316
|
|
|
|
|
|
|
sub column_unique { # ; |
317
|
0
|
|
|
0
|
0
|
0
|
grep $_[1], ('UNIQUE'); |
318
|
|
|
|
|
|
|
} |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
###################################################################### |
322
|
|
|
|
|
|
|
###################################################################### |
323
|
|
|
|
|
|
|
sub table_content { # ; |
324
|
1
|
|
|
1
|
0
|
2
|
my ($self, $def) = @_; |
325
|
1
|
|
|
|
|
3
|
my $key = 'column_definition'; |
326
|
|
|
|
|
|
|
|
327
|
1
|
|
|
|
|
8
|
my $cols = join ",\n", map ' ' . $_, ( |
328
|
|
|
|
|
|
|
(map $self->__apply (%$_), grep exists $_->{$key}, @$def), |
329
|
|
|
|
|
|
|
(map $self->__apply (%$_), grep !exists $_->{$key}, @$def), |
330
|
|
|
|
|
|
|
); |
331
|
|
|
|
|
|
|
|
332
|
1
|
|
|
|
|
13
|
join "\n", '(', $cols, ')'; |
333
|
|
|
|
|
|
|
} |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
###################################################################### |
337
|
|
|
|
|
|
|
###################################################################### |
338
|
|
|
|
|
|
|
sub table_options { # ; |
339
|
0
|
|
|
0
|
0
|
0
|
shift->__values (@_); |
340
|
|
|
|
|
|
|
} |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
###################################################################### |
344
|
|
|
|
|
|
|
###################################################################### |
345
|
|
|
|
|
|
|
sub add_constraint { # ; |
346
|
6
|
|
|
6
|
0
|
10
|
my ($self, $def) = @_; |
347
|
|
|
|
|
|
|
|
348
|
6
|
|
|
|
|
22
|
"\n ",'ADD', $self->__apply (%$def); |
349
|
|
|
|
|
|
|
} |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
###################################################################### |
353
|
|
|
|
|
|
|
###################################################################### |
354
|
|
|
|
|
|
|
sub add_column { # ; |
355
|
0
|
|
|
0
|
0
|
0
|
my ($self, $def) = @_; |
356
|
|
|
|
|
|
|
|
357
|
0
|
|
|
|
|
0
|
'ADD', 'COLUMN', $self->__process ($def); |
358
|
|
|
|
|
|
|
} |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
###################################################################### |
362
|
|
|
|
|
|
|
###################################################################### |
363
|
|
|
|
|
|
|
sub alter_column { # ; |
364
|
0
|
|
|
0
|
0
|
0
|
my ($self, $def) = @_; |
365
|
0
|
|
|
|
|
0
|
my @action; |
366
|
|
|
|
|
|
|
|
367
|
0
|
0
|
|
|
|
0
|
if (exists $def->{default_clause}) { |
|
|
0
|
|
|
|
|
|
368
|
0
|
0
|
|
|
|
0
|
push @action, |
369
|
|
|
|
|
|
|
defined $def->{default_clause} |
370
|
|
|
|
|
|
|
? ('SET', $self->__call (default_clause => $def, $def)) |
371
|
|
|
|
|
|
|
: ('DROP', 'DEFAULT') |
372
|
|
|
|
|
|
|
; |
373
|
|
|
|
|
|
|
} elsif (exists $def->{not_null}) { |
374
|
0
|
0
|
|
|
|
0
|
push @action, ($def->{not_null} ? 'SET' : 'DROP'), 'NOT', 'NULL'; |
375
|
|
|
|
|
|
|
} |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
################################################################## |
378
|
|
|
|
|
|
|
|
379
|
0
|
|
|
|
|
0
|
'ALTER', 'COLUMN', $self->__call (column_name => $def, $def), @action; |
380
|
|
|
|
|
|
|
} |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
###################################################################### |
384
|
|
|
|
|
|
|
###################################################################### |
385
|
|
|
|
|
|
|
sub primary_key_constraint { # ; |
386
|
6
|
|
|
6
|
0
|
10
|
my ($self, $def) = @_; |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
( |
389
|
6
|
|
|
|
|
20
|
$self->__call (constraint_name => $def), |
390
|
|
|
|
|
|
|
'PRIMARY', |
391
|
|
|
|
|
|
|
'KEY', |
392
|
|
|
|
|
|
|
$self->__call (column_list => $def), |
393
|
|
|
|
|
|
|
); |
394
|
|
|
|
|
|
|
} |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
###################################################################### |
398
|
|
|
|
|
|
|
###################################################################### |
399
|
|
|
|
|
|
|
sub unique_constraint { # ; |
400
|
1
|
|
|
1
|
0
|
3
|
my ($self, $def) = @_; |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
( |
403
|
1
|
|
|
|
|
3
|
$self->__call (constraint_name => $def), |
404
|
|
|
|
|
|
|
'UNIQUE', |
405
|
|
|
|
|
|
|
$self->__call (column_list => $def), |
406
|
|
|
|
|
|
|
); |
407
|
|
|
|
|
|
|
} |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
###################################################################### |
411
|
|
|
|
|
|
|
###################################################################### |
412
|
|
|
|
|
|
|
sub foreign_key_constraint { # ; |
413
|
1
|
|
|
1
|
0
|
2
|
my ($self, $def) = @_; |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
( |
416
|
1
|
|
|
|
|
4
|
$self->__call (constraint_name => $def), |
417
|
|
|
|
|
|
|
'FOREIGN', 'KEY', |
418
|
|
|
|
|
|
|
$self->__call (referencing_column_list => $def), |
419
|
|
|
|
|
|
|
"\n ", 'REFERENCES', |
420
|
|
|
|
|
|
|
$self->__call (referenced_table => $def), |
421
|
|
|
|
|
|
|
$self->__call (referenced_column_list => $def), |
422
|
|
|
|
|
|
|
$self->__call (delete_rule => $def), |
423
|
|
|
|
|
|
|
$self->__call (update_rule => $def), |
424
|
|
|
|
|
|
|
); |
425
|
|
|
|
|
|
|
} |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
###################################################################### |
429
|
|
|
|
|
|
|
###################################################################### |
430
|
|
|
|
|
|
|
sub constraint_name { # ; |
431
|
7
|
|
|
7
|
0
|
12
|
my ($self, $def) = @_; |
432
|
|
|
|
|
|
|
|
433
|
7
|
|
|
|
|
19
|
'CONSTRAINT', $self->identifier ($def), "\n "; |
434
|
|
|
|
|
|
|
} |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
###################################################################### |
438
|
|
|
|
|
|
|
###################################################################### |
439
|
|
|
|
|
|
|
sub column_list { # ; |
440
|
13
|
|
|
13
|
0
|
21
|
my ($self, $def) = @_; |
441
|
|
|
|
|
|
|
|
442
|
13
|
|
|
|
|
38
|
'(' . join (', ', map $self->column_name ($_), @$def) . ')'; |
443
|
|
|
|
|
|
|
} |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
###################################################################### |
446
|
|
|
|
|
|
|
###################################################################### |
447
|
|
|
|
|
|
|
sub referencing_column_list { # ; alias: column_list |
448
|
1
|
|
|
1
|
0
|
5
|
shift->column_list (@_); |
449
|
|
|
|
|
|
|
} |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
###################################################################### |
453
|
|
|
|
|
|
|
###################################################################### |
454
|
|
|
|
|
|
|
sub referenced_column_list { # ; alias: column_list |
455
|
1
|
|
|
1
|
0
|
4
|
shift->column_list (@_); |
456
|
|
|
|
|
|
|
} |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
###################################################################### |
460
|
|
|
|
|
|
|
###################################################################### |
461
|
|
|
|
|
|
|
sub referenced_table { # ; alias: table_name |
462
|
1
|
|
|
1
|
0
|
6
|
shift->table_name (@_); |
463
|
|
|
|
|
|
|
} |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
###################################################################### |
467
|
|
|
|
|
|
|
###################################################################### |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
sub statement_insert { # ; |
470
|
3
|
|
|
3
|
0
|
6
|
my ($self, $def) = @_; |
471
|
|
|
|
|
|
|
|
472
|
3
|
|
33
|
|
|
9
|
join ' ', ( |
473
|
|
|
|
|
|
|
'INSERT', |
474
|
|
|
|
|
|
|
'INTO', |
475
|
|
|
|
|
|
|
$self->__call (table_name => $def), |
476
|
|
|
|
|
|
|
$self->__call (column_list => $def), |
477
|
|
|
|
|
|
|
( |
478
|
|
|
|
|
|
|
$self->__call (insert_value_list => $def) |
479
|
|
|
|
|
|
|
|| $self->__call (statement_select => $def) |
480
|
|
|
|
|
|
|
) |
481
|
|
|
|
|
|
|
); |
482
|
|
|
|
|
|
|
} |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
###################################################################### |
486
|
|
|
|
|
|
|
###################################################################### |
487
|
|
|
|
|
|
|
sub insert_value_list { # ; |
488
|
3
|
|
|
3
|
0
|
6
|
my ($self, $def) = @_; |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
( |
491
|
3
|
|
|
|
|
15
|
'VALUES', '(', |
492
|
|
|
|
|
|
|
join ("),\n (", ( |
493
|
|
|
|
|
|
|
map join (', ', map $self->__apply (%$_), @$_), @$def |
494
|
|
|
|
|
|
|
)), |
495
|
|
|
|
|
|
|
')', |
496
|
|
|
|
|
|
|
) |
497
|
|
|
|
|
|
|
} |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
###################################################################### |
501
|
|
|
|
|
|
|
###################################################################### |
502
|
0
|
|
|
0
|
0
|
0
|
sub insert_values { # ; |
503
|
|
|
|
|
|
|
} |
504
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
sub statement_select { # ; |
506
|
0
|
|
|
0
|
0
|
0
|
my ($self, $def) = @_; |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
( |
509
|
0
|
|
|
|
|
0
|
$self->__call ('select_what', $def), |
510
|
|
|
|
|
|
|
$self->__call ('select_from', $def), |
511
|
|
|
|
|
|
|
$self->__call ('select_where', $def), |
512
|
|
|
|
|
|
|
); |
513
|
|
|
|
|
|
|
} |
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
###################################################################### |
517
|
|
|
|
|
|
|
###################################################################### |
518
|
|
|
|
|
|
|
sub select_what { # ; |
519
|
0
|
|
|
0
|
0
|
0
|
my ($self, $def) = @_; |
520
|
|
|
|
|
|
|
|
521
|
0
|
|
|
|
|
0
|
'SELECT', join ', ', $self->__process ($def); |
522
|
|
|
|
|
|
|
} |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
###################################################################### |
526
|
|
|
|
|
|
|
###################################################################### |
527
|
|
|
|
|
|
|
sub select_from { # ; |
528
|
0
|
|
|
0
|
0
|
0
|
my ($self, $def) = @_; |
529
|
|
|
|
|
|
|
|
530
|
0
|
|
|
|
|
0
|
'FROM', join ', ', $self->__process ($def); |
531
|
|
|
|
|
|
|
} |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
###################################################################### |
535
|
|
|
|
|
|
|
###################################################################### |
536
|
|
|
|
|
|
|
sub select_where { # ; |
537
|
0
|
|
|
0
|
0
|
0
|
my ($self, $def) = @_; |
538
|
|
|
|
|
|
|
|
539
|
0
|
|
|
|
|
0
|
'WHERE', join ', ', $self->__apply (%$def); |
540
|
|
|
|
|
|
|
} |
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
###################################################################### |
544
|
|
|
|
|
|
|
###################################################################### |
545
|
|
|
|
|
|
|
sub subselect { # ; |
546
|
0
|
|
|
0
|
0
|
0
|
my ($self, $def) = @_; |
547
|
|
|
|
|
|
|
|
548
|
0
|
|
|
|
|
0
|
'(', ( |
549
|
|
|
|
|
|
|
$self->statement_select ($def), |
550
|
|
|
|
|
|
|
), ')', $self->__call ('select_name', $def); |
551
|
|
|
|
|
|
|
} |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
###################################################################### |
555
|
|
|
|
|
|
|
###################################################################### |
556
|
|
|
|
|
|
|
sub select_name { # ; alias: identifier |
557
|
0
|
|
|
0
|
0
|
0
|
shift->identifier (@_); |
558
|
|
|
|
|
|
|
} |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
###################################################################### |
562
|
|
|
|
|
|
|
###################################################################### |
563
|
|
|
|
|
|
|
sub _unary_operator { # ; |
564
|
0
|
|
|
0
|
|
0
|
my ($self, $name, $def) = @_; |
565
|
|
|
|
|
|
|
|
566
|
0
|
|
|
|
|
0
|
$name, $self->__process ($def); |
567
|
|
|
|
|
|
|
} |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
###################################################################### |
571
|
|
|
|
|
|
|
###################################################################### |
572
|
|
|
|
|
|
|
sub _binary_operator { # ; |
573
|
0
|
|
|
0
|
|
0
|
my ($self, $name, $def) = @_; |
574
|
|
|
|
|
|
|
|
575
|
0
|
|
|
|
|
0
|
my @retval = map +($name, $self->__process ($_)), @$def; |
576
|
0
|
|
|
|
|
0
|
$retval[0] = '('; |
577
|
|
|
|
|
|
|
|
578
|
0
|
|
|
|
|
0
|
@retval, ')'; |
579
|
|
|
|
|
|
|
} |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
###################################################################### |
583
|
|
|
|
|
|
|
###################################################################### |
584
|
|
|
|
|
|
|
sub operator_not { # ; |
585
|
0
|
|
|
0
|
0
|
0
|
shift->_unary_operator ('NOT', @_); |
586
|
|
|
|
|
|
|
} |
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
###################################################################### |
590
|
|
|
|
|
|
|
###################################################################### |
591
|
|
|
|
|
|
|
sub operator_exists { # ; |
592
|
0
|
|
|
0
|
0
|
0
|
shift->_unary_operator ('EXISTS', @_); |
593
|
|
|
|
|
|
|
} |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
###################################################################### |
596
|
|
|
|
|
|
|
###################################################################### |
597
|
|
|
|
|
|
|
sub operator_and { # ; |
598
|
0
|
|
|
0
|
0
|
0
|
shift->_binary_operator ('AND', @_); |
599
|
|
|
|
|
|
|
} |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
###################################################################### |
603
|
|
|
|
|
|
|
###################################################################### |
604
|
|
|
|
|
|
|
sub operator_equal { # ; |
605
|
0
|
|
|
0
|
0
|
0
|
shift->_binary_operator ('=', @_); |
606
|
|
|
|
|
|
|
} |
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
###################################################################### |
610
|
|
|
|
|
|
|
###################################################################### |
611
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
sub null { # ; |
613
|
1
|
|
|
1
|
0
|
4
|
'NULL'; |
614
|
|
|
|
|
|
|
} |
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
###################################################################### |
618
|
|
|
|
|
|
|
###################################################################### |
619
|
|
|
|
|
|
|
sub default { # ; |
620
|
1
|
|
|
1
|
0
|
3
|
'DEFAULT'; |
621
|
|
|
|
|
|
|
} |
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
###################################################################### |
625
|
|
|
|
|
|
|
###################################################################### |
626
|
|
|
|
|
|
|
|
627
|
0
|
|
|
0
|
|
|
sub DESTROY { # ; |
628
|
|
|
|
|
|
|
} |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
###################################################################### |
632
|
|
|
|
|
|
|
###################################################################### |
633
|
|
|
|
|
|
|
sub AUTOLOAD { # ; |
634
|
0
|
|
|
0
|
|
|
warn $AUTOLOAD; |
635
|
0
|
|
|
|
|
|
(); |
636
|
|
|
|
|
|
|
} |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
###################################################################### |
640
|
|
|
|
|
|
|
###################################################################### |
641
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
package SQL::Admin::Driver::Base::Producer; |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
1; |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
__END__ |