Re: Timestamp operator error - Mailing list pgsql-sql

From Tom Lane
Subject Re: Timestamp operator error
Date
Msg-id 27215.1014697694@sss.pgh.pa.us
Whole thread Raw
In response to Timestamp operator error  ("Josh Berkus" <josh@agliodbs.com>)
Responses Re: Timestamp operator error  ("Josh Berkus" <josh@agliodbs.com>)
List pgsql-sql
"Josh Berkus" <josh@agliodbs.com> writes:
> Potentially a real problem bug in 7.2:

> staffos=# select ('6 days'::INTERVAL + current_timestamp);
>       ?column?
> ---------------------
>  2002-02-25 00:00:00
> (1 row)

Well, 7.1's not materially better:

test71=# select ('6 days'::INTERVAL + current_timestamp);?column?
----------23:15:27
(1 row)

AFAICT, what's happening in 7.2 is that the closest-match operator
is "time + date", so it casts the interval to time (yielding 0 hours),
and casts current_timestamp to date (yielding midnight today)
and adds.

7.1 evidently found some different, but equally unintuitive conversion
path.  Probably the difference in behavior is not the result of any
algorithm change, but the addition or subtraction of a type-conversion
operator.

I suspect this is good ammunition for the argument I've made from time
to time that we have too many implicit conversions, not too few.
        regards, tom lane


pgsql-sql by date:

Previous
From: "Josh Berkus"
Date:
Subject: Timestamp operator error
Next
From: "Josh Berkus"
Date:
Subject: Re: Timestamp operator error