| From: | Keyerror Smart <smartkeyerror(at)gmail(dot)com> |
|---|---|
| To: | ethantran(at)quwin(dot)dev |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: [PATCH]Fix planner's strictness check for JsonExpr |
| Date: | 2026-11-23 13:25:02 |
| Message-ID: | CAD=-kXa-=TV_Zs4-_GC1isJ1+tbdhauTssiwqZtYa-B+kq1PUQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Amit, Tomas,
On Fri, Nov 20, 2026 Amit Langote wrote:
> Its JsonBehavior case returned without letting the walker look at the
> behavior's expression any further, which misses a DEFAULT expression
> containing a subquery.
Thanks, v6 has the same bug; this returns 1 instead of NULL:
SELECT v FROM (VALUES (1)) a
LEFT JOIN (SELECT JSON_VALUE(jsonb '{}', '$.a' RETURNING int
DEFAULT num_nulls((SELECT y)) ON EMPTY) v
FROM (VALUES (1), (2)) b(y)) ss ON false;
Attached v7:
0001: the JsonBehavior case now falls through as in your v2, with the
query above as a test. No reference to use_json_coercion, so the same
patch applies to master through 17 and can go in before the flag
removal. I also consolidated the tests, which had grown over the
versions.
0002: the same JsonExpr / JsonBehavior handling in
full_join_expr_nonstrict_walker(), to keep it in sync as Tomas
suggested. Without it, an operand like
JSON_VALUE(jsonb '0', '$' PASSING b.x AS p RETURNING int) counts as
null-preserving, and FULL JOIN ... WHERE COALESCE(a.x, <that>) = 0
loses unmatched rows; see the new tests in join.sql. It only needs to
go back to 17. 0002 covers only JsonExpr; CoerceToDomain is still missing
in both walkers and is left to your thread.
Regards,
Zhenglong
| Attachment | Content-Type | Size |
|---|---|---|
| v7-0001-Fix-planner-s-strictness-check-for-JsonExpr.patch | application/octet-stream | 15.9 KB |
| v7-0002-Handle-JsonExpr-in-FULL-JOIN-null-preservation-ch.patch | application/octet-stream | 7.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Virender Singla | 2026-11-23 13:50:11 | Re: [PATCH] TRUNCATE's reset of n_live_tup/n_dead_tup is lost |
| Previous Message | Abraham Pérez | 2026-11-23 13:20:55 | Re: JSON_SERIALIZE for JSONB returns parts of the internal JSONB representation |