diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c index afb9df4763d..88f83690b37 100644 --- a/src/backend/optimizer/path/indxpath.c +++ b/src/backend/optimizer/path/indxpath.c @@ -35,6 +35,8 @@ #include "utils/lsyscache.h" #include "utils/selfuncs.h" +/* Hook for extensions to provide index clauses for unmatched OpExpr */ +match_opclause_to_indexcol_hook_type match_opclause_to_indexcol_hook = NULL; /* XXX see PartCollMatchesExprColl */ #define IndexCollMatchesExprColl(idxcollation, exprcollation) \ @@ -2451,12 +2453,17 @@ match_opclause_to_indexcol(PlannerInfo *root, * function for the operator's underlying function. */ set_opfuncid(clause); /* make sure we have opfuncid */ - return get_index_clause_from_support(root, + iclause = get_index_clause_from_support(root, rinfo, clause->opfuncid, 0, /* indexarg on left */ indexcol, index); + if (iclause) + return iclause; + if (match_opclause_to_indexcol_hook) + return match_opclause_to_indexcol_hook(root, rinfo, indexcol, index); + return NULL; } if (match_index_to_operand(rightop, indexcol, index) && @@ -2491,12 +2498,17 @@ match_opclause_to_indexcol(PlannerInfo *root, * function for the operator's underlying function. */ set_opfuncid(clause); /* make sure we have opfuncid */ - return get_index_clause_from_support(root, + iclause = get_index_clause_from_support(root, rinfo, clause->opfuncid, 1, /* indexarg on right */ indexcol, index); + if (iclause) + return iclause; + if (match_opclause_to_indexcol_hook) + return match_opclause_to_indexcol_hook(root, rinfo, indexcol, index); + return NULL; } return NULL; diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h index 5e88c0224a4..af9fd2f14bf 100644 --- a/src/include/optimizer/paths.h +++ b/src/include/optimizer/paths.h @@ -48,6 +48,13 @@ typedef RelOptInfo *(*join_search_hook_type) (PlannerInfo *root, List *initial_rels); extern PGDLLIMPORT join_search_hook_type join_search_hook; +/* Hook for plugins to provide index clauses for unmatched OpExpr */ +typedef IndexClause *(*match_opclause_to_indexcol_hook_type) (PlannerInfo *root, + RestrictInfo *rinfo, + int indexcol, + IndexOptInfo *index); +extern PGDLLIMPORT match_opclause_to_indexcol_hook_type match_opclause_to_indexcol_hook; + extern RelOptInfo *make_one_rel(PlannerInfo *root, List *joinlist); extern RelOptInfo *standard_join_search(PlannerInfo *root, int levels_needed,