public inbox for [email protected]  
help / color / mirror / Atom feed
From: Richard Guo <[email protected]>
To: Ayush Tiwari <[email protected]>
Cc: Melanie Plageman <[email protected]>
Cc: Nathan Bossart <[email protected]>
Cc: Tom Lane <[email protected]>
Cc: Amit Langote <[email protected]>
Cc: Vik Fearing <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: Álvaro Herrera <[email protected]>
Cc: Heikki Linnakangas <[email protected]>
Subject: Re: BUG #19418: SQL/JSON JSON_VALUE() does not conform to ISO/IEC 9075-2:2023(E) 6.34 <JSON value constructor>
Date: Fri, 8 May 2026 17:35:27 +0900
Message-ID: <CAMbWs4-yH6nsC4na99rWeXzA+sLXvJdtcevgkQDEU6RwJNbFKQ@mail.gmail.com> (raw)
In-Reply-To: <CAJTYsWXPYqa58YXrU+SQMVonsAhjLS46HNUMU=wO5zm9MgY3_g@mail.gmail.com>
References: <[email protected]>
	<CAMbWs49P2z40f5yb_97ErwtC9ocdR5QQN0gWUZtjgot9+iGAcg@mail.gmail.com>
	<CAMbWs4-NuYP+0Zq9=Ufwy5GcM0XQnEqWjJFucaRGO4EQgiCcow@mail.gmail.com>
	<CAMbWs4-ra9mkBhUs2kmB5KxWuo80oAA33gZ=8JmRxmG3qGNxUg@mail.gmail.com>
	<CA+HiwqEtiTNV2v2P0HGa0B1TMNfmPweKXMZEOYPoQuFf3ZhsXQ@mail.gmail.com>
	<CAMbWs49tDE_niKLr4mzsa2BkX7fkWrorBzWheKTBziZ7z9-AuQ@mail.gmail.com>
	<CAMbWs48KEdgyJhxCOysaRdRJ5NzPObUET+5XbvyiqDfqyABEwg@mail.gmail.com>
	<[email protected]>
	<CAMbWs4_vqNEcHpvKFeFxfRoisrvw6yJ3styhS-arQDHZirw5cQ@mail.gmail.com>
	<CAMbWs49ps9eGWvkwc64ytUxdK0s-=xdFjtf64WyGp65EgTZ_LQ@mail.gmail.com>
	<aevLYeoSSgiwEiO-@nathan>
	<CAAKRu_YU542L_+_H1VFSTtLnj4Yo=GcXykyiw_6GZZiOEt5mVA@mail.gmail.com>
	<CAMbWs4_n8f2kPHkEw=ToZMh2FAzc6BDXq9uND-iY9-MB_fE_Vg@mail.gmail.com>
	<CAMbWs4_TLsrWftz=TzpT9=fp=01LAZWRmdDLUMA9qTzMtXZwig@mail.gmail.com>
	<CAJTYsWXPYqa58YXrU+SQMVonsAhjLS46HNUMU=wO5zm9MgY3_g@mail.gmail.com>

On Thu, May 7, 2026 at 11:45 PM Ayush Tiwari
<[email protected]> 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






reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: BUG #19418: SQL/JSON JSON_VALUE() does not conform to ISO/IEC 9075-2:2023(E) 6.34 <JSON value constructor>
  In-Reply-To: <CAMbWs4-yH6nsC4na99rWeXzA+sLXvJdtcevgkQDEU6RwJNbFKQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox