Re: BUG #4865: replace function returns null - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #4865: replace function returns null
Date
Msg-id 5148.1245419825@sss.pgh.pa.us
Whole thread Raw
In response to BUG #4865: replace function returns null  ("Jamolkhon Khakimov" <jkhakimov@gmail.com>)
List pgsql-bugs
"Jamolkhon Khakimov" <jkhakimov@gmail.com> writes:
> replace( 'abcdefabcdef', 'XX', null)
> // returns null, while it should return 'abcdefabcdef'

No, it should return null.  Like most Postgres functions, replace is
strict, meaning it returns null if any input is null.  This is sensible
in the abstract because an unknown input means the result is unknown
too.  I suppose your argument is that the result here could be
determined without knowing what the third argument value is, but the
mechanism doesn't attempt to make such a fine distinction.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #4862: different results in to_date() between 8.3.7 & 8.4.RC1
Next
From: Brendan Jurd
Date:
Subject: Re: BUG #4862: different results in to_date() between 8.3.7 & 8.4.RC1