Re: BUG #19418: SQL/JSON JSON_VALUE() does not conform to ISO/IEC 9075-2:2023(E) 6.34 <JSON value constructor>

jian he <jian.universality@gmail.com>

From: jian he <jian.universality@gmail.com>
To: Vik Fearing <vik@postgresfriends.org>
Cc: lukas.eder@gmail.com, pgsql-bugs@lists.postgresql.org, PG Bug reporting form <noreply@postgresql.org>
Date: 2026-03-03T02:41:47Z
Lists: pgsql-bugs
On Thu, Feb 26, 2026 at 10:20 PM Vik Fearing <vik@postgresfriends.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 []?



--
jian
https://www.enterprisedb.com/



Commits

  1. Enforce RETURNING typmod for empty-set JSON_ARRAY(query)

  2. Fix JSON_ARRAY(query) empty set handling and view deparsing