mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Rework grammar for REINDEX
The part of grammar have grown needlessly duplicative and more complex that necessary. Rewrite. Reviewed-by: Michaël Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/20220721174212.cmitjpuimx6ssyyj@alvherre.pgsql
This commit is contained in:
@@ -336,7 +336,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
||||
|
||||
%type <str> opt_single_name
|
||||
%type <list> opt_qualified_name
|
||||
%type <boolean> opt_concurrently
|
||||
%type <boolean> opt_concurrently
|
||||
%type <dbehavior> opt_drop_behavior
|
||||
|
||||
%type <node> alter_column_default opclass_item opclass_drop alter_using
|
||||
@@ -564,7 +564,8 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
||||
%type <defelt> generic_option_elem alter_generic_option_elem
|
||||
%type <list> generic_option_list alter_generic_option_list
|
||||
|
||||
%type <ival> reindex_target_type reindex_target_multitable reindex_name_optional
|
||||
%type <ival> reindex_target_type
|
||||
%type <list> opt_reindex_option_list
|
||||
|
||||
%type <node> copy_generic_opt_arg copy_generic_opt_arg_list_item
|
||||
%type <defelt> copy_generic_opt_elem
|
||||
@@ -9091,78 +9092,54 @@ DropTransformStmt: DROP TRANSFORM opt_if_exists FOR Typename LANGUAGE name opt_d
|
||||
*
|
||||
* QUERY:
|
||||
*
|
||||
* REINDEX [ (options) ] type [CONCURRENTLY] <name>
|
||||
* REINDEX [ (options) ] {TABLE | INDEX | SCHEMA} [CONCURRENTLY] <name>
|
||||
* REINDEX [ (options) ] DATABASE [CONCURRENTLY] [<name>]
|
||||
* REINDEX [ (options) ] SYSTEM [<name>]
|
||||
*****************************************************************************/
|
||||
|
||||
ReindexStmt:
|
||||
REINDEX reindex_target_type opt_concurrently qualified_name
|
||||
REINDEX opt_reindex_option_list reindex_target_type opt_concurrently qualified_name
|
||||
{
|
||||
ReindexStmt *n = makeNode(ReindexStmt);
|
||||
|
||||
n->kind = $2;
|
||||
n->relation = $4;
|
||||
n->kind = $3;
|
||||
n->relation = $5;
|
||||
n->name = NULL;
|
||||
n->params = NIL;
|
||||
if ($3)
|
||||
n->params = $2;
|
||||
if ($4)
|
||||
n->params = lappend(n->params,
|
||||
makeDefElem("concurrently", NULL, @3));
|
||||
makeDefElem("concurrently", NULL, @4));
|
||||
$$ = (Node *) n;
|
||||
}
|
||||
| REINDEX reindex_target_multitable opt_concurrently name
|
||||
| REINDEX opt_reindex_option_list SCHEMA opt_concurrently name
|
||||
{
|
||||
ReindexStmt *n = makeNode(ReindexStmt);
|
||||
|
||||
n->kind = $2;
|
||||
n->name = $4;
|
||||
n->kind = REINDEX_OBJECT_SCHEMA;
|
||||
n->name = $5;
|
||||
n->relation = NULL;
|
||||
n->params = NIL;
|
||||
if ($3)
|
||||
n->params = $2;
|
||||
if ($4)
|
||||
n->params = lappend(n->params,
|
||||
makeDefElem("concurrently", NULL, @3));
|
||||
makeDefElem("concurrently", NULL, @4));
|
||||
$$ = (Node *) n;
|
||||
}
|
||||
| REINDEX reindex_name_optional
|
||||
| REINDEX opt_reindex_option_list DATABASE opt_concurrently opt_single_name
|
||||
{
|
||||
ReindexStmt *n = makeNode(ReindexStmt);
|
||||
n->kind = $2;
|
||||
n->kind = REINDEX_OBJECT_DATABASE;
|
||||
n->name = NULL;
|
||||
n->relation = NULL;
|
||||
n->params = NIL;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| REINDEX '(' utility_option_list ')' reindex_name_optional
|
||||
{
|
||||
ReindexStmt *n = makeNode(ReindexStmt);
|
||||
n->kind = $5;
|
||||
n->name = NULL;
|
||||
n->relation = NULL;
|
||||
n->params = $3;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| REINDEX '(' utility_option_list ')' reindex_target_type opt_concurrently qualified_name
|
||||
{
|
||||
ReindexStmt *n = makeNode(ReindexStmt);
|
||||
|
||||
n->kind = $5;
|
||||
n->relation = $7;
|
||||
n->name = NULL;
|
||||
n->params = $3;
|
||||
if ($6)
|
||||
n->params = lappend(n->params,
|
||||
makeDefElem("concurrently", NULL, @6));
|
||||
n->params = $2;
|
||||
$$ = (Node *) n;
|
||||
}
|
||||
| REINDEX '(' utility_option_list ')' reindex_target_multitable opt_concurrently name
|
||||
| REINDEX opt_reindex_option_list SYSTEM_P opt_single_name
|
||||
{
|
||||
ReindexStmt *n = makeNode(ReindexStmt);
|
||||
|
||||
n->kind = $5;
|
||||
n->name = $7;
|
||||
n->kind = REINDEX_OBJECT_SYSTEM;
|
||||
n->name = NULL;
|
||||
n->relation = NULL;
|
||||
n->params = $3;
|
||||
if ($6)
|
||||
n->params = lappend(n->params,
|
||||
makeDefElem("concurrently", NULL, @6));
|
||||
n->params = $2;
|
||||
$$ = (Node *) n;
|
||||
}
|
||||
;
|
||||
@@ -9170,15 +9147,9 @@ reindex_target_type:
|
||||
INDEX { $$ = REINDEX_OBJECT_INDEX; }
|
||||
| TABLE { $$ = REINDEX_OBJECT_TABLE; }
|
||||
;
|
||||
reindex_target_multitable:
|
||||
SCHEMA { $$ = REINDEX_OBJECT_SCHEMA; }
|
||||
| SYSTEM_P { $$ = REINDEX_OBJECT_SYSTEM; }
|
||||
| DATABASE { $$ = REINDEX_OBJECT_DATABASE; }
|
||||
;
|
||||
/* For these options the name is optional */
|
||||
reindex_name_optional:
|
||||
SYSTEM_P { $$ = REINDEX_OBJECT_SYSTEM; }
|
||||
| DATABASE { $$ = REINDEX_OBJECT_DATABASE; }
|
||||
opt_reindex_option_list:
|
||||
'(' utility_option_list ')' { $$ = $2; }
|
||||
| /* EMPTY */ { $$ = NULL; }
|
||||
;
|
||||
|
||||
/*****************************************************************************
|
||||
|
Reference in New Issue
Block a user