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.98.2) (envelope-from ) id 1x7ihM-00000000ct0-3aF8 for pgsql-bugs@arkaria.postgresql.org; Sat, 19 Sep 2026 00:12:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1x7ihL-00000003lf4-3g5m for pgsql-bugs@arkaria.postgresql.org; Sat, 19 Sep 2026 00:12:55 +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.98.2) (envelope-from ) id 1x7ihL-00000003lew-2cPz for pgsql-bugs@lists.postgresql.org; Sat, 19 Sep 2026 00:12:55 +0000 Received: from fhigh-a1-smtp.messagingengine.com ([103.168.172.152]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x7ihJ-000000007fu-1gOG for pgsql-bugs@lists.postgresql.org; Sat, 19 Sep 2026 00:12:55 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id 9535A14000B2; Fri, 18 Sep 2026 20:12:50 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Fri, 18 Sep 2026 20:12:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1789776770; x=1789863170; bh=IDDYtRBT48 s4gVpdP+SsaByW/T81HnJPaU7BHIkp0IA=; b=GLDtftHP+1TsQ6aHbhZWeTRqJ9 8ksVzz/U7g84VSHinzH6t90YTsepYvposIyNITDtwXXoc9FBp2n6VbzcVr/Nqebm gmc7RcVapfR7iVs5GnVrCSU6V7Qy+u+Tgy0cvk20ZIF0PAw3xSfPxiYKOQS/6iS+ lBVTzD/+wTHSHFtLmOlk3FTU6DlJoOwAQtHKUOtFQUft8h8lsl0x37RpV9KmBwIG vxNO3wMf+gE+kqkMwc1urX09fZkNDd99F70nB/aTJqTwPQkLcHAUu5vfoeJiGAtD L5lO4UnjUnhJFRGnAw+YPKsBapCP+xv0+l4rH32gesXtVPzvsft5TTGSK3rw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1789776770; x=1789863170; bh=IDDYtRBT48s4gVpdP+SsaByW/T81HnJPaU7 BHIkp0IA=; b=IUC+UQfeZKPgUDpB3zfU0cZ6fRwEmiBHCX4cS6QGIvyikOLRHQa A4nMh2q2j7ADU7L8AffVLhBvuKhIRlhMH0u+AgNvfDZJd/9V0M81pOp3KDS/CNnN eR1FoajrLbgebAjL6/r9Iyk0BPCR9YWE7SzqqfsZ35WEmKK0LiIlxbFz/UHhRxTW fz1l8eqfyGsZX335Vv63/HiV741wncuD+kei6BOCsNgmgwiRJsoRpnWeaU7Hjm8A 9ax+5GFKWrmiiA90YdSYrhMWMbQxvvIPwUssSCkfOx1zymQ6DMAxLTa8iSK2Wz9l S1/69c/BnAW7kPNbUx6+5fRD7V8SHxWg2aw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFHn9pKJC4QvSDYBKfsJXBdEEyk+JsMCEYMiBMYdKY8i4G3rWSOSxXP/Yjjl+7hSb wpd8qY73IsGFclul7DKQpthOVgsgcacsYESMjWvc5khvwFiLAya8EaL4C53EDwCZF85uBn Gt4ESSiAT3F9ZUNdjDjeSA94VZ8l/qJwISmeOzljPvFpAaha6XadjlFcQiH4YgM9mciaCC pS0bLGaXfSdMEdAi4YPsvFZ82APssVI4dCL0UPOcF5vTvXel60zIfPJocYNAqA8Zf/ur9M 02XLQ2TVJiivC4W1vECC01FnfgroSFKtZlamFIjToAvh9XONJ1JZwx141R1cH6rEY1xdee C+0tmwNpcvBIr8RFksQOwT/3O4kHV/qkfEpmAXkbn2P4kJ4UxZHdYfIY+o1ssB2bofPavw +9Qd0IxhkbpuKxHv3DZTL5eSS2gpq1wUlvLsXZfcfuMMLlP2w7bUO57vC9WohTSOG5NV2o o1lzh8Ep5kTP8a4CT90rEZKJ+g+N6G7VuSMIx9KIBR5RNbi8QFnTHUQHeoBpUhEK/sngkB 2+ulCJogfc6lo/LGD2ArHf/Gs50hMexKCLXZ7ejV+t1+IqybkO1nIv2+l/DOtLEEHvn86v nxHL3dES/UpgshWUZxvpiEE8HHidx1y+k1japKcmlZz1WOIZmgTZFy8Xwm2g X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 18 Sep 2026 20:12:49 -0400 (EDT) Date: Sat, 19 Sep 2026 09:12:46 +0900 From: Michael Paquier To: chaitanyyachoudhary@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19693: JSON_VALUE/JSON_QUERY PASSING a toasted text value reads the toast pointer instead of the text Message-ID: References: <19693-2ecd2b52c838b3e5@postgresql.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="xJAPjhveINc3XRJI" Content-Disposition: inline In-Reply-To: <19693-2ecd2b52c838b3e5@postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --xJAPjhveINc3XRJI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 18, 2026 at 02:39:08AM +0000, PG Bug reporting form wrote: > The datum is never detoasted, so for an out-of-line value the macros read > the toast pointer's own bytes. The value comes from the PASSING argument > via GetJsonPathVar() -> JsonItemFromDatum(var->value, ...) and nothing on > that path detoasts it either. The other varlena cases in this function > (JSONB, and the datetime types through their output paths) go through code > that detoasts. >=20 > Fix: detoast the datum in that case, for example >=20 > text *txt =3D DatumGetTextPP(val); > res->val.string.val =3D VARDATA_ANY(txt); > res->val.string.len =3D VARSIZE_ANY_EXHDR(txt); >=20 > The same code is present on REL_18_STABLE and master as of 2026-09-17. At quick glance, your take seems right and that looks like an oversight. Would you like to write a patch? -- Michael --xJAPjhveINc3XRJI Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmqt034ACgkQnvQgOdby QH09GQ/+NAXLqBRhodExkoej45+yqIY969KpNgvO8OmIzP1g1YqAHSy9EZmRvPUR 2vuswpIw8Fs8IGg8Nt70fp1NG8cyMaxhMLdRZKpX3OMzvNkXqxHp/36QV5smk6iR zV0PtR9UxpGHI/BFZ5wWZb8ANPBPYHniWKvqI4rN4b0necMeGL+4Ji5k7jkYtueI OBpqm1leCH1YiLhXTKdgjBEhXF2F+3TJIgILha6B3tdZmL/+uSg2mSUuM3Crdxuc GvLb6+Uxg03kOOK5u+7Vd8oILxTzGp64hm6Z4+utJzD19Roz6iAnIaRSkx5H2mp9 8sRgkiRY3aH2bgby5MBXGD9er1nFS9RkfRkDbHh64wn0QCV/I7PzD2t+oKmzQTPl IzjfvSlN8umlilT0FrwOPN7hvPiDBzHIikfn9G22dvnHeeikbxx/7Z7aYx4CUMYf DA+GWilCvwhN8rL5EFH5iXUDEQad9GQLbWmxde+nIyZjjubadtdw4i0BSBpHnLft zxBA5v8Co6llpuf0t5M7AcNaeIU6sQpZcGKENwTugEypNpuayLr3my727OU4hTZv TKrqhaD9uPR3zXcBD1UMIbR+hGRhQBU/BRu4dy9BvfM3setXjHZbVCpMUtcCPw6o k/v/rfak8EXkyOnOiUsafMy4J3wRZ+8NXnG18ViKFZLqL6f0uyc= =eg48 -----END PGP SIGNATURE----- --xJAPjhveINc3XRJI--