postgresql/src/backend
Tom Lane 7a844c77ec Fix joinclause removal logic to cope with cloned clauses.
When we're deleting a no-op LEFT JOIN from the query, we must remove
the join's joinclauses from surviving relations' joininfo lists.
The invention of "cloned" clauses in 2489d76c4 broke the logic for
that; it'd fail to remove clones that include OJ relids outside the
doomed join's min relid sets, which could happen if that join was
previously discovered to commute with some other join.

This accidentally failed to cause problems in the majority of cases,
because we'd never decide that such a cloned clause was evaluatable at
any surviving join.  However, Richard Guo discovered a case where that
did happen, leading to "no relation entry for relid" errors later.
Also, adding assertions that a non-removed clause contains no Vars from
the doomed join exposes that there are quite a few existing regression
test cases where the problem happens but is accidentally not exposed.

The fix for this is just to include the target join's commute_above_r
and commute_below_l sets in the relid set we test against when
deciding whether a join clause is "pushed down" and thus not
removable.

While at it, do a little refactoring: the join's relid set can be
computed inside remove_rel_from_query rather than in the caller.

Patch by me; thanks to Richard Guo for review.

Discussion: https://postgr.es/m/CAMbWs4_PHrRqTKDNnTRsxxQy6BtYCVKsgXm1_gdN2yQ=kmcO5g@mail.gmail.com
2023-05-26 12:13:19 -04:00
..
access nbtree VACUUM: cope with right sibling link corruption. 2023-05-25 15:33:00 -07:00
archive Redesign archive modules 2023-02-17 14:26:42 +09:00
backup Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
bootstrap Fix CREATE INDEX progress reporting for multi-level partitioning. 2023-03-25 15:34:03 -04:00
catalog Expand some more uses of "deleg" to "delegation" or "delegated". 2023-05-21 10:55:18 -04:00
commands Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
executor Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
foreign Expand some more uses of "deleg" to "delegation" or "delegated". 2023-05-21 10:55:18 -04:00
jit Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
lib Fix ILIST_DEBUG build 2023-01-18 10:26:15 -08:00
libpq rename "gss_accept_deleg" to "gss_accept_delegation". 2023-05-20 21:32:54 -04:00
main Remove obsolete defense against strxfrm() bugs. 2023-04-20 13:20:14 +12:00
nodes Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
optimizer Fix joinclause removal logic to cope with cloned clauses. 2023-05-26 12:13:19 -04:00
parser Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
partitioning Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
po Translation updates 2023-05-22 12:44:31 +02:00
port Update copyright for 2023 2023-01-02 15:00:37 -05:00
postmaster Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
regex Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
replication Optimize walsender wake up logic using condition variables 2023-05-21 09:44:55 -07:00
rewrite Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
snowball Fix the install rule for snowball_create.sql. 2023-05-23 11:15:57 -04:00
statistics Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
storage Remove over-eager assertion in ExtendBufferedRelTo() 2023-05-21 09:53:49 -07:00
tcop Handle logical slot conflicts on standby 2023-04-08 00:05:44 -07:00
tsearch Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
utils Use lower case for icu_validation_level values 2023-05-23 15:19:33 +02:00
.gitignore
Makefile Redesign archive modules 2023-02-17 14:26:42 +09:00
common.mk Blind attempt to fix LLVM dependency in the backend 2022-09-15 10:53:48 +07:00
meson.build meson: Prevent installation of test files during main install 2023-03-03 07:45:52 +01:00
nls.mk Add missing gettext triggers 2023-05-10 13:51:51 +02:00