pg.ddx.io pgsql-docs@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Documentation Chapter 16: 8.21 3+ messages / 3 participants [nested] [flat]
* Documentation Chapter 16: 8.21 @ 2024-04-20 12:22 PG Doc comments form <noreply@postgresql.org> 0 siblings, 1 reply; 3+ messages in thread From: PG Doc comments form @ 2024-04-20 12:22 UTC (permalink / raw) To: pgsql-docs@lists.postgresql.org; +Cc: sciencewoken@gmail.com 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. And if there is a data type "any" in postgres too, how should it work as parameter and wheres the difference to "anyelement"? ^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Documentation Chapter 16: 8.21 @ 2024-04-22 12:38 Erik Wienhold <ewie@ewie.name> parent: PG Doc comments form <noreply@postgresql.org> 0 siblings, 1 reply; 3+ messages in thread From: Erik Wienhold @ 2024-04-22 12:38 UTC (permalink / raw) To: sciencewoken@gmail.com; pgsql-docs@lists.postgresql.org 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 ^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Documentation Chapter 16: 8.21 @ 2024-04-22 14:24 Tom Lane <tgl@sss.pgh.pa.us> parent: Erik Wienhold <ewie@ewie.name> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2024-04-22 14:24 UTC (permalink / raw) To: Erik Wienhold <ewie@ewie.name>; +Cc: sciencewoken@gmail.com; pgsql-docs@lists.postgresql.org Erik Wienhold <ewie@ewie.name> writes: > On 2024-04-20 14:22 +0200, PG Doc comments form wrote: >> I tryed to implement a safe_cast function with 2 parameters and a return of >> type "any" but it failed. >> 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. By the same token, there is just about no use-case for a function declared to return "any". The parser will not infer some other data type the way it would do for "anyelement", so you'll end up with an object that you can't do anything with. regards, tom lane ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2024-04-22 14:24 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2024-04-20 12:22 Documentation Chapter 16: 8.21 PG Doc comments form <noreply@postgresql.org> 2024-04-22 12:38 ` Erik Wienhold <ewie@ewie.name> 2024-04-22 14:24 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox