From f90eac87f324fd4888bfca4ced7f11b525275475 Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Fri, 25 Jul 2025 16:22:47 +0900 Subject: [PATCH v17 5/6] Modify documents to add null treatment clause. --- doc/src/sgml/func.sgml | 38 +++++++++++++++++----------- doc/src/sgml/syntax.sgml | 10 +++++--- src/backend/catalog/sql_features.txt | 2 +- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index de5b5929ee0..4106e1768d8 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -23543,7 +23543,7 @@ SELECT count(*) FROM sometable; lag ( value anycompatible , offset integer - , default anycompatible ) + , default anycompatible ) null treatment anycompatible @@ -23568,7 +23568,7 @@ SELECT count(*) FROM sometable; lead ( value anycompatible , offset integer - , default anycompatible ) + , default anycompatible ) null treatment anycompatible @@ -23591,7 +23591,7 @@ SELECT count(*) FROM sometable; first_value - first_value ( value anyelement ) + first_value ( value anyelement ) null treatment anyelement @@ -23605,7 +23605,7 @@ SELECT count(*) FROM sometable; last_value - last_value ( value anyelement ) + last_value ( value anyelement ) null treatment anyelement @@ -23619,7 +23619,7 @@ SELECT count(*) FROM sometable; nth_value - nth_value ( value anyelement, n integer ) + nth_value ( value anyelement, n integer ) null treatment anyelement @@ -23668,18 +23668,26 @@ SELECT count(*) FROM sometable; Other frame specifications can be used to obtain other effects. + + The null treatment option must be one of: + + RESPECT NULLS + IGNORE NULLS + + If unspecified, the default is RESPECT NULLS which includes NULL + values in any result calculation. IGNORE NULLS ignores NULL values. + This option is only allowed for the following functions: lag, + lead, first_value, last_value, + nth_value. + + - The SQL standard defines a RESPECT NULLS or - IGNORE NULLS option for lead, lag, - first_value, last_value, and - nth_value. This is not implemented in - PostgreSQL: the behavior is always the - same as the standard's default, namely RESPECT NULLS. - Likewise, the standard's FROM FIRST or FROM LAST - option for nth_value is not implemented: only the - default FROM FIRST behavior is supported. (You can achieve - the result of FROM LAST by reversing the ORDER BY + The SQL standard defines a FROM FIRST or FROM LAST + option for nth_value. This is not implemented in + PostgreSQL: only the default FROM FIRST + behavior is supported. (You can achieve the result of FROM LAST by + reversing the ORDER BY ordering.) diff --git a/doc/src/sgml/syntax.sgml b/doc/src/sgml/syntax.sgml index 916189a7d68..237d7306fe8 100644 --- a/doc/src/sgml/syntax.sgml +++ b/doc/src/sgml/syntax.sgml @@ -1834,8 +1834,8 @@ FROM generate_series(1,10) AS s(i); The syntax of a window function call is one of the following: -function_name (expression , expression ... ) [ FILTER ( WHERE filter_clause ) ] OVER window_name -function_name (expression , expression ... ) [ FILTER ( WHERE filter_clause ) ] OVER ( window_definition ) +function_name (expression , expression ... ) null treatment [ FILTER ( WHERE filter_clause ) ] OVER window_name +function_name (expression , expression ... ) null treatment [ FILTER ( WHERE filter_clause ) ] OVER ( window_definition ) function_name ( * ) [ FILTER ( WHERE filter_clause ) ] OVER window_name function_name ( * ) [ FILTER ( WHERE filter_clause ) ] OVER ( window_definition ) @@ -1873,7 +1873,9 @@ EXCLUDE NO OTHERS Here, expression represents any value - expression that does not itself contain window function calls. + expression that does not itself contain window function calls. Some + non-aggregate functions allow a null treatment clause, + described in . @@ -2048,7 +2050,7 @@ EXCLUDE NO OTHERS The built-in window functions are described in . Other window functions can be added by + linkend="functions-window-table"/>. Other window functions can be added by the user. Also, any built-in or user-defined general-purpose or statistical aggregate can be used as a window function. (Ordered-set and hypothetical-set aggregates cannot presently be used as window functions.) diff --git a/src/backend/catalog/sql_features.txt b/src/backend/catalog/sql_features.txt index ebe85337c28..3a8ad201607 100644 --- a/src/backend/catalog/sql_features.txt +++ b/src/backend/catalog/sql_features.txt @@ -518,7 +518,7 @@ T612 Advanced OLAP operations YES T613 Sampling YES T614 NTILE function YES T615 LEAD and LAG functions YES -T616 Null treatment option for LEAD and LAG functions NO +T616 Null treatment option for LEAD and LAG functions YES T617 FIRST_VALUE and LAST_VALUE functions YES T618 NTH_VALUE function NO function exists, but some options missing T619 Nested window functions NO -- 2.25.1