Skip to content

Commit ccb9041

Browse files
committed
Support LOCK stmt
1 parent 7f113b5 commit ccb9041

File tree

1 file changed

+54
-10
lines changed

1 file changed

+54
-10
lines changed

src/backend/parser/cypher_gram.y

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
295295
DropRoleStmt
296296
ExplainStmt ExplainableStmt
297297
GrantStmt
298-
IndexStmt InsertStmt
298+
IndexStmt InsertStmt
299+
LockStmt
299300
UseGraphStmt
300301
ReindexStmt RemoveFuncStmt ReturnStmt RenameStmt RevokeStmt
301302
SelectStmt
@@ -337,11 +338,19 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
337338
%type <boolean> TransitionRowOrTable TransitionOldOrNew
338339
%type <node> TriggerTransition
339340

340-
%type <integer> cast_context
341+
%type <integer> opt_lock lock_type cast_context
341342
%type <string> utility_option_name
342343
%type <defelt> utility_option_elem
343344
%type <list> utility_option_list
344345
%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+
345354

346355
%type <boolean> opt_instead
347356
%type <boolean> opt_unique opt_concurrently opt_verbose opt_full
@@ -446,8 +455,6 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
446455
%type <jexpr> joined_table
447456
%type <ielem> index_elem index_elem_options
448457

449-
%type <integer> opt_nowait_or_skip
450-
451458
%type <integer> for_locking_strength
452459
%type <node> for_locking_item
453460
%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);
509516

510517
%type <defelt> transaction_mode_item
511518

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
518519

519520
/* CREATE clause */
520521
%type <node> create
@@ -923,6 +924,7 @@ stmt:
923924
| GrantStmt
924925
| IndexStmt
925926
| InsertStmt
927+
| LockStmt
926928
| ReindexStmt
927929
| RemoveFuncStmt
928930
| RenameStmt
@@ -2683,6 +2685,48 @@ CreateGraphStmt:
26832685
;
26842686

26852687

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+
26862730

26872731
/*****************************************************************************
26882732
*

0 commit comments

Comments
 (0)