Re: generic builtin functions

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: generic builtin functions
Date: 2005-11-10 20:42:39
Message-ID: 20051110204239.GK19686@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Nov 10, 2005 at 03:28:55PM -0500, Andrew Dunstan wrote:
> Eek! I would be prepared to go to quite a lot of trouble to avoid that.
>
> My idea was to have the functions that need access to the text values
> look up fcinfo->flinfo->fn_oid and then use that to look up the type
> info. But that would mean we would need pg_proc entries for these
> functions for each enum, even if it's the same function underneath,
> wouldn't it?

There are functions in the backend already to help you:

argoid = procLookupArgType( fcinfo->flinfo->fn_oid, 0 );

returns the OID of the type of your first arguments.

returnoid = procLookupRettype( fcinfo->flinfo->fn_oid );

returns your return type. These work even if you are in a type
input/output function.

Here is some code that uses these:

http://svana.org/kleptog/pgsql/taggedtypes.html

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)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.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2005-11-10 20:44:06 Re: generic builtin functions
Previous Message Tom Lane 2005-11-10 20:36:41 Re: generic builtin functions