From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Chris Bandy <bandy(dot)chris(at)gmail(dot)com> |
Cc: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Unexpected casts while using date_trunc() |
Date: | 2018-05-25 14:41:55 |
Message-ID: | 5099.1527259315@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Chris Bandy <bandy(dot)chris(at)gmail(dot)com> writes:
> On 5/24/18 2:31 PM, Tom Lane wrote:
>> Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> writes:
>>> There's also the option of adding an explicit function
>>> date_trunc(text,date) returns date, which is a workaround that I (and
>>> probably quite a few other people) have used.
> Are we in agreement that the return type should be date?
That is a good question, actually. That would be a larger behavior change
than just avoiding the undesired conversion to TZ. I had imagined this
as just being equivalent to date_trunc(text, date::timestamp). Casting
the result back down to date seems safe, though.
Another thing to consider is that the effective range of date is wider
than timestamp's, meaning coerce-to-timestamp can fail. Is it worth
providing a whole additional code path so we never coerce the date to
timestamp at all? I'd tend to think not, but perhaps somebody wants to
argue differently.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2018-05-25 14:44:16 | Re: SCRAM with channel binding downgrade attack |
Previous Message | Tom Lane | 2018-05-25 14:33:52 | Re: Avoiding Tablespace path collision for primary and standby |