Skip site navigation (1) Skip section navigation (2)

Re: timestamp arithmetic (a possible bug?)

From: Ilir Gashi <I(dot)Gashi(at)city(dot)ac(dot)uk>
To: Theodore Petrosky <tedpet5(at)yahoo(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org,Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
Subject: Re: timestamp arithmetic (a possible bug?)
Date: 2004-07-02 13:23:55
Message-ID: E1BgO1D-0003Rt-00@ms2.city.ac.uk (view raw or flat)
Thread:
Lists: pgsql-bugs
On Jul 2 2004, Achilleus Mantzios wrote:

> SELECT '01.01.2004 10:00:00'::timestamp + ('01.01.2004
> 10:01:00'::timestamp - '01.01.2004 10:00:00'::timestamp)::interval;
>      ?column?
> ---------------------
> 2004-01-01 10:01:00
> (1 row)
>
> works fine in my 7.4.2

Yes. I've just tried it in PostgreSQL 7.2 and it works fine there as well.



On Jul 2 2004, Theodore Petrosky wrote:

> Interesting....
> 
> If I reverse the order it works...
> 
> agencysacks=# SELECT CAST('01.01.2004 10:00:00' AS
> TIMESTAMP) + (CAST('01.01.2004 10:01:00' AS TIMESTAMP)
> - CAST('01.01.2004 10:00:00' AS TIMESTAMP)) as answer;
>        answer        
> ---------------------
>  2004-01-01 10:01:00
> (1 row)

Yes. The above works for me as well in 7.2. 


> 
> However your original...
> 
> 
> agencysacks=# SELECT (CAST('01.01.2004 10:01:00' AS
> TIMESTAMP) - CAST('01.01.2004 10:00:00' AS TIMESTAMP))
> + CAST('01.01.2004 10:00:00' AS TIMESTAMP);
> ERROR:  operator does not exist: interval + timestamp
> without time zone
> HINT:  No operator matches the given name and argument
> type(s). You may need to add explicit type casts.
> 
> 
> agencysacks=# select version();
>                                                       
>   version                                             
>            
>  
>  
> -------------------------------------------------------------------------------------------------------------------------
>  PostgreSQL 7.4.2 on powerpc-apple-darwin7.2.0,
> compiled by GCC gcc (GCC) 3.3 20030304 (Apple
> Computer, Inc. build 1495)
> (1 row)
> 
> Looks like postgresql demands the  order to be 
> timestamp +- interval.
> 
> Ted

I am not getting the error above. I get the incorrect result as reported in 
my original report. Does this mean that this was a buggy behaviour in 7.2 
and then was changed in the latter releases to give the error message that 
7.4.2 is giving?

Thanks for the quick responses. 

Best regards,

Ilir
____________________________________________

Ilir Gashi 
PhD Student 
Centre for Software Reliability 
City University 
Northampton Square, London EC1V 0HB
email: i(dot)gashi(at)city(dot)ac(dot)uk
website: http://www.csr.city.ac.uk/csr_city/staff/gashi/
____________________________________________


pgsql-bugs by date

Next:From: Tom LaneDate: 2004-07-02 13:55:04
Subject: Re: timestamp arithmetic (a possible bug?)
Previous:From: Bruno Wolff IIIDate: 2004-07-02 13:12:58
Subject: Re: BUG #1186: Broken Index?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group