Re: any, anyelement, and anyarray
От | Tom Lane |
---|---|
Тема | Re: any, anyelement, and anyarray |
Дата | |
Msg-id | 24514.1147446402@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: any, anyelement, and anyarray (Thomas Hallgren <thomas@tada.se>) |
Список | pgsql-hackers |
Thomas Hallgren <thomas@tada.se> writes: > I've been trying to use "any" with no luck. How do I declare a function > that takes an "any" as a parameter? ANY is a reserved word, so to use it as a type name you need quotes: regression=# create function foo("any") returns int as '' language sql; ERROR: SQL functions cannot have arguments of type "any" (This may be another reason why we went for "anyelement" ...) > I realize that it would be trickier to return an "any" since the > expected return type must somehow be derived from the context where the > function was called. You really can't use "any" as a function result type; it's not sensible because there's no way to infer an actual type. There are functions for which an "any" argument type is sensible, eg count(*), but I don't see a use for this pseudotype as a result type. > Wouldn't it be a good idea to let the SQL parser recognize the > anyelement[] construct as a synonym for anyarray? [ shrug... ] Can't get excited about it. It'd complicate and confuse the documentation, as well as the code, for zero functional improvement. I also have a gut feeling that this is really wrong anyhow. anyarray isn't an array, it's a placeholder. regards, tom lane
В списке pgsql-hackers по дате отправления: