summaryrefslogtreecommitdiff
path: root/src/backend/commands/indexcmds.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2020-12-03 10:13:21 +0900
committerMichael Paquier <michael@paquier.xyz>2020-12-03 10:13:21 +0900
commitb5913f6120792465f4394b93c15c2e2ac0c08376 (patch)
tree2b1f33655d3b7f1888487b87ad467483a5b57cbd /src/backend/commands/indexcmds.c
parentdc11f31a1a891f8aa8890644e837556bcc5a75e7 (diff)
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
Diffstat (limited to 'src/backend/commands/indexcmds.c')
-rw-r--r--src/backend/commands/indexcmds.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index d35deb433aa..14d24b3cc40 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -2452,6 +2452,42 @@ ChooseIndexColumnNames(List *indexElems)
}
/*
+ * 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.
*/