Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wLGgS-001fIQ-2v for pgsql-bugs@arkaria.postgresql.org; Fri, 08 May 2026 08:35:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wLGgR-008nGr-10 for pgsql-bugs@arkaria.postgresql.org; Fri, 08 May 2026 08:35:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wLGgR-008nGg-0A for pgsql-bugs@lists.postgresql.org; Fri, 08 May 2026 08:35:43 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wLGgP-00000001CSb-0ZlY for pgsql-bugs@lists.postgresql.org; Fri, 08 May 2026 08:35:42 +0000 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-3660ab73adbso973986a91.1 for ; Fri, 08 May 2026 01:35:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1778229339; cv=none; d=google.com; s=arc-20240605; b=CK9jYFZWDpDqkTDYY9FMKGjK6cTR2EypWDlTfgRZ2VGIzaDxRhIS7wnKZYnRzIlV4w +iNGw+pinO0lv+Id+cbKhxKRKNcr0o6rnLmPvk+ZouXrVTjLElWyIQQJDK3v671W2XNh D/OL5toVOz6jbKkqRQPe3XRZb9lAkY7sEZb/R+leUphnm0TqfaNV4oWZfeMSvoZDEAI1 9A1Tii51JVgdGiay24KueRmZzQvjiZQXBP0zYm4KiPM0FC/dphomsmbpUi+ywKA83GOk N5N0EdNEdG0VqBpuertXb3lHv56VqJwqCBouqsa201sJnQ0sheIxgztedyZWalThXODP CnbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ApXDCeBvAZQgV/Uc+Dha7DgKkVMR8sHwrp3DNxDmUYg=; fh=p6pwQIDWUyYEdK5dGa0pawWmvsU/B18du8/MYJT9PGU=; b=V6cOJ+PIAmJj3m0tdQeiZkL0ZZVimSjJcDz6O+uCP20oxgGDqrorKuJfxGINXK9Z8B +v4mAJ8FcKiIaEQbcBf3E2bgFWlmPnpORtxD2hb+5peYmaEF6aZf8SBj2/G0sM7JUGmE 50OMaiyMVjUhhDm4+13/M9RDWvCr2fihYKW173ommgAkSiUj6Pq6utZtMWBD1TmZuOA3 RnntQA97Ydaj++R09qY/fn+cyXeFMA/kGScQbnYLI8e2LctLRHEzM+sbf3U+bS6bcZ6f N6IuPB7JkeIxQ+GdldZcif1jAwyFZuY5yL1vRI4jqw9ctbvQeAVRwoXGcyLU5lRlKse5 Nx2g==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778229339; x=1778834139; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ApXDCeBvAZQgV/Uc+Dha7DgKkVMR8sHwrp3DNxDmUYg=; b=FDa1nbGbH4HW5Fc+yTfeF3hVN/owyHfyTaHINdM66sRPIjuHNkileYehN4clg24pY8 fvL8pCskjXntvg0Yg4O6zaUWMHeuhbfEh1kHvtez1jwoGouN/rGeWOq4d2gYcNXbp1xa uRljA7bpEenqq+EJtVRTFuq1ceML+zRDuyZ7MpKAOyZnl+TrvmyEqKmvJZrQclIzg/9F /hCu0xQ2/NFWlbwKv7wwMr0mimp90KzPKuw1z5VS3JxGH0mETamtvk340lzZgK9sOfJ/ BWvwinbSqh0jr6JEsNGoCHCYb2xIMkJFFDAX83eWsuHsOsYgMoA1AmF7tLj4WW4hbQ4/ oi3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778229339; x=1778834139; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ApXDCeBvAZQgV/Uc+Dha7DgKkVMR8sHwrp3DNxDmUYg=; b=QU1EMtJmgSaT/RcmVeg/Xd2b7AlD2NOQsae0kpgFPgcK7GWTA9aAl5gr1cPvkX61ct YNRfW3JSsfHNIrzIHe7XUxKIVVuY/FZf5Vzc08G7kIlngMJADcTqXeqw2b9RsF4MY7fI cuyjjhaKgjnVjX/ks26sjwjemMsqGtlgxmgubcBpnBq9RG8rKCzBr8/8jvGnkbF4ph2l WF27lfLxtdxiK8JXUCp2V1+IXsUgFU2OT0RzYwlHs6vyljs4GJoFLoIES1ZNuYBwVX9a EJWxINKURCnaN1za5gjlzMrxqFWq3v/E7IXW65cH0oq5GV2yr/qbEFTPTwEfgnE9nUoA +m5g== X-Forwarded-Encrypted: i=1; AFNElJ/sOHE+ebO+cX+HDUqHNg2JoNuSJsE9p3zbszyAlU6i7owTJ9rFGthwSh1RoJVgYR/+36sRAQNdlR6V@lists.postgresql.org X-Gm-Message-State: AOJu0YyIGgVc2om4l4yVbdkLofHmYVGZByG+OWFJeQ1wL9Bn2H6nFs6n Mmewixi0czWN42w9Kgp8M4xdeFiNiuf+fcN/dUu8d2MqrdRT239qCOi/iFn7ZQp826D+T5D2Psj kyRYnbERMJ7sUCeg9/a+8MxNBXWYbF3M= X-Gm-Gg: Acq92OH0tNXpBdh1md1LBhutk1tlQNYpOQVk1wrRo6BDluL6ZOQRSye7BkDTzeOBL5M NfWynMzGlf2LKhtFw9eR+XDIuvLZTVOYxSBb7becE/rUb0ZAVAXxv24hC9JpD+xHGyn+pt+fLEx aas1U6sx5r4SJV/ZMq3VUaddu8pwnq27rgSTruQ+j1gfQOrY7aa7V8rjvq0SHAcHJgcwWcyghrG ZjwjM+/rzQIFaZorVThemMBHosGXAt0FtJTZrBGuZeSa85JMQ7feN+aF0RrlOvQ/pmlh36LNV6m apydNOV3nw== X-Received: by 2002:a17:90b:3844:b0:35f:bc9f:e1b6 with SMTP id 98e67ed59e1d1-3660525bcc4mr5213179a91.1.1778229339249; Fri, 08 May 2026 01:35:39 -0700 (PDT) MIME-Version: 1.0 References: <501040.1772433449@sss.pgh.pa.us> <485641.1776738632@sss.pgh.pa.us> In-Reply-To: From: Richard Guo Date: Fri, 8 May 2026 17:35:27 +0900 X-Gm-Features: AVHnY4LZvdrOr54h9WJoZD1B99I7VdfKXimaJuZcT6psshICl90Uc2w1L_VtkG8 Message-ID: Subject: Re: BUG #19418: SQL/JSON JSON_VALUE() does not conform to ISO/IEC 9075-2:2023(E) 6.34 To: Ayush Tiwari Cc: Melanie Plageman , Nathan Bossart , Tom Lane , Amit Langote , Vik Fearing , lukas.eder@gmail.com, pgsql-bugs@lists.postgresql.org, rmt@lists.postgresql.org, =?UTF-8?Q?=C3=81lvaro_Herrera?= , Heikki Linnakangas Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, May 7, 2026 at 11:45=E2=80=AFPM Ayush Tiwari 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 t= ype: > > 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