pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Remove tuplesort_set_allowbounded() and adjust tuplesort_reset()
Date: Wed, 18 Nov 2026 01:28:22 +0000
Message-ID: <E1xTUTF-00000000ATD-0sci@gemulon.postgresql.org> (raw)

Remove tuplesort_set_allowbounded() and adjust tuplesort_reset()

tuplesort_set_allowbounded() was added to resolve an issue where a
Tuplesortstate was created without TUPLESORT_ALLOWBOUNDED, but a later
scan of Incremental Sort requires that flag because that scan is bounded.
The new function was added in the backbranches as it's not possible to
modify the signature of tuplesort_reset() there.  Since we're free to
adjust that in master, this commit gets rid of
tuplesort_set_allowbounded(), which had to be called before
tuplesort_reset(), and instead adds a new boolean parameter to
tuplesort_reset() to allow the flag to be adjusted.  This is a much
cleaner API.

The fundamental difference between TUPLESORT_ALLOWBOUNDED and not having
that flag is that the tuplecontext uses an AllocSet context for bounded
sorts as the sort only needs to keep the top N tuples and pfrees any
tuples that sort below those.  When no bound is required, tuplecontext
uses a Bump context, which does not support pfree(), but uses less memory
to store the same tuples.

Author: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/CAApHDvpoJenKm2O2aUpLYnYV-o9cg+Zhpur3jimr+q0cA7NS6w@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
src/backend/executor/nodeIncrementalSort.c | 18 ++++++-----------
src/backend/utils/sort/tuplesort.c         | 32 +++++++++++++-----------------
src/include/utils/tuplesort.h              |  4 +---
3 files changed, 21 insertions(+), 33 deletions(-)



Message-ID: <E1xTUTF-00000000ATD-0sci@gemulon.postgresql.org>
Permalink:  ../E1xTUTF-00000000ATD-0sci@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xTUTF-00000000ATD-0sci@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: drowley@postgresql.org
  Subject: Re: pgsql: Remove tuplesort_set_allowbounded() and adjust tuplesort_reset()
  In-Reply-To: <E1xTUTF-00000000ATD-0sci@gemulon.postgresql.org>
  References: <E1xTUTF-00000000ATD-0sci@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox