Re: Unexpected casts while using date_trunc()

2018-05-25 Thread Tom Lane
Chris Bandy writes: > On 5/24/18 2:31 PM, Tom Lane wrote: >> Andrew Gierth 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

Re: Unexpected casts while using date_trunc()

2018-05-25 Thread Chris Bandy
On 5/24/18 2:31 PM, Tom Lane wrote: Andrew Gierth writes: "Tom" == Tom Lane writes: Tom> Yeah. There are two relevant variants of date_trunc(): [...] Tom> So we probably ought to change the docs here. There's also the option of adding an explicit function date_trunc(text,date) return

Re: Unexpected casts while using date_trunc()

2018-05-24 Thread Tom Lane
Andrew Gierth writes: > "Tom" == Tom Lane writes: > Tom> Yeah. There are two relevant variants of date_trunc(): > [...] > Tom> So we probably ought to change the docs here. > There's also the option of adding an explicit function > date_trunc(text,date) returns date, which is a workaround th

Re: Unexpected casts while using date_trunc()

2018-05-24 Thread Andrew Gierth
> "Tom" == Tom Lane writes: Tom> Yeah. There are two relevant variants of date_trunc(): [...] Tom> So we probably ought to change the docs here. 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 f

Re: Unexpected casts while using date_trunc()

2018-05-24 Thread Tom Lane
Chris Bandy writes: > The documentation explains that DATE is first cast to TIMESTAMP. (As I > understand it, this is an immutable cast; sounds find and appropriate.) > https://www.postgresql.org/docs/current/static/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC > But in my testing, the date va

Unexpected casts while using date_trunc()

2018-05-24 Thread Chris Bandy
I have an application generating the following query on a DATE column in PostgreSQL 10.1: > SELECT TO_CHAR(DATE_TRUNC('month', jobs.active_until), '-MM') > FROM jobs > GROUP BY DATE_TRUNC('month', jobs.active_until) > LIMIT 500 I wanted to support it with an expression index, but was surpri