pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: chaitanyyachoudhary@gmail.com
To: 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
Date: Sat, 19 Sep 2026 09:12:46 +0900
Message-ID: <aq3TflHWHS-407w0@paquier.xyz> (raw)
In-Reply-To: <19693-2ecd2b52c838b3e5@postgresql.org>
References: <19693-2ecd2b52c838b3e5@postgresql.org>

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.
> 
> Fix: detoast the datum in that case, for example
> 
>   text *txt = DatumGetTextPP(val);
>   res->val.string.val = VARDATA_ANY(txt);
>   res->val.string.len = VARSIZE_ANY_EXHDR(txt);
> 
> 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

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (4+ messages)  latest in thread

Message-ID: <aq3TflHWHS-407w0@paquier.xyz>
Permalink:  ../aq3TflHWHS-407w0@paquier.xyz/
Also on:    postgresql.org/message-id/aq3TflHWHS-407w0@paquier.xyz

 · 

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: pgsql-bugs@postgresql.org
  Cc: michael@paquier.xyz, 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
  In-Reply-To: <aq3TflHWHS-407w0@paquier.xyz>

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

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