pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: exe-dealer <exe-dealer@yandex.ru>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: jsonb subscript operator returns null when key is fetched from table
Date: Mon, 12 Dec 2022 14:09:21 -0500
Message-ID: <2035559.1670872161@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwaKHLG5cPPmeoE0uYu5MYrHkwxhH1LV9aE0QrcDk0GnpA@mail.gmail.com>
References: <205321670615953@mail.yandex.ru>
	<CAKFQuwaKHLG5cPPmeoE0uYu5MYrHkwxhH1LV9aE0QrcDk0GnpA@mail.gmail.com>

"David G. Johnston" <david.g.johnston@gmail.com> writes:
> Someone more experienced than I will need to actually do the debugging work
> though; hoping this reply will be seen by one of them.

Meh.  Somebody was cavalier about detoasting the subscript:

            jbvp = getKeyJsonValueFromContainer(container,
                                                VARDATA(path[i]),
                                                VARSIZE(path[i]) - VARHDRSZ,
                                                NULL);

Neither VARDATA nor VARSIZE are valid to apply to an arbitrary datum.
Apparently, nobody has ever tested this with a subscript value fetched
straight from disk :-(.  The given example accidentally works with
a NOT MATERIALIZED CTE because the whole thing gets stepwise folded
to constants.  Likewise, the expression with || accidentally works
because concatenation always yields a non-toasted result.

			regards, tom lane





view thread (3+ messages)

Message-ID: <2035559.1670872161@sss.pgh.pa.us>
Permalink:  ../2035559.1670872161@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2035559.1670872161@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, exe-dealer@yandex.ru, pgsql-bugs@lists.postgresql.org
  Subject: Re: jsonb subscript operator returns null when key is fetched from table
  In-Reply-To: <2035559.1670872161@sss.pgh.pa.us>

* 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