@@ -112,11 +112,31 @@ get_index_size(Oid idx)
112
112
static inline Oid
113
113
get_dist_func ()
114
114
{
115
+ MemoryContext oldcxt = CurrentMemoryContext ;
116
+ Datum result ;
117
+
118
+ #if PG_VERSION_NUM >=90600
115
119
text * dist_func_name =
116
120
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 ();
117
138
118
- return DatumGetObjectId (DirectFunctionCall1 (to_regprocedure ,
119
- PointerGetDatum (dist_func_name )));
139
+ return DatumGetObjectId (result );
120
140
}
121
141
122
142
static float8
@@ -303,7 +323,9 @@ create_crossmatch_path(PlannerInfo *root,
303
323
result -> cpath .path .parent = joinrel ;
304
324
result -> cpath .path .param_info = param_info ;
305
325
result -> cpath .path .pathkeys = NIL ;
326
+ #if PG_VERSION_NUM >=90600
306
327
result -> cpath .path .pathtarget = joinrel -> reltarget ;
328
+ #endif
307
329
result -> cpath .path .rows = joinrel -> rows ;
308
330
result -> cpath .flags = 0 ;
309
331
result -> cpath .methods = & crossmatch_path_methods ;
@@ -449,7 +471,12 @@ create_crossmatch_plan(PlannerInfo *root,
449
471
List * joinrestrictclauses = gpath -> joinrestrictinfo ;
450
472
List * joinclauses ;
451
473
CustomScan * cscan ;
474
+
475
+ #if PG_VERSION_NUM >=90600
452
476
PathTarget * target ;
477
+ #else
478
+ List * target ;
479
+ #endif
453
480
454
481
Assert (!IS_OUTER_JOIN (gpath -> jointype ));
455
482
joinclauses = extract_actual_clauses (joinrestrictclauses , false);
@@ -459,12 +486,20 @@ create_crossmatch_plan(PlannerInfo *root,
459
486
cscan -> scan .plan .qual = joinclauses ;
460
487
cscan -> scan .scanrelid = 0 ;
461
488
489
+ #if PG_VERSION_NUM >=90600
462
490
/* Add Vars needed for our extended 'joinclauses' */
463
491
target = copy_pathtarget (rel -> reltarget );
464
492
add_new_columns_to_pathtarget (target ,pull_var_clause ((Node * )joinclauses ,0 ));
465
493
466
494
/* tlist of the 'virtual' join rel we'll have to build and scan */
467
495
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
468
503
469
504
cscan -> flags = best_path -> flags ;
470
505
cscan -> methods = & crossmatch_plan_methods ;