mirror of
https://github.com/postgres/postgres.git
synced 2025-11-24 00:23:06 +03:00
Implement WAIT FOR command
WAIT FOR is to be used on standby and specifies waiting for the specific WAL location to be replayed. This option is useful when the user makes some data changes on primary and needs a guarantee to see these changes are on standby. WAIT FOR needs to wait without any snapshot held. Otherwise, the snapshot could prevent the replay of WAL records, implying a kind of self-deadlock. This is why separate utility command seems appears to be the most robust way to implement this functionality. It's not possible to implement this as a function. Previous experience shows that stored procedures also have limitation in this aspect. Discussion: https://www.postgresql.org/message-id/flat/CAPpHfdsjtZLVzxjGT8rJHCYbM0D5dwkO+BBjcirozJ6nYbOW8Q@mail.gmail.com Discussion: https://www.postgresql.org/message-id/flat/CABPTF7UNft368x-RgOXkfj475OwEbp%2BVVO-wEXz7StgjD_%3D6sw%40mail.gmail.com Author: Kartyshov Ivan <i.kartyshov@postgrespro.ru> Author: Alexander Korotkov <aekorotkov@gmail.com> Author: Xuneng Zhou <xunengzhou@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Peter Eisentraut <peter.eisentraut@enterprisedb.com> Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Reviewed-by: Alexander Lakhin <exclusion@gmail.com> Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> Reviewed-by: Euler Taveira <euler@eulerto.com> Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi> Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Reviewed-by: jian he <jian.universality@gmail.com> Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de> Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
This commit is contained in:
@@ -308,7 +308,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
||||
SecLabelStmt SelectStmt TransactionStmt TransactionStmtLegacy TruncateStmt
|
||||
UnlistenStmt UpdateStmt VacuumStmt
|
||||
VariableResetStmt VariableSetStmt VariableShowStmt
|
||||
ViewStmt CheckPointStmt CreateConversionStmt
|
||||
ViewStmt WaitStmt CheckPointStmt CreateConversionStmt
|
||||
DeallocateStmt PrepareStmt ExecuteStmt
|
||||
DropOwnedStmt ReassignOwnedStmt
|
||||
AlterTSConfigurationStmt AlterTSDictionaryStmt
|
||||
@@ -325,6 +325,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
||||
%type <boolean> opt_concurrently
|
||||
%type <dbehavior> opt_drop_behavior
|
||||
%type <list> opt_utility_option_list
|
||||
%type <list> opt_wait_with_clause
|
||||
%type <list> utility_option_list
|
||||
%type <defelt> utility_option_elem
|
||||
%type <str> utility_option_name
|
||||
@@ -678,7 +679,6 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
||||
json_object_constructor_null_clause_opt
|
||||
json_array_constructor_null_clause_opt
|
||||
|
||||
|
||||
/*
|
||||
* Non-keyword token types. These are hard-wired into the "flex" lexer.
|
||||
* They must be listed first so that their numeric codes do not depend on
|
||||
@@ -748,7 +748,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
||||
|
||||
LABEL LANGUAGE LARGE_P LAST_P LATERAL_P
|
||||
LEADING LEAKPROOF LEAST LEFT LEVEL LIKE LIMIT LISTEN LOAD LOCAL
|
||||
LOCALTIME LOCALTIMESTAMP LOCATION LOCK_P LOCKED LOGGED
|
||||
LOCALTIME LOCALTIMESTAMP LOCATION LOCK_P LOCKED LOGGED LSN_P
|
||||
|
||||
MAPPING MATCH MATCHED MATERIALIZED MAXVALUE MERGE MERGE_ACTION METHOD
|
||||
MINUTE_P MINVALUE MODE MONTH_P MOVE
|
||||
@@ -792,7 +792,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
||||
VACUUM VALID VALIDATE VALIDATOR VALUE_P VALUES VARCHAR VARIADIC VARYING
|
||||
VERBOSE VERSION_P VIEW VIEWS VIRTUAL VOLATILE
|
||||
|
||||
WHEN WHERE WHITESPACE_P WINDOW WITH WITHIN WITHOUT WORK WRAPPER WRITE
|
||||
WAIT WHEN WHERE WHITESPACE_P WINDOW WITH WITHIN WITHOUT WORK WRAPPER WRITE
|
||||
|
||||
XML_P XMLATTRIBUTES XMLCONCAT XMLELEMENT XMLEXISTS XMLFOREST XMLNAMESPACES
|
||||
XMLPARSE XMLPI XMLROOT XMLSERIALIZE XMLTABLE
|
||||
@@ -1120,6 +1120,7 @@ stmt:
|
||||
| VariableSetStmt
|
||||
| VariableShowStmt
|
||||
| ViewStmt
|
||||
| WaitStmt
|
||||
| /*EMPTY*/
|
||||
{ $$ = NULL; }
|
||||
;
|
||||
@@ -16482,6 +16483,26 @@ xml_passing_mech:
|
||||
| BY VALUE_P
|
||||
;
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* WAIT FOR LSN
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
WaitStmt:
|
||||
WAIT FOR LSN_P Sconst opt_wait_with_clause
|
||||
{
|
||||
WaitStmt *n = makeNode(WaitStmt);
|
||||
n->lsn_literal = $4;
|
||||
n->options = $5;
|
||||
$$ = (Node *) n;
|
||||
}
|
||||
;
|
||||
|
||||
opt_wait_with_clause:
|
||||
WITH '(' utility_option_list ')' { $$ = $3; }
|
||||
| /*EMPTY*/ { $$ = NIL; }
|
||||
;
|
||||
|
||||
/*
|
||||
* Aggregate decoration clauses
|
||||
@@ -17969,6 +17990,7 @@ unreserved_keyword:
|
||||
| LOCK_P
|
||||
| LOCKED
|
||||
| LOGGED
|
||||
| LSN_P
|
||||
| MAPPING
|
||||
| MATCH
|
||||
| MATCHED
|
||||
@@ -18139,6 +18161,7 @@ unreserved_keyword:
|
||||
| VIEWS
|
||||
| VIRTUAL
|
||||
| VOLATILE
|
||||
| WAIT
|
||||
| WHITESPACE_P
|
||||
| WITHIN
|
||||
| WITHOUT
|
||||
@@ -18585,6 +18608,7 @@ bare_label_keyword:
|
||||
| LOCK_P
|
||||
| LOCKED
|
||||
| LOGGED
|
||||
| LSN_P
|
||||
| MAPPING
|
||||
| MATCH
|
||||
| MATCHED
|
||||
@@ -18796,6 +18820,7 @@ bare_label_keyword:
|
||||
| VIEWS
|
||||
| VIRTUAL
|
||||
| VOLATILE
|
||||
| WAIT
|
||||
| WHEN
|
||||
| WHITESPACE_P
|
||||
| WORK
|
||||
|
||||
Reference in New Issue
Block a user