Docs: be explicit about datatype matching for lead/lag functions.
authorTom Lane
Tue, 25 Aug 2015 23:11:17 +0000 (19:11 -0400)
committerTom Lane
Tue, 25 Aug 2015 23:11:35 +0000 (19:11 -0400)
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.

doc/src/sgml/func.sgml

index 730ac35b48b64d01fc79cf49c2e9fa76c8c48a3e..1ea9e58f54e6f3a54befb19da0495552c09eced2 100644 (file)
@@ -13216,9 +13216,9 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
         lag
        
        
-         lag(value any
+         lag(value anyelement
              [, offset integer
-             [, default any ]])
+             [, default anyelement ]])
        
       
       
@@ -13228,7 +13228,9 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
        returns value evaluated at
        the row that is offset
        rows before the current row within the partition; if there is no such
-       row, instead return default.
+       row, instead return default
+       (which must be of the same type as
+       value).
        Both offset and
        default are evaluated
        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;
         lead
        
        
-         lead(value any
+         lead(value anyelement
               [, offset integer
-              [, default any ]])
+              [, default anyelement ]])
        
       
       
@@ -13255,7 +13257,9 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
        returns value evaluated at
        the row that is offset
        rows after the current row within the partition; if there is no such
-       row, instead return default.
+       row, instead return default
+       (which must be of the same type as
+       value).
        Both offset and
        default are evaluated
        with respect to the current row.  If omitted,