From: | Darren Duncan <darren(at)darrenduncan(dot)net> |
---|---|
To: | Jaime Casanova <jaime(at)2ndquadrant(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: DOMAINs and CASTs |
Date: | 2011-05-15 07:13:16 |
Message-ID: | 4DCF7D0C.9000108@darrenduncan.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Jaime Casanova wrote:
> On Sat, May 14, 2011 at 8:42 PM, Darren Duncan <darren(at)darrenduncan(dot)net> wrote:
>> First of all, what if "cast(timestamp as int)" was already defined? Which
>> cast then would you expect to be invoked here?
>>
>> '1800-01-01 00:00:00'::int
>
> i will expect an error in that case... what you're doing there is
> casting an "unknown" to integer, for that to be valid you need an
> intermediate cast to timestamp or in my case to datetime
Sorry, my bad; I meant to say (might be slightly misspelled):
('1800-01-01 00:00:00'::timestamp)::int
Now, since all values of a DOMAIN are also values of the base type the DOMAIN is
defined as being a subset of, then the sub-expression within the parenthesis
denotes a value that is both a timestamp and a datetime at the same time.
So, if a generic "CAST(timestamp as int)" is already defined, and you define a
"CAST(datetime as int)", then what should the above code (correct for
misspelling) do, or should it fail?
-- Darren Duncan
From | Date | Subject | |
---|---|---|---|
Next Message | Jaime Casanova | 2011-05-15 07:26:16 | Re: DOMAINs and CASTs |
Previous Message | Jaime Casanova | 2011-05-15 06:43:05 | Re: DOMAINs and CASTs |