Simplify and generalize PrepareSortSupportFromIndexRel()
authorPeter Eisentraut
Fri, 14 Mar 2025 09:34:08 +0000 (10:34 +0100)
committerPeter Eisentraut
Fri, 14 Mar 2025 09:34:08 +0000 (10:34 +0100)
commita359d3701991d040bf7b66cfa7052546eb923c38
tree2d22e60a2d991fc36f085aab87a07789afad5cd2
parent1548c3a30436dd825cfbf57923c6766b2fddd355
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
Discussion: https://www.postgresql.org/message-id/flat/E72EAA49-354D-4C2E-8EB9-255197F55330@enterprisedb.com
src/backend/access/nbtree/nbtsort.c
src/backend/utils/sort/sortsupport.c
src/backend/utils/sort/tuplesortvariants.c
src/include/utils/sortsupport.h