| From: | Narayanan Venkateswaran <narayananvpostgres(at)gmail(dot)com> |
|---|---|
| To: | Nitin Motiani <nitinmotiani(at)google(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-19 19:27:59 |
| Message-ID: | CAFjuD9fKAs3=Suywg=3xMM1GxLjGbCuZ8nt9GK4PFD4JbmY5ow@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Hi,
On Mon, Oct 19, 2026 at 5:03 PM Narayanan Venkateswaran
<narayananvpostgres(at)gmail(dot)com> wrote:
>
> Hi Nitin,
>
> Thank you very much for the review!
>
> On Sun, Oct 18, 2026 at 11:45 AM Nitin Motiani <nitinmotiani(at)google(dot)com> wrote:
> >
> > On Wed, Oct 14, 2026 at 7:06 PM Narayanan Venkateswaran
> > <narayananvpostgres(at)gmail(dot)com> wrote:
> > >
> > Thanks for the patch. It seems to work fine. I think it would be good
> > to make the same change for JSON_ARRAY.
>
> Thank you for pointing this out, I will look into JSON_ARRAY and
> submit a follow up.
>
.
.
.
>
> I will investigate JSON_ARRAY from the perspective of the postgre
> documentation and revert back.
I am able to reproduce the same issue in JSON_ARRAY,
The following works,
postgres=# SELECT JSON_ARRAY();
json_array
------------
[]
(1 row)
postgres=# SELECT JSON_ARRAY('a', NULL, 'b' NULL ON NULL);
json_array
------------------
["a", null, "b"]
(1 row)
postgres=# SELECT JSON_ARRAY('a', NULL, 'b' ABSENT ON NULL);
json_array
------------
["a", "b"]
(1 row)
The following does not work,
postgres=# SELECT JSON_ARRAY(NULL ON NULL);
ERROR: syntax error at or near "ON"
LINE 1: SELECT JSON_ARRAY(NULL ON NULL);
^
postgres=# SELECT JSON_ARRAY(ABSENT ON NULL);
ERROR: syntax error at or near "ON"
LINE 1: SELECT JSON_ARRAY(ABSENT ON NULL);
^
postgres=# SELECT JSON_ARRAY(NULL ON NULL RETURNING jsonb);
ERROR: syntax error at or near "ON"
LINE 1: SELECT JSON_ARRAY(NULL ON NULL RETURNING jsonb);
I also checked the postgres documentation here -
https://www.postgresql.org/docs/devel/functions-json.html#FUNCTIONS-JSON-CREATION-TABLE
json_array ( [ { value_expression [ FORMAT JSON ] } [, ...] ]
[ { NULL | ABSENT } ON NULL ]
[ RETURNING data_type [ FORMAT JSON [ ENCODING UTF8 ] ] ])
[ { value_expression ... } [, ...] ] is an optional bracket.
[ { NULL | ABSENT } ON NULL ] is an independent optional bracket.
[ RETURNING data_type ... ] is an independent optional bracket.
Because each bracket is independent in PostgreSQL's documented syntax,
calling JSON_ARRAY()
with no value expressions while providing a { NULL | ABSENT } ON NULL
modifier clause should be
valid syntax, but is currently rejected by the parser.
I am working on a follow-up patch that addresses json_array also, I
shall submit it soon.
>
> >
> > Thanks & Regards
> > Nitin Motiani,
> > Google
>
> Thank you,
> Narayanan
Thank you,
Narayanan
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Narayanan Venkateswaran | 2026-10-19 20:23:54 | Re: BUG #19737: Empty `JSON_OBJECT` cannot use documented `ON NULL` or unique-key clauses |
| Previous Message | Tom Lane | 2026-10-19 16:44:13 | Re: BUG #19769: int8range() raises an error for an inclusive upper bound at BIGINT_MAX |