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

Nathan Bossart <nathandbossart@gmail.com>

From: Nathan Bossart <nathandbossart@gmail.com>
To: Richard Guo <guofenglinux@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Amit Langote <amitlangote09@gmail.com>, Vik Fearing <vik@postgresfriends.org>, lukas.eder@gmail.com, pgsql-bugs@lists.postgresql.org, rmt@lists.postgresql.org, Álvaro Herrera <alvherre@kurilemu.de>, Heikki Linnakangas <hlinnaka@iki.fi>, Melanie Plageman <melanieplageman@gmail.com>
Date: 2026-04-24T19:58:25Z
Lists: pgsql-bugs
On Thu, Apr 23, 2026 at 09:55:10AM +0900, Richard Guo wrote:
>> Hi RMT,
>>
>> I'd like to commit a fix for JSON_ARRAY(subquery) behavior that
>> involves a user-visible incompatibility, and would appreciate your
>> go/no-go since we're past feature freeze.
>>
>> Summary:
>>
>> - JSON_ARRAY(SELECT ...) currently returns NULL over an empty result
>> set, but the SQL/JSON standard requires it to return '[]'.  Fixing
>> this changes user-visible output.
>>
>> - The same patch also fixes a deparsing issue: views defined with
>> JSON_ARRAY(SELECT ...) are dumped back as the internal JSON_ARRAYAGG
>> rewrite instead of the original syntax.

I am fine with committing this for v19, assuming there is consensus on the
patch content.

Heikki/Melanie: Any objections?

-- 
nathan



Commits

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

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