Re: SQL99, CREATE CAST, and initdb - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: SQL99, CREATE CAST, and initdb
Date
Msg-id Pine.LNX.4.44.0206232248220.929-100000@localhost.localdomain
Whole thread Raw
In response to Re: SQL99, CREATE CAST, and initdb  (Thomas Lockhart <lockhart@fourpalms.org>)
List pgsql-hackers
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





pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Index Scans become Seq Scans after VACUUM ANALYSE
Next
From: Bruce Momjian
Date:
Subject: Re: A fairly obvious optimization?