Re: BUG #4865: replace function returns null

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Jamolkhon Khakimov" <jkhakimov(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4865: replace function returns null
Date: 2009-06-19 13:57:05
Message-ID: 5148.1245419825@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Jamolkhon Khakimov" <jkhakimov(at)gmail(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Brendan Jurd 2009-06-19 15:33:51 Re: BUG #4862: different results in to_date() between 8.3.7 & 8.4.RC1
Previous Message Tom Lane 2009-06-19 13:47:01 Re: BUG #4862: different results in to_date() between 8.3.7 & 8.4.RC1