Skip to content

Commit 7c0c4d0

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 b8c9135 commit 7c0c4d0

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

doc/src/sgml/func.sgml

+10-6
Original file line numberDiff line numberDiff line change
@@ -13606,9 +13606,9 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
1360613606
<primary>lag</primary>
1360713607
</indexterm>
1360813608
<function>
13609-
lag(<replaceable class="parameter">value</replaceable> <type>any</>
13609+
lag(<replaceable class="parameter">value</replaceable> <type>anyelement</>
1361013610
[, <replaceable class="parameter">offset</replaceable> <type>integer</>
13611-
[, <replaceable class="parameter">default</replaceable> <type>any</> ]])
13611+
[, <replaceable class="parameter">default</replaceable> <type>anyelement</> ]])
1361213612
</function>
1361313613
</entry>
1361413614
<entry>
@@ -13618,7 +13618,9 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
1361813618
returns <replaceable class="parameter">value</replaceable> evaluated at
1361913619
the row that is <replaceable class="parameter">offset</replaceable>
1362013620
rows before the current row within the partition; if there is no such
13621-
row, instead return <replaceable class="parameter">default</replaceable>.
13621+
row, instead return <replaceable class="parameter">default</replaceable>
13622+
(which must be of the same type as
13623+
<replaceable class="parameter">value</replaceable>).
1362213624
Both <replaceable class="parameter">offset</replaceable> and
1362313625
<replaceable class="parameter">default</replaceable> are evaluated
1362413626
with respect to the current row. If omitted,
@@ -13633,9 +13635,9 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
1363313635
<primary>lead</primary>
1363413636
</indexterm>
1363513637
<function>
13636-
lead(<replaceable class="parameter">value</replaceable> <type>any</>
13638+
lead(<replaceable class="parameter">value</replaceable> <type>anyelement</>
1363713639
[, <replaceable class="parameter">offset</replaceable> <type>integer</>
13638-
[, <replaceable class="parameter">default</replaceable> <type>any</> ]])
13640+
[, <replaceable class="parameter">default</replaceable> <type>anyelement</> ]])
1363913641
</function>
1364013642
</entry>
1364113643
<entry>
@@ -13645,7 +13647,9 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
1364513647
returns <replaceable class="parameter">value</replaceable> evaluated at
1364613648
the row that is <replaceable class="parameter">offset</replaceable>
1364713649
rows after the current row within the partition; if there is no such
13648-
row, instead return <replaceable class="parameter">default</replaceable>.
13650+
row, instead return <replaceable class="parameter">default</replaceable>
13651+
(which must be of the same type as
13652+
<replaceable class="parameter">value</replaceable>).
1364913653
Both <replaceable class="parameter">offset</replaceable> and
1365013654
<replaceable class="parameter">default</replaceable> are evaluated
1365113655
with respect to the current row. If omitted,

0 commit comments

Comments
 (0)