| From: | Amit Langote <amitlangote09(at)gmail(dot)com> |
|---|---|
| To: | jian he <jian(dot)universality(at)gmail(dot)com> |
| Cc: | Vik Fearing <vik(at)postgresfriends(dot)org>, lukas(dot)eder(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, PG Bug reporting form <noreply(at)postgresql(dot)org> |
| Subject: | Re: BUG #19418: SQL/JSON JSON_VALUE() does not conform to ISO/IEC 9075-2:2023(E) 6.34 <JSON value constructor> |
| Date: | 2026-04-20 08:29:00 |
| Message-ID: | CA+HiwqE1Co392qux47+DK31_HQMF9c-g1To+u1hxSOKwjzEN9g@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Tue, Mar 3, 2026 at 11:42 AM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
> On Thu, Feb 26, 2026 at 10:20 PM Vik Fearing <vik(at)postgresfriends(dot)org> wrote:
> > > Try this:
> > >
> > > select json_array(select 1 where false);
> > >
> > > It produces NULL, not []
> >
> >
> > I can confirm that postgres violates the standard here.
> >
> > --
>
> Since the subject title mentioned JSON_VALUE.
>
> SELECT JSON_VALUE(((select NULL where false)), '$');
> SELECT JSON_QUERY(((select NULL where false)), '$');
> SELECT JSON_EXISTS(((select NULL where false)), '$');
>
> Should the above produce []?
AFAIK about the standard, no. The empty-set -> '[]' rule is specific
to JSON_ARRAY(<query>), whose job is to collect rows into an array.
JSON_VALUE, JSON_QUERY, and JSON_EXISTS return a scalar, a JSON value,
and a boolean, respectively, not array-shaped values, so there's no
empty-array concept to invoke; empty-input behavior is governed by ON
EMPTY / ON ERROR.
--
Thanks, Amit Langote
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Langote | 2026-04-20 09:05:33 | Re: BUG #19418: SQL/JSON JSON_VALUE() does not conform to ISO/IEC 9075-2:2023(E) 6.34 <JSON value constructor> |
| Previous Message | Richard Guo | 2026-04-20 02:51:02 | Re: BUG #19460: FULL JOIN rewriting issue on empty queries |