]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix missed step in removal of useless RESULT RTEs in the planner.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 5 Dec 2020 21:16:13 +0000 (16:16 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 5 Dec 2020 21:16:13 +0000 (16:16 -0500)
commit77a94c30da6152b9cbe5383d29e2aa9661260fbe
tree54e70713199fbd9771d646e849ad8d244959a8ef
parentad3fb04b9cc2d490e64d4a16e516b5f9eeadc7f3
Fix missed step in removal of useless RESULT RTEs in the planner.

Commit 4be058fe9 forgot that the append_rel_list would already be
populated at the time we remove useless result RTEs, and it might contain
PlaceHolderVars that need to be adjusted like the ones in the main parse
tree.  This could lead to "no relation entry for relid N" failures later
on, when the planner tries to do something with an unadjusted PHV.

Per report from Tom Ellis.  Back-patch to v12 where the bug came in.

Discussion: https://postgr.es/m/20201205173056.GF30712@cloudinit-builder
src/backend/optimizer/prep/prepjointree.c
src/test/regress/expected/join.out
src/test/regress/sql/join.sql