Re: BUG #18715: replace() function silently fails if 3rd argument is null - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: BUG #18715: replace() function silently fails if 3rd argument is null
Date
Msg-id CAKFQuwaFtdrDPryMUfBy_+DnsrGishCuXHc+doVLjdczhWWP1w@mail.gmail.com
Whole thread Raw
In response to BUG #18715: replace() function silently fails if 3rd argument is null  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #18715: replace() function silently fails if 3rd argument is null
List pgsql-bugs
On Tue, Nov 19, 2024 at 5:52 AM PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug has been logged on the website:

Bug reference:      18715
Logged by:          Chris
Email address:      xpusostomos@gmail.com
PostgreSQL version: 16.5
Operating system:   Linux
Description:       

OK, but now imagine that at runtime the 3rd argument is null... and we
expect it to be null because that variable is not used in that tuple:
replace('abcdef', '${m}', null) => null

This is not a bug.  Replace is defined to return null on null input (i.e., strict) and that is the behavior you are seeing.

Use Coalesce to convert your null into an empty string.

David J.

pgsql-bugs by date:

Previous
From: Tender Wang
Date:
Subject: Re: BUG #18371: There are wrong constraint residues when detach hash partiton concurrently
Next
From: "David G. Johnston"
Date:
Subject: Re: BUG #18635: " $libdir/adminpack could not be loaded" error with pg_upgrade to PostgreSQL17