Clarify documentation of handling of null arguments for aggregates.
authorTom Lane
Wed, 1 Sep 2010 18:22:35 +0000 (18:22 +0000)
committerTom Lane
Wed, 1 Sep 2010 18:22:35 +0000 (18:22 +0000)
Per discussion.

doc/src/sgml/func.sgml
doc/src/sgml/syntax.sgml

index 042de5b6e13a8e868cab744393bcc9e65351bebd..be01398b9d0afd31370484a4ad5cec046b530a39 100644 (file)
@@ -1,4 +1,4 @@
-
+
 
  
   Functions and Operators
@@ -9760,7 +9760,7 @@ SELECT NULLIF(value, '(none)') ...
       
        array of the argument type
       
-      input values concatenated into an array
+      input values, including nulls, concatenated into an array
      
 
      
index 3d108e1e46b90351fd67ae35aea795f73ea38412..562568c4afaf00444c571dce954ab24dfddd091d 100644 (file)
@@ -1,4 +1,4 @@
-
+
 
 
  SQL Syntax
@@ -1542,23 +1542,29 @@ sqrt(2)
 
    
     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.)
+    once for each input row.
     The second form is the same as the first, since
-    ALL is the default.  The third form invokes the
-    aggregate for all distinct values of the expressions found
-    in the input rows (ignoring nulls if the function chooses to do so).
-    The last form invokes the aggregate once for
-    each input row regardless of null or non-null values; since no
+    ALL is the default.
+    The third form invokes the aggregate once for each distinct value
+    of the expression (or distinct set of values, for multiple expressions)
+    found in the input rows.
+    The last form invokes the aggregate once for each input row; since no
     particular input value is specified, it is generally only useful
     for the count(*) aggregate function.
    
 
+   
+    Most aggregate functions ignore null inputs, so that rows in which
+    one or more of the expression(s) yield null are discarded.  This
+    can be assumed to be true, unless otherwise specified, for all
+    built-in aggregates.
+   
+
    
     For example, count(*) yields the total number
     of input rows; count(f1) yields the number of
-    input rows in which f1 is non-null;
+    input rows in which f1 is non-null, since
+    count ignores nulls; and
     count(distinct f1) yields the number of
     distinct non-null values of f1.