Re: DOMAINs and CASTs - Mailing list pgsql-hackers

From Darren Duncan
Subject Re: DOMAINs and CASTs
Date
Msg-id 4DCF7D0C.9000108@darrenduncan.net
Whole thread Raw
In response to Re: DOMAINs and CASTs  (Jaime Casanova <jaime@2ndquadrant.com>)
Responses Re: DOMAINs and CASTs  (Jaime Casanova <jaime@2ndquadrant.com>)
List pgsql-hackers
Jaime Casanova wrote:
> On Sat, May 14, 2011 at 8:42 PM, Darren Duncan <darren@darrenduncan.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


pgsql-hackers by date:

Previous
From: Jaime Casanova
Date:
Subject: Re: DOMAINs and CASTs
Next
From: Jaime Casanova
Date:
Subject: Re: DOMAINs and CASTs