Tom Lane-2 wrote
> you do have one conceptual error: anyarray to anyelement is supposed
> to return the element type of the input array type. So when you pass
> TEXT[] to this function, the SQL parser decides that the expected
> result type is TEXT.
While this is how it behaves in practice I did not find this described in
the documentation.
There are three relevant psuedo-types in play for this:
anyelement
anyarray
anynonarray
Since the documentation states that anyelement can take on array types the
OP deduced that these signatures:
func(anyelement) returns anyarray
func(anyarray) returns anyelement --including arrays...
if provided array input would be able to echo out the same unmodified array.
if you truly want to enforce an up/down-grading function you would write:
func(anynonarray) returns anyarray
func(anyarray) returns anynonarray
I don't see how the behavior can reasonably change at this point but a
second opinion on the current documentation wouldn't hurt.
http://www.postgresql.org/docs/9.3/interactive/extend-type-system.html#EXTEND-TYPES-POLYMORPHIC
David J.
--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Odd-behavior-in-functions-w-anyarray-anyelement-tp5770537p5777628.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.