@@ -78,6 +78,7 @@ pub struct StatementDefinition {
78
78
pub stmt : SyntaxKind ,
79
79
pub tokens : Vec < SyntaxDefinition > ,
80
80
pub prohibited_following_statements : Vec < SyntaxKind > ,
81
+ pub prohibited_tokens : Vec < SyntaxKind > ,
81
82
}
82
83
83
84
impl StatementDefinition {
@@ -86,9 +87,15 @@ impl StatementDefinition {
86
87
stmt,
87
88
tokens : b. build ( ) ,
88
89
prohibited_following_statements : Vec :: new ( ) ,
90
+ prohibited_tokens : Vec :: new ( ) ,
89
91
}
90
92
}
91
93
94
+ fn with_prohibited_tokens ( mut self , prohibited : Vec < SyntaxKind > ) -> Self {
95
+ self . prohibited_tokens = prohibited;
96
+ self
97
+ }
98
+
92
99
fn with_prohibited_following_statements ( mut self , prohibited : Vec < SyntaxKind > ) -> Self {
93
100
self . prohibited_following_statements = prohibited;
94
101
self
@@ -223,7 +230,11 @@ pub static STATEMENT_DEFINITIONS: LazyLock<HashMap<SyntaxKind, Vec<StatementDefi
223
230
. optional_if_exists_group ( )
224
231
. optional_token ( SyntaxKind :: Only )
225
232
. optional_schema_name_group ( )
226
- . required_token ( SyntaxKind :: Ident )
233
+ . one_of ( vec ! [
234
+ SyntaxKind :: Ident ,
235
+ SyntaxKind :: VersionP ,
236
+ SyntaxKind :: Simple ,
237
+ ] )
227
238
. any_token ( ) ,
228
239
) ) ;
229
240
@@ -273,13 +284,16 @@ pub static STATEMENT_DEFINITIONS: LazyLock<HashMap<SyntaxKind, Vec<StatementDefi
273
284
. required_token ( SyntaxKind :: Ascii41 ) ,
274
285
) ) ;
275
286
276
- m. push ( StatementDefinition :: new (
277
- SyntaxKind :: AlterDefaultPrivilegesStmt ,
278
- SyntaxBuilder :: new ( )
279
- . required_token ( SyntaxKind :: Alter )
280
- . required_token ( SyntaxKind :: Default )
281
- . required_token ( SyntaxKind :: Privileges ) ,
282
- ) ) ;
287
+ m. push (
288
+ StatementDefinition :: new (
289
+ SyntaxKind :: AlterDefaultPrivilegesStmt ,
290
+ SyntaxBuilder :: new ( )
291
+ . required_token ( SyntaxKind :: Alter )
292
+ . required_token ( SyntaxKind :: Default )
293
+ . required_token ( SyntaxKind :: Privileges ) ,
294
+ )
295
+ . with_prohibited_following_statements ( vec ! [ SyntaxKind :: GrantStmt ] ) ,
296
+ ) ;
283
297
284
298
m. push ( StatementDefinition :: new (
285
299
SyntaxKind :: ClusterStmt ,
@@ -387,6 +401,17 @@ pub static STATEMENT_DEFINITIONS: LazyLock<HashMap<SyntaxKind, Vec<StatementDefi
387
401
. required_token ( SyntaxKind :: Ident ) ,
388
402
) ) ;
389
403
404
+ m. push ( StatementDefinition :: new (
405
+ SyntaxKind :: DropStmt ,
406
+ SyntaxBuilder :: new ( )
407
+ . required_token ( SyntaxKind :: Drop )
408
+ . required_token ( SyntaxKind :: Materialized )
409
+ . required_token ( SyntaxKind :: View )
410
+ . optional_if_exists_group ( )
411
+ . optional_schema_name_group ( )
412
+ . required_token ( SyntaxKind :: Ident ) ,
413
+ ) ) ;
414
+
390
415
m. push ( StatementDefinition :: new (
391
416
SyntaxKind :: DropStmt ,
392
417
SyntaxBuilder :: new ( )
@@ -822,6 +847,11 @@ pub static STATEMENT_DEFINITIONS: LazyLock<HashMap<SyntaxKind, Vec<StatementDefi
822
847
SyntaxBuilder :: new ( ) . required_token ( SyntaxKind :: BeginP ) ,
823
848
) ) ;
824
849
850
+ m. push ( StatementDefinition :: new (
851
+ SyntaxKind :: TransactionStmt ,
852
+ SyntaxBuilder :: new ( ) . required_token ( SyntaxKind :: EndP ) ,
853
+ ) ) ;
854
+
825
855
m. push ( StatementDefinition :: new (
826
856
SyntaxKind :: TransactionStmt ,
827
857
SyntaxBuilder :: new ( )
@@ -942,7 +972,11 @@ pub static STATEMENT_DEFINITIONS: LazyLock<HashMap<SyntaxKind, Vec<StatementDefi
942
972
. required_token ( SyntaxKind :: Table )
943
973
. optional_if_not_exists_group ( )
944
974
. optional_schema_name_group ( )
945
- . required_token ( SyntaxKind :: Ident )
975
+ . one_of ( vec ! [
976
+ SyntaxKind :: Ident ,
977
+ SyntaxKind :: VersionP ,
978
+ SyntaxKind :: Simple ,
979
+ ] )
946
980
. any_tokens ( None )
947
981
. required_token ( SyntaxKind :: As )
948
982
. any_token ( ) ,
@@ -973,7 +1007,19 @@ pub static STATEMENT_DEFINITIONS: LazyLock<HashMap<SyntaxKind, Vec<StatementDefi
973
1007
m. push (
974
1008
StatementDefinition :: new (
975
1009
SyntaxKind :: ExplainStmt ,
976
- SyntaxBuilder :: new ( ) . required_token ( SyntaxKind :: Explain ) ,
1010
+ SyntaxBuilder :: new ( )
1011
+ . required_token ( SyntaxKind :: Explain )
1012
+ . one_of ( vec ! [
1013
+ SyntaxKind :: Analyze ,
1014
+ SyntaxKind :: Ascii40 ,
1015
+ SyntaxKind :: Select ,
1016
+ SyntaxKind :: Insert ,
1017
+ SyntaxKind :: Update ,
1018
+ SyntaxKind :: DeleteP ,
1019
+ SyntaxKind :: Merge ,
1020
+ SyntaxKind :: Execute ,
1021
+ SyntaxKind :: Create ,
1022
+ ] ) ,
977
1023
)
978
1024
. with_prohibited_following_statements ( vec ! [
979
1025
SyntaxKind :: VacuumStmt ,
@@ -983,6 +1029,7 @@ pub static STATEMENT_DEFINITIONS: LazyLock<HashMap<SyntaxKind, Vec<StatementDefi
983
1029
SyntaxKind :: UpdateStmt ,
984
1030
SyntaxKind :: MergeStmt ,
985
1031
SyntaxKind :: ExecuteStmt ,
1032
+ SyntaxKind :: CreateTableAsStmt ,
986
1033
] ) ,
987
1034
) ;
988
1035
@@ -1105,6 +1152,18 @@ pub static STATEMENT_DEFINITIONS: LazyLock<HashMap<SyntaxKind, Vec<StatementDefi
1105
1152
. required_token ( SyntaxKind :: Ident ) ,
1106
1153
) ) ;
1107
1154
1155
+ m. push (
1156
+ StatementDefinition :: new (
1157
+ SyntaxKind :: AlterRoleSetStmt ,
1158
+ SyntaxBuilder :: new ( )
1159
+ . required_token ( SyntaxKind :: Alter )
1160
+ . required_token ( SyntaxKind :: Role )
1161
+ . required_token ( SyntaxKind :: Ident )
1162
+ . required_token ( SyntaxKind :: Set ) ,
1163
+ )
1164
+ . with_prohibited_following_statements ( vec ! [ SyntaxKind :: VariableSetStmt ] ) ,
1165
+ ) ;
1166
+
1108
1167
m. push ( StatementDefinition :: new (
1109
1168
SyntaxKind :: DropRoleStmt ,
1110
1169
SyntaxBuilder :: new ( )
@@ -1160,12 +1219,23 @@ pub static STATEMENT_DEFINITIONS: LazyLock<HashMap<SyntaxKind, Vec<StatementDefi
1160
1219
SyntaxBuilder :: new ( ) . required_token ( SyntaxKind :: Checkpoint ) ,
1161
1220
) ) ;
1162
1221
1163
- m. push ( StatementDefinition :: new (
1164
- SyntaxKind :: CreateSchemaStmt ,
1165
- SyntaxBuilder :: new ( )
1166
- . required_token ( SyntaxKind :: Create )
1167
- . required_token ( SyntaxKind :: Schema ) ,
1168
- ) ) ;
1222
+ // CREATE TABLE, CREATE VIEW, CREATE INDEX, CREATE SEQUENCE, CREATE TRIGGER and GRANT
1223
+ m. push (
1224
+ StatementDefinition :: new (
1225
+ SyntaxKind :: CreateSchemaStmt ,
1226
+ SyntaxBuilder :: new ( )
1227
+ . required_token ( SyntaxKind :: Create )
1228
+ . required_token ( SyntaxKind :: Schema ) ,
1229
+ )
1230
+ . with_prohibited_following_statements ( vec ! [
1231
+ SyntaxKind :: CreateTableAsStmt ,
1232
+ SyntaxKind :: CreateStmt ,
1233
+ SyntaxKind :: IndexStmt ,
1234
+ SyntaxKind :: CreateSeqStmt ,
1235
+ SyntaxKind :: CreateTrigStmt ,
1236
+ SyntaxKind :: GrantStmt ,
1237
+ ] ) ,
1238
+ ) ;
1169
1239
1170
1240
m. push ( StatementDefinition :: new (
1171
1241
SyntaxKind :: AlterDatabaseStmt ,
@@ -1233,18 +1303,21 @@ pub static STATEMENT_DEFINITIONS: LazyLock<HashMap<SyntaxKind, Vec<StatementDefi
1233
1303
. required_token ( SyntaxKind :: Ident ) ,
1234
1304
) ) ;
1235
1305
1236
- m. push ( StatementDefinition :: new (
1237
- SyntaxKind :: AlterOpFamilyStmt ,
1238
- SyntaxBuilder :: new ( )
1239
- . required_token ( SyntaxKind :: Alter )
1240
- . required_token ( SyntaxKind :: Operator )
1241
- . required_token ( SyntaxKind :: Family )
1242
- . optional_schema_name_group ( )
1243
- . required_token ( SyntaxKind :: Ident )
1244
- . required_token ( SyntaxKind :: Using )
1245
- . required_token ( SyntaxKind :: Ident )
1246
- . one_of ( vec ! [ SyntaxKind :: Drop , SyntaxKind :: AddP , SyntaxKind :: Rename ] ) ,
1247
- ) ) ;
1306
+ m. push (
1307
+ StatementDefinition :: new (
1308
+ SyntaxKind :: AlterOpFamilyStmt ,
1309
+ SyntaxBuilder :: new ( )
1310
+ . required_token ( SyntaxKind :: Alter )
1311
+ . required_token ( SyntaxKind :: Operator )
1312
+ . required_token ( SyntaxKind :: Family )
1313
+ . optional_schema_name_group ( )
1314
+ . required_token ( SyntaxKind :: Ident )
1315
+ . required_token ( SyntaxKind :: Using )
1316
+ . required_token ( SyntaxKind :: Ident )
1317
+ . one_of ( vec ! [ SyntaxKind :: Drop , SyntaxKind :: AddP , SyntaxKind :: Rename ] ) ,
1318
+ )
1319
+ . with_prohibited_tokens ( vec ! [ SyntaxKind :: Rename ] ) ,
1320
+ ) ;
1248
1321
1249
1322
m. push (
1250
1323
StatementDefinition :: new (
@@ -1256,9 +1329,21 @@ pub static STATEMENT_DEFINITIONS: LazyLock<HashMap<SyntaxKind, Vec<StatementDefi
1256
1329
. required_token ( SyntaxKind :: As )
1257
1330
. any_token ( ) ,
1258
1331
)
1259
- . with_prohibited_following_statements ( vec ! [ SyntaxKind :: SelectStmt ] ) ,
1332
+ . with_prohibited_following_statements ( vec ! [
1333
+ SyntaxKind :: SelectStmt ,
1334
+ SyntaxKind :: InsertStmt ,
1335
+ SyntaxKind :: UpdateStmt ,
1336
+ SyntaxKind :: DeleteStmt ,
1337
+ ] ) ,
1260
1338
) ;
1261
1339
1340
+ m. push ( StatementDefinition :: new (
1341
+ SyntaxKind :: ClosePortalStmt ,
1342
+ SyntaxBuilder :: new ( )
1343
+ . required_token ( SyntaxKind :: Close )
1344
+ . one_of ( vec ! [ SyntaxKind :: Ident , SyntaxKind :: All ] ) ,
1345
+ ) ) ;
1346
+
1262
1347
m. push ( StatementDefinition :: new (
1263
1348
SyntaxKind :: DeallocateStmt ,
1264
1349
SyntaxBuilder :: new ( )
@@ -1331,15 +1416,18 @@ pub static STATEMENT_DEFINITIONS: LazyLock<HashMap<SyntaxKind, Vec<StatementDefi
1331
1416
. required_token ( SyntaxKind :: Ident ) ,
1332
1417
) ) ;
1333
1418
1334
- m. push ( StatementDefinition :: new (
1335
- SyntaxKind :: AlterFdwStmt ,
1336
- SyntaxBuilder :: new ( )
1337
- . required_token ( SyntaxKind :: Alter )
1338
- . required_token ( SyntaxKind :: Foreign )
1339
- . required_token ( SyntaxKind :: DataP )
1340
- . required_token ( SyntaxKind :: Wrapper )
1341
- . required_token ( SyntaxKind :: Ident ) ,
1342
- ) ) ;
1419
+ m. push (
1420
+ StatementDefinition :: new (
1421
+ SyntaxKind :: AlterFdwStmt ,
1422
+ SyntaxBuilder :: new ( )
1423
+ . required_token ( SyntaxKind :: Alter )
1424
+ . required_token ( SyntaxKind :: Foreign )
1425
+ . required_token ( SyntaxKind :: DataP )
1426
+ . required_token ( SyntaxKind :: Wrapper )
1427
+ . required_token ( SyntaxKind :: Ident ) ,
1428
+ )
1429
+ . with_prohibited_tokens ( vec ! [ SyntaxKind :: Rename ] ) ,
1430
+ ) ;
1343
1431
1344
1432
m. push ( StatementDefinition :: new (
1345
1433
SyntaxKind :: CreateForeignServerStmt ,
0 commit comments