mirror of https://github.com/citusdata/citus.git
Introduces ProcessUtility macros for readOnlyTree parameter
New macros: standard_ProcessUtility_compat, ProcessUtility_compat, ColumnarProcessUtility_compat, PrevProcessUtilityHook_compat The functions now have a new bool parameter: readOnlyTree These new macros give us the ability to use this new parameter for PG14 and it doesn't give the parameter for previous versions In multi_ProcessUtility and ColumnarProcessUtility, before doing anything else, we check if readOnlyTree parameter is true and create a copy of pstmt Existing readOnlyTree parameters are set to false since we already handle the read only case at multi_ProcessUtility and ColumnarProcessUtility Relevant PG commit: 7c337b6b527b7052e6a751f966d5734c56f668b5pull/5209/head
parent
5df6251619
commit
82858ca8fe
|
@ -118,6 +118,9 @@ static void ColumnarTableAMObjectAccessHook(ObjectAccessType access, Oid classId
|
|||
void *arg);
|
||||
static void ColumnarProcessUtility(PlannedStmt *pstmt,
|
||||
const char *queryString,
|
||||
#if PG_VERSION_NUM >= PG_VERSION_14
|
||||
bool readOnlyTree,
|
||||
#endif
|
||||
ProcessUtilityContext context,
|
||||
ParamListInfo params,
|
||||
struct QueryEnvironment *queryEnv,
|
||||
|
@ -2006,12 +2009,23 @@ ColumnarTableAMObjectAccessHook(ObjectAccessType access, Oid classId, Oid object
|
|||
static void
|
||||
ColumnarProcessUtility(PlannedStmt *pstmt,
|
||||
const char *queryString,
|
||||
#if PG_VERSION_NUM >= PG_VERSION_14
|
||||
bool readOnlyTree,
|
||||
#endif
|
||||
ProcessUtilityContext context,
|
||||
ParamListInfo params,
|
||||
struct QueryEnvironment *queryEnv,
|
||||
DestReceiver *dest,
|
||||
QueryCompletionCompat *completionTag)
|
||||
{
|
||||
|
||||
#if PG_VERSION_NUM >= PG_VERSION_14
|
||||
if (readOnlyTree)
|
||||
{
|
||||
pstmt = copyObject(pstmt);
|
||||
}
|
||||
#endif
|
||||
|
||||
Node *parsetree = pstmt->utilityStmt;
|
||||
|
||||
if (IsA(parsetree, IndexStmt))
|
||||
|
@ -2034,7 +2048,7 @@ ColumnarProcessUtility(PlannedStmt *pstmt,
|
|||
RelationClose(rel);
|
||||
}
|
||||
|
||||
PrevProcessUtilityHook(pstmt, queryString, context,
|
||||
PrevProcessUtilityHook_compat(pstmt, queryString, false, context,
|
||||
params, queryEnv, dest, completionTag);
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ ProcessUtilityParseTree(Node *node, const char *queryString, ProcessUtilityConte
|
|||
plannedStmt->commandType = CMD_UTILITY;
|
||||
plannedStmt->utilityStmt = node;
|
||||
|
||||
ProcessUtility(plannedStmt, queryString, context, params, NULL, dest,
|
||||
ProcessUtility_compat(plannedStmt, queryString, false, context, params, NULL, dest,
|
||||
completionTag);
|
||||
}
|
||||
|
||||
|
@ -128,13 +128,25 @@ ProcessUtilityParseTree(Node *node, const char *queryString, ProcessUtilityConte
|
|||
void
|
||||
multi_ProcessUtility(PlannedStmt *pstmt,
|
||||
const char *queryString,
|
||||
#if PG_VERSION_NUM >= PG_VERSION_14
|
||||
bool readOnlyTree,
|
||||
#endif
|
||||
ProcessUtilityContext context,
|
||||
ParamListInfo params,
|
||||
struct QueryEnvironment *queryEnv,
|
||||
DestReceiver *dest,
|
||||
QueryCompletionCompat *completionTag)
|
||||
{
|
||||
Node *parsetree = pstmt->utilityStmt;
|
||||
Node *parsetree;
|
||||
|
||||
#if PG_VERSION_NUM >= PG_VERSION_14
|
||||
if (readOnlyTree)
|
||||
{
|
||||
pstmt = copyObject(pstmt);
|
||||
}
|
||||
#endif
|
||||
|
||||
parsetree = pstmt->utilityStmt;
|
||||
|
||||
if (IsA(parsetree, TransactionStmt) ||
|
||||
IsA(parsetree, LockStmt) ||
|
||||
|
@ -154,7 +166,7 @@ multi_ProcessUtility(PlannedStmt *pstmt,
|
|||
* that state. Since we never need to intercept transaction statements,
|
||||
* skip our checks and immediately fall into standard_ProcessUtility.
|
||||
*/
|
||||
standard_ProcessUtility(pstmt, queryString, context,
|
||||
standard_ProcessUtility_compat(pstmt, queryString, false, context,
|
||||
params, queryEnv, dest, completionTag);
|
||||
|
||||
return;
|
||||
|
@ -173,7 +185,7 @@ multi_ProcessUtility(PlannedStmt *pstmt,
|
|||
* Ensure that utility commands do not behave any differently until CREATE
|
||||
* EXTENSION is invoked.
|
||||
*/
|
||||
standard_ProcessUtility(pstmt, queryString, context,
|
||||
standard_ProcessUtility_compat(pstmt, queryString, false, context,
|
||||
params, queryEnv, dest, completionTag);
|
||||
|
||||
return;
|
||||
|
@ -205,7 +217,7 @@ multi_ProcessUtility(PlannedStmt *pstmt,
|
|||
|
||||
PG_TRY();
|
||||
{
|
||||
standard_ProcessUtility(pstmt, queryString, context,
|
||||
standard_ProcessUtility_compat(pstmt, queryString, false, context,
|
||||
params, queryEnv, dest, completionTag);
|
||||
|
||||
StoredProcedureLevel -= 1;
|
||||
|
@ -229,7 +241,7 @@ multi_ProcessUtility(PlannedStmt *pstmt,
|
|||
|
||||
PG_TRY();
|
||||
{
|
||||
standard_ProcessUtility(pstmt, queryString, context,
|
||||
standard_ProcessUtility_compat(pstmt, queryString, false, context,
|
||||
params, queryEnv, dest, completionTag);
|
||||
|
||||
DoBlockLevel -= 1;
|
||||
|
@ -566,7 +578,7 @@ ProcessUtilityInternal(PlannedStmt *pstmt,
|
|||
citusCanBeUpdatedToAvailableVersion = !InstalledAndAvailableVersionsSame();
|
||||
}
|
||||
|
||||
standard_ProcessUtility(pstmt, queryString, context,
|
||||
standard_ProcessUtility_compat(pstmt, queryString, false, context,
|
||||
params, queryEnv, dest, completionTag);
|
||||
|
||||
/*
|
||||
|
|
|
@ -13,7 +13,15 @@
|
|||
#define COLUMNAR_COMPAT_H
|
||||
|
||||
#if PG_VERSION_NUM >= PG_VERSION_14
|
||||
#define ColumnarProcessUtility_compat(a, b, c, d, e, f, g, h) \
|
||||
ColumnarProcessUtility(a, b, c, d, e, f, g, h)
|
||||
#define PrevProcessUtilityHook_compat(a, b, c, d, e, f, g, h) \
|
||||
PrevProcessUtilityHook(a, b, c, d, e, f, g, h)
|
||||
#else
|
||||
#define ColumnarProcessUtility_compat(a, b, c, d, e, f, g, h) \
|
||||
ColumnarProcessUtility(a, b, d, e, f, g, h)
|
||||
#define PrevProcessUtilityHook_compat(a, b, c, d, e, f, g, h) \
|
||||
PrevProcessUtilityHook(a, b, d, e, f, g, h)
|
||||
#endif
|
||||
|
||||
#define ACLCHECK_OBJECT_TABLE OBJECT_TABLE
|
||||
|
|
|
@ -64,6 +64,9 @@ typedef struct DDLJob
|
|||
|
||||
|
||||
extern void multi_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
|
||||
#if PG_VERSION_NUM >= PG_VERSION_14
|
||||
bool readOnlyTree,
|
||||
#endif
|
||||
ProcessUtilityContext context, ParamListInfo params,
|
||||
struct QueryEnvironment *queryEnv, DestReceiver *dest,
|
||||
QueryCompletionCompat *completionTag
|
||||
|
|
|
@ -50,6 +50,10 @@
|
|||
#define IsReindexWithParam_compat(reindex, param) IsReindexWithParam(reindex, param)
|
||||
#define CopyFromState_compat CopyFromState
|
||||
#define BeginCopyFrom_compat(a, b, c, d, e, f, g, h) BeginCopyFrom(a, b, c, d, e, f, g, h)
|
||||
#define standard_ProcessUtility_compat(a, b, c, d, e, f, g, h) \
|
||||
standard_ProcessUtility(a, b, c, d, e, f, g, h)
|
||||
#define ProcessUtility_compat(a, b, c, d, e, f, g, h) \
|
||||
ProcessUtility(a, b, c, d, e, f, g, h)
|
||||
#else
|
||||
#define AlterTableStmtObjType(a) ((a)->relkind)
|
||||
#define F_NEXTVAL_COMPAT F_NEXTVAL_OID
|
||||
|
@ -73,6 +77,9 @@
|
|||
false))
|
||||
#define CopyFromState_compat CopyState
|
||||
#define BeginCopyFrom_compat(a, b, c, d, e, f, g, h) BeginCopyFrom(a, b, d, e, f, g, h)
|
||||
#define standard_ProcessUtility_compat(a, b, c, d, e, f, g, h) \
|
||||
standard_ProcessUtility(a, b, d, e, f, g, h)
|
||||
#define ProcessUtility_compat(a, b, c, d, e, f, g, h) ProcessUtility(a, b, d, e, f, g, h)
|
||||
#endif
|
||||
|
||||
#if PG_VERSION_NUM >= PG_VERSION_13
|
||||
|
|
Loading…
Reference in New Issue