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

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Don't overwrite scan key in systable_beginscan()
Date: 2024-08-08 19:18:36
Message-ID: CA+Tgmoa_cFj7dOfMLDwyu=yjzvtpNhufZS3rGc2FGuAxsmQAdg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Aug 8, 2024 at 2:46 AM Peter Eisentraut <peter(at)eisentraut(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2024-08-08 19:24:11 Re: [patch] Imporve pqmq
Previous Message Robert Haas 2024-08-08 19:13:50 Re: fix CRC algorithm in WAL reliability docs