public inbox for [email protected]
help / color / mirror / Atom feedFrom: Florents Tselai <[email protected]>
To: Tom Lane <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Andrew Dunstan <[email protected]>
Subject: Re: BUG #19409: Function jsonb_strip_nulls() changed from immutable to stable.
Date: Fri, 13 Feb 2026 23:35:04 +0200
Message-ID: <CA+v5N43CCjEtORJdn3Q0+uh=ztorEiiUnWBVc2TNci4zJ57ntQ@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
On Fri, Feb 13, 2026 at 10:18 PM Tom Lane <[email protected]> wrote:
> PG Bug reporting form <[email protected]> writes:
> > ... this fails in PostgreSQL 18, because the jsonb_strip_nulls ( target
> > jsonb [,strip_in_arrays boolean ] ) function changed from immutable to
> > stable.
>
> A bit of git excavation shows that this changed here:
>
> Author: Andrew Dunstan <[email protected]>
> Branch: master Release: REL_18_BR [4603903d2] 2025-03-05 10:04:02 -0500
>
> Allow json{b}_strip_nulls to remove null array elements
>
> An additional paramater ("strip_in_arrays") is added to these
> functions.
> It defaults to false. If true, then null array elements are removed as
> well as null valued object fields. JSON that just consists of a single
> null is not affected.
>
> Author: Florents Tselai <[email protected]>
>
> Discussion:
> https://postgr.es/m/[email protected]
>
> It looks like a thinko to me, because surely the strip_in_arrays
> parameter did not make the function more mutable than before.
>
The perils of going from pg_proc.dat to manual defs in system_functions.sql
Attachments:
[application/octet-stream] v1-0001-Restore-json-b-_strip_nulls-immutability.patch (1.3K, 3-v1-0001-Restore-json-b-_strip_nulls-immutability.patch)
download | inline diff:
From 088e6f2400c50007e63b5f8b18fb60075cc78c46 Mon Sep 17 00:00:00 2001
From: Florents Tselai <[email protected]>
Date: Fri, 13 Feb 2026 22:53:14 +0200
Subject: [PATCH v1] Restore json{b}_strip_nulls immutability
Commit4603903d2 added the strip_in_arrays parameter to these functions
but mistakenly changed their volatility from IMMUTABLE to STABLE. This
commit restores the correct IMMUTABLE marking, as the functions' output
still depends entirely on their input arguments.
---
src/backend/catalog/system_functions.sql | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index eb9e31ae1bf..836a0f9eb3d 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -611,14 +611,14 @@ CREATE OR REPLACE FUNCTION
jsonb_strip_nulls(target jsonb, strip_in_arrays boolean DEFAULT false)
RETURNS jsonb
LANGUAGE INTERNAL
-STRICT STABLE PARALLEL SAFE
+STRICT IMMUTABLE PARALLEL SAFE
AS 'jsonb_strip_nulls';
CREATE OR REPLACE FUNCTION
json_strip_nulls(target json, strip_in_arrays boolean DEFAULT false)
RETURNS json
LANGUAGE INTERNAL
-STRICT STABLE PARALLEL SAFE
+STRICT IMMUTABLE PARALLEL SAFE
AS 'json_strip_nulls';
-- default normalization form is NFC, per SQL standard
--
2.52.0
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], [email protected], [email protected]
Subject: Re: BUG #19409: Function jsonb_strip_nulls() changed from immutable to stable.
In-Reply-To: <CA+v5N43CCjEtORJdn3Q0+uh=ztorEiiUnWBVc2TNci4zJ57ntQ@mail.gmail.com>
* 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