Determining return type of polymorphic function

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Determining return type of polymorphic function
Дата
Msg-id 20050811153328.GC13966@svana.org
обсуждение исходный текст
Ответы Re: Determining return type of polymorphic function  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
[Please CC any replies so I don't have to follow them via the archives]

Hi,

I'm trying to create a set of types that are going to share the INPUT
and OUTPUT functions (written in C). For output you can determine the
type from the arguments, but for INPUT you can't. The prototype is
restricted (by CREATE TYPE) and you can't specify "anyelement" as the
return type because none of the arguments use it.

My current way around that is to create an alias to the function with
different names for each type, but get_fn_expr_rettype() doesn't appear
to be filled in anyway (fcinfo->flinfo->fn_expr == NULL).

What I'm trying to do now is use fcinfo->flinfo->fn_oid to lookup
pg_proc and get the return type from there, but something tells me
there must be an easier way.

Or to put it another way, if I define a function like:

CREATE FUNCTION myfunction(cstring, oid, integer)
RETURNS mytype AS 'mylib.so' LANGUAGE 'C';

How can I determine I'm supposed to return a "mytype"? I'm running 7.4
if it matters...

Thanks in advance,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Project proposal/comments please - query optimization
Следующее
От: Josh Berkus
Дата:
Сообщение: SELECT for UPDATE and outer join?