Treat JsonConstructorExpr as non-strict
Richard Guo <rguo@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
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/optimizer/util/clauses.c | modified | +2 −0 |
| src/test/regress/expected/subselect.out | modified | +28 −0 |
| src/test/regress/sql/subselect.sql | modified | +17 −0 |
Discussion
- BUG #19046: Incorrect result when using json_array() with column reference in subquery combined with RIGHT JOIN 11 messages · 2025-09-10 → 2025-09-16