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
|
||||
List *perminfos = NIL;
|
||||
addRTEPermissionInfo(&perminfos, rte);
|
||||
#else
|
||||
List *perminfos = NIL; /* not used on PG 15 */
|
||||
#endif
|
||||
|
||||
/* 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)
|
||||
{
|
||||
/* 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);
|
||||
}
|
||||
else
|
||||
|
@ -4611,6 +4611,7 @@ get_name_for_var_field(Var *var, int fieldno,
|
|||
case RTE_VALUES:
|
||||
case RTE_NAMEDTUPLESTORE:
|
||||
case RTE_RESULT:
|
||||
case RTE_GROUP:
|
||||
|
||||
/*
|
||||
* 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)
|
||||
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)
|
||||
{
|
||||
/* the SERIALIZE option requires its own tuple receiver */
|
||||
|
|
|
@ -91,23 +91,11 @@ FakeGetForeignPaths(PlannerInfo *root, RelOptInfo *baserel, Oid foreigntableid)
|
|||
Cost startup_cost = 0;
|
||||
Cost total_cost = startup_cost + baserel->rows;
|
||||
|
||||
add_path(baserel,
|
||||
(Path *) create_foreignscan_path_compat(
|
||||
root,
|
||||
baserel,
|
||||
baserel->reltarget, /* ← PathTarget* is the rel’s reltarget */
|
||||
add_path(baserel, (Path *) create_foreignscan_path_compat(root, baserel, NULL,
|
||||
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) */
|
||||
)
|
||||
);
|
||||
startup_cost, total_cost,
|
||||
NIL,
|
||||
NULL, NULL, NIL, NIL));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -384,70 +384,34 @@ getStxstattarget_compat(HeapTuple tup)
|
|||
|
||||
#define matched_compat(a) (a->matchKind == MERGE_WHEN_MATCHED)
|
||||
|
||||
#include "nodes/bitmapset.h" /* for Relids */
|
||||
#include "nodes/pg_list.h" /* for List */
|
||||
#include "nodes/plannodes.h" /* for ForeignScan */
|
||||
#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
|
||||
|
||||
/* PG 18+ signature: 12 args */
|
||||
return create_foreignscan_path(
|
||||
root,
|
||||
rel,
|
||||
target,
|
||||
rows,
|
||||
disabled_nodes,
|
||||
startup_cost,
|
||||
total_cost,
|
||||
pathkeys,
|
||||
required_outer,
|
||||
fdw_outerpath,
|
||||
fdw_restrictinfo,
|
||||
fdw_private
|
||||
);
|
||||
#define create_foreignscan_path_compat(a, b, c, d, e, f, g, h, i, j, k) \
|
||||
create_foreignscan_path( \
|
||||
(a), /* root */ \
|
||||
(b), /* rel */ \
|
||||
(c), /* target */ \
|
||||
(d), /* rows */ \
|
||||
0, /* disabled_nodes */ \
|
||||
(e), /* startup_cost */ \
|
||||
(f), /* total_cost */ \
|
||||
(g), /* pathkeys */ \
|
||||
(h), /* required_outer */ \
|
||||
(i), /* fdw_outerpath */ \
|
||||
(j), /* fdw_restrictinfo*/ \
|
||||
(k) /* fdw_private */ \
|
||||
)
|
||||
#else
|
||||
|
||||
/* PG 17- signature: 11 args */
|
||||
return create_foreignscan_path(
|
||||
root,
|
||||
rel,
|
||||
target,
|
||||
rows,
|
||||
startup_cost,
|
||||
total_cost,
|
||||
pathkeys,
|
||||
required_outer,
|
||||
fdw_outerpath,
|
||||
fdw_private,
|
||||
fdw_scan_tlist
|
||||
);
|
||||
#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), (j), (k) \
|
||||
)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#define getProcNo_compat(a) (a->vxid.procNumber)
|
||||
|
@ -483,6 +447,10 @@ getStxstattarget_compat(HeapTuple tup)
|
|||
|
||||
#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 getLxid_compat(a) (a->lxid)
|
||||
|
||||
|
|
Loading…
Reference in New Issue