117
117
118
118
/* query */
119
119
%type <node> stmt
120
- %type <list> single_query query_part_init query_part_last cypher_stmt
121
- reading_clause_list updating_clause_list_0 updating_clause_list_1
120
+ %type <list> single_query cypher_stmt
122
121
use drop
123
- %type <node> reading_clause updating_clause
122
+
123
+ %type <node> util_stmt
124
+ %type <node> clause
124
125
125
126
/* RETURN and WITH clause */
126
127
%type <node> empty_grouping_set cube_clause rollup_clause group_item having_opt return return_item sort_item skip_opt limit_opt with
@@ -299,6 +300,10 @@ stmt:
299
300
300
301
extra->result = $1 ;
301
302
}
303
+ | util_stmt semicolon_opt
304
+ {
305
+ extra->result = list_make1($1 );
306
+ }
302
307
;
303
308
304
309
cypher_stmt :
@@ -324,6 +329,73 @@ cypher_stmt:
324
329
}
325
330
;
326
331
332
+ util_stmt :
333
+ CREATE GRAPH IDENTIFIER
334
+ {
335
+
336
+ cypher_create_graph *n;
337
+ n = make_ag_node(cypher_create_graph);
338
+ n->graph_name = $3 ;
339
+
340
+ $$ = (Node *)n;
341
+ }
342
+ | CREATE EXTENSION IDENTIFIER create_extension_opt_list
343
+ {
344
+ CreateExtensionStmt *n = makeNode(CreateExtensionStmt);
345
+
346
+ n->extname = $3 ;
347
+ n->if_not_exists = false ;
348
+ n->options = $4 ;
349
+
350
+ $$ = (Node *) n;
351
+ }
352
+ | CREATE EXTENSION IF NOT EXISTS IDENTIFIER create_extension_opt_list
353
+ {
354
+ CreateExtensionStmt *n = makeNode(CreateExtensionStmt);
355
+
356
+ n->extname = $6 ;
357
+ n->if_not_exists = true ;
358
+ n->options = $7 ;
359
+
360
+ $$ = (Node *) n;
361
+ }
362
+ | CREATE OptTemp TABLE qualified_name ' (' OptTableElementList ' )'
363
+ OptInherit OptPartitionSpec table_access_method_clause OptWith
364
+ //OnCommitOption OptTableSpace
365
+ {
366
+ CreateStmt *n = makeNode(CreateStmt);
367
+ /*
368
+ $4->relpersistence = $2;
369
+ n->relation = $4;
370
+ n->tableElts = $6;
371
+ n->inhRelations = $8;
372
+ n->partspec = $9;
373
+ n->ofTypename = NULL;
374
+ n->constraints = NIL;
375
+ n->accessMethod = $10;
376
+ n->options = $11;
377
+ n->oncommit = $12;
378
+ n->tablespacename = $13;
379
+ n->if_not_exists = false;
380
+ */
381
+ $4 ->relpersistence = $2 ;
382
+ n->relation = $4 ;
383
+ n->tableElts = $6 ;
384
+ n->inhRelations = $8 ;
385
+ n->partspec = $9 ;
386
+ n->ofTypename = NULL ;
387
+ n->constraints = NIL;
388
+ n->accessMethod = $10 ;
389
+ n->options = $11 ;
390
+ n->oncommit = ONCOMMIT_NOOP;
391
+ n->tablespacename = NULL ;
392
+ n->if_not_exists = false ;
393
+
394
+ $$ = (Node *)n;
395
+ }
396
+ | use { $$ = linitial($1 ); }
397
+ | drop { $$ = linitial($1 ); }
398
+ ;
327
399
call_stmt :
328
400
CALL expr_func_norm AS var_name where_opt
329
401
{
@@ -451,18 +523,25 @@ all_or_distinct:
451
523
* reading_clause* ( updating_clause+ | updating_clause* return )
452
524
*/
453
525
single_query :
454
- query_part_init query_part_last
455
- {
456
- $$ = list_concat($1 , $2 );
457
- }
458
- | use
459
- {
460
- $$ = $1 ;
461
- }
462
- | drop
463
- {
464
- $$ = $1 ;
465
- }
526
+ clause {
527
+ $$ = list_make1($1 );
528
+ }
529
+ | single_query clause {
530
+ $$ = lappend($1 , $2 );
531
+ }
532
+ ;
533
+
534
+ clause :
535
+ create
536
+ | set
537
+ | remove
538
+ | match
539
+ | with
540
+ | delete
541
+ | merge
542
+ | call_stmt
543
+ | return
544
+ | unwind
466
545
;
467
546
468
547
use :
@@ -485,72 +564,6 @@ drop:
485
564
$$ = list_make1(n);
486
565
}
487
566
488
- query_part_init :
489
- /* empty */
490
- {
491
- $$ = NIL;
492
- }
493
- | query_part_init reading_clause_list updating_clause_list_0 with
494
- {
495
- $$ = lappend(list_concat(list_concat($1 , $2 ), $3 ), $4 );
496
- }
497
- ;
498
-
499
- query_part_last :
500
- reading_clause_list updating_clause_list_1
501
- {
502
- $$ = list_concat($1 , $2 );
503
- }
504
- | reading_clause_list updating_clause_list_0 return
505
- {
506
- $$ = lappend(list_concat($1 , $2 ), $3 );
507
- }
508
- ;
509
-
510
- reading_clause_list :
511
- /* empty */
512
- {
513
- $$ = NIL;
514
- }
515
- | reading_clause_list reading_clause
516
- {
517
- $$ = lappend($1 , $2 );
518
- }
519
- ;
520
-
521
- reading_clause :
522
- match
523
- | unwind
524
- ;
525
-
526
- updating_clause_list_0 :
527
- /* empty */
528
- {
529
- $$ = NIL;
530
- }
531
- | updating_clause_list_1
532
- ;
533
-
534
- updating_clause_list_1 :
535
- updating_clause
536
- {
537
- $$ = list_make1($1 );
538
- }
539
- | updating_clause_list_1 updating_clause
540
- {
541
- $$ = lappend($1 , $2 );
542
- }
543
- ;
544
-
545
- updating_clause :
546
- create
547
- | set
548
- | remove
549
- | delete
550
- | merge
551
- | call_stmt
552
- ;
553
-
554
567
cypher_varlen_opt :
555
568
' *' cypher_range_opt
556
569
{
@@ -1003,69 +1016,7 @@ create:
1003
1016
1004
1017
$$ = (Node *)n;
1005
1018
}
1006
- | CREATE GRAPH IDENTIFIER
1007
- {
1008
-
1009
- cypher_create_graph *n;
1010
- n = make_ag_node(cypher_create_graph);
1011
- n->graph_name = $3 ;
1012
-
1013
- $$ = (Node *)n;
1014
- }
1015
- | CREATE EXTENSION IDENTIFIER create_extension_opt_list
1016
- {
1017
- CreateExtensionStmt *n = makeNode(CreateExtensionStmt);
1018
-
1019
- n->extname = $3 ;
1020
- n->if_not_exists = false ;
1021
- n->options = $4 ;
1022
-
1023
- $$ = (Node *) n;
1024
- }
1025
- | CREATE EXTENSION IF NOT EXISTS IDENTIFIER create_extension_opt_list
1026
- {
1027
- CreateExtensionStmt *n = makeNode(CreateExtensionStmt);
1028
-
1029
- n->extname = $6 ;
1030
- n->if_not_exists = true ;
1031
- n->options = $7 ;
1032
-
1033
- $$ = (Node *) n;
1034
- }
1035
- | CREATE OptTemp TABLE qualified_name ' (' OptTableElementList ' )'
1036
- OptInherit OptPartitionSpec table_access_method_clause OptWith
1037
- //OnCommitOption OptTableSpace
1038
- {
1039
- CreateStmt *n = makeNode(CreateStmt);
1040
- /*
1041
- $4->relpersistence = $2;
1042
- n->relation = $4;
1043
- n->tableElts = $6;
1044
- n->inhRelations = $8;
1045
- n->partspec = $9;
1046
- n->ofTypename = NULL;
1047
- n->constraints = NIL;
1048
- n->accessMethod = $10;
1049
- n->options = $11;
1050
- n->oncommit = $12;
1051
- n->tablespacename = $13;
1052
- n->if_not_exists = false;
1053
- */
1054
- $4 ->relpersistence = $2 ;
1055
- n->relation = $4 ;
1056
- n->tableElts = $6 ;
1057
- n->inhRelations = $8 ;
1058
- n->partspec = $9 ;
1059
- n->ofTypename = NULL ;
1060
- n->constraints = NIL;
1061
- n->accessMethod = $10 ;
1062
- n->options = $11 ;
1063
- n->oncommit = ONCOMMIT_NOOP;
1064
- n->tablespacename = NULL ;
1065
- n->if_not_exists = false ;
1066
-
1067
- $$ = (Node *)n;
1068
- }
1019
+
1069
1020
;
1070
1021
1071
1022
0 commit comments