Re: Don't overwrite scan key in systable_beginscan()

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Noah Misch <noah(at)leadboat(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Don't overwrite scan key in systable_beginscan()
Date: 2024-08-12 07:44:02
Message-ID: 861cec7c-562c-4d33-853f-a657fd377752@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 09.08.24 06:55, Tom Lane wrote:
> Noah Misch <noah(at)leadboat(dot)com> writes:
>> On Thu, Aug 08, 2024 at 08:46:35AM +0200, Peter Eisentraut wrote:
>>> I propose to fix that by making a copy of the scan keys passed by the caller
>>> and make the modifications there.
>
>> No objection, but this would obsolete at least some of these comments (the
>> catcache.c ones if nothing else):
>
> That ties into something I forgot to ask: aren't there any copy steps
> or other overhead that we could remove, given this new API constraint?
> That would help address Robert's concern.

I added two more patches to the series here.

First (or 0004), some additional cleanup for code that had to workaround
systable_beginscan() overwriting the scan keys, along the lines
suggested by Noah.

Second (or 0005), an alternative to palloc is to make the converted scan
keys a normal local variable. Then it's just a question of whether a
smaller palloc is preferred over an over-allocated local variable. I
think I still prefer the palloc version, but it doesn't matter much
either way I think.

Attachment Content-Type Size
v2-0001-Don-t-overwrite-scan-key-in-systable_beginscan.patch text/plain 3.8 KB
v2-0002-Augment-ScanKey-arguments-with-const-qualifiers.patch text/plain 21.6 KB
v2-0003-Replace-gratuitous-memmove-with-memcpy.patch text/plain 5.4 KB
v2-0004-Update-some-code-that-handled-systable_beginscan-.patch text/plain 4.0 KB
v2-0005-Alternative-Store-converted-key-in-local-variable.patch text/plain 1.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message cca5507 2024-08-12 08:34:25 Re: Historic snapshot doesn't track txns committed in BUILDING_SNAPSHOT state
Previous Message Peter Eisentraut 2024-08-12 07:04:23 Re: Remove support for old realpath() API