pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Geoghegan <pg@bowt.ie>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: nbtree: Always set skipScan flag on rescan.
Date: Sun, 14 Sep 2025 01:02:14 +0000
Message-ID: <E1uxb89-000adi-36@gemulon.postgresql.org> (raw)

nbtree: Always set skipScan flag on rescan.

The TimescaleDB extension expects to be able to change an nbtree scan's
keys across rescans.  The issue arises in the extension's implementation
of loose index scan.  This is arguably a misuse of the index AM API,
though apparently it worked until recently.  It stopped working when the
skipScan flag was added to BTScanOpaqueData by commit 8a510275, though.
The flag wouldn't reliably track whether the scan (actually, the current
rescan) has any skip arrays, leading to confusion in _bt_set_startikey.

nbtree preprocessing will now defensively initialize the scan's skipScan
flag in all cases, including the case where _bt_preprocess_array_keys
returns early due to the (re)scan not using arrays.  While nbtree isn't
obligated to support this use case (at least not according to my reading
of the index AM API), it still seems like a good idea to be consistent
here, on general robustness grounds.

Author: Peter Geoghegan <pg@bowt.ie>
Reported-By: Natalya Aksman <natalya@timescale.com>
Discussion: https://postgr.es/m/CAJumhcirfMojbk20+W0YimbNDkwdECvJprQGQ-XqK--ph09nQw@mail.gmail.com
Backpatch-through: 18

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/454c046094ab3431c2ce0c540c46e623bc05bd1a

Modified Files
--------------
src/backend/access/nbtree/nbtpreprocesskeys.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1uxb89-000adi-36@gemulon.postgresql.org>
Permalink:  ../E1uxb89-000adi-36@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1uxb89-000adi-36@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: pg@bowt.ie, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: nbtree: Always set skipScan flag on rescan.
  In-Reply-To: <E1uxb89-000adi-36@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