mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +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:
@ -2451,6 +2451,42 @@ ChooseIndexColumnNames(List *indexElems)
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* ReindexParseOptions
|
||||
* Parse list of REINDEX options, returning a bitmask of ReindexOption.
|
||||
*/
|
||||
int
|
||||
ReindexParseOptions(ParseState *pstate, ReindexStmt *stmt)
|
||||
{
|
||||
ListCell *lc;
|
||||
int options = 0;
|
||||
bool concurrently = false;
|
||||
bool verbose = false;
|
||||
|
||||
/* Parse option list */
|
||||
foreach(lc, stmt->params)
|
||||
{
|
||||
DefElem *opt = (DefElem *) lfirst(lc);
|
||||
|
||||
if (strcmp(opt->defname, "verbose") == 0)
|
||||
verbose = defGetBoolean(opt);
|
||||
else if (strcmp(opt->defname, "concurrently") == 0)
|
||||
concurrently = defGetBoolean(opt);
|
||||
else
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("unrecognized REINDEX option \"%s\"",
|
||||
opt->defname),
|
||||
parser_errposition(pstate, opt->location)));
|
||||
}
|
||||
|
||||
options =
|
||||
(verbose ? REINDEXOPT_VERBOSE : 0) |
|
||||
(concurrently ? REINDEXOPT_CONCURRENTLY : 0);
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
/*
|
||||
* ReindexIndex
|
||||
* Recreate a specific index.
|
||||
|
Reference in New Issue
Block a user