Tom Lane writes:
> What I'd like to suggest (for 7.3 or later) is adding a boolean column
> to pg_proc that indicates "can be implicit coercion".
Great! I've always wished for this sort of thing.
I think from this there are only a few more steps to the full SQL99
specification of user-defined casts. In particular it'd involve two
boolean flags: one that means "this is a cast function" (the function is
used internally for a CAST() invocation), and one for allowing it to be
used for automatic conversion. We currently don't have the first one on
the radar because we use the function name and argument types as the
indicator.
One more thing is that instead of looking up a cast function from type A
to type B as "returns A, is named A, takes arg B" it could be looked up as
"returns A, takes arg B, is a cast function", which would generalize this
whole thing a bit more.
References: SQL99 Part 2 11.49, 11.52 (I haven't read the whole thing,
but I think it's the idea.)
--
Peter Eisentraut peter_e@gmx.net