-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathsql-bubble.txt
417 lines (414 loc) · 10.9 KB
/
sql-bubble.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# This file contains the data used by the three syntax diagram rendering
# programs:
#
# bubble-generator.tcl
# bubble-generator-bnf.tcl
# bubble-generator-bnf.tcl
#
# Graphs:
#
set all_graphs {
sql-stmt-list {
toploop {optx sql-stmt} ;
}
sql-stmt {
line
{opt EXPLAIN {opt QUERY PLAN}}
{or
alter-table-stmt
analyze-stmt
attach-stmt
begin-stmt
commit-stmt
create-index-stmt
create-table-stmt
create-trigger-stmt
create-view-stmt
create-virtual-table-stmt
delete-stmt
delete-stmt-limited
detach-stmt
drop-index-stmt
drop-table-stmt
drop-trigger-stmt
drop-view-stmt
insert-stmt
pragma-stmt
reindex-stmt
release-stmt
rollback-stmt
savepoint-stmt
select-stmt
update-stmt
update-stmt-limited
vacuum-stmt
}
}
alter-table-stmt {
stack
{line ALTER TABLE {optx /database-name .} /table-name}
{tailbranch
{line RENAME TO /new-table-name}
{line ADD {optx COLUMN} column-def}
}
}
analyze-stmt {
line ANALYZE {or nil /database-name /table-or-index-name
{line /database-name . /table-or-index-name}}
}
attach-stmt {
line ATTACH {or DATABASE nil} expr AS /database-name
}
begin-stmt {
line BEGIN {or nil DEFERRED IMMEDIATE EXCLUSIVE}
{optx TRANSACTION}
}
commit-stmt {
line {or COMMIT END} {optx TRANSACTION}
}
rollback-stmt {
line ROLLBACK {optx TRANSACTION}
{optx TO {optx SAVEPOINT} /savepoint-name}
}
savepoint-stmt {
line SAVEPOINT /savepoint-name
}
release-stmt {
line RELEASE {optx SAVEPOINT} /savepoint-name
}
create-index-stmt {
stack
{line CREATE {opt UNIQUE} INDEX {opt IF NOT EXISTS}}
{line {optx /database-name .} /index-name
ON /table-name ( {loop indexed-column ,} )}
}
indexed-column {
line /column-name {optx COLLATE /collation-name} {or ASC DESC nil}
}
create-table-stmt {
stack
{line CREATE {or {} TEMP TEMPORARY} TABLE {opt IF NOT EXISTS}}
{line {optx /database-name .} /table-name
{tailbranch
{line ( {loop column-def ,} {loop {} {line , table-constraint}} )}
{line AS select-stmt}
}
}
}
column-def {
line /column-name {or type-name nil} {loop nil {nil column-constraint nil}}
}
type-name {
line {loop /name {}} {or {}
{line ( signed-number )}
{line ( signed-number , signed-number )}
}
}
column-constraint {
stack
{optx CONSTRAINT /name}
{or
{line PRIMARY KEY {or nil ASC DESC}
conflict-clause {opt AUTOINCREMENT}
}
{line NOT NULL conflict-clause}
{line UNIQUE conflict-clause}
{line CHECK ( expr )}
{line DEFAULT
{or
signed-number
literal-value
{line ( expr )}
}
}
{line COLLATE /collation-name}
{line foreign-key-clause}
}
}
signed-number {
line {or nil + -} /numeric-literal
}
table-constraint {
stack
{optx CONSTRAINT /name}
{or
{line {or {line PRIMARY KEY} UNIQUE}
( {loop indexed-column ,} ) conflict-clause}
{line CHECK ( expr )}
{line FOREIGN KEY ( {loop /column-name ,} ) foreign-key-clause }
}
}
foreign-key-clause {
stack
{line REFERENCES /foreign-table {optx ( {loop /column-name ,} )}}
{optx
{loop
{or
{line ON {or DELETE UPDATE}
{or {line SET NULL} {line SET DEFAULT}
CASCADE RESTRICT {line NO ACTION}
}
}
{line MATCH /name}
}
{}
}
}
{optx
{line {optx NOT} DEFERRABLE
{or
{line INITIALLY DEFERRED}
{line INITIALLY IMMEDIATE}
{}
}
}
nil
}
}
conflict-clause {
opt {line ON CONFLICT {or ROLLBACK ABORT FAIL IGNORE REPLACE}}
}
create-trigger-stmt {
stack
{line CREATE {or {} TEMP TEMPORARY} TRIGGER {opt IF NOT EXISTS}}
{line {optx /database-name .} /trigger-name
{or BEFORE AFTER {line INSTEAD OF} nil}
}
{line
{or DELETE INSERT
{line UPDATE {opt OF {loop /column-name ,} }}
}
ON /table-name
}
{line {optx FOR EACH ROW}
{optx WHEN expr}
}
{line BEGIN
{loop
{line {or update-stmt insert-stmt delete-stmt select-stmt} ;}
nil
}
END
}
}
create-view-stmt {
stack
{line CREATE {or {} TEMP TEMPORARY} VIEW {opt IF NOT EXISTS}}
{line {optx /database-name .} /view-name AS select-stmt}
}
create-virtual-table-stmt {
stack
{line CREATE VIRTUAL TABLE {optx /database-name .} /table-name}
{line USING /module-name {optx ( {loop /module-argument ,} )}}
}
delete-stmt {
line DELETE FROM qualified-table-name {optx WHERE expr}
}
delete-stmt-limited {
stack
{line DELETE FROM qualified-table-name {optx WHERE expr}}
{optx
{stack
{optx ORDER BY {loop ordering-term ,}}
{line LIMIT /expr {optx {or OFFSET ,} /expr}}
}
}
}
detach-stmt {
line DETACH {optx DATABASE} /database-name
}
drop-index-stmt {
line DROP INDEX {optx IF EXISTS} {optx /database-name .} /index-name
}
drop-table-stmt {
line DROP TABLE {optx IF EXISTS} {optx /database-name .} /table-name
}
drop-trigger-stmt {
line DROP TRIGGER {optx IF EXISTS} {optx /database-name .} /trigger-name
}
drop-view-stmt {
line DROP VIEW {optx IF EXISTS} {optx /database-name .} /view-name
}
expr {
or
{line literal-value}
{line bind-parameter}
{line {optx {optx /database-name .} /table-name .} /column-name}
{line /unary-operator expr}
{line expr /binary-operator expr}
{line /function-name ( {or {line {optx DISTINCT} {toploop expr ,}} {} *} )}
{line ( expr )}
{line CAST ( expr AS type-name )}
{line expr COLLATE /collation-name}
{line expr {optx NOT} {or LIKE GLOB REGEXP MATCH} expr
{optx ESCAPE expr}}
{line expr {or ISNULL NOTNULL {line NOT NULL}}}
{line expr IS {optx NOT} expr}
{line expr {optx NOT} BETWEEN expr AND expr}
{line expr {optx NOT} IN
{or
{line ( {or {} select-stmt {loop expr ,}} )}
{line {optx /database-name .} /table-name}
}
}
{line {optx {optx NOT} EXISTS} ( select-stmt )}
{line CASE {optx expr} {loop {line WHEN expr THEN expr} {}}
{optx ELSE expr} END}
{line raise-function}
}
raise-function {
line RAISE (
{or IGNORE
{line {or ROLLBACK ABORT FAIL} , /error-message }
} )
}
literal-value {
or
{line /numeric-literal}
{line /string-literal}
{line /blob-literal}
{line NULL}
{line CURRENT_TIME}
{line CURRENT_DATE}
{line CURRENT_TIMESTAMP}
}
numeric-literal {
line {or
{line {loop /digit nil} {opt /decimal-point {loop nil /digit}}}
{line /decimal-point {loop /digit nil}}
}
{opt E {or nil + -} {loop /digit nil}}
}
insert-stmt {
stack
{line
{or
{line INSERT {opt OR {or ROLLBACK ABORT REPLACE FAIL IGNORE}}}
REPLACE
}
INTO {optx /database-name .} /table-name
}
{tailbranch
{line
{optx ( {loop /column-name ,} )}
{tailbranch
{line VALUES ( {loop expr ,} )}
select-stmt
}
}
{line DEFAULT VALUES}
}
}
pragma-stmt {
line PRAGMA {optx /database-name .} /pragma-name
{or
nil
{line = pragma-value}
{line ( pragma-value )}
}
}
pragma-value {
or
signed-number
/name
/string-literal
}
reindex-stmt {
line REINDEX
{tailbranch nil
/collation-name
{line {optx /database-name .}
{tailbranch /table-name /index-name}
}
}
}
select-stmt {
stack
{loop {line select-core nil} {nil compound-operator nil}}
{optx ORDER BY {loop ordering-term ,}}
{optx LIMIT /expr {optx {or OFFSET ,} /expr}}
}
select-core {
stack
{line SELECT {or nil DISTINCT ALL} {loop result-column ,}}
{optx FROM join-source}
{optx WHERE expr}
{optx GROUP BY {loop ordering-term ,} {optx HAVING expr}}
}
result-column {
or
*
{line /table-name . *}
{line expr {optx {optx AS} /column-alias}}
}
join-source {
line
single-source
{opt {loop {line nil join-op single-source join-constraint nil} {}}}
}
single-source {
or
{line
{optx /database-name .} /table-name
{optx {optx AS} /table-alias}
{or nil {line INDEXED BY /index-name} {line NOT INDEXED}}
}
{line
( select-stmt ) {optx {optx AS} /table-alias}
}
{line ( join-source )}
}
join-op {
or
{line ,}
{line
{opt NATURAL}
{or nil {line LEFT {or OUTER nil}} INNER CROSS}
JOIN
}
}
join-constraint {
or
{line ON expr}
{line USING ( {loop /column-name ,} )}
nil
}
ordering-term {
line expr {opt COLLATE /collation-name} {or nil ASC DESC}
}
compound-operator {
or {line UNION {optx ALL}} INTERSECT EXCEPT
}
update-stmt {
stack
{line UPDATE {opt OR {or ROLLBACK ABORT REPLACE FAIL IGNORE}}
qualified-table-name}
{line SET {loop {line /column-name = expr} ,} {optx WHERE expr}}
}
update-stmt-limited {
stack
{line UPDATE {opt OR {or ROLLBACK ABORT REPLACE FAIL IGNORE}}
qualified-table-name}
{line SET {loop {line /column-name = expr} ,} {optx WHERE expr}}
{optx
{stack
{optx ORDER BY {loop ordering-term ,}}
{line LIMIT /expr {optx {or OFFSET ,} /expr}}
}
}
}
qualified-table-name {
line {optx /database-name .} /table-name
{or nil {line INDEXED BY /index-name} {line NOT INDEXED}}
}
vacuum-stmt {
line VACUUM
}
comment-syntax {
or
{line -- {loop nil /anything-except-newline}
{or /newline /end-of-input}}
{line /* {loop nil /anything-except-*/}
{or */ /end-of-input}}
}
}