Thomas Lockhart writes:
> It doesn't match perfectly in that one field is ignored as being
> (afaict) redundant for us. The basic definition from SQL99 is
>
> CREATE CAST(from AS to) WITH FUNCTION func(args) [AS ASSIGNMENT]
>
> I can map this to something equivalent to
>
> CREATE FUNCTION to(from) RETURNS to AS 'select func($1)' LANGUAGE 'sql';
>
> with another clause or two to get the implicit coersion enabled, and
> ignoring the "args" field(s).
I think this is wrong. When you call CREATE CAST ... WITH FUNCTION
func(args) then func(args) must already exist. So the closest you could
map it to would be
ALTER FUNCTION to(from) IMPLICIT CAST
iff the name of the function and the target data type agree. (Of course
this command doesn't exit, but you get the idea.) The SQL99 feature is
more general than ours, but in order to use if effectively we would need
to maintain another index on pg_proc. Tom Lane once opined that that
would be too costly.
--
Peter Eisentraut peter_e@gmx.net