]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix computation of varnullingrels when const-folding field selection.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 9 Nov 2023 20:46:16 +0000 (15:46 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 9 Nov 2023 20:46:16 +0000 (15:46 -0500)
commit6bf2efb38285626a9de3004dd1c23d9a85453372
treef55a3f2d8b29284685fd4839bbea13ff9b34d523
parent06a546382aafe0cc9d895b2861c5b8a8e9f0b002
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
src/backend/optimizer/util/clauses.c
src/test/regress/expected/join.out
src/test/regress/sql/join.sql