Disallow removing placeholders during Self-Join Elimination.
authorAlexander Korotkov <[email protected]>
Sun, 27 Apr 2025 22:40:42 +0000 (01:40 +0300)
committerAlexander Korotkov <[email protected]>
Sun, 27 Apr 2025 22:40:42 +0000 (01:40 +0300)
commit1aa7cf9eb85972aaf2969306e84f5fc794fbef7f
tree50c2fd67ea3eb8bc88ec595ebab3d5f9b31e6cdf
parent2f5b05620330baed1648a1a6e2f231c7ba1368d1
Disallow removing placeholders during Self-Join Elimination.

fc069a3a6319 implements Self-Join Elimination (SJE), which can remove base
relations when appropriate.  However, regressions tests for SJE only cover
the case when placeholder variables (PHVs) are evaluated and needed only
in a single base rel.  If this baserel is removed due to SJE, its clauses,
including PHVs, will be transferred to the keeping relation.  Removing these
PHVs may trigger an error on plan creation -- thanks to the b3ff6c742f6c for
detecting that.

This commit skips removal of PHVs during SJE.  This might also happen that
we skip the removal of some PHVs that could be removed.  However, the overhead
of extra PHVs is small compared to the complexity of analysis needed to remove
them.

Reported-by: Alexander Lakhin <[email protected]>
Author: Alena Rybakina <[email protected]>
Author: Andrei Lepikhov <[email protected]>
Reviewed-by: Alexander Korotkov <[email protected]>
Reviewed-by: Richard Guo <[email protected]>
src/backend/optimizer/plan/analyzejoins.c
src/test/regress/expected/join.out
src/test/regress/sql/join.sql