pgsql: Simplify and generalize PrepareSortSupportFromIndexRel()

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Simplify and generalize PrepareSortSupportFromIndexRel()
Date: 2025-03-14 09:54:41
Message-ID: E1tt1kX-002QDQ-1O@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(dot)dilger(at)enterprisedb(dot)com>
Discussion: https://www.postgresql.org/message-id/flat/E72EAA49-354D-4C2E-8EB9-255197F55330(at)enterprisedb(dot)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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2025-03-14 13:51:25 pgsql: Optimize iteration over PGPROC for fast-path lock searches.
Previous Message Álvaro Herrera 2025-03-14 08:29:35 pgsql: Remove direct handling of reloptions for toast tables