Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/backend/optimizer/path/indxpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down Expand Up @@ -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) &&
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/include/optimizer/paths.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading