Re: Casting from a domain
| От | Tom Lane |
|---|---|
| Тема | Re: Casting from a domain |
| Дата | |
| Msg-id | 10873.1109968817@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Casting from a domain ("Jim C. Nasby" <decibel@decibel.org>) |
| Ответы |
Re: Casting from a domain
|
| Список | pgsql-general |
"Jim C. Nasby" <decibel@decibel.org> writes:
> decibel=# create cast (interval as rrs.seconds) WITH FUNCTION rrs.interval_to_seconds(interval) AS IMPLICIT;
> CREATE CAST
> decibel=# select cast('1 month'::interval AS seconds);
> ERROR: cannot cast type interval to seconds
Given the current coercion rules, we should probably disallow attempts
to define casts that involve domains. Casts are on base types. The
down-cast from a domain to its base type is hardwired, and the up-cast
from base type to domain is too (with invocation of any constraints
that may apply). Adding random user-defined casts to this would
probably just create confusion and ambiguity. In particular, this
was already meaningless:
decibel=# create domain rrs.seconds as double precision;
CREATE DOMAIN
decibel=# create cast (double precision as rrs.seconds) WITHOUT FUNCTION AS IMPLICIT;
CREATE CAST
since the presence of the cast might be thought to justify coercing
floats to "seconds" without invoking domain constraints.
regards, tom lane
В списке pgsql-general по дате отправления: