From: | David Johnston <polobo(at)yahoo(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Odd behavior in functions w/ anyarray & anyelement |
Date: | 2013-11-10 05:21:59 |
Message-ID: | 1384060919649-5777628.post@n5.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2013-11-10 06:16:30 | Re: Odd behavior in functions w/ anyarray & anyelement |
Previous Message | Tom Lane | 2013-11-10 04:49:55 | Re: Odd behavior in functions w/ anyarray & anyelement |