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.
74dfe58a59 Allow extensions to generate lossy index conditions.
doc/src/sgml/xfunc.sgml | 14 +
src/backend/optimizer/path/indxpath.c | 2024 +++++++++++-----------------
src/backend/optimizer/util/clauses.c | 3 +-
src/backend/utils/adt/Makefile | 3 +-
src/backend/utils/adt/like_support.c | 313 +++++
src/backend/utils/adt/network.c | 207 +++
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_proc.dat | 98 +-
src/include/nodes/nodes.h | 3 +-
src/include/nodes/pathnodes.h | 9 +-
src/include/nodes/supportnodes.h | 74 +-
src/include/optimizer/optimizer.h | 10 +-
src/test/regress/expected/btree_index.out | 71 +
src/test/regress/expected/create_index.out | 18 +
src/test/regress/expected/inet.out | 55 +
src/test/regress/expected/rowtypes.out | 99 ++
src/test/regress/sql/btree_index.sql | 18 +
src/test/regress/sql/create_index.sql | 4 +
src/test/regress/sql/inet.sql | 10 +
src/test/regress/sql/rowtypes.sql | 27 +
20 files changed, 1771 insertions(+), 1291 deletions(-)