@@ -902,18 +902,27 @@ replaceStatement
902
902
)? ((' (' columnNames ' )' )? replaceStatementValuesOrSelectOrTable | setAssignmentList)
903
903
;
904
904
905
- // into clause within a given statement can appear only once
905
+ // selectStatement
906
+ // : querySpecification lockClause? # simpleSelect
907
+ // | querySpecificationNointo lockClause? intoClause? # simpleSelect
908
+ // | queryExpression lockClause? # parenthesisSelect
909
+ // | querySpecificationNointo unionStatement+ (
910
+ // KW_UNION unionType=(KW_ALL | KW_DISTINCT)? (querySpecification | queryExpression)
911
+ // )? orderByClause? limitClause? lockClause? # unionSelect
912
+ // | queryExpressionNointo unionParenthesis+ (
913
+ // KW_UNION unionType=(KW_ALL | KW_DISTINCT)? queryExpression
914
+ // )? orderByClause? limitClause? lockClause? # unionParenthesisSelect
915
+ // | querySpecificationNointo (',' lateralStatement)+ # withLateralStatement
916
+ // ;
917
+
918
+ // TODO: Simplify the rules to fit SLL(*) Mode
906
919
selectStatement
907
- : querySpecification lockClause? # simpleSelect
908
- | querySpecificationNointo lockClause? intoClause? # simpleSelect
909
- | queryExpression lockClause? # parenthesisSelect
910
- | querySpecificationNointo unionStatement+ (
920
+ : querySpecification unionStatement* (
911
921
KW_UNION unionType=(KW_ALL | KW_DISTINCT )? (querySpecification | queryExpression)
912
- )? orderByClause? limitClause? lockClause? # unionSelect
913
- | queryExpressionNointo unionParenthesis+ (
922
+ )? ( ' , ' lateralStatement)* orderByClause? limitClause? lockClause? intoClause? # unionAndLateralSelect
923
+ | queryExpression unionStatement* (
914
924
KW_UNION unionType=(KW_ALL | KW_DISTINCT )? queryExpression
915
- )? orderByClause? limitClause? lockClause? # unionParenthesisSelect
916
- | querySpecificationNointo (' ,' lateralStatement)+ # withLateralStatement
925
+ )? orderByClause? limitClause? lockClause? # selectExpression
917
926
;
918
927
919
928
// https://dev.mysql.com/doc/refman/8.0/en/set-operations.html
@@ -1106,34 +1115,24 @@ queryExpression
1106
1115
| ' (' queryExpression ' )'
1107
1116
;
1108
1117
1109
- queryExpressionNointo
1110
- : ' (' querySpecificationNointo ' )'
1111
- | ' (' queryExpressionNointo ' )'
1112
- ;
1113
-
1114
- // into clause within a given statement can appear only once
1118
+ /* *
1119
+ * TODO: intoClause is allowed to appear multiple times,
1120
+ * which is inconsistent with the actual syntax,
1121
+ * but is currently unsolvable because the correct syntax cannot be handled by SLL(*) Mode
1122
+ */
1115
1123
querySpecification
1116
- : KW_SELECT selectSpec* selectElements intoClause? fromClause groupByClause? havingClause? windowClause? orderByClause? limitClause?
1117
- | KW_SELECT selectSpec* selectElements fromClause groupByClause? havingClause? windowClause? orderByClause? limitClause? intoClause?
1118
- ;
1119
-
1120
- querySpecificationNointo
1121
- : KW_SELECT selectSpec* selectElements fromClause groupByClause? havingClause? windowClause? orderByClause? limitClause?
1122
- ;
1123
-
1124
- unionParenthesis
1125
- : KW_UNION unionType=(KW_ALL | KW_DISTINCT )? queryExpressionNointo
1124
+ : KW_SELECT selectSpec* selectElements intoClause? fromClause groupByClause? havingClause? windowClause? orderByClause? limitClause? intoClause?
1126
1125
;
1127
1126
1128
1127
unionStatement
1129
- : KW_UNION unionType=(KW_ALL | KW_DISTINCT )? (querySpecificationNointo | queryExpressionNointo )
1128
+ : KW_UNION unionType=(KW_ALL | KW_DISTINCT )? (querySpecification | queryExpression )
1130
1129
;
1131
1130
1132
1131
lateralStatement
1133
1132
: KW_LATERAL (
1134
- querySpecificationNointo
1135
- | queryExpressionNointo
1136
- | (' (' (querySpecificationNointo | queryExpressionNointo ) ' )' (KW_AS ? alias=uid)?)
1133
+ querySpecification
1134
+ | queryExpression
1135
+ | (' (' (querySpecification | queryExpression ) ' )' (KW_AS ? alias=uid)?)
1137
1136
)
1138
1137
;
1139
1138
@@ -1187,10 +1186,10 @@ selectElements
1187
1186
;
1188
1187
1189
1188
selectElement
1190
- : select_element=fullId ' .' ' *' # selectStarElement
1191
- | columnName (KW_AS ? alias=uid)? # selectColumnElement
1189
+ : (LOCAL_ID VAR_ASSIGN )? expression (KW_AS ? alias=uid)? # selectExpressionElement
1192
1190
| functionCall (KW_AS ? alias=uid)? # selectFunctionElement
1193
- | (LOCAL_ID VAR_ASSIGN )? expression (KW_AS ? alias=uid)? # selectExpressionElement
1191
+ | select_element=fullId ' .' ' *' # selectStarElement
1192
+ | columnName (KW_AS ? alias=uid)? # selectColumnElement
1194
1193
;
1195
1194
1196
1195
intoClause
@@ -1767,13 +1766,14 @@ userSpecification
1767
1766
;
1768
1767
1769
1768
alterUserAuthOption
1770
- : userName KW_IDENTIFIED KW_BY STRING_LITERAL authOptionClause
1771
- | userName KW_IDENTIFIED KW_BY KW_RANDOM KW_PASSWORD authOptionClause
1772
- | userName KW_IDENTIFIED KW_WITH authenticationRule
1773
- | userName KW_DISCARD KW_OLD KW_PASSWORD
1774
- | userName ((KW_ADD | KW_MODIFY | KW_DROP ) factor factorAuthOption?)+
1775
- | userName registrationOption?
1776
- | userName
1769
+ : userName (
1770
+ KW_IDENTIFIED KW_BY STRING_LITERAL authOptionClause
1771
+ | KW_IDENTIFIED KW_BY KW_RANDOM KW_PASSWORD authOptionClause
1772
+ | KW_IDENTIFIED KW_WITH authenticationRule
1773
+ | KW_DISCARD KW_OLD KW_PASSWORD
1774
+ | ((KW_ADD | KW_MODIFY | KW_DROP ) factor factorAuthOption?)+
1775
+ | registrationOption
1776
+ )?
1777
1777
;
1778
1778
1779
1779
// createUser auth_option, 2fa_auth_option, 3fa_auth_option
0 commit comments