summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-08-25 19:12:34 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2015-08-25 19:12:34 -0400
commit8cffc4f5bdfbd41e27680fca27d82ae939cdeda8 (patch)
treee3d1298d3438aaa146e8ddf40f6297ef040d330c
parentd951d6065dbf11cca35fd1f7741156d0c55dcd7e (diff)
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.
-rw-r--r--doc/src/sgml/func.sgml16
1 files changed, 10 insertions, 6 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 87c3e5a1ee1..4e0715aab13 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -11790,9 +11790,9 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
<primary>lag</primary>
</indexterm>
<function>
- lag(<replaceable class="parameter">value</replaceable> <type>any</>
+ lag(<replaceable class="parameter">value</replaceable> <type>anyelement</>
[, <replaceable class="parameter">offset</replaceable> <type>integer</>
- [, <replaceable class="parameter">default</replaceable> <type>any</> ]])
+ [, <replaceable class="parameter">default</replaceable> <type>anyelement</> ]])
</function>
</entry>
<entry>
@@ -11802,7 +11802,9 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
returns <replaceable class="parameter">value</replaceable> evaluated at
the row that is <replaceable class="parameter">offset</replaceable>
rows before the current row within the partition; if there is no such
- row, instead return <replaceable class="parameter">default</replaceable>.
+ row, instead return <replaceable class="parameter">default</replaceable>
+ (which must be of the same type as
+ <replaceable class="parameter">value</replaceable>).
Both <replaceable class="parameter">offset</replaceable> and
<replaceable class="parameter">default</replaceable> are evaluated
with respect to the current row. If omitted,
@@ -11817,9 +11819,9 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
<primary>lead</primary>
</indexterm>
<function>
- lead(<replaceable class="parameter">value</replaceable> <type>any</>
+ lead(<replaceable class="parameter">value</replaceable> <type>anyelement</>
[, <replaceable class="parameter">offset</replaceable> <type>integer</>
- [, <replaceable class="parameter">default</replaceable> <type>any</> ]])
+ [, <replaceable class="parameter">default</replaceable> <type>anyelement</> ]])
</function>
</entry>
<entry>
@@ -11829,7 +11831,9 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
returns <replaceable class="parameter">value</replaceable> evaluated at
the row that is <replaceable class="parameter">offset</replaceable>
rows after the current row within the partition; if there is no such
- row, instead return <replaceable class="parameter">default</replaceable>.
+ row, instead return <replaceable class="parameter">default</replaceable>
+ (which must be of the same type as
+ <replaceable class="parameter">value</replaceable>).
Both <replaceable class="parameter">offset</replaceable> and
<replaceable class="parameter">default</replaceable> are evaluated
with respect to the current row. If omitted,