pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Don't overwrite scan key in systable_beginscan()
Date: Thu, 12 Sep 2024 09:17:30 +0000
Message-ID: <E1sofxC-000imG-1G@gemulon.postgresql.org> (raw)

Don't overwrite scan key in systable_beginscan()

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.

Fix that by making a copy of the scan keys passed by the caller and
make the modifications there.

Also, some code that had to work around the previous situation is
simplified.

Discussion: https://www.postgresql.org/message-id/flat/f8c739d9-f48d-4187-b214-df3391ba41ab@eisentraut.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/811af9786b919d7acb22ea00ecb63f47de7942cd

Modified Files
--------------
src/backend/access/index/genam.c           | 24 ++++++++++++-----
src/backend/utils/cache/catcache.c         | 42 ++++++++++++++----------------
src/backend/utils/cache/relfilenumbermap.c |  7 +++--
3 files changed, 40 insertions(+), 33 deletions(-)



Message-ID: <E1sofxC-000imG-1G@gemulon.postgresql.org>
Permalink:  ../E1sofxC-000imG-1G@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sofxC-000imG-1G@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: peter@eisentraut.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Don't overwrite scan key in systable_beginscan()
  In-Reply-To: <E1sofxC-000imG-1G@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