Re: array_agg() NULL Handling - Mailing list pgsql-hackers

From Thom Brown
Subject Re: array_agg() NULL Handling
Date
Msg-id AANLkTinWJ7w-w6K1Y156=gja25D2aNaLqURoMHcXQkPJ@mail.gmail.com
Whole thread Raw
In response to array_agg() NULL Handling  ("David E. Wheeler" <david@kineticode.com>)
Responses Re: array_agg() NULL Handling  ("David E. Wheeler" <david@kineticode.com>)
Re: array_agg() NULL Handling  (Thom Brown <thom@linux.com>)
List pgsql-hackers
On 1 September 2010 06:45, David E. Wheeler <david@kineticode.com> wrote:
> The aggregate docs say:
>
>> The first form of aggregate expression invokes the aggregate across all input rows for which the given expression(s)
yieldnon-null values. (Actually, it is up to the aggregate function whether to ignore null values or not — but all the
standardones do.) 
>
> -- http://developer.postgresql.org/pgdocs/postgres/sql-expressions.html#SYNTAX-AGGREGATES
>
> That, however, is not true of array_agg():
>
> try=# CREATE TABLE foo(id int);
> CREATE TABLE
> try=# INSERT INTO foo values(1), (2), (NULL), (3);
> INSERT 0 4
> try=# select array_agg(id) from foo;
>  array_agg
> ──────────────
>  {1,2,NULL,3}
> (1 row)
>
> So are the docs right, or is array_agg() right?

I think it might be both.  array_agg doesn't return NULL, it returns
an array which contains NULL.

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935


pgsql-hackers by date:

Previous
From: Sushant Sinha
Date:
Subject: Re: english parser in text search: support for multiple words in the same position
Next
From: "David E. Wheeler"
Date:
Subject: Re: array_agg() NULL Handling