Re: SQL99, CREATE CAST, and initdb

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Thomas Lockhart <lockhart(at)fourpalms(dot)org>
Cc: PostgreSQL Hackers List <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SQL99, CREATE CAST, and initdb
Date: 2002-06-23 21:50:49
Message-ID: Pine.LNX.4.44.0206232248220.929-100000@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmx(dot)net

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2002-06-23 21:51:02 Re: COPY syntax improvement
Previous Message Peter Eisentraut 2002-06-23 21:49:34 Re: COPY syntax improvement