From: | Erik Wienhold <ewie(at)ewie(dot)name> |
---|---|
To: | sciencewoken(at)gmail(dot)com, pgsql-docs(at)lists(dot)postgresql(dot)org |
Subject: | Re: Documentation Chapter 16: 8.21 |
Date: | 2024-04-22 12:38:48 |
Message-ID: | plfzlyggyd5grlwtvtvrcllusjav66guzpytancgca7d4ly7a6@ogkqd3e7uavu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-docs |
On 2024-04-20 14:22 +0200, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/16/datatype-pseudo.html
> Description:
>
> I tryed to implement a safe_cast function with 2 parameters and a return of
> type "any" but it failed. I get a syntax error, if I use "any" as a data
> type, because it is a sql function (similar to array contains) and not a
> data type.
You have to use a double-quoted identifier, i.e. "any" instead of ANY.
But it won't work with PL languages:
=> create function f() returns "any" as 'select 1' language sql;
ERROR: SQL functions cannot return type "any"
You have to code a C function for that.
> And if there is a data type "any" in postgres too, how should it work as
> parameter and wheres the difference to "anyelement"?
"any" is like "anyelement" just without the polymorphic[1] behavior.
So an argument of type "any" does not determine the result type for
"anyarray" as "anyelement" would.
[1] https://www.postgresql.org/docs/current/extend-type-system.html#EXTEND-TYPES-POLYMORPHIC
--
Erik
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-04-22 14:24:21 | Re: Documentation Chapter 16: 8.21 |
Previous Message | Daniel Gustafsson | 2024-04-22 08:45:15 | Re: The prompt is not displayed correctly in the example on psql page |