aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-03-17 15:05:17 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2020-03-17 15:05:17 -0400
commitf99363e23102c1dceb83d066e3b16c4688079634 (patch)
treed07f8b3c5fe8c38baa7d02cb14b0c20b70e2d538
parentda254148f4deff3cc5f4a5003e5b3c026c04f4a9 (diff)
downloadpostgresql-f99363e23102c1dceb83d066e3b16c4688079634.tar.gz
postgresql-f99363e23102c1dceb83d066e3b16c4688079634.zip
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.
-rw-r--r--doc/src/sgml/extend.sgml21
1 files changed, 17 insertions, 4 deletions
diff --git a/doc/src/sgml/extend.sgml b/doc/src/sgml/extend.sgml
index 74130dc51d1..afd2b8f9fcc 100644
--- a/doc/src/sgml/extend.sgml
+++ b/doc/src/sgml/extend.sgml
@@ -225,10 +225,12 @@
<type>anyarray</type> positions must be an array whose elements are
the same type appearing in the <type>anyelement</type> positions.
Similarly, if there are positions declared <type>anyrange</type>
- and others declared <type>anyelement</type>, the actual range type in
- the <type>anyrange</type> positions must be a range whose subtype is
- the same type appearing in the <type>anyelement</type> positions.
- <type>anynonarray</> is treated exactly the same as <type>anyelement</>,
+ and others declared <type>anyelement</type> or <type>anyarray</type>,
+ the actual range type in the <type>anyrange</type> positions must be a
+ 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>,
but adds the additional constraint that the actual type must not be
an array type.
<type>anyenum</> is treated exactly the same as <type>anyelement</>,
@@ -259,6 +261,17 @@
</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>
Note that <type>anynonarray</> and <type>anyenum</> do not represent
separate type variables; they are the same type as
<type>anyelement</type>, just with an additional constraint. For