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

From: Andreas Joseph Krogh <andreak(at)officenet(dot)no>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Csaba Nagy <nagy(at)ecircle-ag(dot)com>
Subject: Re: bug or feature, || -operator and NULLs
Date: 2006-10-18 12:28:50
Message-ID: 200610181428.50964.andreak@officenet.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wednesday 18 October 2006 14:15, Csaba Nagy wrote:
> > 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...
>
> Why would it be more logical ?

How many times do you *really* want to get the "not known" answer here instead
of 'fisk'? To put it another way: When will it be *wrong* to return 'fisk'?

> NULL means "value not known".

I know.

> Concatenate "value not known" with 'fisk' -> what's the logical answer?
>
> I would say the logical result is 'value not known'... if one of the
> components is not known, how can you know what is the result ?

That's like saying: SELECT sum(field) should return NULL(value not known) if
some of the tuples are NULL, which is definitly not what you want.

--
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 Martijn van Oosterhout 2006-10-18 12:39:36 Re: bug or feature, || -operator and NULLs
Previous Message Martijn van Oosterhout 2006-10-18 12:17:54 Re: Asynchronous I/O Support