mirror of https://github.com/citusdata/citus.git
Add PG 18Beta2 Build compatibility (#8060)
Fixes #8061 Add PG 18Beta2 Build compatibility Revert "Don't lock partitions pruned by initial pruning Relevant PG commit: 1722d5eb05d8e5d2e064cd1798abcae4f296ca9d https://github.com/postgres/postgres/commit/1722d5epull/8071/head
parent
9ccf758bb8
commit
9327df8446
|
|
@ -764,24 +764,6 @@ ExecuteTaskPlan(PlannedStmt *taskPlan, char *queryString,
|
||||||
localPlacementIndex) :
|
localPlacementIndex) :
|
||||||
CreateDestReceiver(DestNone);
|
CreateDestReceiver(DestNone);
|
||||||
|
|
||||||
/* Create a QueryDesc for the query */
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_18
|
|
||||||
|
|
||||||
/* PG18+: nine‐arg CreateQueryDesc with a CachedPlan slot */
|
|
||||||
QueryDesc *queryDesc = CreateQueryDesc(
|
|
||||||
taskPlan, /* PlannedStmt *plannedstmt */
|
|
||||||
NULL, /* CachedPlan *cplan (none) */
|
|
||||||
queryString, /* const char *sourceText */
|
|
||||||
GetActiveSnapshot(), /* Snapshot snapshot */
|
|
||||||
InvalidSnapshot, /* Snapshot crosscheck_snapshot */
|
|
||||||
destReceiver, /* DestReceiver *dest */
|
|
||||||
paramListInfo, /* ParamListInfo params */
|
|
||||||
queryEnv, /* QueryEnvironment *queryEnv */
|
|
||||||
0 /* int instrument_options */
|
|
||||||
);
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* PG15–17: eight‐arg CreateQueryDesc without CachedPlan */
|
|
||||||
QueryDesc *queryDesc = CreateQueryDesc(
|
QueryDesc *queryDesc = CreateQueryDesc(
|
||||||
taskPlan, /* PlannedStmt *plannedstmt */
|
taskPlan, /* PlannedStmt *plannedstmt */
|
||||||
queryString, /* const char *sourceText */
|
queryString, /* const char *sourceText */
|
||||||
|
|
@ -792,8 +774,6 @@ ExecuteTaskPlan(PlannedStmt *taskPlan, char *queryString,
|
||||||
queryEnv, /* QueryEnvironment *queryEnv */
|
queryEnv, /* QueryEnvironment *queryEnv */
|
||||||
0 /* int instrument_options */
|
0 /* int instrument_options */
|
||||||
);
|
);
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
ExecutorStart(queryDesc, eflags);
|
ExecutorStart(queryDesc, eflags);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -701,21 +701,6 @@ ExecutePlanIntoDestReceiver(PlannedStmt *queryPlan, ParamListInfo params,
|
||||||
/* don't display the portal in pg_cursors, it is for internal use only */
|
/* don't display the portal in pg_cursors, it is for internal use only */
|
||||||
portal->visible = false;
|
portal->visible = false;
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_18
|
|
||||||
|
|
||||||
/* PostgreSQL 18+ adds a seventh “plansource” argument */
|
|
||||||
PortalDefineQuery(
|
|
||||||
portal,
|
|
||||||
NULL, /* no prepared statement name */
|
|
||||||
"", /* query text */
|
|
||||||
CMDTAG_SELECT, /* command tag */
|
|
||||||
list_make1(queryPlan),/* list of PlannedStmt* */
|
|
||||||
NULL, /* no CachedPlan */
|
|
||||||
NULL /* no CachedPlanSource */
|
|
||||||
);
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* PostgreSQL 17-: six-arg signature */
|
|
||||||
PortalDefineQuery(
|
PortalDefineQuery(
|
||||||
portal,
|
portal,
|
||||||
NULL, /* no prepared statement name */
|
NULL, /* no prepared statement name */
|
||||||
|
|
@ -724,7 +709,6 @@ ExecutePlanIntoDestReceiver(PlannedStmt *queryPlan, ParamListInfo params,
|
||||||
list_make1(queryPlan),/* list of PlannedStmt* */
|
list_make1(queryPlan),/* list of PlannedStmt* */
|
||||||
NULL /* no CachedPlan */
|
NULL /* no CachedPlan */
|
||||||
);
|
);
|
||||||
#endif
|
|
||||||
|
|
||||||
PortalStart(portal, params, eflags, GetActiveSnapshot());
|
PortalStart(portal, params, eflags, GetActiveSnapshot());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -315,21 +315,6 @@ StartPortalForQueryExecution(const char *queryString)
|
||||||
/* don't display the portal in pg_cursors, it is for internal use only */
|
/* don't display the portal in pg_cursors, it is for internal use only */
|
||||||
portal->visible = false;
|
portal->visible = false;
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_18
|
|
||||||
|
|
||||||
/* PG 18+: new CachedPlanSource slot */
|
|
||||||
PortalDefineQuery(
|
|
||||||
portal,
|
|
||||||
NULL, /* no prepared‐stmt name */
|
|
||||||
queryString, /* the SQL text */
|
|
||||||
CMDTAG_SELECT, /* we’re running a SELECT */
|
|
||||||
list_make1(queryPlan), /* plan trees */
|
|
||||||
NULL, /* no CachedPlan */
|
|
||||||
NULL /* no CachedPlanSource */
|
|
||||||
);
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* PG 15–17: six‐arg signature */
|
|
||||||
PortalDefineQuery(
|
PortalDefineQuery(
|
||||||
portal,
|
portal,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
@ -338,7 +323,6 @@ StartPortalForQueryExecution(const char *queryString)
|
||||||
list_make1(queryPlan),
|
list_make1(queryPlan),
|
||||||
NULL /* no CachedPlan */
|
NULL /* no CachedPlan */
|
||||||
);
|
);
|
||||||
#endif
|
|
||||||
|
|
||||||
int eflags = 0;
|
int eflags = 0;
|
||||||
PortalStart(portal, NULL, eflags, GetActiveSnapshot());
|
PortalStart(portal, NULL, eflags, GetActiveSnapshot());
|
||||||
|
|
|
||||||
|
|
@ -543,22 +543,7 @@ ExplainSubPlans(DistributedPlan *distributedPlan, ExplainState *es)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_18
|
#if PG_VERSION_NUM >= PG_VERSION_17
|
||||||
ExplainOnePlan(
|
|
||||||
plan, /* PlannedStmt *plannedstmt */
|
|
||||||
NULL, /* CachedPlan *cplan */
|
|
||||||
NULL, /* CachedPlanSource *plansource */
|
|
||||||
0, /* query_index */
|
|
||||||
into, /* IntoClause *into */
|
|
||||||
es, /* struct ExplainState *es */
|
|
||||||
queryString, /* const char *queryString */
|
|
||||||
params, /* ParamListInfo params */
|
|
||||||
NULL, /* QueryEnvironment *queryEnv */
|
|
||||||
&planduration, /* const instr_time *planduration */
|
|
||||||
(es->buffers ? &bufusage : NULL),/* const BufferUsage *bufusage */
|
|
||||||
(es->memory ? &mem_counters : NULL) /* const MemoryContextCounters *mem_counters */
|
|
||||||
);
|
|
||||||
#elif PG_VERSION_NUM >= PG_VERSION_17
|
|
||||||
ExplainOnePlan(
|
ExplainOnePlan(
|
||||||
plan,
|
plan,
|
||||||
into,
|
into,
|
||||||
|
|
@ -1606,22 +1591,7 @@ CitusExplainOneQuery(Query *query, int cursorOptions, IntoClause *into,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_18
|
#if PG_VERSION_NUM >= PG_VERSION_17
|
||||||
ExplainOnePlan(
|
|
||||||
plan, /* PlannedStmt *plannedstmt */
|
|
||||||
NULL, /* no CachedPlan */
|
|
||||||
NULL, /* no CachedPlanSource */
|
|
||||||
0, /* query_index */
|
|
||||||
into, /* IntoClause *into */
|
|
||||||
es, /* struct ExplainState *es */
|
|
||||||
queryString, /* const char *queryString */
|
|
||||||
params, /* ParamListInfo params */
|
|
||||||
queryEnv, /* QueryEnvironment *queryEnv */
|
|
||||||
&planduration, /* const instr_time *planduration */
|
|
||||||
(es->buffers ? &bufusage : NULL), /* const BufferUsage *bufusage */
|
|
||||||
(es->memory ? &mem_counters : NULL) /* const MemoryContextCounters *mem_counters */
|
|
||||||
);
|
|
||||||
#elif PG_VERSION_NUM >= PG_VERSION_17
|
|
||||||
|
|
||||||
/* PostgreSQL 17 signature (9 args: includes mem_counters) */
|
/* PostgreSQL 17 signature (9 args: includes mem_counters) */
|
||||||
ExplainOnePlan(
|
ExplainOnePlan(
|
||||||
|
|
@ -2107,22 +2077,7 @@ ExplainOneQuery(Query *query, int cursorOptions,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_18
|
#if PG_VERSION_NUM >= PG_VERSION_17
|
||||||
ExplainOnePlan(
|
|
||||||
plan, /* PlannedStmt *plannedstmt */
|
|
||||||
NULL, /* CachedPlan *cplan */
|
|
||||||
NULL, /* CachedPlanSource *plansource */
|
|
||||||
0, /* query_index */
|
|
||||||
into, /* IntoClause *into */
|
|
||||||
es, /* struct ExplainState *es */
|
|
||||||
queryString, /* const char *queryString */
|
|
||||||
params, /* ParamListInfo params */
|
|
||||||
queryEnv, /* QueryEnvironment *queryEnv */
|
|
||||||
&planduration, /* const instr_time *planduration */
|
|
||||||
(es->buffers ? &bufusage : NULL),
|
|
||||||
(es->memory ? &mem_counters: NULL)
|
|
||||||
);
|
|
||||||
#elif PG_VERSION_NUM >= PG_VERSION_17
|
|
||||||
ExplainOnePlan(
|
ExplainOnePlan(
|
||||||
plan,
|
plan,
|
||||||
into,
|
into,
|
||||||
|
|
@ -2146,7 +2101,6 @@ ExplainOneQuery(Query *query, int cursorOptions,
|
||||||
(es->buffers ? &bufusage : NULL)
|
(es->buffers ? &bufusage : NULL)
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2208,19 +2162,6 @@ ExplainWorkerPlan(PlannedStmt *plannedstmt, DestReceiver *dest, ExplainState *es
|
||||||
UpdateActiveSnapshotCommandId();
|
UpdateActiveSnapshotCommandId();
|
||||||
|
|
||||||
/* Create a QueryDesc for the query */
|
/* Create a QueryDesc for the query */
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_18
|
|
||||||
queryDesc = CreateQueryDesc(
|
|
||||||
plannedstmt, /* PlannedStmt *plannedstmt */
|
|
||||||
NULL, /* CachedPlan *cplan (none) */
|
|
||||||
queryString, /* const char *sourceText */
|
|
||||||
GetActiveSnapshot(), /* Snapshot snapshot */
|
|
||||||
InvalidSnapshot, /* Snapshot crosscheck_snapshot */
|
|
||||||
dest, /* DestReceiver *dest */
|
|
||||||
params, /* ParamListInfo params */
|
|
||||||
queryEnv, /* QueryEnvironment *queryEnv */
|
|
||||||
instrument_option /* int instrument_options */
|
|
||||||
);
|
|
||||||
#else
|
|
||||||
queryDesc = CreateQueryDesc(
|
queryDesc = CreateQueryDesc(
|
||||||
plannedstmt, /* PlannedStmt *plannedstmt */
|
plannedstmt, /* PlannedStmt *plannedstmt */
|
||||||
queryString, /* const char *sourceText */
|
queryString, /* const char *sourceText */
|
||||||
|
|
@ -2231,7 +2172,6 @@ ExplainWorkerPlan(PlannedStmt *plannedstmt, DestReceiver *dest, ExplainState *es
|
||||||
queryEnv, /* QueryEnvironment *queryEnv */
|
queryEnv, /* QueryEnvironment *queryEnv */
|
||||||
instrument_option /* int instrument_options */
|
instrument_option /* int instrument_options */
|
||||||
);
|
);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Select execution options */
|
/* Select execution options */
|
||||||
if (es->analyze)
|
if (es->analyze)
|
||||||
|
|
|
||||||
|
|
@ -386,51 +386,29 @@ static const struct config_enum_entry metadata_sync_mode_options[] = {
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*
|
/*----------------------------------------------------------------------*
|
||||||
* On PG 18+ the hook signatures changed; we wrap the old Citus handlers
|
* On PG 18+ the hook signature changed; we wrap the old Citus handler
|
||||||
* in fresh functions that match the new typedefs exactly.
|
* in a fresh function that matches the new typedef exactly.
|
||||||
*----------------------------------------------------------------------*/
|
*----------------------------------------------------------------------*/
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_18
|
|
||||||
static bool
|
|
||||||
citus_executor_start_adapter(QueryDesc *queryDesc, int eflags)
|
|
||||||
{
|
|
||||||
/* PG18+ expects a bool return */
|
|
||||||
CitusExecutorStart(queryDesc, eflags);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
citus_executor_run_adapter(QueryDesc *queryDesc,
|
citus_executor_run_adapter(QueryDesc *queryDesc,
|
||||||
ScanDirection direction,
|
ScanDirection direction,
|
||||||
uint64 count)
|
uint64 count
|
||||||
{
|
#if PG_VERSION_NUM < PG_VERSION_18
|
||||||
/* PG18+ has no run_once flag
|
, bool run_once
|
||||||
* call the original Citus hook (which still expects the old 4-arg form) */
|
|
||||||
CitusExecutorRun(queryDesc, direction, count, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* PG15–17: adapter signatures must match the *old* typedefs */
|
|
||||||
static void
|
|
||||||
citus_executor_start_adapter(QueryDesc *queryDesc, int eflags)
|
|
||||||
{
|
|
||||||
CitusExecutorStart(queryDesc, eflags);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
citus_executor_run_adapter(QueryDesc *queryDesc,
|
|
||||||
ScanDirection direction,
|
|
||||||
uint64 count,
|
|
||||||
bool run_once)
|
|
||||||
{
|
|
||||||
CitusExecutorRun(queryDesc, direction, count, run_once);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
)
|
||||||
|
{
|
||||||
|
/* PG18+ has no run_once flag */
|
||||||
|
CitusExecutorRun(queryDesc,
|
||||||
|
direction,
|
||||||
|
count,
|
||||||
|
#if PG_VERSION_NUM >= PG_VERSION_18
|
||||||
|
true
|
||||||
|
#else
|
||||||
|
run_once
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* shared library initialization function */
|
/* shared library initialization function */
|
||||||
|
|
@ -507,7 +485,7 @@ _PG_init(void)
|
||||||
set_rel_pathlist_hook = multi_relation_restriction_hook;
|
set_rel_pathlist_hook = multi_relation_restriction_hook;
|
||||||
get_relation_info_hook = multi_get_relation_info_hook;
|
get_relation_info_hook = multi_get_relation_info_hook;
|
||||||
set_join_pathlist_hook = multi_join_restriction_hook;
|
set_join_pathlist_hook = multi_join_restriction_hook;
|
||||||
ExecutorStart_hook = citus_executor_start_adapter;
|
ExecutorStart_hook = CitusExecutorStart;
|
||||||
ExecutorRun_hook = citus_executor_run_adapter;
|
ExecutorRun_hook = citus_executor_run_adapter;
|
||||||
ExplainOneQuery_hook = CitusExplainOneQuery;
|
ExplainOneQuery_hook = CitusExplainOneQuery;
|
||||||
prev_ExecutorEnd = ExecutorEnd_hook;
|
prev_ExecutorEnd = ExecutorEnd_hook;
|
||||||
|
|
|
||||||
|
|
@ -1907,20 +1907,6 @@ ExecuteSqlString(const char *sql)
|
||||||
/* Don't display the portal in pg_cursors */
|
/* Don't display the portal in pg_cursors */
|
||||||
portal->visible = false;
|
portal->visible = false;
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_18
|
|
||||||
|
|
||||||
/* PG18+ added a seventh “plansource” argument */
|
|
||||||
PortalDefineQuery(
|
|
||||||
portal,
|
|
||||||
NULL, /* no prepared‐stmt name */
|
|
||||||
sql, /* the query text */
|
|
||||||
commandTag, /* the CommandTag */
|
|
||||||
plantree_list, /* List of PlannedStmt* */
|
|
||||||
NULL, /* no CachedPlan */
|
|
||||||
NULL /* no CachedPlanSource */
|
|
||||||
);
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* PG17-: six‐arg signature */
|
/* PG17-: six‐arg signature */
|
||||||
PortalDefineQuery(
|
PortalDefineQuery(
|
||||||
portal,
|
portal,
|
||||||
|
|
@ -1930,7 +1916,6 @@ ExecuteSqlString(const char *sql)
|
||||||
plantree_list, /* List of PlannedStmt* */
|
plantree_list, /* List of PlannedStmt* */
|
||||||
NULL /* no CachedPlan */
|
NULL /* no CachedPlan */
|
||||||
);
|
);
|
||||||
#endif
|
|
||||||
|
|
||||||
PortalStart(portal, NULL, 0, InvalidSnapshot);
|
PortalStart(portal, NULL, 0, InvalidSnapshot);
|
||||||
int16 format[] = { 1 };
|
int16 format[] = { 1 };
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue