mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
Refactor CLUSTER and REINDEX grammar to use DefElem for option lists
This changes CLUSTER and REINDEX so as a parenthesized grammar becomes
possible for options, while unifying the grammar parsing rules for
option lists with the existing ones.
This is a follow-up of the work done in 873ea9e for VACUUM, ANALYZE and
EXPLAIN. This benefits REINDEX for a potential backend-side filtering
for collatable-sensitive indexes and TABLESPACE, while CLUSTER would
benefit from the latter.
Author: Alexey Kondratov, Justin Pryzby
Discussion: https://postgr.es/m/8a8f5f73-00d3-55f8-7583-1375ca8f6a91@postgrespro.ru
This commit is contained in:
@@ -515,7 +515,6 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
||||
%type <list> generic_option_list alter_generic_option_list
|
||||
|
||||
%type <ival> reindex_target_type reindex_target_multitable
|
||||
%type <ival> reindex_option_list reindex_option_elem
|
||||
|
||||
%type <node> copy_generic_opt_arg copy_generic_opt_arg_list_item
|
||||
%type <defelt> copy_generic_opt_elem
|
||||
@@ -8217,9 +8216,10 @@ ReindexStmt:
|
||||
n->kind = $2;
|
||||
n->relation = $4;
|
||||
n->name = NULL;
|
||||
n->options = 0;
|
||||
n->params = NIL;
|
||||
if ($3)
|
||||
n->options |= REINDEXOPT_CONCURRENTLY;
|
||||
n->params = lappend(n->params,
|
||||
makeDefElem("concurrently", NULL, @3));
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| REINDEX reindex_target_multitable opt_concurrently name
|
||||
@@ -8228,31 +8228,34 @@ ReindexStmt:
|
||||
n->kind = $2;
|
||||
n->name = $4;
|
||||
n->relation = NULL;
|
||||
n->options = 0;
|
||||
n->params = NIL;
|
||||
if ($3)
|
||||
n->options |= REINDEXOPT_CONCURRENTLY;
|
||||
n->params = lappend(n->params,
|
||||
makeDefElem("concurrently", NULL, @3));
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| REINDEX '(' reindex_option_list ')' reindex_target_type opt_concurrently qualified_name
|
||||
| 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->options = $3;
|
||||
n->params = $3;
|
||||
if ($6)
|
||||
n->options |= REINDEXOPT_CONCURRENTLY;
|
||||
n->params = lappend(n->params,
|
||||
makeDefElem("concurrently", NULL, @6));
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| REINDEX '(' reindex_option_list ')' reindex_target_multitable opt_concurrently name
|
||||
| REINDEX '(' utility_option_list ')' reindex_target_multitable opt_concurrently name
|
||||
{
|
||||
ReindexStmt *n = makeNode(ReindexStmt);
|
||||
n->kind = $5;
|
||||
n->name = $7;
|
||||
n->relation = NULL;
|
||||
n->options = $3;
|
||||
n->params = $3;
|
||||
if ($6)
|
||||
n->options |= REINDEXOPT_CONCURRENTLY;
|
||||
n->params = lappend(n->params,
|
||||
makeDefElem("concurrently", NULL, @6));
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
;
|
||||
@@ -8265,13 +8268,6 @@ reindex_target_multitable:
|
||||
| SYSTEM_P { $$ = REINDEX_OBJECT_SYSTEM; }
|
||||
| DATABASE { $$ = REINDEX_OBJECT_DATABASE; }
|
||||
;
|
||||
reindex_option_list:
|
||||
reindex_option_elem { $$ = $1; }
|
||||
| reindex_option_list ',' reindex_option_elem { $$ = $1 | $3; }
|
||||
;
|
||||
reindex_option_elem:
|
||||
VERBOSE { $$ = REINDEXOPT_VERBOSE; }
|
||||
;
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
@@ -10407,6 +10403,7 @@ CreateConversionStmt:
|
||||
*
|
||||
* QUERY:
|
||||
* CLUSTER [VERBOSE] <qualified_name> [ USING <index_name> ]
|
||||
* CLUSTER [ (options) ] <qualified_name> [ USING <index_name> ]
|
||||
* CLUSTER [VERBOSE]
|
||||
* CLUSTER [VERBOSE] <index_name> ON <qualified_name> (for pre-8.3)
|
||||
*
|
||||
@@ -10418,9 +10415,18 @@ ClusterStmt:
|
||||
ClusterStmt *n = makeNode(ClusterStmt);
|
||||
n->relation = $3;
|
||||
n->indexname = $4;
|
||||
n->options = 0;
|
||||
n->params = NIL;
|
||||
if ($2)
|
||||
n->options |= CLUOPT_VERBOSE;
|
||||
n->params = lappend(n->params, makeDefElem("verbose", NULL, @2));
|
||||
$$ = (Node*)n;
|
||||
}
|
||||
|
||||
| CLUSTER '(' utility_option_list ')' qualified_name cluster_index_specification
|
||||
{
|
||||
ClusterStmt *n = makeNode(ClusterStmt);
|
||||
n->relation = $5;
|
||||
n->indexname = $6;
|
||||
n->params = $3;
|
||||
$$ = (Node*)n;
|
||||
}
|
||||
| CLUSTER opt_verbose
|
||||
@@ -10428,9 +10434,9 @@ ClusterStmt:
|
||||
ClusterStmt *n = makeNode(ClusterStmt);
|
||||
n->relation = NULL;
|
||||
n->indexname = NULL;
|
||||
n->options = 0;
|
||||
n->params = NIL;
|
||||
if ($2)
|
||||
n->options |= CLUOPT_VERBOSE;
|
||||
n->params = lappend(n->params, makeDefElem("verbose", NULL, @2));
|
||||
$$ = (Node*)n;
|
||||
}
|
||||
/* kept for pre-8.3 compatibility */
|
||||
@@ -10439,9 +10445,9 @@ ClusterStmt:
|
||||
ClusterStmt *n = makeNode(ClusterStmt);
|
||||
n->relation = $5;
|
||||
n->indexname = $3;
|
||||
n->options = 0;
|
||||
n->params = NIL;
|
||||
if ($2)
|
||||
n->options |= CLUOPT_VERBOSE;
|
||||
n->params = lappend(n->params, makeDefElem("verbose", NULL, @2));
|
||||
$$ = (Node*)n;
|
||||
}
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user