public inbox for [email protected]  
help / color / mirror / Atom feed
From: PG Bug reporting form <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: BUG #19454: PL/pgSQL mishandling jsonb attribute reference
Date: Sun, 12 Apr 2026 15:45:39 +0000
Message-ID: <[email protected]> (raw)

The following bug has been logged on the website:

Bug reference:      19454
Logged by:          CN Liou
Email address:      [email protected]
PostgreSQL version: 18.3
Operating system:   Linux Debian Bookworm
Description:        

It appears the PL/pgSQL assignment operator := fails to maintain the
stability of a jsonb attribute reference (from a function result) during a
self-concatenation operation, whereas a SELECT wrapper forces correct
materialization.

DO $$
DECLARE
        v_payload JSONB := '[]'::jsonb;
        tj JSONB;
BEGIN
        tj := '{"delta": [["1221", "1221", "TWD", 577.82, {"tags":
[]}]]}'::jsonb;
        RAISE NOTICE 'Before: %, Delta is Null: %', (v_payload IS NULL),
(tj->'delta' IS NULL);
        v_payload := v_payload || tj->'delta'; -- The problematic line
        --v_payload := (SELECT v_payload || (tj->'delta')); --This avoids
the issue.
        RAISE NOTICE 'After: %', (v_payload IS NULL);
END $$;








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]
  Subject: Re: BUG #19454: PL/pgSQL mishandling jsonb attribute reference
  In-Reply-To: <[email protected]>

* 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