pgsql: Fix computation of varnullingrels when const-folding field selec

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix computation of varnullingrels when const-folding field selec
Date: 2023-11-09 20:46:24
Message-ID: E1r1Bux-004hOw-I4@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix computation of varnullingrels when const-folding field selection.

We can simplify FieldSelect on a whole-row Var into a plain Var
for the selected field. However, we should copy the whole-row Var's
varnullingrels when we do so, because the new Var is clearly nullable
by exactly the same rels as the original. Failure to do this led to
errors like "wrong varnullingrels (b) (expected (b 3)) for Var 2/2".

Richard Guo, per bug #18184 from Marian Krucina. Back-patch to
v16 where varnullingrels was introduced.

Discussion: https://postgr.es/m/18184-5868dd258782058e@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/36f5594c0fe694600c07c803324b51fcfbea4079

Modified Files
--------------
src/backend/optimizer/util/clauses.c | 19 +++++++++++++------
src/test/regress/expected/join.out | 26 ++++++++++++++++++++++++++
src/test/regress/sql/join.sql | 12 ++++++++++++
3 files changed, 51 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2023-11-09 21:45:03 pgsql: doc: remove unnecessary comma in postgres-fdw
Previous Message Peter Eisentraut 2023-11-09 14:17:40 pgsql: meson: Install missing example files