@@ -112,11 +112,31 @@ get_index_size(Oid idx)
112112static inline Oid
113113get_dist_func ()
114114{
115+ MemoryContext oldcxt = CurrentMemoryContext ;
116+ Datum result ;
117+
118+ #if PG_VERSION_NUM >=90600
115119text * dist_func_name =
116120cstring_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
122142static float8
@@ -303,7 +323,9 @@ create_crossmatch_path(PlannerInfo *root,
303323result -> cpath .path .parent = joinrel ;
304324result -> cpath .path .param_info = param_info ;
305325result -> cpath .path .pathkeys = NIL ;
326+ #if PG_VERSION_NUM >=90600
306327result -> cpath .path .pathtarget = joinrel -> reltarget ;
328+ #endif
307329result -> cpath .path .rows = joinrel -> rows ;
308330result -> cpath .flags = 0 ;
309331result -> cpath .methods = & crossmatch_path_methods ;
@@ -449,7 +471,12 @@ create_crossmatch_plan(PlannerInfo *root,
449471List * joinrestrictclauses = gpath -> joinrestrictinfo ;
450472List * joinclauses ;
451473CustomScan * cscan ;
474+
475+ #if PG_VERSION_NUM >=90600
452476PathTarget * target ;
477+ #else
478+ List * target ;
479+ #endif
453480
454481Assert (!IS_OUTER_JOIN (gpath -> jointype ));
455482joinclauses = extract_actual_clauses (joinrestrictclauses , false);
@@ -459,12 +486,20 @@ create_crossmatch_plan(PlannerInfo *root,
459486cscan -> scan .plan .qual = joinclauses ;
460487cscan -> scan .scanrelid = 0 ;
461488
489+ #if PG_VERSION_NUM >=90600
462490/* Add Vars needed for our extended 'joinclauses' */
463491target = copy_pathtarget (rel -> reltarget );
464492add_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 */
467495cscan -> 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
469504cscan -> flags = best_path -> flags ;
470505cscan -> methods = & crossmatch_plan_methods ;