From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Doc/improve confusing, inefficient tests to locate CTID variable
Date: Tue, 25 Oct 2022 21:36:14 +0000
Message-ID: <E1onRao-000nbJ-Df@gemulon.postgresql.org> (raw)
Doc/improve confusing, inefficient tests to locate CTID variable.
The IsCTIDVar() tests in nodeTidscan.c and nodeTidrangescan.c
look buggy at first sight: they aren't checking that the varno
matches the table to be scanned. Actually they're safe because
any Var in a scan-level qual must be for the correct table ...
but if we're depending on that, it's pretty pointless to verify
varlevelsup. (Besides which, varlevelsup is *always* zero at
execution, since we've flattened the rangetable long since.)
Remove the useless varlevelsup check, and instead add some
commentary explaining why we don't need to check varno.
Noted while fooling with a planner change that causes the order
of "t1.ctid = t2.ctid" to change in some tidscan.sql tests;
I was briefly fooled into thinking there was a live bug here.
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/13d53aa7a83383c9d1343e7d725e615f8678aea8
Modified Files
--------------
src/backend/executor/nodeTidrangescan.c | 9 +++++++--
src/backend/executor/nodeTidscan.c | 9 +++++++--
2 files changed, 14 insertions(+), 4 deletions(-)
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Doc/improve confusing, inefficient tests to locate CTID variable
In-Reply-To: <E1onRao-000nbJ-Df@gemulon.postgresql.org>
References: <E1onRao-000nbJ-Df@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