forked from pingcap/parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.y
7855 lines (7387 loc) · 161 KB
/
parser.y
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
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%{
// Copyright 2013 The ql Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSES/QL-LICENSE file.
// Copyright 2015 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.
// Initial yacc source generated by ebnf2y[1]
// at 2013-10-04 23:10:47.861401015 +0200 CEST
//
// $ ebnf2y -o ql.y -oe ql.ebnf -start StatementList -pkg ql -p _
//
// [1]: http://github.com/cznic/ebnf2y
package parser
import (
"strings"
"github.com/pingcap/parser/mysql"
"github.com/pingcap/parser/ast"
"github.com/pingcap/parser/model"
"github.com/pingcap/parser/opcode"
"github.com/pingcap/parser/auth"
"github.com/pingcap/parser/charset"
"github.com/pingcap/parser/types"
)
%}
%union {
offset int // offset
item interface{}
ident string
expr ast.ExprNode
statement ast.StmtNode
}
%token <ident>
/*yy:token "%c" */ identifier "identifier"
/*yy:token "_%c" */ underscoreCS "UNDERSCORE_CHARSET"
/*yy:token "\"%c\"" */ stringLit "string literal"
singleAtIdentifier "identifier with single leading at"
doubleAtIdentifier "identifier with double leading at"
invalid "a special token never used by parser, used by lexer to indicate error"
hintBegin "hintBegin is a virtual token for optimizer hint grammar"
hintEnd "hintEnd is a virtual token for optimizer hint grammar"
andand "&&"
pipes "||"
/* The following tokens belong to ODBCDateTimeType. */
odbcDateType "d"
odbcTimeType "t"
odbcTimestampType "ts"
/* The following tokens belong to ReservedKeyword. */
add "ADD"
all "ALL"
alter "ALTER"
analyze "ANALYZE"
and "AND"
as "AS"
asc "ASC"
between "BETWEEN"
bigIntType "BIGINT"
binaryType "BINARY"
blobType "BLOB"
both "BOTH"
by "BY"
cascade "CASCADE"
caseKwd "CASE"
change "CHANGE"
character "CHARACTER"
charType "CHAR"
check "CHECK"
collate "COLLATE"
column "COLUMN"
constraint "CONSTRAINT"
convert "CONVERT"
create "CREATE"
cross "CROSS"
cumeDist "CUME_DIST"
currentDate "CURRENT_DATE"
currentTime "CURRENT_TIME"
currentTs "CURRENT_TIMESTAMP"
currentUser "CURRENT_USER"
database "DATABASE"
databases "DATABASES"
dayHour "DAY_HOUR"
dayMicrosecond "DAY_MICROSECOND"
dayMinute "DAY_MINUTE"
daySecond "DAY_SECOND"
decimalType "DECIMAL"
defaultKwd "DEFAULT"
delayed "DELAYED"
deleteKwd "DELETE"
denseRank "DENSE_RANK"
desc "DESC"
describe "DESCRIBE"
distinct "DISTINCT"
distinctRow "DISTINCTROW"
div "DIV"
doubleType "DOUBLE"
drop "DROP"
dual "DUAL"
elseKwd "ELSE"
enclosed "ENCLOSED"
escaped "ESCAPED"
exists "EXISTS"
explain "EXPLAIN"
falseKwd "FALSE"
firstValue "FIRST_VALUE"
floatType "FLOAT"
forKwd "FOR"
force "FORCE"
foreign "FOREIGN"
from "FROM"
fulltext "FULLTEXT"
generated "GENERATED"
grant "GRANT"
group "GROUP"
groups "GROUPS"
having "HAVING"
highPriority "HIGH_PRIORITY"
hourMicrosecond "HOUR_MICROSECOND"
hourMinute "HOUR_MINUTE"
hourSecond "HOUR_SECOND"
ifKwd "IF"
ignore "IGNORE"
in "IN"
index "INDEX"
infile "INFILE"
inner "INNER"
integerType "INTEGER"
interval "INTERVAL"
into "INTO"
is "IS"
insert "INSERT"
intType "INT"
int1Type "INT1"
int2Type "INT2"
int3Type "INT3"
int4Type "INT4"
int8Type "INT8"
join "JOIN"
key "KEY"
keys "KEYS"
kill "KILL"
lag "LAG"
lastValue "LAST_VALUE"
lead "LEAD"
leading "LEADING"
left "LEFT"
like "LIKE"
limit "LIMIT"
lines "LINES"
load "LOAD"
localTime "LOCALTIME"
localTs "LOCALTIMESTAMP"
lock "LOCK"
longblobType "LONGBLOB"
longtextType "LONGTEXT"
lowPriority "LOW_PRIORITY"
maxValue "MAXVALUE"
mediumblobType "MEDIUMBLOB"
mediumIntType "MEDIUMINT"
mediumtextType "MEDIUMTEXT"
minuteMicrosecond "MINUTE_MICROSECOND"
minuteSecond "MINUTE_SECOND"
mod "MOD"
not "NOT"
noWriteToBinLog "NO_WRITE_TO_BINLOG"
nthValue "NTH_VALUE"
ntile "NTILE"
null "NULL"
numericType "NUMERIC"
nvarcharType "NVARCHAR"
on "ON"
option "OPTION"
optionally "OPTIONALLY"
or "OR"
order "ORDER"
outer "OUTER"
over "OVER"
packKeys "PACK_KEYS"
partition "PARTITION"
percentRank "PERCENT_RANK"
precisionType "PRECISION"
primary "PRIMARY"
procedure "PROCEDURE"
shardRowIDBits "SHARD_ROW_ID_BITS"
rangeKwd "RANGE"
rank "RANK"
read "READ"
realType "REAL"
references "REFERENCES"
regexpKwd "REGEXP"
rename "RENAME"
repeat "REPEAT"
replace "REPLACE"
restrict "RESTRICT"
revoke "REVOKE"
right "RIGHT"
rlike "RLIKE"
row "ROW"
rows "ROWS"
rowNumber "ROW_NUMBER"
secondMicrosecond "SECOND_MICROSECOND"
selectKwd "SELECT"
set "SET"
show "SHOW"
smallIntType "SMALLINT"
sql "SQL"
sqlCalcFoundRows "SQL_CALC_FOUND_ROWS"
starting "STARTING"
straightJoin "STRAIGHT_JOIN"
tableKwd "TABLE"
stored "STORED"
terminated "TERMINATED"
then "THEN"
tinyblobType "TINYBLOB"
tinyIntType "TINYINT"
tinytextType "TINYTEXT"
to "TO"
trailing "TRAILING"
trigger "TRIGGER"
trueKwd "TRUE"
unique "UNIQUE"
union "UNION"
unlock "UNLOCK"
unsigned "UNSIGNED"
update "UPDATE"
usage "USAGE"
use "USE"
using "USING"
utcDate "UTC_DATE"
utcTimestamp "UTC_TIMESTAMP"
utcTime "UTC_TIME"
values "VALUES"
long "LONG"
varcharType "VARCHAR"
varbinaryType "VARBINARY"
virtual "VIRTUAL"
when "WHEN"
where "WHERE"
write "WRITE"
window "WINDOW"
with "WITH"
xor "XOR"
yearMonth "YEAR_MONTH"
zerofill "ZEROFILL"
natural "NATURAL"
/* The following tokens belong to UnReservedKeyword. */
action "ACTION"
after "AFTER"
always "ALWAYS"
algorithm "ALGORITHM"
any "ANY"
ascii "ASCII"
autoIncrement "AUTO_INCREMENT"
avgRowLength "AVG_ROW_LENGTH"
avg "AVG"
begin "BEGIN"
binlog "BINLOG"
bitType "BIT"
booleanType "BOOLEAN"
boolType "BOOL"
btree "BTREE"
byteType "BYTE"
cascaded "CASCADED"
charsetKwd "CHARSET"
checksum "CHECKSUM"
cleanup "CLEANUP"
client "CLIENT"
coalesce "COALESCE"
collation "COLLATION"
columns "COLUMNS"
comment "COMMENT"
commit "COMMIT"
committed "COMMITTED"
compact "COMPACT"
compressed "COMPRESSED"
compression "COMPRESSION"
connection "CONNECTION"
consistent "CONSISTENT"
current "CURRENT"
day "DAY"
data "DATA"
dateType "DATE"
datetimeType "DATETIME"
deallocate "DEALLOCATE"
definer "DEFINER"
delayKeyWrite "DELAY_KEY_WRITE"
disable "DISABLE"
do "DO"
duplicate "DUPLICATE"
dynamic "DYNAMIC"
enable "ENABLE"
end "END"
engine "ENGINE"
engines "ENGINES"
enum "ENUM"
event "EVENT"
events "EVENTS"
escape "ESCAPE"
exclusive "EXCLUSIVE"
execute "EXECUTE"
fields "FIELDS"
first "FIRST"
fixed "FIXED"
flush "FLUSH"
following "FOLLOWING"
format "FORMAT"
full "FULL"
function "FUNCTION"
grants "GRANTS"
hash "HASH"
hour "HOUR"
identified "IDENTIFIED"
isolation "ISOLATION"
indexes "INDEXES"
invoker "INVOKER"
jsonType "JSON"
keyBlockSize "KEY_BLOCK_SIZE"
local "LOCAL"
last "LAST"
less "LESS"
level "LEVEL"
master "MASTER"
microsecond "MICROSECOND"
minute "MINUTE"
mode "MODE"
modify "MODIFY"
month "MONTH"
maxRows "MAX_ROWS"
maxConnectionsPerHour "MAX_CONNECTIONS_PER_HOUR"
maxQueriesPerHour "MAX_QUERIES_PER_HOUR"
maxUpdatesPerHour "MAX_UPDATES_PER_HOUR"
maxUserConnections "MAX_USER_CONNECTIONS"
merge "MERGE"
minRows "MIN_ROWS"
names "NAMES"
national "NATIONAL"
no "NO"
none "NONE"
nulls "NULLS"
offset "OFFSET"
only "ONLY"
password "PASSWORD"
partitions "PARTITIONS"
pipesAsOr
plugins "PLUGINS"
preceding "PRECEDING"
prepare "PREPARE"
privileges "PRIVILEGES"
process "PROCESS"
processlist "PROCESSLIST"
profiles "PROFILES"
quarter "QUARTER"
query "QUERY"
queries "QUERIES"
quick "QUICK"
recover "RECOVER"
redundant "REDUNDANT"
reload "RELOAD"
repeatable "REPEATABLE"
respect "RESPECT"
replication "REPLICATION"
reverse "REVERSE"
rollback "ROLLBACK"
routine "ROUTINE"
rowCount "ROW_COUNT"
rowFormat "ROW_FORMAT"
second "SECOND"
security "SECURITY"
separator "SEPARATOR"
serializable "SERIALIZABLE"
session "SESSION"
share "SHARE"
shared "SHARED"
signed "SIGNED"
slave "SLAVE"
slow "SLOW"
snapshot "SNAPSHOT"
sqlCache "SQL_CACHE"
sqlNoCache "SQL_NO_CACHE"
start "START"
statsPersistent "STATS_PERSISTENT"
status "STATUS"
subpartition "SUBPARTITION"
subpartitions "SUBPARTITIONS"
super "SUPER"
some "SOME"
global "GLOBAL"
tables "TABLES"
tablespace "TABLESPACE"
temporary "TEMPORARY"
temptable "TEMPTABLE"
textType "TEXT"
than "THAN"
timeType "TIME"
timestampType "TIMESTAMP"
trace "TRACE"
transaction "TRANSACTION"
triggers "TRIGGERS"
truncate "TRUNCATE"
unbounded "UNBOUNDED"
uncommitted "UNCOMMITTED"
unknown "UNKNOWN"
user "USER"
undefined "UNDEFINED"
value "VALUE"
variables "VARIABLES"
view "VIEW"
binding "BINDING"
bindings "BINDINGS"
warnings "WARNINGS"
identSQLErrors "ERRORS"
week "WEEK"
yearType "YEAR"
/* The following tokens belong to NotKeywordToken. */
addDate "ADDDATE"
bitAnd "BIT_AND"
bitOr "BIT_OR"
bitXor "BIT_XOR"
cast "CAST"
copyKwd "COPY"
count "COUNT"
curTime "CURTIME"
dateAdd "DATE_ADD"
dateSub "DATE_SUB"
extract "EXTRACT"
getFormat "GET_FORMAT"
groupConcat "GROUP_CONCAT"
next_row_id "NEXT_ROW_ID"
inplace "INPLACE"
internal "INTERNAL"
min "MIN"
max "MAX"
maxExecutionTime "MAX_EXECUTION_TIME"
now "NOW"
position "POSITION"
recent "RECENT"
std "STD"
stddev "STDDEV"
stddevPop "STDDEV_POP"
stddevSamp "STDDEV_SAMP"
subDate "SUBDATE"
sum "SUM"
substring "SUBSTRING"
timestampAdd "TIMESTAMPADD"
timestampDiff "TIMESTAMPDIFF"
top "TOP"
trim "TRIM"
variance "VARIANCE"
varPop "VAR_POP"
varSamp "VAR_SAMP"
/* The following tokens belong to TiDBKeyword. */
admin "ADMIN"
buckets "BUCKETS"
cancel "CANCEL"
ddl "DDL"
jobs "JOBS"
job "JOB"
stats "STATS"
statsMeta "STATS_META"
statsHistograms "STATS_HISTOGRAMS"
statsBuckets "STATS_BUCKETS"
statsHealthy "STATS_HEALTHY"
tidb "TIDB"
tidbHJ "TIDB_HJ"
tidbSMJ "TIDB_SMJ"
tidbINLJ "TIDB_INLJ"
restore "RESTORE"
builtinAddDate
builtinBitAnd
builtinBitOr
builtinBitXor
builtinCast
builtinCount
builtinCurDate
builtinCurTime
builtinDateAdd
builtinDateSub
builtinExtract
builtinGroupConcat
builtinMax
builtinMin
builtinNow
builtinPosition
builtinSubDate
builtinSubstring
builtinSum
builtinSysDate
builtinStddevPop
builtinStddevSamp
builtinTrim
builtinUser
builtinVarPop
builtinVarSamp
%token <item>
/*yy:token "1.%d" */ floatLit "floating-point literal"
/*yy:token "1.%d" */ decLit "decimal literal"
/*yy:token "%d" */ intLit "integer literal"
/*yy:token "%x" */ hexLit "hexadecimal literal"
/*yy:token "%b" */ bitLit "bit literal"
andnot "&^"
assignmentEq ":="
eq "="
ge ">="
le "<="
jss "->"
juss "->>"
lsh "<<"
neq "!="
neqSynonym "<>"
nulleq "<=>"
paramMarker "?"
rsh ">>"
%token not2
%type <expr>
Expression "expression"
MaxValueOrExpression "maxvalue or expression"
BoolPri "boolean primary expression"
ExprOrDefault "expression or default"
PredicateExpr "Predicate expression factor"
SetExpr "Set variable statement value's expression"
BitExpr "bit expression"
SimpleExpr "simple expression"
SimpleIdent "Simple Identifier expression"
SumExpr "aggregate functions"
FunctionCallGeneric "Function call with Identifier"
FunctionCallKeyword "Function call with keyword as function name"
FunctionCallNonKeyword "Function call with nonkeyword as function name"
Literal "literal value"
Variable "User or system variable"
SystemVariable "System defined variable name"
UserVariable "User defined variable name"
SubSelect "Sub Select"
StringLiteral "text literal"
ExpressionOpt "Optional expression"
SignedLiteral "Literal or NumLiteral with sign"
DefaultValueExpr "DefaultValueExpr(Now or Signed Literal)"
NowSymOptionFraction "NowSym with optional fraction part"
%type <statement>
AdminStmt "Check table statement or show ddl statement"
AlterTableStmt "Alter table statement"
AlterUserStmt "Alter user statement"
AnalyzeTableStmt "Analyze table statement"
BeginTransactionStmt "BEGIN TRANSACTION statement"
BinlogStmt "Binlog base64 statement"
CommitStmt "COMMIT statement"
CreateTableStmt "CREATE TABLE statement"
CreateViewStmt "CREATE VIEW stetement"
CreateUserStmt "CREATE User statement"
CreateDatabaseStmt "Create Database Statement"
CreateIndexStmt "CREATE INDEX statement"
CreateBindingStmt "CREATE BINDING statement"
DoStmt "Do statement"
DropDatabaseStmt "DROP DATABASE statement"
DropIndexStmt "DROP INDEX statement"
DropStatsStmt "DROP STATS statement"
DropTableStmt "DROP TABLE statement"
DropUserStmt "DROP USER"
DropViewStmt "DROP VIEW statement"
DropBindingStmt "DROP BINDING statement"
DeallocateStmt "Deallocate prepared statement"
DeleteFromStmt "DELETE FROM statement"
EmptyStmt "empty statement"
ExecuteStmt "Execute statement"
ExplainStmt "EXPLAIN statement"
ExplainableStmt "explainable statement"
FlushStmt "Flush statement"
GrantStmt "Grant statement"
InsertIntoStmt "INSERT INTO statement"
KillStmt "Kill statement"
LoadDataStmt "Load data statement"
LoadStatsStmt "Load statistic statement"
LockTablesStmt "Lock tables statement"
PreparedStmt "PreparedStmt"
SelectStmt "SELECT statement"
RenameTableStmt "rename table statement"
ReplaceIntoStmt "REPLACE INTO statement"
RevokeStmt "Revoke statement"
RollbackStmt "ROLLBACK statement"
SetStmt "Set variable statement"
ShowStmt "Show engines/databases/tables/user/columns/warnings/status statement"
Statement "statement"
TraceStmt "TRACE statement"
TraceableStmt "traceable statment"
TruncateTableStmt "TRUNCATE TABLE statement"
UnlockTablesStmt "Unlock tables statement"
UpdateStmt "UPDATE statement"
UnionStmt "Union select state ment"
UseStmt "USE statement"
%type <item>
AdminShowSlow "Admin Show Slow statement"
AlterTableOptionListOpt "alter table option list opt"
AlterTableSpec "Alter table specification"
AlterTableSpecList "Alter table specification list"
AnyOrAll "Any or All for subquery"
Assignment "assignment"
AssignmentList "assignment list"
AssignmentListOpt "assignment list opt"
AuthOption "User auth option"
AuthString "Password string value"
OptionalBraces "optional braces"
CastType "Cast function target type"
CharsetName "Character set name"
ColumnDef "table column definition"
ColumnDefList "table column definition list"
ColumnName "column name"
ColumnNameList "column name list"
ColumnList "column list"
ColumnNameListOpt "column name list opt"
ColumnNameListOptWithBrackets "column name list opt with brackets"
ColumnSetValue "insert statement set value by column name"
ColumnSetValueList "insert statement set value by column name list"
CompareOp "Compare opcode"
ColumnOption "column definition option"
ColumnOptionList "column definition option list"
VirtualOrStored "indicate generated column is stored or not"
ColumnOptionListOpt "optional column definition option list"
Constraint "table constraint"
ConstraintElem "table constraint element"
ConstraintKeywordOpt "Constraint Keyword or empty"
CreateIndexStmtUnique "CREATE INDEX optional UNIQUE clause"
CreateTableOptionListOpt "create table option list opt"
CreateTableSelectOpt "Select/Union statement in CREATE TABLE ... SELECT"
DatabaseOption "CREATE Database specification"
DatabaseOptionList "CREATE Database specification list"
DatabaseOptionListOpt "CREATE Database specification list opt"
DBName "Database Name"
DistinctOpt "Explicit distinct option"
DefaultFalseDistinctOpt "Distinct option which defaults to false"
DefaultTrueDistinctOpt "Distinct option which defaults to true"
BuggyDefaultFalseDistinctOpt "Distinct option which accepts DISTINCT ALL and defaults to false"
Enclosed "Enclosed by"
EqOpt "= or empty"
EscapedTableRef "escaped table reference"
Escaped "Escaped by"
ExpressionList "expression list"
MaxValueOrExpressionList "maxvalue or expression list"
ExpressionListOpt "expression list opt"
FuncDatetimePrecListOpt "Function datetime precision list opt"
FuncDatetimePrecList "Function datetime precision list"
Field "field expression"
Fields "Fields clause"
FieldsTerminated "Fields terminated by"
FieldAsName "Field alias name"
FieldAsNameOpt "Field alias name opt"
FieldList "field expression list"
FlushOption "Flush option"
TableRefsClause "Table references clause"
FuncDatetimePrec "Function datetime precision"
GlobalScope "The scope of variable"
GroupByClause "GROUP BY clause"
HashString "Hashed string"
HavingClause "HAVING clause"
HandleRange "handle range"
HandleRangeList "handle range list"
IfExists "If Exists"
IfNotExists "If Not Exists"
IgnoreOptional "IGNORE or empty"
IndexColName "Index column name"
IndexColNameList "List of index column name"
IndexHint "index hint"
IndexHintList "index hint list"
IndexHintListOpt "index hint list opt"
IndexHintScope "index hint scope"
IndexHintType "index hint type"
IndexName "index name"
IndexNameList "index name list"
IndexOption "Index Option"
IndexOptionList "Index Option List or empty"
IndexType "index type"
IndexTypeOpt "Optional index type"
InsertValues "Rest part of INSERT/REPLACE INTO statement"
JoinTable "join table"
JoinType "join type"
KillOrKillTiDB "Kill or Kill TiDB"
LikeEscapeOpt "like escape option"
LikeTableWithOrWithoutParen "LIKE table_name or ( LIKE table_name )"
LimitClause "LIMIT clause"
LimitOption "Limit option could be integer or parameter marker."
Lines "Lines clause"
LinesTerminated "Lines terminated by"
LocalOpt "Local opt"
LockClause "Alter table lock clause"
MaxNumBuckets "Max number of buckets"
NumLiteral "Num/Int/Float/Decimal Literal"
NoWriteToBinLogAliasOpt "NO_WRITE_TO_BINLOG alias LOCAL or empty"
ObjectType "Grant statement object type"
OnDuplicateKeyUpdate "ON DUPLICATE KEY UPDATE value list"
DuplicateOpt "[IGNORE|REPLACE] in CREATE TABLE ... SELECT statement"
OptFull "Full or empty"
Order "ORDER BY clause optional collation specification"
OrderBy "ORDER BY clause"
OrReplace "or replace"
ByItem "BY item"
OrderByOptional "Optional ORDER BY clause optional"
ByList "BY list"
QuickOptional "QUICK or empty"
PartitionDefinition "Partition definition"
PartitionDefinitionList "Partition definition list"
PartitionDefinitionListOpt "Partition definition list option"
PartitionOpt "Partition option"
PartitionNameList "Partition name list"
PartitionNameListOpt "table partition names list optional"
PartitionNumOpt "PARTITION NUM option"
PartDefValuesOpt "VALUES {LESS THAN {(expr | value_list) | MAXVALUE} | IN {value_list}"
PartDefOptionsOpt "PartDefOptionList option"
PartDefOptionList "PartDefOption list"
PartDefOption "COMMENT [=] xxx | TABLESPACE [=] tablespace_name | ENGINE [=] xxx"
PasswordOpt "Password option"
ColumnPosition "Column position [First|After ColumnName]"
PrepareSQL "Prepare statement sql string"
PriorityOpt "Statement priority option"
PrivElem "Privilege element"
PrivElemList "Privilege element list"
PrivLevel "Privilege scope"
PrivType "Privilege type"
ReferDef "Reference definition"
OnDeleteOpt "optional ON DELETE clause"
OnUpdateOpt "optional ON UPDATE clause"
OptGConcatSeparator "optional GROUP_CONCAT SEPARATOR"
ReferOpt "reference option"
RowFormat "Row format option"
RowValue "Row value"
SelectLockOpt "FOR UPDATE or LOCK IN SHARE MODE,"
SelectStmtCalcFoundRows "SELECT statement optional SQL_CALC_FOUND_ROWS"
SelectStmtSQLCache "SELECT statement optional SQL_CAHCE/SQL_NO_CACHE"
SelectStmtStraightJoin "SELECT statement optional STRAIGHT_JOIN"
SelectStmtFieldList "SELECT statement field list"
SelectStmtLimit "SELECT statement optional LIMIT clause"
SelectStmtOpts "Select statement options"
SelectStmtBasic "SELECT statement from constant value"
SelectStmtFromDualTable "SELECT statement from dual table"
SelectStmtFromTable "SELECT statement from table"
SelectStmtGroup "SELECT statement optional GROUP BY clause"
ShowTargetFilterable "Show target that can be filtered by WHERE or LIKE"
ShowDatabaseNameOpt "Show tables/columns statement database name option"
ShowTableAliasOpt "Show table alias option"
ShowLikeOrWhereOpt "Show like or where clause option"
Starting "Starting by"
StatementList "statement list"
StatsPersistentVal "stats_persistent value"
StringName "string literal or identifier"
StringList "string list"
SubPartitionOpt "SubPartition option"
SubPartitionNumOpt "SubPartition NUM option"
Symbol "Constraint Symbol"
TableAsName "table alias name"
TableAsNameOpt "table alias name optional"
TableElement "table definition element"
TableElementList "table definition element list"
TableElementListOpt "table definition element list optional"
TableFactor "table factor"
TableLock "Table name and lock type"
TableLockList "Table lock list"
TableName "Table name"
TableNameList "Table name list"
TableNameListOpt "Table name list opt"
TableOption "create table option"
TableOptionList "create table option list"
TableRef "table reference"
TableRefs "table references"
TableToTable "rename table to table"
TableToTableList "rename table to table by list"
TransactionChar "Transaction characteristic"
TransactionChars "Transaction characteristic list"
TrimDirection "Trim string direction"
UnionOpt "Union Option(empty/ALL/DISTINCT)"
UnionClauseList "Union select clause list"
UnionSelect "Union (select) item"
Username "Username"
UsernameList "UsernameList"
UserSpec "Username and auth option"
UserSpecList "Username and auth option list"
UserVariableList "User defined variable name list"
Values "values"
ValuesList "values list"
ValuesOpt "values optional"
VariableAssignment "set variable value"
VariableAssignmentList "set variable value list"
ViewAlgorithm "view algorithm"
ViewCheckOption "view check option"
ViewDefiner "view definer"
ViewName "view name"
ViewFieldList "create view statement field list"
ViewSQLSecurity "view sql security"
WhereClause "WHERE clause"
WhereClauseOptional "Optional WHERE clause"
WhenClause "When clause"
WhenClauseList "When clause list"
WithReadLockOpt "With Read Lock opt"
WithGrantOptionOpt "With Grant Option opt"
ElseOpt "Optional else clause"
Type "Types"
OptExistingWindowName "Optional existing WINDOW name"
OptFromFirstLast "Optional FROM FIRST/LAST"
OptLLDefault "Optional LEAD/LAG default"
OptLeadLagInfo "Optional LEAD/LAG info"
OptNullTreatment "Optional NULL treatment"
OptPartitionClause "Optional PARTITION clause"
OptWindowOrderByClause "Optional ORDER BY clause in WINDOW"
OptWindowFrameClause "Optional FRAME clause in WINDOW"
OptWindowingClause "Optional OVER clause"
WindowingClause "OVER clause"
WindowClauseOptional "Optional WINDOW clause"
WindowDefinitionList "WINDOW definition list"
WindowDefinition "WINDOW definition"
WindowFrameUnits "WINDOW frame units"
WindowFrameBetween "WINDOW frame between"
WindowFrameBound "WINDOW frame bound"
WindowFrameExtent "WINDOW frame extent"
WindowFrameStart "WINDOW frame start"
WindowFuncCall "WINDOW function call"
WindowName "WINDOW name"
WindowNameOrSpec "WINDOW name or spec"
WindowSpec "WINDOW spec"
WindowSpecDetails "WINDOW spec details"
BetweenOrNotOp "Between predicate"
IsOrNotOp "Is predicate"
InOrNotOp "In predicate"
LikeOrNotOp "Like predicate"
RegexpOrNotOp "Regexp predicate"
NumericType "Numeric types"
IntegerType "Integer Types types"
BooleanType "Boolean Types types"
FixedPointType "Exact value types"
FloatingPointType "Approximate value types"
BitValueType "bit value types"
StringType "String types"
BlobType "Blob types"
TextType "Text types"
DateAndTimeType "Date and Time types"
OptFieldLen "Field length or empty"
FieldLen "Field length"
FieldOpts "Field type definition option list"
FieldOpt "Field type definition option"
FloatOpt "Floating-point type option"
Precision "Floating-point precision option"
OptBinary "Optional BINARY"
OptBinMod "Optional BINARY mode"
OptCharset "Optional Character setting"
OptCollate "Optional Collate setting"
IgnoreLines "Ignore num(int) lines"
NUM "A number"
NumList "Some numbers"
LengthNum "Field length num(uint64)"
HintTableList "Table list in optimizer hint"
TableOptimizerHintOpt "Table level optimizer hint"
TableOptimizerHints "Table level optimizer hints"
TableOptimizerHintList "Table level optimizer hint list"
%type <ident>
AsOpt "AS or EmptyString"
KeyOrIndex "{KEY|INDEX}"
ColumnKeywordOpt "Column keyword or empty"
PrimaryOpt "Optional primary keyword"
NowSym "CURRENT_TIMESTAMP/LOCALTIME/LOCALTIMESTAMP"
NowSymFunc "CURRENT_TIMESTAMP/LOCALTIME/LOCALTIMESTAMP/NOW"
DefaultKwdOpt "optional DEFAULT keyword"
DatabaseSym "DATABASE or SCHEMA"
ExplainSym "EXPLAIN or DESCRIBE or DESC"
RegexpSym "REGEXP or RLIKE"
IntoOpt "INTO or EmptyString"
ValueSym "Value or Values"
Varchar "{NATIONAL VARCHAR|VARCHAR|NVARCHAR}"
TimeUnit "Time unit for 'DATE_ADD', 'DATE_SUB', 'ADDDATE', 'SUBDATE', 'EXTRACT'"
TimestampUnit "Time unit for 'TIMESTAMPADD' and 'TIMESTAMPDIFF'"
DeallocateSym "Deallocate or drop"
OuterOpt "optional OUTER clause"
CrossOpt "Cross join option"
TablesTerminalSym "{TABLE|TABLES}"
IsolationLevel "Isolation level"
ShowIndexKwd "Show index/indexs/key keyword"
DistinctKwd "DISTINCT/DISTINCTROW keyword"
FromOrIn "From or In"
OptTable "Optional table keyword"
OptInteger "Optional Integer keyword"
NationalOpt "National option"
CharsetKw "charset or charater set"
CommaOpt "optional comma"
LockType "Table locks type"
logAnd "logical and operator"
logOr "logical or operator"
FieldsOrColumns "Fields or columns"
GetFormatSelector "{DATE|DATETIME|TIME|TIMESTAMP}"
%type <ident>
ODBCDateTimeType "ODBC type keywords for date and time literals"
Identifier "identifier or unreserved keyword"
NotKeywordToken "Tokens not mysql keyword but treated specially"
UnReservedKeyword "MySQL unreserved keywords"
TiDBKeyword "TiDB added keywords"
FunctionNameConflict "Built-in function call names which are conflict with keywords"
FunctionNameOptionalBraces "Function with optional braces, all of them are reserved keywords."
FunctionNameDatetimePrecision "Function with optional datetime precision, all of them are reserved keywords."
FunctionNameDateArith "Date arith function call names (date_add or date_sub)"
FunctionNameDateArithMultiForms "Date arith function call names (adddate or subdate)"
%precedence empty
%precedence sqlCache sqlNoCache
%precedence lowerThanIntervalKeyword
%precedence interval
%precedence lowerThanStringLitToken
%precedence stringLit
%precedence lowerThanSetKeyword
%precedence set
%precedence lowerThanInsertValues
%precedence insertValues
%precedence lowerThanCreateTableSelect
%precedence createTableSelect
%precedence lowerThanKey
%precedence key
%left join straightJoin inner cross left right full natural
/* A dummy token to force the priority of TableRef production in a join. */
%left tableRefPriority
%precedence lowerThanOn
%precedence on using
%right assignmentEq
%left pipes or pipesAsOr
%left xor
%left andand and
%left between
%precedence lowerThanEq
%left eq ge le neq neqSynonym '>' '<' is like in
%left '|'
%left '&'
%left rsh lsh
%left '-' '+'
%left '*' '/' '%' div mod
%left '^'
%left '~' neg
%right not not2
%right collate
%precedence '('
%precedence quick
%precedence escape
%precedence lowerThanComma
%precedence ','
%precedence higherThanComma
%start Start
%%
Start:
StatementList
/**************************************AlterTableStmt***************************************
* See https://dev.mysql.com/doc/refman/5.7/en/alter-table.html
*******************************************************************************************/
AlterTableStmt:
"ALTER" IgnoreOptional "TABLE" TableName AlterTableSpecList
{
$$ = &ast.AlterTableStmt{
Table: $4.(*ast.TableName),
Specs: $5.([]*ast.AlterTableSpec),
}
}
| "ALTER" IgnoreOptional "TABLE" TableName "ANALYZE" "PARTITION" PartitionNameList MaxNumBuckets
{
$$ = &ast.AnalyzeTableStmt{TableNames: []*ast.TableName{$4.(*ast.TableName)}, PartitionNames: $7.([]model.CIStr), MaxNumBuckets: $8.(uint64),}
}
| "ALTER" IgnoreOptional "TABLE" TableName "ANALYZE" "PARTITION" PartitionNameList "INDEX" IndexNameList MaxNumBuckets
{
$$ = &ast.AnalyzeTableStmt{