pgsql: Fix _bt_readnextpage half-dead leftmost page assert.

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix _bt_readnextpage half-dead leftmost page assert.
Date: 2026-10-15 16:18:37
Message-ID: E1xHOA9-00000001ktI-0P0l@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix _bt_readnextpage half-dead leftmost page assert.

Backwards scans that reach a half-dead leftmost leaf page step over the
page without calling _bt_readpage. This happens whenever the most
recent _bt_lock_and_validate_left call returned a half-dead leftmost
page. An assertion within _bt_readnextpage failed to consider this,
causing it to fail spuriously.

To fix, make the assertion accept the case where currPage doesn't match
lastcurrblkno as long as blkno is P_NONE (it's always P_NONE when the
last leaf page examined by _bt_readnextpage is either the leftmost or
rightmost page).

Oversight in commit caca6d8d27.

Author: Peter Geoghegan <pg(at)bowt(dot)ie>
Backpatch-through: 18

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6d4ee9203686d0426ec089ce965a96a86ef4651d

Modified Files
--------------
src/backend/access/nbtree/nbtsearch.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2026-10-15 16:43:01 pgsql: Simplify restriction matching in self-join elimination.
Previous Message Tom Lane 2026-10-15 16:02:45 pgsql: Weaken libxml2 behavioral test added by 30d4a6daa.