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

array_agg() NULL Handling

From: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: array_agg() NULL Handling
Date: 2010-09-01 05:45:05
Message-ID: 770F1292-EC1C-4EEA-A315-186BC5AF3A40@kineticode.com (view raw or flat)
Thread:
Lists: pgsql-hackers
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.)

-- 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?

Best,

David


Responses

pgsql-hackers by date

Next:From: Sushant SinhaDate: 2010-09-01 06:42:04
Subject: Re: english parser in text search: support for multiple words in the same position
Previous:From: Heikki LinnakangasDate: 2010-09-01 05:33:07
Subject: Re: Synchronous replication - patch status inquiry

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