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 1wCH9c-001pG2-0s for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Apr 2026 13:16:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wCH9a-00760H-1v for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Apr 2026 13:16:39 +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 1wBx0q-002mai-2x for pgsql-bugs@lists.postgresql.org; Sun, 12 Apr 2026 15:46:17 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wBx0m-00000000gqq-1U6o for pgsql-bugs@lists.postgresql.org; Sun, 12 Apr 2026 15:46:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=0bLwCigO1yLsJGo0uSpZu0l72FdEZaVRlxAk3w95WQs=; b=b3u//mc6cwF0bST5tRtm5MfBcc MRZqaQLKVBeNBxB1n6lAMY7hsAWwMG5mP8r/N6BhgnEXfsXlV0n2hVgW2m1+mdVeq3/Le8DOvxE/R 5FuaqAj4Z+5y9HLUhyB73uQkq5JRAI0bL5GsRIw3Y7ByAGfS8CBpEyl1wIs1ATnsVdAF0AiBgnuzG IX/3TLiUcE6glW+3ERG+SVEbWkqOiEr90rzfUN2WkaN7LtbQiTU7aVfpa0xwe5jf0yt9mM1UQXF7c N3zqY+pxaRMJCAwqMBNk3IjFbvckn8+p8HDTAsgPMk2APKAAokC8NuSYpLPlfcStZs1Kvgyb207L2 LE+Co0tg==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wBx0i-001xSF-2z for pgsql-bugs@lists.postgresql.org; Sun, 12 Apr 2026 15:46:10 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wBx0c-003ydk-1T for pgsql-bugs@lists.postgresql.org; Sun, 12 Apr 2026 15:46:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19454: PL/pgSQL mishandling jsonb attribute reference To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: ma.sao@msa.hinet.net Reply-To: ma.sao@msa.hinet.net, pgsql-bugs@lists.postgresql.org Date: Sun, 12 Apr 2026 15:45:39 +0000 Message-ID: <19454-98a60db746b6dd22@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19454 Logged by: CN Liou Email address: ma.sao@msa.hinet.net PostgreSQL version: 18.3 Operating system: Linux Debian Bookworm Description: =20 It appears the PL/pgSQL assignment operator :=3D 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 :=3D '[]'::jsonb; tj JSONB; BEGIN tj :=3D '{"delta": [["1221", "1221", "TWD", 577.82, {"tags": []}]]}'::jsonb; RAISE NOTICE 'Before: %, Delta is Null: %', (v_payload IS NULL), (tj->'delta' IS NULL); v_payload :=3D v_payload || tj->'delta'; -- The problematic line --v_payload :=3D (SELECT v_payload || (tj->'delta')); --This avoids the issue. RAISE NOTICE 'After: %', (v_payload IS NULL); END $$;