From da1b51ecc52ffdb3f8fb1cda1e15dc60ff00cd11 Mon Sep 17 00:00:00 2001 From: Tom Lane <tgl@sss.pgh.pa.us> Date: Tue, 27 Aug 2019 16:37:21 -0400 Subject: [PATCH] Doc: clarify behavior of standard aggregates for null inputs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Section 4.2.7 says that unless otherwise specified, built-in aggregates ignore rows in which any input is null. This is not true of the JSON aggregates, but it wasn't documented. Fix that. Of the other entries in table 9.55, some were explicit about ignoring nulls, and some weren't; for consistency and self-contained-ness, make them all say it explicitly. Per bug #15884 from Tim Möhlmann. Back-patch to all supported branches. Discussion: https://postgr.es/m/15884-c32d848f787fcae3@postgresql.org --- doc/src/sgml/func.sgml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index a7abf8c2ee..c878a0ba4d 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -14604,7 +14604,7 @@ NULL baz</literallayout>(3 rows)</entry> <entry>No</entry> <entry>input arrays concatenated into array of one higher dimension (inputs must all have same dimensionality, - and cannot be empty or NULL)</entry> + and cannot be empty or null)</entry> </row> <row> @@ -14628,7 +14628,7 @@ NULL baz</literallayout>(3 rows)</entry> otherwise the same as the argument data type </entry> <entry>Yes</entry> - <entry>the average (arithmetic mean) of all input values</entry> + <entry>the average (arithmetic mean) of all non-null input values</entry> </row> <row> @@ -14756,7 +14756,7 @@ NULL baz</literallayout>(3 rows)</entry> <type>json</type> </entry> <entry>No</entry> - <entry>aggregates values as a JSON array</entry> + <entry>aggregates values, including nulls, as a JSON array</entry> </row> <row> @@ -14773,7 +14773,7 @@ NULL baz</literallayout>(3 rows)</entry> <type>jsonb</type> </entry> <entry>No</entry> - <entry>aggregates values as a JSON array</entry> + <entry>aggregates values, including nulls, as a JSON array</entry> </row> <row> @@ -14790,7 +14790,8 @@ NULL baz</literallayout>(3 rows)</entry> <type>json</type> </entry> <entry>No</entry> - <entry>aggregates name/value pairs as a JSON object</entry> + <entry>aggregates name/value pairs as a JSON object; values can be + null, but not names</entry> </row> <row> @@ -14807,7 +14808,8 @@ NULL baz</literallayout>(3 rows)</entry> <type>jsonb</type> </entry> <entry>No</entry> - <entry>aggregates name/value pairs as a JSON object</entry> + <entry>aggregates name/value pairs as a JSON object; values can be + null, but not names</entry> </row> <row> @@ -14823,7 +14825,7 @@ NULL baz</literallayout>(3 rows)</entry> <entry>Yes</entry> <entry> maximum value of <replaceable - class="parameter">expression</replaceable> across all input + class="parameter">expression</replaceable> across all non-null input values </entry> </row> @@ -14841,7 +14843,7 @@ NULL baz</literallayout>(3 rows)</entry> <entry>Yes</entry> <entry> minimum value of <replaceable - class="parameter">expression</replaceable> across all input + class="parameter">expression</replaceable> across all non-null input values </entry> </row> @@ -14863,7 +14865,7 @@ NULL baz</literallayout>(3 rows)</entry> same as argument types </entry> <entry>No</entry> - <entry>input values concatenated into a string, separated by delimiter</entry> + <entry>non-null input values concatenated into a string, separated by delimiter</entry> </row> <row> @@ -14886,7 +14888,8 @@ NULL baz</literallayout>(3 rows)</entry> argument data type </entry> <entry>Yes</entry> - <entry>sum of <replaceable class="parameter">expression</replaceable> across all input values</entry> + <entry>sum of <replaceable class="parameter">expression</replaceable> + across all non-null input values</entry> </row> <row> @@ -14903,7 +14906,8 @@ NULL baz</literallayout>(3 rows)</entry> <type>xml</type> </entry> <entry>No</entry> - <entry>concatenation of XML values (see also <xref linkend="functions-xml-xmlagg"/>)</entry> + <entry>concatenation of non-null XML values + (see also <xref linkend="functions-xml-xmlagg"/>)</entry> </row> </tbody> </tgroup>