Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 81a491e

Browse files
committed
restore compatibility with PostgreSQL 9.5
1 parent 3395a25 commit 81a491e

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

init.c

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,31 @@ get_index_size(Oid idx)
112112
static inline Oid
113113
get_dist_func()
114114
{
115+
MemoryContext oldcxt = CurrentMemoryContext;
116+
Datum result;
117+
118+
#if PG_VERSION_NUM >= 90600
115119
text *dist_func_name =
116120
cstring_to_text("public.dist(public.spoint, public.spoint)");
121+
#else
122+
char *dist_func_name = "public.dist(public.spoint, public.spoint)";
123+
#endif
124+
125+
PG_TRY();
126+
{
127+
result = DirectFunctionCall1(to_regprocedure,
128+
PointerGetDatum(dist_func_name));
129+
}
130+
PG_CATCH();
131+
{
132+
MemoryContextSwitchTo(oldcxt);
133+
FlushErrorState();
134+
135+
elog(ERROR, "can't find function \"dist(spoint, spoint)\"");
136+
}
137+
PG_END_TRY();
117138

118-
return DatumGetObjectId(DirectFunctionCall1(to_regprocedure,
119-
PointerGetDatum(dist_func_name)));
139+
return DatumGetObjectId(result);
120140
}
121141

122142
static float8
@@ -303,7 +323,9 @@ create_crossmatch_path(PlannerInfo *root,
303323
result->cpath.path.parent = joinrel;
304324
result->cpath.path.param_info = param_info;
305325
result->cpath.path.pathkeys = NIL;
326+
#if PG_VERSION_NUM >= 90600
306327
result->cpath.path.pathtarget = joinrel->reltarget;
328+
#endif
307329
result->cpath.path.rows = joinrel->rows;
308330
result->cpath.flags = 0;
309331
result->cpath.methods = &crossmatch_path_methods;
@@ -449,7 +471,12 @@ create_crossmatch_plan(PlannerInfo *root,
449471
List *joinrestrictclauses = gpath->joinrestrictinfo;
450472
List *joinclauses;
451473
CustomScan *cscan;
474+
475+
#if PG_VERSION_NUM >= 90600
452476
PathTarget *target;
477+
#else
478+
List *target;
479+
#endif
453480

454481
Assert(!IS_OUTER_JOIN(gpath->jointype));
455482
joinclauses = extract_actual_clauses(joinrestrictclauses, false);
@@ -459,12 +486,20 @@ create_crossmatch_plan(PlannerInfo *root,
459486
cscan->scan.plan.qual = joinclauses;
460487
cscan->scan.scanrelid = 0;
461488

489+
#if PG_VERSION_NUM >= 90600
462490
/* Add Vars needed for our extended 'joinclauses' */
463491
target = copy_pathtarget(rel->reltarget);
464492
add_new_columns_to_pathtarget(target, pull_var_clause((Node *) joinclauses, 0));
465493

466494
/* tlist of the 'virtual' join rel we'll have to build and scan */
467495
cscan->custom_scan_tlist = make_tlist_from_pathtarget(target);
496+
#else
497+
target = list_copy(tlist);
498+
target = add_to_flat_tlist(target, pull_var_clause((Node *) joinclauses,
499+
PVC_REJECT_AGGREGATES,
500+
PVC_REJECT_PLACEHOLDERS));
501+
cscan->custom_scan_tlist = target;
502+
#endif
468503

469504
cscan->flags = best_path->flags;
470505
cscan->methods = &crossmatch_plan_methods;

0 commit comments

Comments
 (0)