Re: BUG #19851: Adding a tautological CHECK(true) to a domain changes JSON_VALUE's result (silent NULL, value/type c

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: Ishjaap Singh <ishjaap(dot)singh07(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 303677365(at)qq(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, e1638616(at)u(dot)nus(dot)edu
Subject: Re: BUG #19851: Adding a tautological CHECK(true) to a domain changes JSON_VALUE's result (silent NULL, value/type c
Date: 2026-12-04 12:40:45
Message-ID: CA+HiwqFbM6xXuWVJ5Morn0MQSPM9NWNazFz_UTF8-_SQn5gU0A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Ishjaap,

On Fri, Dec 4, 2026 at 3:43 PM Ishjaap Singh <ishjaap(dot)singh07(at)gmail(dot)com> wrote:
>
> Hi Amit,
>
> I tested v2 on master, 19, 18 and 17. All four build cleanly and pass
> make check, and the new tests fail without the fix. My #19825 tests
> pass too.
>
> I also tried a few dozen cases with different domains, DEFAULTs and
> NULLs on stock and patched builds. The only results that changed are
> the ones in your commit message, and 17 to 19 match master.
>
> About the minor release question: I created views on 17 with stock and
> with v2 in the same data directory, and each version could read the
> other's views fine.

Thanks for testing.

> One nit: the comment in ExecEvalJsonExprPath() says a NULL input skips
> ON ERROR, but ON ERROR still applies when the domain rejects the NULL,
> e.g. JSON_VALUE(NULL::jsonb, '$' RETURNING d DEFAULT 'x' ON ERROR)
> gives 'x' with a NOT NULL domain. That was already the case before v2.
>
> Otherwise looks good to me.

Ah, good catch, let's fix that while we're here. Done in the attached
v3, no other changes.

--
Thanks, Amit Langote

Attachment Content-Type Size
v3-REL_17-0001-SQL-JSON-Decide-how-to-coerce-JsonExpr-res.patch application/octet-stream 34.7 KB
v3-master-0001-SQL-JSON-Decide-how-to-coerce-JsonExpr-res.patch application/octet-stream 35.9 KB
v3-REL_18-0001-SQL-JSON-Decide-how-to-coerce-JsonExpr-res.patch application/octet-stream 34.7 KB
v3-REL_19-0001-SQL-JSON-Decide-how-to-coerce-JsonExpr-res.patch application/octet-stream 34.7 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message ZizhuanLiu X-MAN 2026-12-04 13:49:07 Re: BUG #17545: Incorrect selectivity for IS NOT DISTINCT FROM and NULLs
Previous Message Shuntian Jiao 2026-12-04 11:19:07 Re: reltuples kept decreasing with each autovacuum run Re: BUG #18773