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

From: Andreas Joseph Krogh <andreak(at)officenet(dot)no>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Mario Weilguni <mweilguni(at)sime(dot)com>
Subject: Re: bug or feature, || -operator and NULLs
Date: 2006-10-18 13:07:42
Message-ID: 200610181507.43034.andreak@officenet.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wednesday 18 October 2006 14:44, Mario Weilguni wrote:
> Am Mittwoch, 18. Oktober 2006 13:52 schrieb Andreas Joseph Krogh:
> > This has been been discussed before, but Oracle behaves differently, and
> > IMHO in a more correct way.
> >
> > The following query returns NULL in PG:
> > SELECT NULL || 'fisk';
> >
> > But in Oracle, it returns 'fisk':
> > SELECT NULL || 'fisk' FROM DUAL;
> >
> > The latter seems more logical...
>
> I've worked alot with oracle a few years ago and I agree, the feature is
> handy and makes sometimes life easier, but it's simply wrong. I heard a
> while ago that newer oracle versions changed this to sql - standard, is
> this true?

Oracle(10.1.0.4.0) still treats '' as NULL.

Why do these discussions always end in academic arguments over whats more
logical then not? 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.

On Wednesday 18 October 2006 14:42, Csaba Nagy wrote:
> And it would really return null, if aggregates wouldn't ignore the NULL
> values altogether... the null values are skipped before they get into
> the summing. The same happens with count, if you specify a column it
> will only count the ones which are not null:

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

--
Andreas Joseph Krogh <andreak(at)officenet(dot)no>
Senior Software Developer / Manager
gpg public_key: http://dev.officenet.no/~andreak/public_key.asc
------------------------+---------------------------------------------+
OfficeNet AS | The most difficult thing in the world is to |
Karenslyst Allé 11 | know how to do a thing and to watch |
PO. Box 529 Skøyen | somebody else doing it wrong, without |
0214 Oslo | comment. |
NORWAY | |
Mobile: +47 909 56 963 | |
------------------------+---------------------------------------------+

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2006-10-18 13:11:32 Re: bug or feature, || -operator and NULLs
Previous Message Michael Paesold 2006-10-18 12:55:58 Re: [HACKERS] Mirror problems for download