pgsql: Reduce match_pattern_prefix()'s dependencies on index opfamilies - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Reduce match_pattern_prefix()'s dependencies on index opfamilies
Date
Msg-id E1iXVPe-0007k6-8T@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Reduce match_pattern_prefix()'s dependencies on index opfamilies.

Historically, the planner's LIKE/regex index optimizations were only
carried out for specific index opfamilies.  That's never been a great
idea from the standpoint of extensibility, but it didn't matter so
much as long as we had no practical way to extend such behaviors anyway.
With the addition of planner support functions, and in view of ongoing
work to support additional table and index AMs, it seems like a good
time to relax this.

Hence, recast the decisions in match_pattern_prefix() so that rather
than decide which operators to generate by looking at what the index
opfamily contains, we decide which operators to generate a-priori
and then see if the opfamily supports them.  This is much more
defensible from a semantic standpoint anyway, since we know the
semantics of the chosen operators precisely, and we only need to
assume that the opfamily correctly implements operators it claims
to support.

The existing "pattern" opfamilies put a crimp in this approach, since
we need to select the pattern operators if we want those to work.
So we still have to special-case those opfamilies.  But that seems
all right, since in view of the addition of collations, the pattern
opfamilies seem like a legacy hack that nobody will be building on.

The only immediate effect of this change, so far as the core code is
concerned, is that anchored LIKE/regex patterns can be mapped onto
BRIN index searches, and exact-match patterns can be mapped onto hash
indexes, not only btree and spgist indexes as before.  That's not a
terribly exciting result, but it does fix an omission mentioned in
the ancient comments here.

Note: no catversion bump, even though this touches pg_operator.dat,
because it's only adding OID macros not changing the contents of
postgres.bki.

Per consideration of a report from Manuel Rigger.

Discussion: https://postgr.es/m/CA+u7OA7nnGYy8rY0vdTe811NuA+Frr9nbcBO9u2Z+JxqNaud+g@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2ddedcafca116c99e08c777ab2ab3a4de6f00c7e

Modified Files
--------------
src/backend/utils/adt/like_support.c | 142 +++++++++++++++++++++--------------
src/include/catalog/pg_operator.dat  |  38 ++++++----
2 files changed, 108 insertions(+), 72 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Doc: improve discussion of object owners' inherent privileges.
Next
From: Peter Geoghegan
Date:
Subject: pgsql: Fix HeapTupleSatisfiesNonVacuumable() comment.