Commit 31d846e0 authored by Tom Lane's avatar Tom Lane

Doc: clarify behavior of "anyrange" pseudo-type.

I noticed that we completely failed to document the restriction
that an "anyrange" result type has to be inferred from an "anyrange"
input.  The docs also were less clear than they could be about the
relationship between "anyrange" and "anyarray".

It's been like this all along, so back-patch.
parent 9d9784c8
...@@ -256,9 +256,11 @@ ...@@ -256,9 +256,11 @@
<type>anyarray</type> positions must be an array whose elements are <type>anyarray</type> positions must be an array whose elements are
the same type appearing in the <type>anyelement</type> positions. the same type appearing in the <type>anyelement</type> positions.
Similarly, if there are positions declared <type>anyrange</type> Similarly, if there are positions declared <type>anyrange</type>
and others declared <type>anyelement</type>, the actual range type in and others declared <type>anyelement</type> or <type>anyarray</type>,
the <type>anyrange</type> positions must be a range whose subtype is the actual range type in the <type>anyrange</type> positions must be a
the same type appearing in the <type>anyelement</type> positions. range whose subtype is the same type appearing in
the <type>anyelement</type> positions and the same as the element type
of the <type>anyarray</type> positions.
<type>anynonarray</type> is treated exactly the same as <type>anyelement</type>, <type>anynonarray</type> is treated exactly the same as <type>anyelement</type>,
but adds the additional constraint that the actual type must not be but adds the additional constraint that the actual type must not be
an array type. an array type.
...@@ -289,6 +291,17 @@ ...@@ -289,6 +291,17 @@
will only accept arrays of enum types. will only accept arrays of enum types.
</para> </para>
<para>
In most cases, the parser can infer the actual data type for a
polymorphic result type from arguments that are of a different
polymorphic type; for example <type>anyarray</type> can be deduced
from <type>anyelement</type> or vice versa. The exception is that a
polymorphic result of type <type>anyrange</type> requires an argument
of type <type>anyrange</type>; it cannot be deduced
from <type>anyarray</type> or <type>anyelement</type> arguments. This
is because there could be multiple range types with the same subtype.
</para>
<para> <para>
Note that <type>anynonarray</type> and <type>anyenum</type> do not represent Note that <type>anynonarray</type> and <type>anyenum</type> do not represent
separate type variables; they are the same type as separate type variables; they are the same type as
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment