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@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.