Re: ARRAY() returning NULL instead of ARRAY[] resp. {} - Mailing list pgsql-sql

From Achilleus Mantzios
Subject Re: ARRAY() returning NULL instead of ARRAY[] resp. {}
Date
Msg-id Pine.LNX.4.44.0505240911160.10967-100000@matrix.gatewaynet.com
Whole thread Raw
In response to Re: ARRAY() returning NULL instead of ARRAY[] resp. {}  (Joe Conway <mail@joeconway.com>)
List pgsql-sql
O Joe Conway έγραψε στις May 23, 2005 :

> Markus Bertheau wrote:
> > why does SELECT ARRAY(SELECT 1 WHERE FALSE) return NULL instead of
> > ARRAY[] resp. '{}'?
> > 
> 
> Why would you expect an empty array instead of a NULL? NULL is what 
> you'd get for other data types -- for example:

One could ask in the same fashion why someone would want a table
if this table contains no rows.

A null value may mean "dont know",
wheras a '{}' (empty) value may mean "empty set".

For instance lets consider the case where an array holds
the factors of a polynomial formula.

An null value might mean that the person defining
the formulas haven't been bothered with this one yet.
An empty value might mean that the person indicates
that has worked on this particular one, but he/she has no data yet.

Ok extreme cases, but to me there is a clean distinction
between a null array and an empty array.

Also what is definately needed is arrays that may contain
null values.

> 
> regression=# SELECT (SELECT 1 WHERE FALSE) IS NULL;
>   ?column?
> ----------
>   t
> (1 row)
> 
> Joe
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
>                http://www.postgresql.org/docs/faq
> 

-- 
-Achilleus



pgsql-sql by date:

Previous
From: Markus Bertheau
Date:
Subject: Re: ARRAY() returning NULL instead of ARRAY[] resp. {}
Next
From: Richard Huxton
Date:
Subject: Re: datatype conversion on postgresql 7.4.1