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

From Csaba Nagy
Subject Re: bug or feature, || -operator and NULLs
Date
Msg-id 1161177415.32342.41.camel@coppola.muc.ecircle.de
Whole thread Raw
In response to Re: bug or feature, || -operator and NULLs  (Andreas Joseph Krogh <andreak@officenet.no>)
List pgsql-hackers
> Why do these discussions always end in academic arguments over whats more 
> logical then not? 

Because you asked the (rhetorical from your POV) question 'isn't this
more logical ?'

> From a *user's* point of view I really would like it to 
> treat the NULL operand of || as '', and obviously many other (at least 
> Oracle) users tend to agree with me on that.

They have to, otherwise they can't meaningfully concatenate an empty
string to anything in Oracle, because there's no such thing in Oracle...
empty string = NULL in Oracle, which is the real cause of the problem.
We've been bitten by this on Oracle before.

> If aggregates ignore NULL one could argue that so shuld the ||-operator?

OK, this is more complicated I guess, check out the rules related to
'strict' state transition functions in:

http://www.postgresql.org/docs/8.1/static/sql-createaggregate.html

Basically, if you like, you could define a 'my_sum' aggregate which does
not ignore nulls. Or you can define an operator which treats NULLs as
empty string if you like...

Cheers,
Csaba.





pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: bug or feature, || -operator and NULLs
Next
From: "Indira Muthuswamy"
Date:
Subject: Bug?