mirror of https://github.com/citusdata/citus.git
Introduces IsReindexWithParam_compat macro
In ReindexStmt concurrent field is moved to options and then options are converted to params list. This macro uses previous fields for previous versions and the new params list with a new function named IsReindexWithParam for PG14 Relevant PG commits: 844c05abc3f1c1703bf17cf44ab66351ed9711d2 b5913f6120792465f4394b93c15c2e2ac0c08376talha_pg14_support
parent
c9d694bf63
commit
9c59290434
|
@ -529,8 +529,8 @@ PreprocessReindexStmt(Node *node, const char *reindexCommand,
|
||||||
{
|
{
|
||||||
Relation relation = NULL;
|
Relation relation = NULL;
|
||||||
Oid relationId = InvalidOid;
|
Oid relationId = InvalidOid;
|
||||||
LOCKMODE lockmode = reindexStatement->concurrent ? ShareUpdateExclusiveLock :
|
LOCKMODE lockmode = IsReindexWithParam_compat(reindexStatement, "concurrently") ?
|
||||||
AccessExclusiveLock;
|
ShareUpdateExclusiveLock : AccessExclusiveLock;
|
||||||
MemoryContext relationContext = NULL;
|
MemoryContext relationContext = NULL;
|
||||||
|
|
||||||
Assert(reindexStatement->kind == REINDEX_OBJECT_INDEX ||
|
Assert(reindexStatement->kind == REINDEX_OBJECT_INDEX ||
|
||||||
|
@ -539,7 +539,8 @@ PreprocessReindexStmt(Node *node, const char *reindexCommand,
|
||||||
if (reindexStatement->kind == REINDEX_OBJECT_INDEX)
|
if (reindexStatement->kind == REINDEX_OBJECT_INDEX)
|
||||||
{
|
{
|
||||||
struct ReindexIndexCallbackState state;
|
struct ReindexIndexCallbackState state;
|
||||||
state.concurrent = reindexStatement->concurrent;
|
state.concurrent = IsReindexWithParam_compat(reindexStatement,
|
||||||
|
"concurrently");
|
||||||
state.locked_table_oid = InvalidOid;
|
state.locked_table_oid = InvalidOid;
|
||||||
|
|
||||||
Oid indOid = RangeVarGetRelidExtended(reindexStatement->relation,
|
Oid indOid = RangeVarGetRelidExtended(reindexStatement->relation,
|
||||||
|
@ -590,8 +591,10 @@ PreprocessReindexStmt(Node *node, const char *reindexCommand,
|
||||||
{
|
{
|
||||||
DDLJob *ddlJob = palloc0(sizeof(DDLJob));
|
DDLJob *ddlJob = palloc0(sizeof(DDLJob));
|
||||||
ddlJob->targetRelationId = relationId;
|
ddlJob->targetRelationId = relationId;
|
||||||
ddlJob->concurrentIndexCmd = reindexStatement->concurrent;
|
ddlJob->concurrentIndexCmd = IsReindexWithParam_compat(reindexStatement,
|
||||||
ddlJob->startNewTransaction = reindexStatement->concurrent;
|
"concurrently");
|
||||||
|
ddlJob->startNewTransaction = IsReindexWithParam_compat(reindexStatement,
|
||||||
|
"concurrently");
|
||||||
ddlJob->commandString = reindexCommand;
|
ddlJob->commandString = reindexCommand;
|
||||||
ddlJob->taskList = CreateReindexTaskList(relationId, reindexStatement);
|
ddlJob->taskList = CreateReindexTaskList(relationId, reindexStatement);
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "commands/defrem.h"
|
#include "commands/defrem.h"
|
||||||
#include "commands/extension.h"
|
#include "commands/extension.h"
|
||||||
#include "distributed/citus_ruleutils.h"
|
#include "distributed/citus_ruleutils.h"
|
||||||
|
#include "distributed/commands.h"
|
||||||
#include "distributed/listutils.h"
|
#include "distributed/listutils.h"
|
||||||
#include "distributed/multi_partitioning_utils.h"
|
#include "distributed/multi_partitioning_utils.h"
|
||||||
#include "distributed/metadata_cache.h"
|
#include "distributed/metadata_cache.h"
|
||||||
|
@ -740,7 +741,8 @@ deparse_shard_reindex_statement(ReindexStmt *origStmt, Oid distrelid, int64 shar
|
||||||
{
|
{
|
||||||
ReindexStmt *reindexStmt = copyObject(origStmt); /* copy to avoid modifications */
|
ReindexStmt *reindexStmt = copyObject(origStmt); /* copy to avoid modifications */
|
||||||
char *relationName = NULL;
|
char *relationName = NULL;
|
||||||
const char *concurrentlyString = reindexStmt->concurrent ? "CONCURRENTLY " : "";
|
const char *concurrentlyString =
|
||||||
|
IsReindexWithParam_compat(reindexStmt, "concurrently") ? "CONCURRENTLY " : "";
|
||||||
|
|
||||||
|
|
||||||
if (reindexStmt->kind == REINDEX_OBJECT_INDEX ||
|
if (reindexStmt->kind == REINDEX_OBJECT_INDEX ||
|
||||||
|
@ -754,7 +756,7 @@ deparse_shard_reindex_statement(ReindexStmt *origStmt, Oid distrelid, int64 shar
|
||||||
|
|
||||||
appendStringInfoString(buffer, "REINDEX ");
|
appendStringInfoString(buffer, "REINDEX ");
|
||||||
|
|
||||||
if (reindexStmt->options == REINDEXOPT_VERBOSE)
|
if (IsReindexWithParam_compat(reindexStmt, "verbose"))
|
||||||
{
|
{
|
||||||
appendStringInfoString(buffer, "(VERBOSE) ");
|
appendStringInfoString(buffer, "(VERBOSE) ");
|
||||||
}
|
}
|
||||||
|
@ -1237,3 +1239,29 @@ RoleSpecString(RoleSpec *spec, bool withQuoteIdentifier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if PG_VERSION_NUM >= PG_VERSION_14
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IsReindexWithParam searches the ReindexStmt's params for paramName
|
||||||
|
* and returns true if it exists and value of param is true and returns
|
||||||
|
* false otherwise
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
IsReindexWithParam(ReindexStmt *stmt, char *paramName)
|
||||||
|
{
|
||||||
|
ListCell *lc;
|
||||||
|
foreach(lc, stmt->params)
|
||||||
|
{
|
||||||
|
DefElem *opt = (DefElem *) lfirst(lc);
|
||||||
|
if (strcmp(opt->defname, paramName) == 0)
|
||||||
|
{
|
||||||
|
return defGetBoolean(opt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -288,6 +288,9 @@ extern void ErrorIfUnsupportedAlterIndexStmt(AlterTableStmt *alterTableStatement
|
||||||
extern void MarkIndexValid(IndexStmt *indexStmt);
|
extern void MarkIndexValid(IndexStmt *indexStmt);
|
||||||
extern List * ExecuteFunctionOnEachTableIndex(Oid relationId, PGIndexProcessor
|
extern List * ExecuteFunctionOnEachTableIndex(Oid relationId, PGIndexProcessor
|
||||||
pgIndexProcessor, int flags);
|
pgIndexProcessor, int flags);
|
||||||
|
#if PG_VERSION_NUM >= PG_VERSION_14
|
||||||
|
extern bool IsReindexWithParam(ReindexStmt *stmt, char *paramName);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* objectaddress.c - forward declarations */
|
/* objectaddress.c - forward declarations */
|
||||||
extern ObjectAddress CreateExtensionStmtObjectAddress(Node *stmt, bool missing_ok);
|
extern ObjectAddress CreateExtensionStmtObjectAddress(Node *stmt, bool missing_ok);
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#define VACOPTVALUE_UNSPECIFIED_COMPAT VACOPTVALUE_UNSPECIFIED
|
#define VACOPTVALUE_UNSPECIFIED_COMPAT VACOPTVALUE_UNSPECIFIED
|
||||||
#define VACOPTVALUE_DISABLED_COMPAT VACOPTVALUE_DISABLED
|
#define VACOPTVALUE_DISABLED_COMPAT VACOPTVALUE_DISABLED
|
||||||
#define VACOPTVALUE_ENABLED_COMPAT VACOPTVALUE_ENABLED
|
#define VACOPTVALUE_ENABLED_COMPAT VACOPTVALUE_ENABLED
|
||||||
|
#define IsReindexWithParam_compat(reindex, param) IsReindexWithParam(reindex, param)
|
||||||
#else
|
#else
|
||||||
#define AlterTableStmtObjType(a) ((a)->relkind)
|
#define AlterTableStmtObjType(a) ((a)->relkind)
|
||||||
#define F_NEXTVAL_COMPAT F_NEXTVAL_OID
|
#define F_NEXTVAL_COMPAT F_NEXTVAL_OID
|
||||||
|
@ -64,6 +65,10 @@
|
||||||
#define VACOPTVALUE_UNSPECIFIED_COMPAT VACOPT_TERNARY_DEFAULT
|
#define VACOPTVALUE_UNSPECIFIED_COMPAT VACOPT_TERNARY_DEFAULT
|
||||||
#define VACOPTVALUE_DISABLED_COMPAT VACOPT_TERNARY_DISABLED
|
#define VACOPTVALUE_DISABLED_COMPAT VACOPT_TERNARY_DISABLED
|
||||||
#define VACOPTVALUE_ENABLED_COMPAT VACOPT_TERNARY_ENABLED
|
#define VACOPTVALUE_ENABLED_COMPAT VACOPT_TERNARY_ENABLED
|
||||||
|
#define IsReindexWithParam_compat(reindex, param) \
|
||||||
|
((strcmp(param, "concurrently") == 0) ? ((reindex)->concurrent) : \
|
||||||
|
((strcmp(param, "verbose") == 0) ? ((reindex)->options == REINDEXOPT_VERBOSE) : \
|
||||||
|
false))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_13
|
#if PG_VERSION_NUM >= PG_VERSION_13
|
||||||
|
|
Loading…
Reference in New Issue