public inbox for [email protected]  
help / color / mirror / Atom feed
Re: BUG #19409: Function jsonb_strip_nulls() changed from immutable to stable.
9+ messages / 3 participants
[nested] [flat]

* Re: BUG #19409: Function jsonb_strip_nulls() changed from immutable to stable.
@ 2026-02-13 20:18  Tom Lane <[email protected]>
  0 siblings, 2 replies; 9+ messages in thread

From: Tom Lane @ 2026-02-13 20:18 UTC (permalink / raw)
  To: [email protected]; +Cc: [email protected]; Andrew Dunstan <[email protected]>; Florents Tselai <[email protected]>

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.
Nor did a quick search find any discussion of the point in the
thread.

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: BUG #19409: Function jsonb_strip_nulls() changed from immutable to stable.
@ 2026-02-13 21:35  Florents Tselai <[email protected]>
  parent: Tom Lane <[email protected]>
  1 sibling, 0 replies; 9+ messages in thread

From: Florents Tselai @ 2026-02-13 21:35 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: [email protected]; [email protected]; Andrew Dunstan <[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



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: BUG #19409: Function jsonb_strip_nulls() changed from immutable to stable.
@ 2026-02-16 16:18  Andrew Dunstan <[email protected]>
  parent: Tom Lane <[email protected]>
  1 sibling, 1 reply; 9+ messages in thread

From: Andrew Dunstan @ 2026-02-16 16:18 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; [email protected]; +Cc: [email protected]; Florents Tselai <[email protected]>


On 2026-02-13 Fr 3:18 PM, Tom Lane 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.
> Nor did a quick search find any discussion of the point in the
> thread.
>
> 			


Yeah. <paperbag>

In penance for this I have worked up a mechanism to generate 
default-setting statements from pg_proc.dat that I will post separately 
about in -hackers. In the meantime, I guess we should fix it in release 
18 and master, with a release note that people might need to do a manual 
update if affected, along the lines of

    update pg_proc set provolatile = 'i' where oid in (3261,3262);


cheers


andrew

--
Andrew Dunstan
EDB:https://www.enterprisedb.com


^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: BUG #19409: Function jsonb_strip_nulls() changed from immutable to stable.
@ 2026-02-16 16:48  Tom Lane <[email protected]>
  parent: Andrew Dunstan <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Tom Lane @ 2026-02-16 16:48 UTC (permalink / raw)
  To: Andrew Dunstan <[email protected]>; +Cc: [email protected]; [email protected]; Florents Tselai <[email protected]>

Andrew Dunstan <[email protected]> writes:
> In penance for this I have worked up a mechanism to generate 
> default-setting statements from pg_proc.dat that I will post separately 
> about in -hackers. In the meantime, I guess we should fix it in release 
> 18 and master, with a release note that people might need to do a manual 
> update if affected, along the lines of
>     update pg_proc set provolatile = 'i' where oid in (3261,3262);

Yeah, the $64 question is what to do in REL_18_STABLE.  In master
we can commit this with a catversion bump, but we can't change
v18's catversion.  I think I agree that we should just change v18's
system_functions.sql anyway.  That will at least solve it for people
upgrading in future.

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: BUG #19409: Function jsonb_strip_nulls() changed from immutable to stable.
@ 2026-02-16 20:19  Andrew Dunstan <[email protected]>
  parent: Tom Lane <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Andrew Dunstan @ 2026-02-16 20:19 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: [email protected]; [email protected]; Florents Tselai <[email protected]>


On 2026-02-16 Mo 11:48 AM, Tom Lane wrote:
> Andrew Dunstan<[email protected]> writes:
>> In penance for this I have worked up a mechanism to generate
>> default-setting statements from pg_proc.dat that I will post separately
>> about in -hackers. In the meantime, I guess we should fix it in release
>> 18 and master, with a release note that people might need to do a manual
>> update if affected, along the lines of
>>      update pg_proc set provolatile = 'i' where oid in (3261,3262);
> Yeah, the $64 question is what to do in REL_18_STABLE.  In master
> we can commit this with a catversion bump, but we can't change
> v18's catversion.  I think I agree that we should just change v18's
> system_functions.sql anyway.  That will at least solve it for people
> upgrading in future.


OK, barring objections I will make that happen in a day or two.


cheers


andrew

--
Andrew Dunstan
EDB:https://www.enterprisedb.com


^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: BUG #19409: Function jsonb_strip_nulls() changed from immutable to stable.
@ 2026-02-17 21:25  Andrew Dunstan <[email protected]>
  parent: Andrew Dunstan <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Andrew Dunstan @ 2026-02-17 21:25 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: [email protected]; [email protected]; Florents Tselai <[email protected]>


On 2026-02-16 Mo 3:19 PM, Andrew Dunstan wrote:
>
>
> On 2026-02-16 Mo 11:48 AM, Tom Lane wrote:
>> Andrew Dunstan<[email protected]> writes:
>>> In penance for this I have worked up a mechanism to generate
>>> default-setting statements from pg_proc.dat that I will post separately
>>> about in -hackers. In the meantime, I guess we should fix it in release
>>> 18 and master, with a release note that people might need to do a manual
>>> update if affected, along the lines of
>>>      update pg_proc set provolatile = 'i' where oid in (3261,3262);
>> Yeah, the $64 question is what to do in REL_18_STABLE.  In master
>> we can commit this with a catversion bump, but we can't change
>> v18's catversion.  I think I agree that we should just change v18's
>> system_functions.sql anyway.  That will at least solve it for people
>> upgrading in future.
>
>
> OK, barring objections I will make that happen in a day or two.
>
>
>


In view of later discussions, fixing master seems pointless, as that 
code is going away. When it does we should do a catversion bump.


So I'm just planning to patch v18 now.


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com







^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: BUG #19409: Function jsonb_strip_nulls() changed from immutable to stable.
@ 2026-02-17 21:55  Tom Lane <[email protected]>
  parent: Andrew Dunstan <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Tom Lane @ 2026-02-17 21:55 UTC (permalink / raw)
  To: Andrew Dunstan <[email protected]>; +Cc: [email protected]; [email protected]; Florents Tselai <[email protected]>

Andrew Dunstan <[email protected]> writes:
> In view of later discussions, fixing master seems pointless, as that 
> code is going away. When it does we should do a catversion bump.
> So I'm just planning to patch v18 now.

Makes sense.

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: BUG #19409: Function jsonb_strip_nulls() changed from immutable to stable.
@ 2026-02-18 18:05  Andrew Dunstan <[email protected]>
  parent: Tom Lane <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Andrew Dunstan @ 2026-02-18 18:05 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: [email protected]; [email protected]; Florents Tselai <[email protected]>


On 2026-02-17 Tu 4:55 PM, Tom Lane wrote:
> Andrew Dunstan <[email protected]> writes:
>> In view of later discussions, fixing master seems pointless, as that
>> code is going away. When it does we should do a catversion bump.
>> So I'm just planning to patch v18 now.
> Makes sense.
>
> 			



Done.


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com







^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: BUG #19409: Function jsonb_strip_nulls() changed from immutable to stable.
@ 2026-02-18 19:18  Tom Lane <[email protected]>
  parent: Andrew Dunstan <[email protected]>
  0 siblings, 0 replies; 9+ messages in thread

From: Tom Lane @ 2026-02-18 19:18 UTC (permalink / raw)
  To: Andrew Dunstan <[email protected]>; +Cc: [email protected]; [email protected]; Florents Tselai <[email protected]>

Andrew Dunstan <[email protected]> writes:
> Done.

I pushed the patch for master too, so this is closed now.

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2026-02-18 19:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-02-13 20:18 Re: BUG #19409: Function jsonb_strip_nulls() changed from immutable to stable. Tom Lane <[email protected]>
2026-02-13 21:35 ` Florents Tselai <[email protected]>
2026-02-16 16:18 ` Andrew Dunstan <[email protected]>
2026-02-16 16:48   ` Tom Lane <[email protected]>
2026-02-16 20:19     ` Andrew Dunstan <[email protected]>
2026-02-17 21:25       ` Andrew Dunstan <[email protected]>
2026-02-17 21:55         ` Tom Lane <[email protected]>
2026-02-18 18:05           ` Andrew Dunstan <[email protected]>
2026-02-18 19:18             ` Tom Lane <[email protected]>

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