diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2019-02-11 21:26:08 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2019-02-11 21:26:14 -0500 |
commit | 74dfe58a5927b22c744b29534e67bfdd203ac028 (patch) | |
tree | 1f3a0efabf8580127f9a3032df522032e512f3d1 /src/include/optimizer/optimizer.h | |
parent | ea92368cd1da1e290f9ab8efb7f60cb7598fc310 (diff) | |
download | postgresql-74dfe58a5927b22c744b29534e67bfdd203ac028.tar.gz postgresql-74dfe58a5927b22c744b29534e67bfdd203ac028.zip |
Allow extensions to generate lossy index conditions.
For a long time, indxpath.c has had the ability to extract derived (lossy)
index conditions from certain operators such as LIKE. For just as long,
it's been obvious that we really ought to make that capability available
to extensions. This commit finally accomplishes that, by adding another
API for planner support functions that lets them create derived index
conditions for their functions. As proof of concept, the hardwired
"special index operator" code formerly present in indxpath.c is pushed
out to planner support functions attached to LIKE and other relevant
operators.
A weak spot in this design is that an extension needs to know OIDs for
the operators, datatypes, and opfamilies involved in the transformation
it wants to make. The core-code prototypes use hard-wired OID references
but extensions don't have that option for their own operators etc. It's
usually possible to look up the required info, but that may be slow and
inconvenient. However, improving that situation is a separate task.
I want to do some additional refactorization around selfuncs.c, but
that also seems like a separate task.
Discussion: https://postgr.es/m/15193.1548028093@sss.pgh.pa.us
Diffstat (limited to 'src/include/optimizer/optimizer.h')
-rw-r--r-- | src/include/optimizer/optimizer.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/include/optimizer/optimizer.h b/src/include/optimizer/optimizer.h index ffaf5b9450b..ffd812a4ed8 100644 --- a/src/include/optimizer/optimizer.h +++ b/src/include/optimizer/optimizer.h @@ -35,7 +35,11 @@ typedef struct PlannerInfo PlannerInfo; #define HAVE_PLANNERINFO_TYPEDEF 1 #endif -/* Likewise for SpecialJoinInfo. */ +/* Likewise for IndexOptInfo and SpecialJoinInfo. */ +#ifndef HAVE_INDEXOPTINFO_TYPEDEF +typedef struct IndexOptInfo IndexOptInfo; +#define HAVE_INDEXOPTINFO_TYPEDEF 1 +#endif #ifndef HAVE_SPECIALJOININFO_TYPEDEF typedef struct SpecialJoinInfo SpecialJoinInfo; #define HAVE_SPECIALJOININFO_TYPEDEF 1 @@ -74,6 +78,10 @@ extern PGDLLIMPORT int effective_cache_size; extern double clamp_row_est(double nrows); +/* in path/indxpath.c: */ + +extern bool is_pseudo_constant_for_index(Node *expr, IndexOptInfo *index); + /* in plan/planner.c: */ /* possible values for force_parallel_mode */ |