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

From: Andreas Joseph Krogh <andreak(at)officenet(dot)no>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: bug or feature, || -operator and NULLs
Date: 2006-10-18 13:44:05
Message-ID: 200610181544.05664.andreak@officenet.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wednesday 18 October 2006 15:13, Andrew Dunstan wrote:
> Andreas Joseph Krogh wrote:
> > 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...
>
> When in doubt, consult the standard ... Oracle's treatment of NULL is
> known to violate the standard, IIRC. Your measure of correctness seems
> to be "appears to me more logical", but ours is "complies with the
> standard".

I know PG violates the standard in other places and core's favourite argument
for doing so is "the standard is braindead here, so we do it our way".

> In any case, why should null have a string value of '' any more than it
> should have a value of 'blurfl'?
>
> Your analogy elsewhere with aggregate functions like sum() is not
> relevant, as these are documented to ignore null values.

I'm not advocating that NULL should have a string-vaule of anything, just that
the ||-operator shuld treat NULL as "dont bother with it and proceed
concatenation".

--
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 Andreas Joseph Krogh 2006-10-18 13:47:49 Re: bug or feature, || -operator and NULLs
Previous Message Andrew Dunstan 2006-10-18 13:31:54 Re: Bug?