agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix incorrect block accounting in TID Range Scans
Date: Wed, 23 Sep 2026 13:22:01 +0000
Message-ID: <E1x9MvB-00000000vPC-1Glk@gemulon.postgresql.org> (raw)

Fix incorrect block accounting in TID Range Scans

heapgettup_advance_block() (or heapgettup() and heapgettup_pagemode() in
versions before v16) would incorrectly decrement rs_numblocks when
advancing to the next block.  Ordinarily this was fine, but if the TID
Range scan plan was used by a scrollable cursor and the cursor was fetched
backwards enough to result in another block being required, then
rs_numblocks may have reached 0 prematurely resulting in the scan ending
prematurely.

Reported-by: Jeff Davis <pgsql@j-davis.com>
Author: Ewan Young <kdbase.hack@gmail.com>
Discussion: https://postgr.es/m/6b50233fcc0f7d6f4845f083777fa9702d9612e4.camel@j-davis.com
Backpatch-through: 14

Branch
------
REL_14_STABLE

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

Modified Files
--------------
src/backend/access/heap/heapam.c           | 48 +++++++++++++++++++++++++-----
src/test/regress/expected/tidrangescan.out | 26 ++++++++++++++++
src/test/regress/sql/tidrangescan.sql      | 12 ++++++++
3 files changed, 78 insertions(+), 8 deletions(-)



view thread (7+ messages)

Message-ID: <E1x9MvB-00000000vPC-1Glk@gemulon.postgresql.org>
Permalink:  ../E1x9MvB-00000000vPC-1Glk@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1x9MvB-00000000vPC-1Glk@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: drowley@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix incorrect block accounting in TID Range Scans
  In-Reply-To: <E1x9MvB-00000000vPC-1Glk@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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox