pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Treat JsonConstructorExpr as non-strict 4+ messages / 1 participants [nested] [flat]
* pgsql: Treat JsonConstructorExpr as non-strict @ 2025-09-16 09:42 Richard Guo <rguo@postgresql.org> 0 siblings, 0 replies; 4+ messages in thread From: Richard Guo @ 2025-09-16 09:42 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/b63a822452152a7bd613fd4b28e0967e626e274e Modified Files -------------- src/backend/optimizer/util/clauses.c | 2 ++ src/test/regress/expected/subselect.out | 28 ++++++++++++++++++++++++++++ src/test/regress/sql/subselect.sql | 17 +++++++++++++++++ 3 files changed, 47 insertions(+) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Treat JsonConstructorExpr as non-strict @ 2025-09-16 09:44 Richard Guo <rguo@postgresql.org> 0 siblings, 0 replies; 4+ messages in thread From: Richard Guo @ 2025-09-16 09:44 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/d29a3f4b46a043323dd5f39e9b97f1aaabbbec87 Modified Files -------------- src/backend/optimizer/util/clauses.c | 2 ++ src/test/regress/expected/subselect.out | 28 ++++++++++++++++++++++++++++ src/test/regress/sql/subselect.sql | 17 +++++++++++++++++ 3 files changed, 47 insertions(+) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Treat JsonConstructorExpr as non-strict @ 2025-09-16 09:45 Richard Guo <rguo@postgresql.org> 0 siblings, 0 replies; 4+ messages in thread From: Richard Guo @ 2025-09-16 09:45 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/d719e2ecb1886d8eae15bb46384751db783719a8 Modified Files -------------- src/backend/optimizer/util/clauses.c | 2 ++ src/test/regress/expected/subselect.out | 28 ++++++++++++++++++++++++++++ src/test/regress/sql/subselect.sql | 17 +++++++++++++++++ 3 files changed, 47 insertions(+) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Treat JsonConstructorExpr as non-strict @ 2025-09-16 09:47 Richard Guo <rguo@postgresql.org> 0 siblings, 0 replies; 4+ messages in thread From: Richard Guo @ 2025-09-16 09:47 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/62397bb1893ba4f0b5e3a715ba21ee3c6a211d93 Modified Files -------------- src/backend/optimizer/util/clauses.c | 2 ++ src/test/regress/expected/subselect.out | 28 ++++++++++++++++++++++++++++ src/test/regress/sql/subselect.sql | 17 +++++++++++++++++ 3 files changed, 47 insertions(+) ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2025-09-16 09:47 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2025-09-16 09:42 pgsql: Treat JsonConstructorExpr as non-strict Richard Guo <rguo@postgresql.org> 2025-09-16 09:44 pgsql: Treat JsonConstructorExpr as non-strict Richard Guo <rguo@postgresql.org> 2025-09-16 09:45 pgsql: Treat JsonConstructorExpr as non-strict Richard Guo <rguo@postgresql.org> 2025-09-16 09:47 pgsql: Treat JsonConstructorExpr as non-strict Richard Guo <rguo@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox