Re: Timestamp operator error

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Josh Berkus" <josh(at)agliodbs(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Timestamp operator error
Date: 2002-02-26 04:28:14
Message-ID: 27215.1014697694@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Josh Berkus" <josh(at)agliodbs(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2002-02-26 04:34:36 Re: Timestamp operator error
Previous Message Josh Berkus 2002-02-26 04:10:29 Timestamp operator error