summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorMichael Paquier2020-12-03 01:13:21 +0000
committerMichael Paquier2020-12-03 01:13:21 +0000
commitb5913f6120792465f4394b93c15c2e2ac0c08376 (patch)
tree2b1f33655d3b7f1888487b87ad467483a5b57cbd /src/include
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/include')
-rw-r--r--src/include/catalog/index.h9
-rw-r--r--src/include/commands/cluster.h10
-rw-r--r--src/include/commands/defrem.h1
-rw-r--r--src/include/nodes/parsenodes.h17
4 files changed, 21 insertions, 16 deletions
diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h
index f4559b09d73..c0416280499 100644
--- a/src/include/catalog/index.h
+++ b/src/include/catalog/index.h
@@ -29,6 +29,15 @@ typedef enum
INDEX_DROP_SET_DEAD
} IndexStateFlagsAction;
+/* options for REINDEX */
+typedef enum ReindexOption
+{
+ REINDEXOPT_VERBOSE = 1 << 0, /* print progress info */
+ REINDEXOPT_REPORT_PROGRESS = 1 << 1, /* report pgstat progress */
+ REINDEXOPT_MISSING_OK = 1 << 2, /* skip missing relations */
+ REINDEXOPT_CONCURRENTLY = 1 << 3 /* concurrent mode */
+} ReindexOption;
+
/* state info for validate_index bulkdelete callback */
typedef struct ValidateIndexState
{
diff --git a/src/include/commands/cluster.h b/src/include/commands/cluster.h
index e05884781b9..7cfb37c9b2b 100644
--- a/src/include/commands/cluster.h
+++ b/src/include/commands/cluster.h
@@ -14,11 +14,19 @@
#define CLUSTER_H
#include "nodes/parsenodes.h"
+#include "parser/parse_node.h"
#include "storage/lock.h"
#include "utils/relcache.h"
-extern void cluster(ClusterStmt *stmt, bool isTopLevel);
+/* options for CLUSTER */
+typedef enum ClusterOption
+{
+ CLUOPT_RECHECK = 1 << 0, /* recheck relation state */
+ CLUOPT_VERBOSE = 1 << 1 /* print progress info */
+} ClusterOption;
+
+extern void cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel);
extern void cluster_rel(Oid tableOid, Oid indexOid, int options);
extern void check_index_is_clusterable(Relation OldHeap, Oid indexOid,
bool recheck, LOCKMODE lockmode);
diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h
index 7a079ef07f0..1133ae11437 100644
--- a/src/include/commands/defrem.h
+++ b/src/include/commands/defrem.h
@@ -34,6 +34,7 @@ extern ObjectAddress DefineIndex(Oid relationId,
bool check_not_in_use,
bool skip_build,
bool quiet);
+extern int ReindexParseOptions(ParseState *pstate, ReindexStmt *stmt);
extern void ReindexIndex(RangeVar *indexRelation, int options, bool isTopLevel);
extern Oid ReindexTable(RangeVar *relation, int options, bool isTopLevel);
extern void ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind,
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 92df76c2d35..ec14fc2036f 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -3197,18 +3197,12 @@ typedef struct AlterSystemStmt
* Cluster Statement (support pbrown's cluster index implementation)
* ----------------------
*/
-typedef enum ClusterOption
-{
- CLUOPT_RECHECK = 1 << 0, /* recheck relation state */
- CLUOPT_VERBOSE = 1 << 1 /* print progress info */
-} ClusterOption;
-
typedef struct ClusterStmt
{
NodeTag type;
RangeVar *relation; /* relation being indexed, or NULL if all */
char *indexname; /* original index defined */
- int options; /* OR of ClusterOption flags */
+ List *params; /* list of DefElem nodes */
} ClusterStmt;
/* ----------------------
@@ -3346,13 +3340,6 @@ typedef struct ConstraintsSetStmt
* REINDEX Statement
* ----------------------
*/
-
-/* Reindex options */
-#define REINDEXOPT_VERBOSE (1 << 0) /* print progress info */
-#define REINDEXOPT_REPORT_PROGRESS (1 << 1) /* report pgstat progress */
-#define REINDEXOPT_MISSING_OK (1 << 2) /* skip missing relations */
-#define REINDEXOPT_CONCURRENTLY (1 << 3) /* concurrent mode */
-
typedef enum ReindexObjectType
{
REINDEX_OBJECT_INDEX, /* index */
@@ -3369,7 +3356,7 @@ typedef struct ReindexStmt
* etc. */
RangeVar *relation; /* Table or index to reindex */
const char *name; /* name of database to reindex */
- int options; /* Reindex options flags */
+ List *params; /* list of DefElem nodes */
} ReindexStmt;
/* ----------------------