Re: bug or feature, || -operator and NULLs

From: Csaba Nagy <nagy(at)ecircle-ag(dot)com>
To: Andreas Joseph Krogh <andreak(at)officenet(dot)no>
Cc: postgres hackers <pgsql-hackers(at)postgresql(dot)org>, Mario Weilguni <mweilguni(at)sime(dot)com>
Subject: Re: bug or feature, || -operator and NULLs
Date: 2006-10-18 13:16:56
Message-ID: 1161177415.32342.41.camel@coppola.muc.ecircle.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Indira Muthuswamy 2006-10-18 13:23:46 Bug?
Previous Message Mario Weilguni 2006-10-18 13:15:01 Re: bug or feature, || -operator and NULLs