myrtille 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- myrtille/lib/cfg.py +12 -0
- myrtille/lib/db.py +120 -0
- myrtille/lib/util.py +9 -0
- myrtille/mysql/export.py +59 -0
- myrtille/mysql/generator.py +353 -0
- myrtille/mysql/grammar.lark +692 -0
- myrtille/mysql/parser.py +1093 -0
- myrtille/mysql/types.py +676 -0
- myrtille-0.1.2.dist-info/METADATA +23 -0
- myrtille-0.1.2.dist-info/RECORD +12 -0
- {myrtille-0.1.0.dist-info → myrtille-0.1.2.dist-info}/WHEEL +1 -1
- myrtille-0.1.2.dist-info/licenses/LICENSE +21 -0
- myrtille/__init__.py +0 -2
- myrtille-0.1.0.dist-info/METADATA +0 -6
- myrtille-0.1.0.dist-info/RECORD +0 -5
- myrtille-0.1.0.dist-info/entry_points.txt +0 -2
|
@@ -0,0 +1,692 @@
|
|
|
1
|
+
create_table: "CREATE"i "TABLE"i identifier ["(" table_element_list ")"] [create_table_options] [partition_clause]
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
partition_clause: "PARTITION"i "BY"i (range_partition_clause | list_partition_clause | key_hash_partition_clause)
|
|
5
|
+
subpartition_clause: "SUBPARTITION"i "BY"i key_hash_partition_type ["SUBPARTITIONS"i int_literal]
|
|
6
|
+
|
|
7
|
+
LINEAR: "LINEAR"i
|
|
8
|
+
key_hash_partition_type: [LINEAR] "HASH"i expr_with_par -> hash_partition_type
|
|
9
|
+
| [LINEAR] "KEY"i ["1" | "2"] identifier_list_with_par -> key_partition_type
|
|
10
|
+
|
|
11
|
+
expr_or_columns: expr_with_par | COLUMNS "(" [identifier_list] ")"
|
|
12
|
+
|
|
13
|
+
range_partition_clause: "RANGE"i expr_or_columns [subpartition_clause] range_partitions
|
|
14
|
+
list_partition_clause: "LIST"i expr_or_columns [subpartition_clause] list_partitions
|
|
15
|
+
key_hash_partition_clause: key_hash_partition_type ["PARTITIONS"i int_literal] [key_hash_partitions]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
partition_option: "TABLESPACE"i ["="] identifier -> tablespace_partition_option
|
|
20
|
+
| ["STORAGE"i] "ENGINE"i ["="] identifier -> engine_partition_option
|
|
21
|
+
| "NODEGROUP"i ["="] int_literal -> nodegroup_partition_option
|
|
22
|
+
| "MAX_ROWS"i ["="] int_literal -> max_rows_partition_option
|
|
23
|
+
| "MIN_ROWS"i ["="] int_literal -> min_rows_partition_option
|
|
24
|
+
| "DATA"i "DIRECTORY"i ["="] text_literal -> data_directory_partition_option
|
|
25
|
+
| "INDEX"i "DIRECTORY"i ["="] text_literal -> index_directory_partition_option
|
|
26
|
+
| "COMMENT"i ["="] text_literal -> comment_partition_option
|
|
27
|
+
|
|
28
|
+
partition_options: partition_option*
|
|
29
|
+
|
|
30
|
+
max_value: "MAXVALUE"i
|
|
31
|
+
partition_lt_value: expr | max_value
|
|
32
|
+
partition_lt_value_list: "(" partition_lt_value ("," partition_lt_value)* ")"
|
|
33
|
+
|
|
34
|
+
partition_in_value_list: "(" expr_list ")"
|
|
35
|
+
partition_in_value_list_list: "(" partition_in_value_list ("," partition_in_value_list)* ")"
|
|
36
|
+
|
|
37
|
+
partition_values_lt: "VALUES"i "LESS"i "THAN"i (partition_lt_value_list | max_value)
|
|
38
|
+
range_partition: "PARTITION"i identifier partition_values_lt partition_options [key_hash_subpartitions]
|
|
39
|
+
range_partitions: "(" range_partition ("," range_partition)* ")"
|
|
40
|
+
|
|
41
|
+
partition_values_in: "VALUES"i "IN"i partition_in_value_list | partition_in_value_list_list
|
|
42
|
+
list_partition: "PARTITION"i identifier partition_values_in partition_options [key_hash_subpartitions]
|
|
43
|
+
list_partitions: "(" list_partition ("," list_partition)* ")"
|
|
44
|
+
|
|
45
|
+
key_hash_partition_def: identifier partition_options
|
|
46
|
+
key_hash_partition: "PARTITION"i key_hash_partition_def
|
|
47
|
+
key_hash_partitions: "(" key_hash_partition ("," key_hash_partition)* ")"
|
|
48
|
+
key_hash_subpartition: "SUBPARTITION"i key_hash_partition_def
|
|
49
|
+
key_hash_subpartitions: "(" key_hash_subpartition ("," key_hash_subpartition)* ")"
|
|
50
|
+
|
|
51
|
+
create_table_options: create_table_option ([","] create_table_option)*
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
create_table_option: "ENGINE"i ["="] identifier -> engine_create_option
|
|
55
|
+
| "SECONDARY_ENGINE"i ["="] identifier -> secondary_engine_create_option
|
|
56
|
+
| "MAX_ROWS"i ["="] int_literal -> max_rows_create_option
|
|
57
|
+
| "MIN_ROWS"i ["="] int_literal -> min_rows_create_option
|
|
58
|
+
| "AVG_ROW_LENGTH"i ["="] int_literal -> avg_row_length_create_option
|
|
59
|
+
| "PASSWORD"i ["="] text_literal -> password_create_option
|
|
60
|
+
| "COMMENT"i ["="] text_literal -> comment_create_option
|
|
61
|
+
| "COMPRESSION"i ["="] text_literal -> compression_create_option
|
|
62
|
+
| "ENCRYPTION"i ["="] text_literal -> encryption_create_option
|
|
63
|
+
| "AUTO_INCREMENT"i ["="] int_literal -> auto_increment_create_option
|
|
64
|
+
| "PACK_KEYS"i ["="] ternary_option -> pack_keys_create_option
|
|
65
|
+
| "STATS_AUTO_RECALC"i ["="] ternary_option -> stats_auto_recalc_create_option
|
|
66
|
+
| "STATS_PERSISTENT"i ["="] ternary_option -> stats_persistent_create_option
|
|
67
|
+
| "STATS_SAMPLE_PAGES"i ["="] ternary_option -> stats_sample_pages_create_option
|
|
68
|
+
| ("CHECKSUM"i | "TABLE_CHECKSUM"i) ["="] int_literal -> checksum_create_option
|
|
69
|
+
| "DELAY_KEY_WRITE"i ["="] int_literal -> delay_key_write_create_option
|
|
70
|
+
| "ROW_FORMAT"i ["="] row_format -> row_format_create_option
|
|
71
|
+
| "UNION"i ["="] "(" qual_identifier_list ")" -> union_create_option
|
|
72
|
+
| ["DEFAULT"i] charset ["="] charset_value -> charset_create_option
|
|
73
|
+
| ["DEFAULT"i] "COLLATE"i ["="] identifier -> collate_create_option
|
|
74
|
+
| "INSERT_METHOD"i ["="] insert_method -> insert_method_create_option
|
|
75
|
+
| "DATA"i "DIRECTORY"i ["="] text_literal -> data_directory_create_option
|
|
76
|
+
| "INDEX"i "DIRECTORY"i ["="] text_literal -> index_directory_create_option
|
|
77
|
+
| "TABLESPACE"i identifier -> tablespace_create_option
|
|
78
|
+
| "STORAGE"i storage_type -> storage_create_option
|
|
79
|
+
| "CONNECTION"i ["="] text_literal -> connection_create_option
|
|
80
|
+
| "KEY_BLOCK_SIZE"i ["="] int_literal -> key_block_size_create_option
|
|
81
|
+
|
|
82
|
+
row_format: "DEFAULT"i -> default_row_format
|
|
83
|
+
| "DYNAMIC"i -> dynamic_row_format
|
|
84
|
+
| "FIXED"i -> fixed_row_format
|
|
85
|
+
| "COMPRESSED"i -> compressed_row_format
|
|
86
|
+
| "REDUNDANT"i -> redundant_row_format
|
|
87
|
+
| "COMPACT"i -> compact_row_format
|
|
88
|
+
|
|
89
|
+
insert_method: "NO"i | "FIRST"i | "LAST"i
|
|
90
|
+
storage_type: "DISK"i | "MEMORY"i
|
|
91
|
+
|
|
92
|
+
table_element_list: table_element ("," table_element)*
|
|
93
|
+
table_element: column_definition | table_constraint_def
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
table_constraint_def: key_or_index [identifier] [index_type_clause] key_list index_option* -> index_constraint
|
|
98
|
+
| [constraint_name] "PRIMARY"i "KEY"i [identifier] [index_type_clause] key_list index_option* -> primary_constraint
|
|
99
|
+
| [constraint_name] "UNIQUE"i [key_or_index] [identifier] [index_type_clause] key_list index_option* -> unique_constraint
|
|
100
|
+
| "FULLTEXT"i [key_or_index] [identifier] key_list index_option* -> fulltext_constraint
|
|
101
|
+
| "SPATIAL"i [key_or_index] [identifier] key_list index_option* -> spatial_constraint
|
|
102
|
+
| [constraint_name] "FOREIGN"i "KEY"i [identifier] key_list references -> foreign_contraint
|
|
103
|
+
| [constraint_name] "CHECK"i expr_with_par [constraint_enforcement] -> check_contraint
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
constraint_name: "CONSTRAINT"i [identifier]
|
|
107
|
+
|
|
108
|
+
index_type: "BTREE"i -> btree_index_type
|
|
109
|
+
| "RTREE"i -> rtree_index_type
|
|
110
|
+
| "HASH"i -> hash_index_type
|
|
111
|
+
|
|
112
|
+
index_type_clause: ("USING"i | "TYPE"i) index_type
|
|
113
|
+
|
|
114
|
+
key_list: "(" key_part ("," key_part)* ")"
|
|
115
|
+
|
|
116
|
+
key_part: identifier [int_arg] [direction] -> identifier_key_part
|
|
117
|
+
| expr_with_par [direction] -> expr_key_part
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
index_option: "KEY_BLOCK_SIZE"i ["="] int_literal -> key_block_size_index_option
|
|
121
|
+
| "COMMENT"i text_literal -> comment_index_option
|
|
122
|
+
| "VISIBLE"i -> visible_index_option
|
|
123
|
+
| "INVISIBLE"i -> invisible_index_option
|
|
124
|
+
// primary - unique - key
|
|
125
|
+
| index_type_clause -> type_index_option
|
|
126
|
+
// fulltext
|
|
127
|
+
| "WITH"i "PARSER"i identifier -> with_parser_index_option
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
column_definition: identifier data_type attribute*
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
data_type: TINYINT [int_arg] -> tinyint_data_type
|
|
135
|
+
| SMALLINT [int_arg] -> smallint_data_type
|
|
136
|
+
| MEDIUMINT [int_arg] -> mediumint_data_type
|
|
137
|
+
| INT [int_arg] -> int_data_type
|
|
138
|
+
| BIGINT [int_arg] -> bigint_data_type
|
|
139
|
+
| DECIMAL [int_arg | int_pair_arg] -> fixed_point_data_type
|
|
140
|
+
| FLOAT [int_arg | int_pair_arg] -> float_data_type
|
|
141
|
+
| REAL [int_pair_arg] -> double_data_type
|
|
142
|
+
| BOOL -> bool_data_type
|
|
143
|
+
| "SERIAL"i -> serial_data_type
|
|
144
|
+
| "BIT"i [int_arg] -> bit_data_type
|
|
145
|
+
//
|
|
146
|
+
| "DATE"i -> date_data_type
|
|
147
|
+
| "DATETIME"i [int_arg] -> datetime_data_type
|
|
148
|
+
| "TIMESTAMP"i [int_arg] -> timestamp_data_type
|
|
149
|
+
| "TIME"i [int_arg] -> time_data_type
|
|
150
|
+
| YEAR ["(" "4" ")"] -> year_data_type
|
|
151
|
+
//
|
|
152
|
+
| CHAR [int_arg] -> char_data_type
|
|
153
|
+
| nchar [int_arg] -> nchar_data_type
|
|
154
|
+
| varchar int_arg -> varchar_data_type
|
|
155
|
+
| nvarchar int_arg -> nvarchar_data_type
|
|
156
|
+
//
|
|
157
|
+
| binary [int_arg] -> binary_data_type
|
|
158
|
+
| "VARBINARY"i int_arg -> varbinary_data_type
|
|
159
|
+
//
|
|
160
|
+
| "TINYBLOB"i -> tinyblob_data_type
|
|
161
|
+
| "TINYTEXT"i -> tinytext_data_type
|
|
162
|
+
| "BLOB"i [int_arg] -> blob_data_type
|
|
163
|
+
| "TEXT"i [int_arg] -> text_data_type
|
|
164
|
+
| "MEDIUMBLOB"i -> mediumblob_data_type
|
|
165
|
+
| MEDIUM_TEXT -> mediumtext_data_type
|
|
166
|
+
| "LONGBLOB"i -> longblob_data_type
|
|
167
|
+
| "LONGTEXT"i -> longtext_data_type
|
|
168
|
+
//
|
|
169
|
+
| "ENUM"i text_list -> enum_data_type
|
|
170
|
+
| "SET"i text_list -> set_data_type
|
|
171
|
+
//
|
|
172
|
+
| "GEOMETRY"i -> geometry_data_type
|
|
173
|
+
| "POINT"i -> point_data_type
|
|
174
|
+
| "LINESTRING"i -> linestring_data_type
|
|
175
|
+
| "POLYGON"i -> polygon_data_type
|
|
176
|
+
| "MULTIPOINT"i -> multipoint_data_type
|
|
177
|
+
| "MULTILINESTRING"i -> multilinestring_data_type
|
|
178
|
+
| "MULTIPOLYGON"i -> multipolygon_data_type
|
|
179
|
+
| GEOMETRYCOLLECTION -> geometrycollection_data_type
|
|
180
|
+
//
|
|
181
|
+
| "JSON"i -> json_data_type
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
attribute: NOT "NULL"i -> non_nullable_attribute
|
|
185
|
+
| "NULL"i -> nullable_attribute
|
|
186
|
+
| "DEFAULT"i literal -> literal_default_attribute
|
|
187
|
+
| "DEFAULT"i expr_with_par -> expr_default_attribute
|
|
188
|
+
| "DEFAULT"i NOW [int_arg] -> now_default_attribute
|
|
189
|
+
| ["GENERATED"i "ALWAYS"i] "AS"i expr_with_par [generation_type] -> generated_attribute
|
|
190
|
+
| "ON"i "UPDATE"i NOW [int_arg] -> on_update_attribute
|
|
191
|
+
| "COMMENT"i text_literal -> comment_attribute
|
|
192
|
+
| "COLUMN_FORMAT"i column_format -> column_format_attribute
|
|
193
|
+
| "STORAGE"i storage_media -> storage_attribute
|
|
194
|
+
| "INVISIBLE"i -> invisible_attribute
|
|
195
|
+
| "VISIBLE"i -> visible_attribute
|
|
196
|
+
| "NOT"i "SECONDARY"i -> not_secondary_attribute
|
|
197
|
+
//
|
|
198
|
+
| "AUTO_INCREMENT"i -> auto_increment_attribute
|
|
199
|
+
| "UNSIGNED"i -> unsigned_attribute
|
|
200
|
+
| "ZEROFILL"i -> zerofill_attribute
|
|
201
|
+
| charset charset_value -> charset_attribute
|
|
202
|
+
| "COLLATE"i identifier -> collate_attribute
|
|
203
|
+
| "SRID"i int_literal -> srid_attribute
|
|
204
|
+
|
|
205
|
+
references: "REFERENCES"i identifier [identifier_list_with_par] ["MATCH"i ref_match_type] ref_rule*
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
column_format: "FIXED"i -> fixed_column_format
|
|
209
|
+
| "DYNAMIC"i -> dynamic_column_format
|
|
210
|
+
| "DEFAULT"i -> default_column_format
|
|
211
|
+
|
|
212
|
+
storage_media: "DISK"i -> disk_storage_media
|
|
213
|
+
| "MEMORY"i -> memory_storage_media
|
|
214
|
+
| "DEFAULT"i -> default_storage_media
|
|
215
|
+
|
|
216
|
+
generation_type: "VIRTUAL"i -> virtual_generation_type
|
|
217
|
+
| "STORED"i -> stored_generation_type
|
|
218
|
+
|
|
219
|
+
constraint_enforcement: "ENFORCED"i -> enforced_constraint_enforcement
|
|
220
|
+
| NOT "ENFORCED"i -> not_enforced_constraint_enforcement
|
|
221
|
+
|
|
222
|
+
charset_value: identifier -> custom_charset
|
|
223
|
+
| "BINARY"i -> binary_charset
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
ref_match_type: "FULL"i -> full_ref_match_type
|
|
227
|
+
| "PARTIAL"i -> partial_ref_match_type
|
|
228
|
+
| "SIMPLE"i -> simple_ref_match_type
|
|
229
|
+
|
|
230
|
+
ref_rule: "ON"i "UPDATE"i ref_action -> on_update_ref_rule
|
|
231
|
+
| "ON"i "DELETE"i ref_action -> on_delete_ref_rule
|
|
232
|
+
|
|
233
|
+
ref_action: "RESTRICT"i -> restrict_ref_action
|
|
234
|
+
| "CASCADE"i -> cascade_ref_action
|
|
235
|
+
| "SET"i "NULL"i -> set_null_ref_action
|
|
236
|
+
| "NO"i "ACTION"i -> no_action_ref_action
|
|
237
|
+
|
|
238
|
+
// Expression
|
|
239
|
+
|
|
240
|
+
expr: bool_pri ["IS"i [NOT] ("TRUE"i | "FALSE"i | "UNKNOWN"i)]
|
|
241
|
+
| NOT expr
|
|
242
|
+
| expr ("AND"i | "&&") expr
|
|
243
|
+
| expr "XOR"i expr
|
|
244
|
+
| expr ("OR"i | "||") expr
|
|
245
|
+
bool_pri: predicate
|
|
246
|
+
| bool_pri "IS"i [NOT] "NULL"i
|
|
247
|
+
| bool_pri comp_op predicate
|
|
248
|
+
| bool_pri comp_op ("ALL"i | ANY) query_expression_parens
|
|
249
|
+
comp_op: "="| "<=>" | ">=" | ">" | "<=" | "<" | "!=" | "<>"
|
|
250
|
+
predicate: bit_expr [[NOT] predicate_operations | "MEMBER"i ["OF"i] simple_expr_with_parentheses | "SOUNDS"i "LIKE"i bit_expr]
|
|
251
|
+
predicate_operations: "IN"i (query_expression_parens | "(" expr_list ")")
|
|
252
|
+
| "BETWEEN"i bit_expr "AND"i predicate
|
|
253
|
+
| "LIKE"i simple_expr ["ESCAPE"i simple_expr]
|
|
254
|
+
| REGEXP bit_expr
|
|
255
|
+
bit_expr: simple_expr
|
|
256
|
+
| bit_expr "^" bit_expr
|
|
257
|
+
| bit_expr ("*" | "/" | "%" | "DIV"i | "MOD"i) bit_expr
|
|
258
|
+
| bit_expr ("+" | "-") bit_expr
|
|
259
|
+
| bit_expr ("+" | "-") "INTERVAL"i expr interval
|
|
260
|
+
| bit_expr ("<<" | ">>") bit_expr
|
|
261
|
+
| bit_expr "&" bit_expr
|
|
262
|
+
| bit_expr "|" bit_expr
|
|
263
|
+
simple_expr: variable [equal expr]
|
|
264
|
+
| field_identifier [json_operator]
|
|
265
|
+
| runtime_function_call
|
|
266
|
+
| function_call
|
|
267
|
+
| simple_expr "COLLATE"i text_or_identifier
|
|
268
|
+
| literal
|
|
269
|
+
| "?"
|
|
270
|
+
| sum_expr
|
|
271
|
+
| grouping_operation
|
|
272
|
+
| window_function_call
|
|
273
|
+
| simple_expr "CONCAT_PIPES"i simple_expr
|
|
274
|
+
| ("+" | "-" | "~") simple_expr
|
|
275
|
+
| ("!" | "NOT2"i) simple_expr
|
|
276
|
+
| ["ROW"i] "(" expr_list ")"
|
|
277
|
+
| ["EXISTS"i] query_expression_parens
|
|
278
|
+
| "{"i identifier expr "}"i
|
|
279
|
+
| "MATCH"i ident_list_arg "AGAINST"i "(" bit_expr [fulltext_options] ")"
|
|
280
|
+
| "BINARY"i simple_expr
|
|
281
|
+
| "CAST"i "(" expr "AS"i cast_type [array_cast] ")"
|
|
282
|
+
| "CASE"i [expr] (when_expression then_expression)+ [else_expression] "END"i
|
|
283
|
+
| "CONVERT"i "(" expr "," cast_type ")"
|
|
284
|
+
| "CONVERT"i "(" expr "USING"i charset_value ")"
|
|
285
|
+
| "DEFAULT"i "(" simple_identifier ")"
|
|
286
|
+
| "VALUES"i "(" simple_identifier ")"
|
|
287
|
+
| "INTERVAL"i expr interval "+" expr
|
|
288
|
+
else_expression: "ELSE"i expr
|
|
289
|
+
then_expression: "THEN"i expr
|
|
290
|
+
when_expression: "WHEN"i expr
|
|
291
|
+
array_cast: "ARRAY"i
|
|
292
|
+
cast_type: "BINARY"i [int_arg]
|
|
293
|
+
| CHAR [int_arg] [charset_with_opt_binary]
|
|
294
|
+
| nchar [int_arg]
|
|
295
|
+
| "SIGNED"i [INT]
|
|
296
|
+
| "UNSIGNED"i [INT]
|
|
297
|
+
| "DATE"i
|
|
298
|
+
| "TIME"i [int_arg]
|
|
299
|
+
| "DATETIME"i [int_arg]
|
|
300
|
+
| DECIMAL [int_arg | int_pair_arg]
|
|
301
|
+
| "JSON"i
|
|
302
|
+
| REAL
|
|
303
|
+
| FLOAT [int_pair_arg]
|
|
304
|
+
charset_with_opt_binary: ascii | unicode | "BYTE"i | charset charset_value ["BINARY"i] | "BINARY"i [charset charset_value]
|
|
305
|
+
unicode: "UNICODE"i ["BINARY"i] | "BINARY"i "UNICODE"i
|
|
306
|
+
ascii: "ASCII"i ["BINARY"i] | "BINARY"i "ASCII"i
|
|
307
|
+
fulltext_options: "IN"i BOOL "MODE"i
|
|
308
|
+
| "IN"i "NATURAL"i "LANGUAGE"i "MODE"i ["WITH"i "QUERY"i "EXPANSION"i]
|
|
309
|
+
| "WITH"i "QUERY"i "EXPANSION"i
|
|
310
|
+
ident_list_arg: ident_list | "(" ident_list ")"
|
|
311
|
+
ident_list: simple_identifier ("," simple_identifier)*
|
|
312
|
+
simple_identifier: identifier [dot_identifier [dot_identifier]]
|
|
313
|
+
query_expression_parens:"(" (query_expression_parens | query_expression [locking_clause_list]) ")"
|
|
314
|
+
locking_clause_list: locking_clause+
|
|
315
|
+
locking_clause: "FOR"i lock_strengh ["OF"i table_alias_ref_list] [locked_row_action] | "LOCK"i "IN"i "SHARE"i "MODE"i
|
|
316
|
+
locked_row_action: "SKIP"i "LOCKED"i | "NOWAIT"i
|
|
317
|
+
table_alias_ref_list: table_ref_with_wildcard ("," table_ref_with_wildcard)*
|
|
318
|
+
table_ref_with_wildcard: identifier ["." "*" | dot_identifier ["." "*"]]
|
|
319
|
+
lock_strengh: "UPDATE"i | "SHARE"i
|
|
320
|
+
query_expression: [with_clause] (query_expression_body [order_clause] [limit_clause] | query_expression_parens [order_clause] [limit_clause])
|
|
321
|
+
limit_clause: "LIMIT"i limit_options
|
|
322
|
+
limit_options: limit_option [("COMMA"i | "OFFSET"i) limit_option]
|
|
323
|
+
limit_option: identifier | "?" | int_literal
|
|
324
|
+
query_expression_body: (query_primary | query_expression_parens "UNION"i [union_option] (query_primary | query_expression_parens)) ("UNION"i [union_option] ( query_primary | query_expression_parens))*
|
|
325
|
+
union_option: DISTINCT | "ALL"i
|
|
326
|
+
query_primary: query_specification | table_value_constructor | explicit_table
|
|
327
|
+
explicit_table: "TABLE"i table_ref
|
|
328
|
+
table_ref: qual_identifier | dot_identifier
|
|
329
|
+
table_value_constructor: "VALUES"i row_value_explicit ("," row_value_explicit)*
|
|
330
|
+
row_value_explicit: "ROW"i "(" [values] ")"
|
|
331
|
+
values: (expr | "DEFAULT"i) ("," (expr | "DEFAULT"i))*
|
|
332
|
+
query_specification: "SELECT"i select_option* select_item_list [into_clause] [from_clause] [where_clause] [group_by_clause] [having_clause] [window_clause]
|
|
333
|
+
window_clause: "WINDOW"i window_definition ("," window_definition)*
|
|
334
|
+
window_definition: identifier "AS"i window_spec
|
|
335
|
+
window_spec: "(" window_spec_details ")"
|
|
336
|
+
having_clause: "HAVING"i expr
|
|
337
|
+
group_by_clause: "GROUP"i "BY"i order_list [olap_option]
|
|
338
|
+
olap_option: "WITH"i "ROLLUP"i
|
|
339
|
+
where_clause: "WHERE"i expr
|
|
340
|
+
from_clause: "FROM"i ("DUAL"i | table_reference_list)
|
|
341
|
+
table_reference_list: table_reference ("COMMA"i table_reference)*
|
|
342
|
+
table_reference: (table_factor | "{" "OJ"i escaped_table_reference "}") joined_table*
|
|
343
|
+
escaped_table_reference: table_factor joined_table*
|
|
344
|
+
joined_table: inner_join_type table_reference ["ON"i expr| "USING"i identifier_list_with_par]
|
|
345
|
+
| outer_join_type table_reference ("ON"i expr | "USING"i identifier_list_with_par)
|
|
346
|
+
| natural_join_type table_factor
|
|
347
|
+
natural_join_type: "NATURAL"i ["INNER"i | ("LEFT"i | "RIGHT"i) ["OUTER"i]] "JOIN"i
|
|
348
|
+
outer_join_type: ("LEFT"i | "RIGHT"i) ["OUTER"i] "JOIN"i
|
|
349
|
+
inner_join_type: ["INNER"i | "CROSS"i] "JOIN"i | "STRAIGHT_JOIN"i
|
|
350
|
+
table_factor: single_table | single_table_parens | derived_table | table_reference_list_parens | table_function
|
|
351
|
+
table_function: "JSON_TABLE"i "(" expr "," quoted_text columns_clause ")" [table_alias]
|
|
352
|
+
columns_clause: COLUMNS "(" jt_column ("," jt_column)* ")"
|
|
353
|
+
jt_column: identifier "FOR"i "ORDINALITY"i
|
|
354
|
+
| identifier data_type ["COLLATE" text_or_identifier] ["EXISTS"i] "PATH"i quoted_text [on_empty_or_error]
|
|
355
|
+
| "NESTED"i "PATH"i quoted_text columns_clause
|
|
356
|
+
on_empty_or_error: on_empty [on_error] | on_error [on_empty]
|
|
357
|
+
on_empty: jt_on_response "ON"i "EMPTY"i
|
|
358
|
+
on_error: jt_on_response "ON"i "ERROR"i
|
|
359
|
+
jt_on_response: "ERROR"i | "NULL"i | "DEFAULT"i quoted_text
|
|
360
|
+
table_reference_list_parens: "(" (table_reference_list | table_reference_list_parens) ")"
|
|
361
|
+
derived_table: query_expression_parens [table_alias] [identifier_list_with_par]
|
|
362
|
+
| "LATERAL"i query_expression_parens [table_alias] [identifier_list_with_par]
|
|
363
|
+
single_table_parens: "(" (single_table | single_table_parens) ")"
|
|
364
|
+
single_table: table_ref [use_partition] [table_alias] [index_hint_list]
|
|
365
|
+
index_hint_list: index_hint (","i index_hint)*
|
|
366
|
+
index_hint: index_hint_type key_or_index [index_hint_clause] "("i index_list ")"i
|
|
367
|
+
| "USE"i key_or_index [index_hint_clause] "("i [index_list] ")"i
|
|
368
|
+
index_list: index_list_element ("," index_list_element)*
|
|
369
|
+
index_list_element: identifier | "PRIMARY"i
|
|
370
|
+
index_hint_clause: "FOR"i ("JOIN"i | "ORDER"i "BY"i | "GROUP"i "BY"i)
|
|
371
|
+
index_hint_type: "FORCE"i | "IGNORE"i
|
|
372
|
+
table_alias: ["AS"i] identifier
|
|
373
|
+
use_partition: "PARTITION"i identifier_list_with_par
|
|
374
|
+
into_clause: "INTO"i ("OUTFILE"i quoted_text [charset charset_value] [fields_clause] [lines_clause]
|
|
375
|
+
| "DUMPFILE"i quoted_text
|
|
376
|
+
| (text_or_identifier | user_variable) ("," (text_or_identifier | user_variable))*)
|
|
377
|
+
lines_clause: "LINES"i line_term+
|
|
378
|
+
line_term: ("TERMINATED"i | "STARTING"i) "BY"i quoted_text
|
|
379
|
+
fields_clause: COLUMNS field_term+
|
|
380
|
+
field_term: "TERMINATED"i "BY"i quoted_text | ["OPTIONALLY"i] "ENCLOSED"i "BY"i quoted_text | "ESCAPED"i "BY"i quoted_text
|
|
381
|
+
select_item_list: (select_item | "*") ("," select_item)*
|
|
382
|
+
select_item: table_wild | expr [select_alias]
|
|
383
|
+
select_alias: ["AS"i] text_or_identifier
|
|
384
|
+
table_wild: identifier "." [identifier "."] "*"
|
|
385
|
+
select_option: query_spec_option | "SQL_NO_CACHE"i
|
|
386
|
+
query_spec_option: "ALL"i
|
|
387
|
+
| DISTINCT
|
|
388
|
+
| "STRAIGHT_JOIN"i
|
|
389
|
+
| "HIGH_PRIORITY"i
|
|
390
|
+
| "SQL_SMALL_RESULT"i
|
|
391
|
+
| "SQL_BIG_RESULT"i
|
|
392
|
+
| "SQL_BUFFER_RESULT"i
|
|
393
|
+
| "SQL_CALC_FOUND_ROWS"i
|
|
394
|
+
with_clause: "WITH"i ["RECURSIVE"i] common_table_expression ("," common_table_expression)*
|
|
395
|
+
common_table_expression: identifier [identifier_list_with_par] "AS"i query_expression_parens
|
|
396
|
+
window_function_call: ("ROW_NUMBER"i | "RANK"i | "DENSE_RANK"i | "CUME_DIST"i | "PERCENT_RANK"i) parentheses windowing_clause
|
|
397
|
+
| "NTILE"i simple_expr_with_parentheses windowing_clause
|
|
398
|
+
| ("LEAD"i | "LAG"i) "(" expr [lead_lag_info] ")" [null_treatment] windowing_clause
|
|
399
|
+
| ("FIRST_VALUE"i | "LAST_VALUE"i) expr_with_par [null_treatment] windowing_clause
|
|
400
|
+
| "NTH_VALUE"i "(" expr "," simple_expr ")" ["FROM"i ("FIRST"i | "LAST"i)] [null_treatment] windowing_clause
|
|
401
|
+
null_treatment: ("RESPECT"i | "IGNORE"i) "NULLS"i
|
|
402
|
+
lead_lag_info: "," (int_literal | "?") ["," expr]
|
|
403
|
+
simple_expr_with_parentheses: "(" simple_expr ")"
|
|
404
|
+
grouping_operation: "GROUPING"i "(" expr_list ")"
|
|
405
|
+
sum_expr: "AVG"i "(" [DISTINCT] in_sum_expr ")" [windowing_clause]
|
|
406
|
+
| ("BIT_AND"i | "BIT_OR"i | "BIT_XOR"i) "(" in_sum_expr ")" [windowing_clause]
|
|
407
|
+
| json_function
|
|
408
|
+
| "COUNT"i "(" ["ALL"i] "*" ")" [windowing_clause]
|
|
409
|
+
| "COUNT"i "(" (["ALL"i] "*" | in_sum_expr | DISTINCT expr_list) ")" [windowing_clause]
|
|
410
|
+
| "MIN"i "(" [DISTINCT] in_sum_expr ")" [windowing_clause]
|
|
411
|
+
| "MAX"i "(" [DISTINCT] in_sum_expr ")" [windowing_clause]
|
|
412
|
+
| "STD"i "(" in_sum_expr ")" [windowing_clause]
|
|
413
|
+
| "VARIANCE"i "(" in_sum_expr ")" [windowing_clause]
|
|
414
|
+
| "STDDEV_SAMP"i "(" in_sum_expr ")" [windowing_clause]
|
|
415
|
+
| "VAR_SAMP"i "(" in_sum_expr ")" [windowing_clause]
|
|
416
|
+
| "SUM"i "(" [DISTINCT] in_sum_expr ")" [windowing_clause]
|
|
417
|
+
| "GROUP_CONCAT"i "(" [DISTINCT] expr_list [order_clause] ["SEPARATOR"i quoted_text] ")" [windowing_clause]
|
|
418
|
+
json_function: "JSON_ARRAYAGG"i "(" in_sum_expr ")" [windowing_clause]
|
|
419
|
+
| "JSON_OBJECTAGG"i "(" in_sum_expr "," in_sum_expr ")" [windowing_clause]
|
|
420
|
+
windowing_clause: "OVER"i (identifier | "(" window_spec_details ")")
|
|
421
|
+
window_spec_details: [identifier] ["PARTITION"i "BY"i order_list] [order_clause] [window_frame_clause]
|
|
422
|
+
window_frame_clause: window_frame_units window_frame_extent [window_frame_exclusion]
|
|
423
|
+
window_frame_exclusion: "EXCLUDE"i ("CURRENT"i "ROW"i | "GROUP"i | "TIES"i | "NO"i "OTHERS"i)
|
|
424
|
+
window_frame_extent: window_frame_start | window_frame_between
|
|
425
|
+
window_frame_start: "UNBOUNDED"i "PRECEDING"i
|
|
426
|
+
| int_literal "PRECEDING"i
|
|
427
|
+
| "?" "PRECEDING"i
|
|
428
|
+
| "INTERVAL"i expr interval "PRECEDING"i
|
|
429
|
+
| "CURRENT"i "ROW"i
|
|
430
|
+
window_frame_between: "BETWEEN"i window_frame_bound "AND"i window_frame_bound
|
|
431
|
+
window_frame_bound: window_frame_start
|
|
432
|
+
| "UNBOUNDED"i "FOLLOWING"i
|
|
433
|
+
| int_literal "FOLLOWING"i
|
|
434
|
+
| "?" "FOLLOWING"i
|
|
435
|
+
| "INTERVAL"i expr interval "FOLLOWING"i
|
|
436
|
+
window_frame_units: "ROWS"i | "RANGE"i | "GROUPS"i
|
|
437
|
+
order_clause: "ORDER"i "BY"i order_list
|
|
438
|
+
order_list: order_expression ("," order_expression)*
|
|
439
|
+
order_expression: expr [direction]
|
|
440
|
+
in_sum_expr: ["ALL"i] expr
|
|
441
|
+
function_call: identifier "(" [udf_expr_list] ")" | qual_identifier "(" [expr_list] ")"
|
|
442
|
+
udf_expr_list: udf_expr ("," udf_expr)*
|
|
443
|
+
udf_expr: expr [["AS"i] text_or_identifier]
|
|
444
|
+
runtime_function_call: CHAR "(" expr_list ["USING"i charset_value] ")"
|
|
445
|
+
| "CURRENT_USER"i [parentheses]
|
|
446
|
+
| "DATE"i expr_with_par
|
|
447
|
+
| DAY expr_with_par
|
|
448
|
+
| HOUR expr_with_par
|
|
449
|
+
| "INSERT"i "(" expr "," expr "," expr "," expr ")"
|
|
450
|
+
| "INTERVAL"i "(" expr ("," expr)+ ")"
|
|
451
|
+
| "LEFT"i "(" expr "," expr ")"
|
|
452
|
+
| MINUTE expr_with_par
|
|
453
|
+
| MONTH expr_with_par
|
|
454
|
+
| "RIGHT"i "(" expr "," expr ")"
|
|
455
|
+
| SECOND expr_with_par
|
|
456
|
+
| "TIME"i expr_with_par
|
|
457
|
+
| "TIMESTAMP"i "(" expr ["," expr] ")"
|
|
458
|
+
| trim_function
|
|
459
|
+
| "USER"i parentheses
|
|
460
|
+
| "VALUES"i expr_with_par
|
|
461
|
+
| YEAR expr_with_par
|
|
462
|
+
// Function names that are not keywords.
|
|
463
|
+
| ("ADDDATE"i | "SUBDATE"i) "(" expr "," (expr | "INTERVAL"i expr interval) ")"
|
|
464
|
+
| "CURDATE"i [parentheses]
|
|
465
|
+
| "CURTIME"i [int_arg]
|
|
466
|
+
| ("DATE_ADD"i | "DATE_SUB"i) "(" expr "," "INTERVAL"i expr interval ")"
|
|
467
|
+
| "EXTRACT"i "(" interval "FROM"i expr ")"
|
|
468
|
+
| "GET_FORMAT"i "(" date_time_ttype "," expr ")"
|
|
469
|
+
| NOW [int_arg]
|
|
470
|
+
| "POSITION"i "(" bit_expr "IN"i expr ")"
|
|
471
|
+
| substring_function
|
|
472
|
+
| "SYSDATE"i [int_arg]
|
|
473
|
+
| ("TIMESTAMP_ADD"i | "TIMESTAMP_DIFF"i) "(" interval_time_stamp "," expr "," expr ")"
|
|
474
|
+
| "UTC_DATE"i [parentheses]
|
|
475
|
+
| "UTC_TIME"i [int_arg]
|
|
476
|
+
| "UTC_TIMESTAMP"i [int_arg]
|
|
477
|
+
// Function calls with other conflicts.
|
|
478
|
+
| "ASCII"i expr_with_par
|
|
479
|
+
| "CHARSET"i expr_with_par
|
|
480
|
+
| "COALESCE"i expr_list_with_parentheses
|
|
481
|
+
| "COLLATION"i expr_with_par
|
|
482
|
+
| DATABASE parentheses
|
|
483
|
+
| "IF"i "(" expr "," expr "," expr ")"
|
|
484
|
+
| "FORMAT"i "(" expr "," expr ["," expr] ")"
|
|
485
|
+
| "MICROSECOND"i expr_with_par
|
|
486
|
+
| "MOD"i "(" expr "," expr ")"
|
|
487
|
+
| QUARTER expr_with_par
|
|
488
|
+
| "REPEAT"i "(" expr "," expr ")"
|
|
489
|
+
| "REPLACE"i "(" expr "," expr "," expr ")"
|
|
490
|
+
| "REVERSE"i expr_with_par
|
|
491
|
+
| "ROW_COUNT"i parentheses
|
|
492
|
+
| "TRUNCATE"i "(" expr "," expr ")"
|
|
493
|
+
| WEEK "(" expr ["," expr] ")"
|
|
494
|
+
| "WEIGHT_STRING"i "(" expr (["AS"i CHAR ws_num_codepoints]
|
|
495
|
+
| "AS"i "BINARY"i ws_num_codepoints
|
|
496
|
+
| "," int_literal "," int_literal "," int_literal) ")"
|
|
497
|
+
| geometry_function
|
|
498
|
+
geometry_function: GEOMETRYCOLLECTION "(" [expr_list] ")"
|
|
499
|
+
| "LINESTRING"i expr_list_with_parentheses
|
|
500
|
+
| "MULTILINESTRING"i expr_list_with_parentheses
|
|
501
|
+
| "MULTIPOINT"i expr_list_with_parentheses
|
|
502
|
+
| "MULTIPOLYGON"i expr_list_with_parentheses
|
|
503
|
+
| "POINT"i "(" expr "," expr ")"
|
|
504
|
+
| "POLYGON"i expr_list_with_parentheses
|
|
505
|
+
ws_num_codepoints: "(" int_literal ")"
|
|
506
|
+
expr_list_with_parentheses: "(" expr_list ")"
|
|
507
|
+
substring_function: "SUBSTRING"i "(" expr ("," expr ["," expr] | "FROM"i expr ["FOR"i expr]) ")"
|
|
508
|
+
date_time_ttype: "DATE"i | "TIME"i | "DATETIME"i | "TIMESTAMP"i
|
|
509
|
+
interval: interval_time_stamp
|
|
510
|
+
| "SECOND_MICROSECOND"i
|
|
511
|
+
| "MINUTE_MICROSECOND"i
|
|
512
|
+
| "MINUTE_SECOND"i
|
|
513
|
+
| "HOUR_MICROSECOND"i
|
|
514
|
+
| "HOUR_SECOND"i
|
|
515
|
+
| "HOUR_MINUTE"i
|
|
516
|
+
| "DAY_MICROSECOND"i
|
|
517
|
+
| "DAY_SECOND"i
|
|
518
|
+
| "DAY_MINUTE"i
|
|
519
|
+
| "DAY_HOUR"i
|
|
520
|
+
| "YEAR_MONTH"i
|
|
521
|
+
interval_time_stamp: "MICROSECOND"i| SECOND | MINUTE | HOUR | DAY | WEEK | MONTH | QUARTER | YEAR
|
|
522
|
+
trim_function: "TRIM"i "(" (expr ["FROM"i expr] | ("LEADING"i | "TRAILING"i | "BOTH"i) [expr] "FROM"i expr) ")"
|
|
523
|
+
parentheses: "(" ")"
|
|
524
|
+
expr_list: expr ("," expr)*
|
|
525
|
+
json_operator: ("->" | "->>") quoted_text
|
|
526
|
+
field_identifier: dot_identifier | qual_identifier [dot_identifier]
|
|
527
|
+
equal: "=" | ":="
|
|
528
|
+
variable: user_variable | system_variable
|
|
529
|
+
system_variable: "@@" [var_ident_type] text_or_identifier [dot_identifier]
|
|
530
|
+
var_ident_type: ("GLOBAL"i | "LOCAL"i | "SESSION"i) "."
|
|
531
|
+
user_variable: "@" text_or_identifier
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
// General
|
|
535
|
+
|
|
536
|
+
text_list: "(" quoted_text ("," quoted_text)* ")"
|
|
537
|
+
text_or_identifier: identifier | text_literal
|
|
538
|
+
|
|
539
|
+
expr_with_par: "(" expr ")"
|
|
540
|
+
|
|
541
|
+
int_arg: "(" (int_literal) ")"
|
|
542
|
+
int_pair_arg: "(" int_literal "," int_literal ")"
|
|
543
|
+
|
|
544
|
+
dot_identifier: "." identifier
|
|
545
|
+
identifier_list_with_par: "(" identifier_list ")"
|
|
546
|
+
identifier_list: identifier ("," identifier)*
|
|
547
|
+
qual_identifier: identifier [dot_identifier]
|
|
548
|
+
qual_identifier_list: qual_identifier ("," qual_identifier)*
|
|
549
|
+
|
|
550
|
+
charset: CHAR "SET"i | "CHARSET"i
|
|
551
|
+
nchar: "NCHAR"i | "NATIONAL"i CHAR
|
|
552
|
+
varchar: VARCHAR | CHAR "VARYING"i
|
|
553
|
+
nvarchar: "NVARCHAR"i | "NCHAR"i ("VARYING"i | VARCHAR) | "NATIONAL"i (VARCHAR | CHAR "VARYING"i)
|
|
554
|
+
binary: "BINARY"i | "CHAR BYTE"i
|
|
555
|
+
key_or_index: "KEY"i | "INDEX"i
|
|
556
|
+
|
|
557
|
+
direction: "ASC"i -> asc_direction
|
|
558
|
+
| "DESC"i -> desc_direction
|
|
559
|
+
|
|
560
|
+
ternary_option: "0" -> zero_ternary_option
|
|
561
|
+
| "1" -> one_ternary_option
|
|
562
|
+
| "DEFAULT"i -> default_ternary_option
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
// Identifier
|
|
567
|
+
|
|
568
|
+
identifier: unquoted_identifier | back_tick_text
|
|
569
|
+
|
|
570
|
+
back_tick_text: BACK_TICK_TEXT
|
|
571
|
+
BACK_TICK_TEXT: "`" /.*?/ "`"
|
|
572
|
+
|
|
573
|
+
unquoted_identifier: UNQUOTED_IDENTIFIER
|
|
574
|
+
UNQUOTED_IDENTIFIER: DIGITS+ "E"i [LETTER_WHEN_UNQUOTED_NO_DIGIT LETTER_WHEN_UNQUOTED*]
|
|
575
|
+
| DIGITS+ LETTER_WITHOUT_FLOAT_PART LETTER_WHEN_UNQUOTED*
|
|
576
|
+
| LETTER_WHEN_UNQUOTED_NO_DIGIT LETTER_WHEN_UNQUOTED*
|
|
577
|
+
LETTER_WHEN_UNQUOTED_NO_DIGIT: "a".."z" | "A".."Z" | "_" | "$"
|
|
578
|
+
LETTER_WHEN_UNQUOTED: DIGIT | LETTER_WHEN_UNQUOTED_NO_DIGIT
|
|
579
|
+
LETTER_WITHOUT_FLOAT_PART: ("a".."d" | "f".."z" | "A".."D" | "F".."Z" | "_" | "$")
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
// Literals
|
|
583
|
+
|
|
584
|
+
literal: text_literal
|
|
585
|
+
| hex_literal
|
|
586
|
+
| bin_literal
|
|
587
|
+
| int_literal
|
|
588
|
+
| real_literal
|
|
589
|
+
| temporal_literal
|
|
590
|
+
| bool_literal
|
|
591
|
+
| null_literal
|
|
592
|
+
|
|
593
|
+
// Text Literal
|
|
594
|
+
|
|
595
|
+
text_literal: charset_text quoted_text*
|
|
596
|
+
|
|
597
|
+
charset_text: [UNDERSCORE_CHARSET] quoted_text -> underscore_charset_text
|
|
598
|
+
| "N"i quoted_text -> national_char_text
|
|
599
|
+
|
|
600
|
+
quoted_text: SINGLE_QUOTED_TEXT | DOUBLE_QUOTE_TEXT
|
|
601
|
+
|
|
602
|
+
UNDERSCORE_CHARSET: "_" ["a".."z" | "0".."9"]+
|
|
603
|
+
SINGLE_QUOTED_TEXT: "'" /.*?/ "'"
|
|
604
|
+
DOUBLE_QUOTE_TEXT: "\"" /.*?/ "\""
|
|
605
|
+
|
|
606
|
+
// Hex Literal
|
|
607
|
+
|
|
608
|
+
hex_literal: [UNDERSCORE_CHARSET] hex_value
|
|
609
|
+
|
|
610
|
+
hex_value: "0x" [HEX_VALUE] -> zero_x
|
|
611
|
+
| "x'" [HEX_VALUE] "'" -> x_quote
|
|
612
|
+
|
|
613
|
+
HEX_VALUE: HEX_DIGIT+
|
|
614
|
+
HEX_DIGIT: ("0".."9" | "a".."f" | "A".."F")
|
|
615
|
+
|
|
616
|
+
// Bin Literal
|
|
617
|
+
|
|
618
|
+
bin_literal: [UNDERSCORE_CHARSET] bin_value
|
|
619
|
+
|
|
620
|
+
bin_value: "0b" [BIN_VALUE] -> zero_b
|
|
621
|
+
| "b'" [BIN_VALUE] "'" -> b_quote
|
|
622
|
+
|
|
623
|
+
BIN_VALUE: BIN_DIGIT+
|
|
624
|
+
BIN_DIGIT: "0" | "1"
|
|
625
|
+
|
|
626
|
+
// Numeric Literal
|
|
627
|
+
|
|
628
|
+
int_literal: INT_LITERAL
|
|
629
|
+
INT_LITERAL: [NUM_SIGN] DIGITS
|
|
630
|
+
|
|
631
|
+
real_literal: REAL_LITERAL
|
|
632
|
+
REAL_LITERAL: [NUM_SIGN] [[DIGITS] "."] DIGITS ("e" | "E") ["-" | "+"] DIGITS | [DIGITS] "." DIGITS
|
|
633
|
+
|
|
634
|
+
NUM_SIGN: "+" | "-"
|
|
635
|
+
DIGITS: DIGIT+
|
|
636
|
+
DIGIT: "0".."9"
|
|
637
|
+
|
|
638
|
+
// Temporal Literal
|
|
639
|
+
|
|
640
|
+
temporal_literal: "DATE"i quoted_text -> date_literal
|
|
641
|
+
| "TIME"i quoted_text -> time_literal
|
|
642
|
+
| "TIMESTAMP"i quoted_text -> timestamp_literal
|
|
643
|
+
|
|
644
|
+
// Other Literal
|
|
645
|
+
|
|
646
|
+
bool_literal: "TRUE"i | "FALSE"i
|
|
647
|
+
null_literal: "NULL"i
|
|
648
|
+
|
|
649
|
+
// Synonyms
|
|
650
|
+
|
|
651
|
+
NOT: "NOT"i | "NOT2"i
|
|
652
|
+
DISTINCT: "DISTINCT"i | "DISTINCTROW"i
|
|
653
|
+
COLUMNS: "COLUMNS"i | "FIELDS"i
|
|
654
|
+
REGEXP: "REGEXP"i | "RLIKE"i
|
|
655
|
+
DATABASE: "DATABASE"i | "SCHEMA"i
|
|
656
|
+
ANY: "ANY"i | "SOME"i
|
|
657
|
+
|
|
658
|
+
CHAR: "CHAR"i | "CHARACTER"i
|
|
659
|
+
VARCHAR: "VARCHAR"i | "VARCHARACTER"i
|
|
660
|
+
MEDIUM_TEXT: "MEDIUMTEXT"i | "LONG"i | "LONG"i VARCHAR
|
|
661
|
+
|
|
662
|
+
BOOL: "BOOL"i | "BOOLEAN"i
|
|
663
|
+
|
|
664
|
+
TINYINT: "TINYINT"i | "INT1"i
|
|
665
|
+
SMALLINT: "SMALLINT"i | "INT2"i
|
|
666
|
+
MEDIUMINT: "MEDIUMINT"i | "MIDDLEINT"i | "INT3"i
|
|
667
|
+
INT: "INT"i | "INTEGER"i | "INT4"i
|
|
668
|
+
BIGINT: "BIGINT"i | "INT8"i
|
|
669
|
+
DECIMAL: "DECIMAL"i | "NUMERIC"i | "DEC"i | "FIXED"i
|
|
670
|
+
FLOAT: "FLOAT"i | "FLOAT4"i
|
|
671
|
+
DOUBLE: "DOUBLE"i | "FLOAT8"i
|
|
672
|
+
REAL: "REAL"i | (DOUBLE) ["PRECISION"i]
|
|
673
|
+
|
|
674
|
+
SECOND: "SECOND"i | "SQL_TSI_SECOND"i
|
|
675
|
+
MINUTE: "MINUTE"i | "SQL_TSI_MINUTE"i
|
|
676
|
+
HOUR: "HOUR"i | "SQL_TSI_HOUR"i
|
|
677
|
+
DAY: "DAY"i | "DAYOFMONTH"i | "SQL_TSI_DAY"i
|
|
678
|
+
WEEK: "WEEK"i | "SQL_TSI_WEEK"i
|
|
679
|
+
MONTH: "MONTH"i | "SQL_TSI_MONTH"i
|
|
680
|
+
QUARTER: "QUARTER"i | "SQL_TSI_QUARTER"i
|
|
681
|
+
YEAR: "YEAR"i | "SQL_TSI_YEAR"i
|
|
682
|
+
NOW: "NOW"i | "LOCALTIME"i | "LOCALTIMESTAMP"i | "CURRENT_TIMESTAMP"i
|
|
683
|
+
|
|
684
|
+
GEOMETRYCOLLECTION: "GEOMETRYCOLLECTION"i | "GEOMCOLLECTION"i
|
|
685
|
+
|
|
686
|
+
// Ignored
|
|
687
|
+
|
|
688
|
+
WS: " " | "\t"i | "\f"i | "\r"i | "\n"i
|
|
689
|
+
%ignore WS
|
|
690
|
+
|
|
691
|
+
COMMENT: "/*" ["!" [DIGITS]] | "*/"
|
|
692
|
+
%ignore COMMENT
|