@@ -119,6 +119,88 @@ public MySqlCreateTableStatement parseCreateTable(boolean acceptCreate) {
119
119
}
120
120
}
121
121
122
+ boolean local = false ;
123
+ if (lexer .identifierEquals (FnvHash .Constants .LOCAL )) {
124
+ final Lexer .SavePoint mark = lexer .mark ();
125
+ lexer .nextToken ();
126
+ if (lexer .token () == Token .INDEX || lexer .token () == Token .KEY
127
+ || lexer .token () == Token .UNIQUE ) {
128
+ local = true ;
129
+ } else if (lexer .token () == Token .FULLTEXT ) {
130
+ lexer .nextToken ();
131
+
132
+ if (lexer .token () == Token .KEY ) {
133
+ MySqlKey fulltextKey = new MySqlKey ();
134
+ this .exprParser .parseIndex (fulltextKey .getIndexDefinition ());
135
+ fulltextKey .setIndexType ("FULLTEXT" );
136
+ fulltextKey .setParent (stmt );
137
+ stmt .getTableElementList ().add (fulltextKey );
138
+
139
+ while (lexer .token () == Token .HINT ) {
140
+ lexer .nextToken ();
141
+ }
142
+
143
+ if (lexer .token () == Token .RPAREN ) {
144
+ break ;
145
+ } else if (lexer .token () == Token .COMMA ) {
146
+ lexer .nextToken ();
147
+ continue ;
148
+ }
149
+ } else if (lexer .token () == Token .INDEX ) {
150
+ MySqlTableIndex idx = new MySqlTableIndex ();
151
+ this .exprParser .parseIndex (idx .getIndexDefinition ());
152
+ idx .setIndexType ("FULLTEXT" );
153
+ idx .setParent (stmt );
154
+ stmt .getTableElementList ().add (idx );
155
+
156
+ if (lexer .token () == Token .RPAREN ) {
157
+ break ;
158
+ } else if (lexer .token () == Token .COMMA ) {
159
+ lexer .nextToken ();
160
+ continue ;
161
+ }
162
+ } else if (lexer .token () == Token .IDENTIFIER && MySqlUtils .isBuiltinDataType (
163
+ lexer .stringVal ())) {
164
+ lexer .reset (mark );
165
+ } else {
166
+ MySqlTableIndex idx = new MySqlTableIndex ();
167
+ this .exprParser .parseIndex (idx .getIndexDefinition ());
168
+ idx .setIndexType ("FULLTEXT" );
169
+ idx .setParent (stmt );
170
+ stmt .getTableElementList ().add (idx );
171
+
172
+ if (lexer .token () == Token .RPAREN ) {
173
+ break ;
174
+ } else if (lexer .token () == Token .COMMA ) {
175
+ lexer .nextToken ();
176
+ continue ;
177
+ }
178
+ }
179
+
180
+ } else if (lexer .identifierEquals (FnvHash .Constants .SPATIAL )) {
181
+ lexer .nextToken ();
182
+ if (lexer .token () == Token .INDEX || lexer .token () == Token .KEY ||
183
+ lexer .token () != Token .IDENTIFIER || !MySqlUtils .isBuiltinDataType (lexer .stringVal ())) {
184
+ MySqlTableIndex idx = new MySqlTableIndex ();
185
+ this .exprParser .parseIndex (idx .getIndexDefinition ());
186
+ idx .setIndexType ("SPATIAL" );
187
+ idx .setParent (stmt );
188
+ stmt .getTableElementList ().add (idx );
189
+
190
+ if (lexer .token () == Token .RPAREN ) {
191
+ break ;
192
+ } else if (lexer .token () == Token .COMMA ) {
193
+ lexer .nextToken ();
194
+ continue ;
195
+ }
196
+ } else {
197
+ lexer .reset (mark );
198
+ }
199
+ } else {
200
+ lexer .reset (mark );
201
+ }
202
+ }
203
+
122
204
if (lexer .token () == Token .FULLTEXT ) {
123
205
Lexer .SavePoint mark = lexer .mark ();
124
206
lexer .nextToken ();
@@ -286,6 +368,9 @@ public MySqlCreateTableStatement parseCreateTable(boolean acceptCreate) {
286
368
if (global ) {
287
369
unique .setGlobal (true );
288
370
}
371
+ if (local ){
372
+ unique .setLocal (true );
373
+ }
289
374
}
290
375
291
376
stmt .getTableElementList ().add (constraint );
@@ -297,6 +382,10 @@ public MySqlCreateTableStatement parseCreateTable(boolean acceptCreate) {
297
382
idx .getIndexDefinition ().setGlobal (true );
298
383
}
299
384
385
+ if (local ) {
386
+ idx .getIndexDefinition ().setLocal (true );
387
+ }
388
+
300
389
idx .setParent (stmt );
301
390
stmt .getTableElementList ().add (idx );
302
391
} else if (lexer .token () == (Token .KEY )) {
@@ -836,6 +925,12 @@ public MySqlCreateTableStatement parseCreateTable(boolean acceptCreate) {
836
925
continue ;
837
926
}
838
927
928
+ if (lexer .identifierEquals (FnvHash .Constants .LOCAL )) {
929
+ SQLPartitionBy localPartitionClause = parseLocalPartitionBy ();
930
+ stmt .setLocalPartitioning (localPartitionClause );
931
+ continue ;
932
+ }
933
+
839
934
if (lexer .identifierEquals (FnvHash .Constants .BROADCAST )) {
840
935
lexer .nextToken ();
841
936
stmt .setBroadCast (true );
@@ -1060,6 +1155,51 @@ public MySqlCreateTableStatement parseCreateTable(boolean acceptCreate) {
1060
1155
return stmt ;
1061
1156
}
1062
1157
1158
+ public SQLPartitionBy parseLocalPartitionBy () {
1159
+ lexer .nextToken ();
1160
+ accept (Token .PARTITION );
1161
+ accept (Token .BY );
1162
+ acceptIdentifier ("RANGE" );
1163
+
1164
+ SQLPartitionByRange partitionClause = new SQLPartitionByRange ();
1165
+
1166
+ accept (Token .LPAREN );
1167
+ partitionClause .addColumn (this .exprParser .name ());
1168
+ accept (Token .RPAREN );
1169
+
1170
+ if (lexer .identifierEquals (FnvHash .Constants .STARTWITH )) {
1171
+ lexer .nextToken ();
1172
+ partitionClause .setStartWith (exprParser .expr ());
1173
+ }
1174
+
1175
+ partitionClause .setInterval (getExprParser ().parseInterval ());
1176
+
1177
+ if (lexer .identifierEquals ("EXPIRE" )) {
1178
+ acceptIdentifier ("EXPIRE" );
1179
+ acceptIdentifier ("AFTER" );
1180
+ partitionClause .setExpireAfter ((SQLIntegerExpr ) exprParser .expr ());
1181
+ }
1182
+
1183
+ if (lexer .identifierEquals ("PRE" )) {
1184
+ acceptIdentifier ("PRE" );
1185
+ acceptIdentifier ("ALLOCATE" );
1186
+ partitionClause .setPreAllocate ((SQLIntegerExpr ) exprParser .expr ());
1187
+ }
1188
+
1189
+ if (lexer .identifierEquals ("PIVOTDATE" )) {
1190
+ acceptIdentifier ("PIVOTDATE" );
1191
+ partitionClause .setPivotDateExpr (exprParser .expr ());
1192
+ }
1193
+
1194
+ if (lexer .token () == Token .DISABLE ) {
1195
+ lexer .nextToken ();
1196
+ acceptIdentifier ("SCHEDULE" );
1197
+ partitionClause .setDisableSchedule (true );
1198
+ }
1199
+
1200
+ return partitionClause ;
1201
+ }
1202
+
1063
1203
public SQLPartitionBy parsePartitionBy () {
1064
1204
lexer .nextToken ();
1065
1205
accept (Token .BY );
0 commit comments