| From: | Richard Guo <guofenglinux(at)gmail(dot)com> |
|---|---|
| To: | Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com> |
| Cc: | Melanie Plageman <melanieplageman(at)gmail(dot)com>, Nathan Bossart <nathandbossart(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Amit Langote <amitlangote09(at)gmail(dot)com>, Vik Fearing <vik(at)postgresfriends(dot)org>, lukas(dot)eder(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, rmt(at)lists(dot)postgresql(dot)org, Álvaro Herrera <alvherre(at)kurilemu(dot)de>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
| 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-05-08 08:35:27 |
| Message-ID: | CAMbWs4-yH6nsC4na99rWeXzA+sLXvJdtcevgkQDEU6RwJNbFKQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Thu, May 7, 2026 at 11:45 PM Ayush Tiwari
<ayushtiwari(dot)slg01(at)gmail(dot)com> wrote:
> The non-empty query form enforces the RETURNING typmod:
>
> SELECT JSON_ARRAY(SELECT 1 RETURNING varchar(1));
> ERROR: value too long for type character varying(1)
>
> but the empty query form returns a value that does not fit the declared type:
>
> SELECT JSON_ARRAY(SELECT 1 WHERE false RETURNING varchar(1));
> json_array
> ------------
> []
> (1 row)
Nice catch. The empty-array Const was built with typmod -1, and the
type input function was invoked with typmod -1, so any RETURNING
length restriction was silently bypassed.
I've pushed a fix that builds Const and calls the input function with
the typmod of the non-empty COALESCE argument.
- Richard
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Fujii Masao | 2026-05-08 14:41:56 | Re: pg_restore: error: could not execute query: ERROR: schema does not exist |
| Previous Message | Michał Tęcza | 2026-05-07 20:06:23 | pg_restore: error: could not execute query: ERROR: schema does not exist |