Doc/improve confusing, inefficient tests to locate CTID variable.
commit13d53aa7a83383c9d1343e7d725e615f8678aea8
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 25 Oct 2022 21:35:19 +0000 (25 17:35 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 25 Oct 2022 21:35:19 +0000 (25 17:35 -0400)
tree1bd462e7b0ca9171de592bde2f5ae2c1f7f67673
parent0e972f50fdc9f33b01d02bbcc2f26aa32f1c58ab
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.
src/backend/executor/nodeTidrangescan.c
src/backend/executor/nodeTidscan.c