aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-11-04 15:08:37 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2020-11-04 15:08:37 -0500
commit5c292e6b90433c760a3e15027646c7b94afd0cdd (patch)
treef7a22ff756c6234eb7c234aab6d4d60253847767 /doc/src
parent40c24bfef92530bd846e111c1742c2a54441c62c (diff)
downloadpostgresql-5c292e6b90433c760a3e15027646c7b94afd0cdd.tar.gz
postgresql-5c292e6b90433c760a3e15027646c7b94afd0cdd.zip
Declare lead() and lag() using anycompatible not anyelement.
This allows use of a "default" expression that doesn't slavishly match the data column's type. Formerly you got something like "function lag(numeric, integer, integer) does not exist", which is not just unhelpful but actively misleading. The SQL spec suggests that the default should be coerced to the data column's type, but this implementation instead chooses the common supertype, which seems at least as reasonable. (Note: I took the opportunity to run "make reformat-dat-files" on pg_proc.dat, so this commit includes some cosmetic changes to recently-added entries that aren't related to lead/lag.) Vik Fearing Discussion: https://postgr.es/m/77675130-89da-dab1-51dd-492c93dcf5d1@postgresfriends.org
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/func.sgml16
1 files changed, 8 insertions, 8 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 87a6ba8d10f..46d6db3cfe0 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -19594,17 +19594,17 @@ SELECT count(*) FROM sometable;
<indexterm>
<primary>lag</primary>
</indexterm>
- <function>lag</function> ( <parameter>value</parameter> <type>anyelement</type>
+ <function>lag</function> ( <parameter>value</parameter> <type>anycompatible</type>
<optional>, <parameter>offset</parameter> <type>integer</type>
- <optional>, <parameter>default</parameter> <type>anyelement</type> </optional></optional> )
- <returnvalue>anyelement</returnvalue>
+ <optional>, <parameter>default</parameter> <type>anycompatible</type> </optional></optional> )
+ <returnvalue>anycompatible</returnvalue>
</para>
<para>
Returns <parameter>value</parameter> evaluated at
the row that is <parameter>offset</parameter>
rows before the current row within the partition; if there is no such
row, instead returns <parameter>default</parameter>
- (which must be of the same type as
+ (which must be of a type compatible with
<parameter>value</parameter>).
Both <parameter>offset</parameter> and
<parameter>default</parameter> are evaluated
@@ -19619,17 +19619,17 @@ SELECT count(*) FROM sometable;
<indexterm>
<primary>lead</primary>
</indexterm>
- <function>lead</function> ( <parameter>value</parameter> <type>anyelement</type>
+ <function>lead</function> ( <parameter>value</parameter> <type>anycompatible</type>
<optional>, <parameter>offset</parameter> <type>integer</type>
- <optional>, <parameter>default</parameter> <type>anyelement</type> </optional></optional> )
- <returnvalue>anyelement</returnvalue>
+ <optional>, <parameter>default</parameter> <type>anycompatible</type> </optional></optional> )
+ <returnvalue>anycompatible</returnvalue>
</para>
<para>
Returns <parameter>value</parameter> evaluated at
the row that is <parameter>offset</parameter>
rows after the current row within the partition; if there is no such
row, instead returns <parameter>default</parameter>
- (which must be of the same type as
+ (which must be of a type compatible with
<parameter>value</parameter>).
Both <parameter>offset</parameter> and
<parameter>default</parameter> are evaluated