@@ -295,7 +295,8 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
295
295
DropRoleStmt
296
296
ExplainStmt ExplainableStmt
297
297
GrantStmt
298
- IndexStmt InsertStmt
298
+ IndexStmt InsertStmt
299
+ LockStmt
299
300
UseGraphStmt
300
301
ReindexStmt RemoveFuncStmt ReturnStmt RenameStmt RevokeStmt
301
302
SelectStmt
@@ -337,11 +338,19 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
337
338
%type <boolean> TransitionRowOrTable TransitionOldOrNew
338
339
%type <node> TriggerTransition
339
340
340
- %type <integer> cast_context
341
+ %type <integer> opt_lock lock_type cast_context
341
342
%type <string> utility_option_name
342
343
%type <defelt> utility_option_elem
343
344
%type <list> utility_option_list
344
345
%type <node> utility_option_arg
346
+ %type <boolean> opt_or_replace opt_no
347
+ opt_grant_grant_option
348
+ opt_nowait opt_if_exists
349
+ opt_with_data
350
+ opt_transaction_chain
351
+ optional_opt
352
+ %type <integer> opt_nowait_or_skip
353
+
345
354
346
355
%type <boolean> opt_instead
347
356
%type <boolean> opt_unique opt_concurrently opt_verbose opt_full
@@ -446,8 +455,6 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
446
455
%type <jexpr> joined_table
447
456
%type <ielem> index_elem index_elem_options
448
457
449
- %type <integer> opt_nowait_or_skip
450
-
451
458
%type <integer> for_locking_strength
452
459
%type <node> for_locking_item
453
460
%type <list> for_locking_clause opt_for_locking_clause for_locking_items
@@ -509,12 +516,6 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
509
516
510
517
%type <defelt> transaction_mode_item
511
518
512
- %type <boolean> opt_or_replace opt_no
513
- opt_grant_grant_option
514
- opt_nowait opt_if_exists
515
- opt_with_data
516
- opt_transaction_chain
517
- optional_opt
518
519
519
520
/* CREATE clause */
520
521
%type <node> create
@@ -923,6 +924,7 @@ stmt:
923
924
| GrantStmt
924
925
| IndexStmt
925
926
| InsertStmt
927
+ | LockStmt
926
928
| ReindexStmt
927
929
| RemoveFuncStmt
928
930
| RenameStmt
@@ -2683,6 +2685,48 @@ CreateGraphStmt:
2683
2685
;
2684
2686
2685
2687
2688
+ /* ****************************************************************************
2689
+ *
2690
+ * QUERY:
2691
+ * LOCK TABLE
2692
+ *
2693
+ *****************************************************************************/
2694
+
2695
+ LockStmt : LOCK_P opt_table relation_expr_list opt_lock opt_nowait
2696
+ {
2697
+ LockStmt *n = makeNode(LockStmt);
2698
+
2699
+ n->relations = $3 ;
2700
+ n->mode = $4 ;
2701
+ n->nowait = $5 ;
2702
+ $$ = (Node *)n;
2703
+ }
2704
+ ;
2705
+
2706
+ opt_lock : IN lock_type MODE { $$ = $2 ; }
2707
+ | /* EMPTY*/ { $$ = AccessExclusiveLock; }
2708
+ ;
2709
+
2710
+ lock_type : ACCESS SHARE { $$ = AccessShareLock; }
2711
+ | ROW SHARE { $$ = RowShareLock; }
2712
+ | ROW EXCLUSIVE { $$ = RowExclusiveLock; }
2713
+ | SHARE UPDATE EXCLUSIVE { $$ = ShareUpdateExclusiveLock; }
2714
+ | SHARE { $$ = ShareLock; }
2715
+ | SHARE ROW EXCLUSIVE { $$ = ShareRowExclusiveLock; }
2716
+ | EXCLUSIVE { $$ = ExclusiveLock; }
2717
+ | ACCESS EXCLUSIVE { $$ = AccessExclusiveLock; }
2718
+ ;
2719
+
2720
+ opt_nowait : NOWAIT { $$ = true ; }
2721
+ | /* EMPTY*/ { $$ = false ; }
2722
+ ;
2723
+
2724
+ opt_nowait_or_skip :
2725
+ NOWAIT { $$ = LockWaitError; }
2726
+ | SKIP LOCKED { $$ = LockWaitSkip; }
2727
+ | /* EMPTY*/ { $$ = LockWaitBlock; }
2728
+ ;
2729
+
2686
2730
2687
2731
/* ****************************************************************************
2688
2732
*
0 commit comments