diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c index 4fe8e5164c7..92bdd87035f 100644 --- a/src/backend/optimizer/path/indxpath.c +++ b/src/backend/optimizer/path/indxpath.c @@ -36,6 +36,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) \ @@ -2964,12 +2966,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) && @@ -3004,12 +3011,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 70380276c84..944e9fde662 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,