Subject: Re: Removing BTScanPosUnpinIfPinned idiom from nbtree, simplifying mark/restore support

From: Peter Geoghegan <[email-masked]>
Date: Wed, 3 Dec 2025 16:10:44 -0500

On Wed, Jun 11, 2025 at 1:29 PM Peter Geoghegan <[email-masked]> wrote:
> Removing BTScanPosUnpinIfPinned allows me to significantly simplify
> the management of buffer pins with mark/restore. The patch also gets
> rid of all of the calls to IncrBufferRefCount made from
> nbtree, since it's no longer necessary to support a so->markPos
> representation of a mark that needs its own pin, independent of the
> pin held by/for so->currPos (if so->markPos needs its own pin it'll be
> because it has its own page).

I'm going to withdraw this patch.

The rationale for the patch still makes perfect sense. However, the
patch has now been superseded by the ongoing work on adding a new
amgetbatch interface. That other work (which is tied up in work on I/O
prefetching for index scans) does everything that this patch does as a
stepping stone to allowing nbtree index scans to return batches
(so->currPos style positions that contain at least one matching item
to return to the scan) that are controlled by the caller/the table AM
that manages the index scan.

Independently implementing these changes without any of the much more
extensive changes required for amgetbatch was a useful exercise. But
there's no reason to keep the patch in the next CF anymore.

-- 
Peter Geoghegan