• Tom Lane's avatar
    Reduce match_pattern_prefix()'s dependencies on index opfamilies. · 2ddedcaf
    Tom Lane authored
    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
    2ddedcaf
like_support.c 48.7 KB