]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Treat JsonConstructorExpr as non-strict
authorRichard Guo <rguo@postgresql.org>
Tue, 16 Sep 2025 09:42:20 +0000 (18:42 +0900)
committerRichard Guo <rguo@postgresql.org>
Tue, 16 Sep 2025 09:43:57 +0000 (18:43 +0900)
commitd29a3f4b46a043323dd5f39e9b97f1aaabbbec87
tree381093923460fa344f32609a2569b6e07cfc337a
parent409543da5411d55d3455d6acbd885f592f20c429
Treat JsonConstructorExpr as non-strict

JsonConstructorExpr can produce non-NULL output with a NULL input, so
it should be treated as a non-strict construct.  Failing to do so can
lead to incorrect query behavior.

For example, in the reported case, when pulling up a subquery that is
under an outer join, if the subquery's target list contains a
JsonConstructorExpr that uses subquery variables and it is mistakenly
treated as strict, it will be pulled up without being wrapped in a
PlaceHolderVar.  As a result, the expression will be evaluated at the
wrong place and will not be forced to null when the outer join should
do so.

Back-patch to v16 where JsonConstructorExpr was introduced.

Bug: #19046
Reported-by: Runyuan He <runyuan@berkeley.edu>
Author: Tender Wang <tndrwang@gmail.com>
Co-authored-by: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/19046-765b6602b0a8cfdf@postgresql.org
Backpatch-through: 16
src/backend/optimizer/util/clauses.c
src/test/regress/expected/subselect.out
src/test/regress/sql/subselect.sql