Re: BUG #19418: SQL/JSON JSON_VALUE() does not conform to ISO/IEC 9075-2:2023(E) 6.34 <JSON value constructor>
Richard Guo <guofenglinux@gmail.com>
From: Richard Guo <guofenglinux@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Vik Fearing <vik@postgresfriends.org>, lukas.eder@gmail.com, pgsql-bugs@lists.postgresql.org, Álvaro Herrera <alvherre@kurilemu.de>
Date: 2026-03-04T06:35:56Z
Lists: pgsql-bugs
Attachments
- v3-0001-Fix-JSON_ARRAY-query-empty-set-handling-and-view-.patch (application/octet-stream) patch v3-0001
On Tue, Mar 3, 2026 at 11:32 PM Richard Guo <guofenglinux@gmail.com> wrote: > On Tue, Mar 3, 2026 at 10:03 AM Richard Guo <guofenglinux@gmail.com> wrote: > > That is a good point I hadn't considered. So I think the ideal fix is > > to have the parser preserve the user's original JSON_ARRAY(query) > > syntax as much as possible, and then defer the JSON_ARRAYAGG rewrite > > trick to the planner, perhaps during expression preprocessing. > I tried hacking on this idea to see how it would look in practice, and > here is what I got. Here is an updated version of the patch. The main change is that it now uses DirectFunctionCall1 to build the empty JSON array constant, which is more efficient and consistent with other call sites. - Richard
Commits
-
Enforce RETURNING typmod for empty-set JSON_ARRAY(query)
- 9d124a14b3d4 19 (unreleased) landed
-
Fix JSON_ARRAY(query) empty set handling and view deparsing
- 8d829f5a0203 19 (unreleased) landed