Re: Add SQL/JSON ON MISMATCH clause to JSON_VALUE

From: Florents Tselai <florents(dot)tselai(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add SQL/JSON ON MISMATCH clause to JSON_VALUE
Date: 2026-01-25 01:15:39
Message-ID: CA+v5N40MaAQQOxucapnW9kVxyHgt8qVmrt4vxv_2=DRxQ+y+AA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> I've had trouble making JSON_QUERY work too,
> so I suspect that although my tests pass,
> there may be something I'm missing in the executor side of things.
>

"For those curious, I found the issue: in ExecEvalJsonExprPath, I
had misplaced the check for jsexpr->on_mismatch.
I wasn't setting jsestate->escontext.details_wanted = true early enough.
Without this, the soft error context wasn't capturing the specific SQL
error code needed to identify the mismatch.

Attaching a v2 that implements ON MISMATCH for JSON_QUERY and JSON_TABLE
too.

That said, the semantics of ON ERROR / MISMATCH / EMPTY are complex.
I expect someone with access to and detailed knowledge of the standard
might be able to poke holes in certain edge cases, particularly regarding
precedence.

Attachment Content-Type Size
v2-0001-Add-SQL-JSON-ON-MISMATCH-clause-to-JSON_VALUE-JSO.patch application/octet-stream 47.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-01-25 01:24:48 Re: Extended Statistics set/restore/clear functions.
Previous Message Tom Lane 2026-01-25 01:02:44 Re: Time to drop RADIUS support?