pgsql: Fix incorrect block accounting in TID Range Scans - Mailing list pgsql-committers

From David Rowley
Subject pgsql: Fix incorrect block accounting in TID Range Scans
Date
Msg-id E1x9Mty-00000000vJz-0bze@gemulon.postgresql.org
Whole thread
List pgsql-committers
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>
Author: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/6b50233fcc0f7d6f4845f083777fa9702d9612e4.camel@j-davis.com
Backpatch-through: 14

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/25ebf0097fcc1aaf7bb56816e7508142c1613ab9

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


pgsql-committers by date:

Previous
From: David Rowley
Date:
Subject: pgsql: Fix incorrect block accounting in TID Range Scans
Next
From: David Rowley
Date:
Subject: pgsql: Fix incorrect block accounting in TID Range Scans