Re: Don't overwrite scan key in systable_beginscan() - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Don't overwrite scan key in systable_beginscan()
Date
Msg-id CA+Tgmoa_cFj7dOfMLDwyu=yjzvtpNhufZS3rGc2FGuAxsmQAdg@mail.gmail.com
Whole thread Raw
In response to Don't overwrite scan key in systable_beginscan()  (Peter Eisentraut <peter@eisentraut.org>)
Responses Re: Don't overwrite scan key in systable_beginscan()
List pgsql-hackers
On Thu, Aug 8, 2024 at 2:46 AM Peter Eisentraut <peter@eisentraut.org> wrote:
> When systable_beginscan() and systable_beginscan_ordered() choose an
> index scan, they remap the attribute numbers in the passed-in scan keys
> to the attribute numbers of the index, and then write those remapped
> attribute numbers back into the scan key passed by the caller.  This
> second part is surprising and gratuitous.  It means that a scan key
> cannot safely be used more than once (but it might sometimes work,
> depending on circumstances).  Also, there is no value in providing these
> remapped attribute numbers back to the caller, since they can't do
> anything with that.
>
> I propose to fix that by making a copy of the scan keys passed by the
> caller and make the modifications there.

This does have the disadvantage of adding more palloc overhead.

--
Robert Haas
EDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: fix CRC algorithm in WAL reliability docs
Next
From: Robert Haas
Date:
Subject: Re: [patch] Imporve pqmq