Skip to content

Commit fc3649f

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 fe939d9 commit fc3649f

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
@@ -13216,9 +13216,9 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
1321613216
<primary>lag</primary>
1321713217
</indexterm>
1321813218
<function>
13219-
lag(<replaceable class="parameter">value</replaceable> <type>any</>
13219+
lag(<replaceable class="parameter">value</replaceable> <type>anyelement</>
1322013220
[, <replaceable class="parameter">offset</replaceable> <type>integer</>
13221-
[, <replaceable class="parameter">default</replaceable> <type>any</> ]])
13221+
[, <replaceable class="parameter">default</replaceable> <type>anyelement</> ]])
1322213222
</function>
1322313223
</entry>
1322413224
<entry>
@@ -13228,7 +13228,9 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
1322813228
returns <replaceable class="parameter">value</replaceable> evaluated at
1322913229
the row that is <replaceable class="parameter">offset</replaceable>
1323013230
rows before the current row within the partition; if there is no such
13231-
row, instead return <replaceable class="parameter">default</replaceable>.
13231+
row, instead return <replaceable class="parameter">default</replaceable>
13232+
(which must be of the same type as
13233+
<replaceable class="parameter">value</replaceable>).
1323213234
Both <replaceable class="parameter">offset</replaceable> and
1323313235
<replaceable class="parameter">default</replaceable> are evaluated
1323413236
with respect to the current row. If omitted,
@@ -13243,9 +13245,9 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
1324313245
<primary>lead</primary>
1324413246
</indexterm>
1324513247
<function>
13246-
lead(<replaceable class="parameter">value</replaceable> <type>any</>
13248+
lead(<replaceable class="parameter">value</replaceable> <type>anyelement</>
1324713249
[, <replaceable class="parameter">offset</replaceable> <type>integer</>
13248-
[, <replaceable class="parameter">default</replaceable> <type>any</> ]])
13250+
[, <replaceable class="parameter">default</replaceable> <type>anyelement</> ]])
1324913251
</function>
1325013252
</entry>
1325113253
<entry>
@@ -13255,7 +13257,9 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
1325513257
returns <replaceable class="parameter">value</replaceable> evaluated at
1325613258
the row that is <replaceable class="parameter">offset</replaceable>
1325713259
rows after the current row within the partition; if there is no such
13258-
row, instead return <replaceable class="parameter">default</replaceable>.
13260+
row, instead return <replaceable class="parameter">default</replaceable>
13261+
(which must be of the same type as
13262+
<replaceable class="parameter">value</replaceable>).
1325913263
Both <replaceable class="parameter">offset</replaceable> and
1326013264
<replaceable class="parameter">default</replaceable> are evaluated
1326113265
with respect to the current row. If omitted,

0 commit comments

Comments
 (0)