Re: bug or feature, || -operator and NULLs - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: bug or feature, || -operator and NULLs
Date
Msg-id 20061018184331.GH11184@svana.org
Whole thread Raw
In response to Re: bug or feature, || -operator and NULLs  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: bug or feature, || -operator and NULLs
List pgsql-hackers
On Wed, Oct 18, 2006 at 11:36:44AM -0700, Jeff Davis wrote:
> > What's being suggested simply violates common sense. Basically:
> >
> > if (a = b) then (a||c = b||c)
> >
>
> If a is 'x' and b is 'x' and c is NULL, the above statement doesn't hold
> in PostgreSQL.

Heh, well, c is supposed to be not NULL. Missed that. I was using the
equals to include (NULL = NULL) but in SQL it's not like that.

> I'm not disagreeing with your overall point, I'm just missing what you
> meant by the above statement. What are a, b, and c supposed to be?

I was trying to point out that what was being proposed was:

NULL || 'bar'    => 'bar'
'' || 'bar'      => 'bar'

But NULL is not an empty string. Oracle chooses to make NULL and the
empty string the same, we don't. So logically we shouldn't treat them
the same for text concatination either.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

pgsql-hackers by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: Bug?
Next
From: Jeff Davis
Date:
Subject: Re: bug or feature, || -operator and NULLs