Skip to content

Commit 23ddcd7

Browse files
committed
Docs: be explicit about datatype matching for lead/lag functions.
The default argument, if given, has to be of exactly the same datatype as the first argument; but this was not stated in so many words, and the error message you get about it might not lead your thought in the right direction. Per bug #13587 from Robert McGehee. A quick scan says that these are the only two built-in functions with two anyelement arguments and no other polymorphic arguments. There are plenty of cases of, eg, anyarray and anyelement, but those seem less likely to confuse. For instance this doesn't seem terribly hard to figure out: "function array_remove(integer[], numeric) does not exist". So I've contented myself with fixing these two cases.
1 parent 7c57449 commit 23ddcd7

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

doc/src/sgml/func.sgml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10603,9 +10603,9 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
1060310603
<primary>lag</primary>
1060410604
</indexterm>
1060510605
<function>
10606-
lag(<replaceable class="parameter">value</replaceable> <type>any</>
10606+
lag(<replaceable class="parameter">value</replaceable> <type>anyelement</>
1060710607
[, <replaceable class="parameter">offset</replaceable> <type>integer</>
10608-
[, <replaceable class="parameter">default</replaceable> <type>any</> ]])
10608+
[, <replaceable class="parameter">default</replaceable> <type>anyelement</> ]])
1060910609
</function>
1061010610
</entry>
1061110611
<entry>
@@ -10615,7 +10615,9 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
1061510615
returns <replaceable class="parameter">value</replaceable> evaluated at
1061610616
the row that is <replaceable class="parameter">offset</replaceable>
1061710617
rows before the current row within the partition; if there is no such
10618-
row, instead return <replaceable class="parameter">default</replaceable>.
10618+
row, instead return <replaceable class="parameter">default</replaceable>
10619+
(which must be of the same type as
10620+
<replaceable class="parameter">value</replaceable>).
1061910621
Both <replaceable class="parameter">offset</replaceable> and
1062010622
<replaceable class="parameter">default</replaceable> are evaluated
1062110623
with respect to the current row. If omitted,
@@ -10630,9 +10632,9 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
1063010632
<primary>lead</primary>
1063110633
</indexterm>
1063210634
<function>
10633-
lead(<replaceable class="parameter">value</replaceable> <type>any</>
10635+
lead(<replaceable class="parameter">value</replaceable> <type>anyelement</>
1063410636
[, <replaceable class="parameter">offset</replaceable> <type>integer</>
10635-
[, <replaceable class="parameter">default</replaceable> <type>any</> ]])
10637+
[, <replaceable class="parameter">default</replaceable> <type>anyelement</> ]])
1063610638
</function>
1063710639
</entry>
1063810640
<entry>
@@ -10642,7 +10644,9 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
1064210644
returns <replaceable class="parameter">value</replaceable> evaluated at
1064310645
the row that is <replaceable class="parameter">offset</replaceable>
1064410646
rows after the current row within the partition; if there is no such
10645-
row, instead return <replaceable class="parameter">default</replaceable>.
10647+
row, instead return <replaceable class="parameter">default</replaceable>
10648+
(which must be of the same type as
10649+
<replaceable class="parameter">value</replaceable>).
1064610650
Both <replaceable class="parameter">offset</replaceable> and
1064710651
<replaceable class="parameter">default</replaceable> are evaluated
1064810652
with respect to the current row. If omitted,

0 commit comments

Comments
 (0)