| From: | Nitin Motiani <nitinmotiani(at)google(dot)com> |
|---|---|
| To: | Narayanan Venkateswaran <narayananvpostgres(at)gmail(dot)com> |
| Cc: | theshallow27(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, Dilip Kumar <dilipbalaut(at)gmail(dot)com> |
| Subject: | Re: BUG #19737: Empty `JSON_OBJECT` cannot use documented `ON NULL` or unique-key clauses |
| Date: | 2026-10-18 06:15:28 |
| Message-ID: | CAH5HC96d3bDPz3GtiOCNvkEGCkStHdmpkwhcAjUykKr74rpqZA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Wed, Oct 14, 2026 at 7:06 PM Narayanan Venkateswaran
<narayananvpostgres(at)gmail(dot)com> wrote:
>
>
> Currently, calling JSON_OBJECT() without key-value arguments fails
> with a syntax error
> if modifier clauses like ABSENT ON NULL or WITH UNIQUE KEYS are specified. This
> happens because the grammar rule in gram.y handling modifier clauses
> unconditionally
> required key-value pairs.
>
> The attached patch adds conflict-free productions in gram.y to allow empty
> JSON_OBJECT() calls with NULL, UNIQUE, and RETURNING clauses.
> Regression tests have also been added to sqljson.sql covering all clause
> combinations for empty objects.
>
Thanks for the patch. It seems to work fine. I think it would be good
to make the same change for JSON_ARRAY.
One question: The commit message has this line
> The SQL standard permits calling JSON_OBJECT() with no key-value pairs
> to construct an empty JSON object while still specifying modifier
> clauses such as NULL-handling (NULL ON NULL / ABSENT ON NULL), key
> uniqueness constraints (WITH / WITHOUT UNIQUE KEYS), and the output type
> (RETURNING ...).
Is there any reference for this? I searched for this using an LLM and
found that the standard doesn't specify it but Oracle etc implement it
this way.
Thanks & Regards
Nitin Motiani,
Google
| From | Date | Subject | |
|---|---|---|---|
| Next Message | PG Bug reporting form | 2026-10-18 11:59:47 | BUG #19769: int8range() raises an error for an inclusive upper bound at BIGINT_MAX |
| Previous Message | BHUVAN CHILUKUTI | 2026-10-18 01:23:48 | Re: BUG #19766: Assert in shm_toc_insert: EXPLAIN ANALYZE of a SubPlan shared by Parallel Append children |