Skip to content

Commit 43e48de

Browse files
committed
Clarify documentation of handling of null arguments for aggregates.
Per discussion.
1 parent 41c8287 commit 43e48de

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

doc/src/sgml/func.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.521.2.4 2010/08/17 04:37:16 petere Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.521.2.5 2010/09/01 18:22:35 tgl Exp $ -->
22

33
<chapter id="functions">
44
<title>Functions and Operators</title>
@@ -9760,7 +9760,7 @@ SELECT NULLIF(value, '(none)') ...
97609760
<entry>
97619761
array of the argument type
97629762
</entry>
9763-
<entry>input values concatenated into an array</entry>
9763+
<entry>input values, including nulls, concatenated into an array</entry>
97649764
</row>
97659765

97669766
<row>

doc/src/sgml/syntax.sgml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.147.2.5 2010/08/13 01:12:51 rhaas Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.147.2.6 2010/09/01 18:22:35 tgl Exp $ -->
22

33
<chapter id="sql-syntax">
44
<title>SQL Syntax</title>
@@ -1542,23 +1542,29 @@ sqrt(2)
15421542

15431543
<para>
15441544
The first form of aggregate expression invokes the aggregate
1545-
across all input rows for which the given expression(s) yield
1546-
non-null values. (Actually, it is up to the aggregate function
1547-
whether to ignore null values or not &mdash; but all the standard ones do.)
1545+
once for each input row.
15481546
The second form is the same as the first, since
1549-
<literal>ALL</literal> is the default. The third form invokes the
1550-
aggregate for all distinct values of the expressions found
1551-
in the input rows (ignoring nulls if the function chooses to do so).
1552-
The last form invokes the aggregate once for
1553-
each input row regardless of null or non-null values; since no
1547+
<literal>ALL</literal> is the default.
1548+
The third form invokes the aggregate once for each distinct value
1549+
of the expression (or distinct set of values, for multiple expressions)
1550+
found in the input rows.
1551+
The last form invokes the aggregate once for each input row; since no
15541552
particular input value is specified, it is generally only useful
15551553
for the <function>count(*)</function> aggregate function.
15561554
</para>
15571555

1556+
<para>
1557+
Most aggregate functions ignore null inputs, so that rows in which
1558+
one or more of the expression(s) yield null are discarded. This
1559+
can be assumed to be true, unless otherwise specified, for all
1560+
built-in aggregates.
1561+
</para>
1562+
15581563
<para>
15591564
For example, <literal>count(*)</literal> yields the total number
15601565
of input rows; <literal>count(f1)</literal> yields the number of
1561-
input rows in which <literal>f1</literal> is non-null;
1566+
input rows in which <literal>f1</literal> is non-null, since
1567+
<function>count</> ignores nulls; and
15621568
<literal>count(distinct f1)</literal> yields the number of
15631569
distinct non-null values of <literal>f1</literal>.
15641570
</para>

0 commit comments

Comments
 (0)