On Tue, May 16, 2006 at 10:29:27AM -0700, Don Y wrote:
> Given a user defined type foo...
> I've created several casts to/from foo and built-in types.
> I had adopted a naming convention of:
> baz foo_to_baz(foo);
> foo foo_from_baz(baz);
>
> But:
<snip>
> I don't see how I can do this in my declarations. E.g.,
> if I have
> baz = {int4, text, float8, ...}
> then I end up with several (C) functions all named foo()
> but each taking a different argument type (baz). Since
> C doesn't support more than a single namespace for functions,
> this just won't work.
>
> What am I failing to see, here?
That the name of the function in C doesn't have to be the same as the
name of the function in SQL. You can even define many SQL functions
that all refer to the same C function.
So in your C file yo call them:
cast_foo_to_baz()
and in the SQL you declare as just:
baz()
Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.