pgsql: Fix missed step in removal of useless RESULT RTEs in the planner

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix missed step in removal of useless RESULT RTEs in the planner
Date: 2020-12-05 21:16:33
Message-ID: E1kleuv-0002Ab-I3@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e98c900993e89ad9278cdfbf0ba5495381a1faac

Modified Files
--------------
src/backend/optimizer/prep/prepjointree.c | 1 +
src/test/regress/expected/join.out | 36 +++++++++++++++++++++++++++++++
src/test/regress/sql/join.sql | 22 +++++++++++++++++++
3 files changed, 59 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2020-12-07 00:33:26 pgsql: Fix fd leak in pg_verifybackup
Previous Message Heikki Linnakangas 2020-12-04 16:43:13 pgsql: Fix race conditions in newly-added test.