CREATE CAST requires immutable cast function?

Lists: pgsql-hackers
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: CREATE CAST requires immutable cast function?
Date: 2002-09-01 02:42:00
Message-ID: 16732.1030848120@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

It says here that CREATE CAST insists the cast function be immutable.
This seems wrong to me, in view of the fact that we have numerous
built-in casts that don't adhere to that rule --- for example,
timestamptz(date) is not immutable because it depends on the timezone
setting.

Perhaps there's a case for prohibiting volatile casts (as opposed to
stable ones), but I don't really see it. I'd prefer to just remove
this restriction. Comments?

regards, tom lane


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: CREATE CAST requires immutable cast function?
Date: 2002-09-01 02:45:00
Message-ID: 200209010245.g812j0b04425@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Perhaps there's a case for prohibiting volatile casts (as opposed to
> stable ones), but I don't really see it. I'd prefer to just remove
> this restriction. Comments?

Volatile casts can blow up. I am sure that is the reasoning. ;-)

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: CREATE CAST requires immutable cast function?
Date: 2002-09-03 18:53:03
Message-ID: Pine.LNX.4.44.0209031900390.1157-100000@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane writes:

> Perhaps there's a case for prohibiting volatile casts (as opposed to
> stable ones), but I don't really see it. I'd prefer to just remove
> this restriction. Comments?

I'm not wedded to it, I just modelled it after the SQL standard, but
evidently the volatility levels are different in detail. I would disallow
volatile casts in any case. There ought to be a minimal behavioral
contract between creators and users of types.

--
Peter Eisentraut peter_e(at)gmx(dot)net


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: CREATE CAST requires immutable cast function?
Date: 2002-09-03 20:09:40
Message-ID: 16219.1031083780@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> I'm not wedded to it, I just modelled it after the SQL standard, but
> evidently the volatility levels are different in detail. I would disallow
> volatile casts in any case. There ought to be a minimal behavioral
> contract between creators and users of types.

Shrug ... ISTM the behavior of a type is whatever the type creator says
it should be. Whether a volatile cast is a good idea is dubious
(I can't think of any good examples of one offhand) but I don't see the
argument for having the system restrict the type creator's choices.

regards, tom lane