mirror of https://github.com/citusdata/citus.git
Refactor compatibility handling for PostgreSQL versions in various files
parent
93df6fd0bf
commit
63c32c0d81
|
@ -1743,8 +1743,6 @@ create_estate_for_relation(Relation rel)
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
#if PG_VERSION_NUM >= PG_VERSION_16
|
||||||
List *perminfos = NIL;
|
List *perminfos = NIL;
|
||||||
addRTEPermissionInfo(&perminfos, rte);
|
addRTEPermissionInfo(&perminfos, rte);
|
||||||
#else
|
|
||||||
List *perminfos = NIL; /* not used on PG 15 */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Initialize the range table, with the right signature for each PG version */
|
/* Initialize the range table, with the right signature for each PG version */
|
||||||
|
|
|
@ -1211,7 +1211,7 @@ set_relation_column_names(deparse_namespace *dpns, RangeTblEntry *rte,
|
||||||
if (rte->rtekind == RTE_FUNCTION && rte->functions != NIL)
|
if (rte->rtekind == RTE_FUNCTION && rte->functions != NIL)
|
||||||
{
|
{
|
||||||
/* Since we're not creating Vars, rtindex etc. don't matter */
|
/* Since we're not creating Vars, rtindex etc. don't matter */
|
||||||
expandRTE(rte, 1, 0, -1, true /* include dropped */ ,
|
expandRTE(rte, 1, 0, VAR_RETURNING_DEFAULT, -1, true /* include dropped */ ,
|
||||||
&colnames, NULL);
|
&colnames, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -4611,6 +4611,7 @@ get_name_for_var_field(Var *var, int fieldno,
|
||||||
case RTE_VALUES:
|
case RTE_VALUES:
|
||||||
case RTE_NAMEDTUPLESTORE:
|
case RTE_NAMEDTUPLESTORE:
|
||||||
case RTE_RESULT:
|
case RTE_RESULT:
|
||||||
|
case RTE_GROUP:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This case should not occur: a column of a table or values list
|
* This case should not occur: a column of a table or values list
|
||||||
|
|
|
@ -2315,7 +2315,7 @@ ExplainWorkerPlan(PlannedStmt *plannedstmt, DestReceiver *dest, ExplainState *es
|
||||||
if (es->costs)
|
if (es->costs)
|
||||||
ExplainPrintJITSummary(es, queryDesc);
|
ExplainPrintJITSummary(es, queryDesc);
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_17 && PG_VERSION_NUM < PG_VERSION_1
|
#if PG_VERSION_NUM >= PG_VERSION_17 && PG_VERSION_NUM < PG_VERSION_18
|
||||||
if (es->serialize != EXPLAIN_SERIALIZE_NONE)
|
if (es->serialize != EXPLAIN_SERIALIZE_NONE)
|
||||||
{
|
{
|
||||||
/* the SERIALIZE option requires its own tuple receiver */
|
/* the SERIALIZE option requires its own tuple receiver */
|
||||||
|
|
|
@ -91,23 +91,11 @@ FakeGetForeignPaths(PlannerInfo *root, RelOptInfo *baserel, Oid foreigntableid)
|
||||||
Cost startup_cost = 0;
|
Cost startup_cost = 0;
|
||||||
Cost total_cost = startup_cost + baserel->rows;
|
Cost total_cost = startup_cost + baserel->rows;
|
||||||
|
|
||||||
add_path(baserel,
|
add_path(baserel, (Path *) create_foreignscan_path_compat(root, baserel, NULL,
|
||||||
(Path *) create_foreignscan_path_compat(
|
baserel->rows,
|
||||||
root,
|
startup_cost, total_cost,
|
||||||
baserel,
|
NIL,
|
||||||
baserel->reltarget, /* ← PathTarget* is the rel’s reltarget */
|
NULL, NULL, NIL, NIL));
|
||||||
baserel->rows,
|
|
||||||
0, /* ← disabled_nodes (only used in PG18+) */
|
|
||||||
startup_cost,
|
|
||||||
total_cost,
|
|
||||||
NIL, /* pathkeys */
|
|
||||||
NULL, /* required_outer */
|
|
||||||
NULL, /* fdw_outerpath */
|
|
||||||
NIL, /* fdw_restrictinfo (PG18+) */
|
|
||||||
NIL, /* fdw_private */
|
|
||||||
NIL /* fdw_scan_tlist (PG15–17) */
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -384,70 +384,34 @@ getStxstattarget_compat(HeapTuple tup)
|
||||||
|
|
||||||
#define matched_compat(a) (a->matchKind == MERGE_WHEN_MATCHED)
|
#define matched_compat(a) (a->matchKind == MERGE_WHEN_MATCHED)
|
||||||
|
|
||||||
#include "nodes/pg_list.h" /* for List */
|
#include "nodes/bitmapset.h" /* for Relids */
|
||||||
#include "nodes/plannodes.h" /* for ForeignScan */
|
#include "nodes/pg_list.h" /* for List */
|
||||||
#include "optimizer/pathnode.h" /* for create_foreignscan_path, ForeignPath */
|
#include "optimizer/pathnode.h" /* for create_foreignscan_path() */
|
||||||
|
|
||||||
/*
|
|
||||||
* A single entry point for Citus code to build ForeignPath
|
|
||||||
* using the *full* superset of parameters:
|
|
||||||
*
|
|
||||||
* root, rel, target, rows,
|
|
||||||
* disabled_nodes, startup_cost, total_cost,
|
|
||||||
* pathkeys, required_outer,
|
|
||||||
* fdw_outerpath, fdw_restrictinfo,
|
|
||||||
* fdw_private, fdw_scan_tlist
|
|
||||||
*/
|
|
||||||
static inline ForeignPath *
|
|
||||||
create_foreignscan_path_compat(PlannerInfo *root,
|
|
||||||
RelOptInfo *rel,
|
|
||||||
PathTarget *target,
|
|
||||||
double rows,
|
|
||||||
int disabled_nodes,
|
|
||||||
Cost startup_cost,
|
|
||||||
Cost total_cost,
|
|
||||||
List *pathkeys,
|
|
||||||
Relids required_outer,
|
|
||||||
Path *fdw_outerpath,
|
|
||||||
List *fdw_restrictinfo,
|
|
||||||
List *fdw_private,
|
|
||||||
List *fdw_scan_tlist)
|
|
||||||
{
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_18
|
#if PG_VERSION_NUM >= PG_VERSION_18
|
||||||
|
#define create_foreignscan_path_compat(a, b, c, d, e, f, g, h, i, j, k) \
|
||||||
/* PG 18+ signature: 12 args */
|
create_foreignscan_path( \
|
||||||
return create_foreignscan_path(
|
(a), /* root */ \
|
||||||
root,
|
(b), /* rel */ \
|
||||||
rel,
|
(c), /* target */ \
|
||||||
target,
|
(d), /* rows */ \
|
||||||
rows,
|
0, /* disabled_nodes */ \
|
||||||
disabled_nodes,
|
(e), /* startup_cost */ \
|
||||||
startup_cost,
|
(f), /* total_cost */ \
|
||||||
total_cost,
|
(g), /* pathkeys */ \
|
||||||
pathkeys,
|
(h), /* required_outer */ \
|
||||||
required_outer,
|
(i), /* fdw_outerpath */ \
|
||||||
fdw_outerpath,
|
(j), /* fdw_restrictinfo*/ \
|
||||||
fdw_restrictinfo,
|
(k) /* fdw_private */ \
|
||||||
fdw_private
|
)
|
||||||
);
|
|
||||||
#else
|
#else
|
||||||
|
#define create_foreignscan_path_compat(a, b, c, d, e, f, g, h, i, j, k) \
|
||||||
/* PG 17- signature: 11 args */
|
create_foreignscan_path( \
|
||||||
return create_foreignscan_path(
|
(a), (b), (c), (d), \
|
||||||
root,
|
(e), (f), \
|
||||||
rel,
|
(g), (h), (i), (j), (k) \
|
||||||
target,
|
)
|
||||||
rows,
|
|
||||||
startup_cost,
|
|
||||||
total_cost,
|
|
||||||
pathkeys,
|
|
||||||
required_outer,
|
|
||||||
fdw_outerpath,
|
|
||||||
fdw_private,
|
|
||||||
fdw_scan_tlist
|
|
||||||
);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define getProcNo_compat(a) (a->vxid.procNumber)
|
#define getProcNo_compat(a) (a->vxid.procNumber)
|
||||||
|
@ -483,6 +447,10 @@ getStxstattarget_compat(HeapTuple tup)
|
||||||
|
|
||||||
#define matched_compat(a) (a->matched)
|
#define matched_compat(a) (a->matched)
|
||||||
|
|
||||||
|
#define create_foreignscan_path_compat(a, b, c, d, e, f, g, h, i, j, \
|
||||||
|
k) create_foreignscan_path(a, b, c, d, e, f, g, h, \
|
||||||
|
i, k)
|
||||||
|
|
||||||
#define getProcNo_compat(a) (a->pgprocno)
|
#define getProcNo_compat(a) (a->pgprocno)
|
||||||
#define getLxid_compat(a) (a->lxid)
|
#define getLxid_compat(a) (a->lxid)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue