Thread: pgsql: Relax ordering-related hardcoded btree requirements in planning

pgsql: Relax ordering-related hardcoded btree requirements in planning

From
Peter Eisentraut
Date:
Relax ordering-related hardcoded btree requirements in planning

There were several places in ordering-related planning where a
requirement for btree was hardcoded but an amcanorder index could
suffice.  This fixes that.  We just need to do the necessary mapping
between strategy numbers and compare types and adjust some related
APIs so that this works independent of btree strategy numbers.  For
instance, non-btree amcanorder indexes can now be used to support
sorting and merge joins.  Also, predtest.c works independent of btree
strategy numbers now.

To avoid performance regressions, some details on btree and other
built-in index types are still hardcoded as shortcuts, but other index
types now have access to the same features by providing the required
flags and callbacks.

Author: Mark Dilger <mark.dilger@enterprisedb.com>
Co-authored-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://www.postgresql.org/message-id/flat/E72EAA49-354D-4C2E-8EB9-255197F55330@enterprisedb.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a8025f544854ad8b865c6b4509030ee84aa8f4a0

Modified Files
--------------
src/backend/access/index/amapi.c        |  10 ++
src/backend/executor/nodeMergejoin.c    |   2 +-
src/backend/optimizer/path/allpaths.c   |  28 +++---
src/backend/optimizer/path/equivclass.c |   3 +-
src/backend/optimizer/path/pathkeys.c   |  22 ++---
src/backend/optimizer/plan/createplan.c |  10 +-
src/backend/optimizer/util/plancat.c    |  38 ++++----
src/backend/optimizer/util/predtest.c   | 122 +++++++++++------------
src/backend/parser/parse_clause.c       |   4 +-
src/backend/parser/parse_expr.c         |  34 +++----
src/backend/utils/adt/selfuncs.c        |  62 +++++++-----
src/backend/utils/cache/lsyscache.c     | 165 +++++++++++++++++++++-----------
src/backend/utils/sort/sortsupport.c    |   6 +-
src/include/utils/lsyscache.h           |  14 +--
src/include/utils/selfuncs.h            |   2 +-
src/tools/pgindent/typedefs.list        |   2 +-
16 files changed, 298 insertions(+), 226 deletions(-)