Thread: pgsql: Simplify and generalize PrepareSortSupportFromIndexRel()

pgsql: Simplify and generalize PrepareSortSupportFromIndexRel()

From
Peter Eisentraut
Date:
Simplify and generalize PrepareSortSupportFromIndexRel()

PrepareSortSupportFromIndexRel() was accepting btree strategy numbers
purely for the purpose of comparing it later against btree strategies
to determine if the sort direction was forward or reverse.  Change
that.  Instead, pass a bool directly, to indicate the same without an
unfortunate assumption that a strategy number refers specifically to a
btree strategy.  (This is similar in spirit to commits 0d2aa4d4937 and
c594f1ad2ba.)

(This could arguably be simplfied further by having the callers fill
in ssup_reverse directly.  But this way, it preserves consistency by
having all PrepareSortSupport*() variants be responsible for filling
in ssup_reverse.)

Moreover, remove the hardcoded check against BTREE_AM_OID, and check
against amcanorder instead, which is the actual requirement.

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

Branch
------
master

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

Modified Files
--------------
src/backend/access/nbtree/nbtsort.c        |  7 +++----
src/backend/utils/sort/sortsupport.c       | 15 ++++++---------
src/backend/utils/sort/tuplesortvariants.c | 14 ++++++--------
src/include/utils/sortsupport.h            |  2 +-
4 files changed, 16 insertions(+), 22 deletions(-)