Relax ordering-related hardcoded btree requirements in planning
authorPeter Eisentraut <peter@eisentraut.org>
Sun, 6 Apr 2025 12:43:51 +0000 (14:43 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Sun, 6 Apr 2025 12:43:51 +0000 (14:43 +0200)
commita8025f544854ad8b865c6b4509030ee84aa8f4a0
tree845091557eeb98a01ef6ce7ca0e26315f67e8cfc
parent3a1a7c5a7071c75676c15b26e242c7df17560bd1
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
16 files changed:
src/backend/access/index/amapi.c
src/backend/executor/nodeMergejoin.c
src/backend/optimizer/path/allpaths.c
src/backend/optimizer/path/equivclass.c
src/backend/optimizer/path/pathkeys.c
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/util/plancat.c
src/backend/optimizer/util/predtest.c
src/backend/parser/parse_clause.c
src/backend/parser/parse_expr.c
src/backend/utils/adt/selfuncs.c
src/backend/utils/cache/lsyscache.c
src/backend/utils/sort/sortsupport.c
src/include/utils/lsyscache.h
src/include/utils/selfuncs.h
src/tools/pgindent/typedefs.list