Skip site navigation (1) Skip section navigation (2)

Re: array_agg() NULL Handling

From: Thom Brown <thom(at)linux(dot)com>
To: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: array_agg() NULL Handling
Date: 2010-09-01 08:06:48
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
On 1 September 2010 07:56, Thom Brown <thom(at)linux(dot)com> wrote:
> On 1 September 2010 06:45, David E. Wheeler <david(at)kineticode(dot)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) yield non-null values. (Actually, it is up to the aggregate function whether to ignore null values or not — but all the standard ones do.)
>> --
>> That, however, is not true of array_agg():
>> try=# CREATE TABLE foo(id int);
>> 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.

The second I wrote that, I realised it was b*ll%$ks, as I was still in
the process of waking up.

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

In response to


pgsql-hackers by date

Next:From: KaiGai KoheiDate: 2010-09-01 08:37:57
Subject: Re: leaky views, yet again
Previous:From: Fujii MasaoDate: 2010-09-01 07:53:38
Subject: Re: Synchronous replication - patch status inquiry

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group