time interval behaviour seems odd - Mailing list pgsql-hackers

From Tilo Schwarz
Subject time interval behaviour seems odd
Date
Msg-id 200312172056.38376.mail@tilo-schwarz.de
Whole thread Raw
Responses Re: time interval behaviour seems odd
List pgsql-hackers
Hi,

while trying to create a query this afternoon dealing with intervals, I 
noticed the following behaviour and I wondered, if it is intended. (It was 
non-intuitive to me and if there was a warning in the docs i missed it.)
The lines marked   <---   make me wonder ...

tschwarz=> select version();                               version
------------------------------------------------------------------------PostgreSQL 7.3.2 on i386-pc-linux-gnu, compiled
byGCC gcc (GCC) 3.2.3
 
(1 row)

tschwarz=> select '1'::interval;interval
----------00:00:01
(1 row)

tschwarz=> select -'1'::interval;?column?
------------00:00:01
(1 row)

tschwarz=> select '-1'::interval;interval
-----------01:00        <---
(1 row)

tschwarz=> select -'-1'::interval;?column?
----------01:00        <---
(1 row)


Now with 1.0 everything looks fine:


tschwarz=> select '1.0'::interval;interval
----------00:00:01
(1 row)

tschwarz=> select -'1.0'::interval;?column?
------------00:00:01
(1 row)

tschwarz=> select '-1.0'::interval;interval
------------00:00:01
(1 row)

tschwarz=> select -'-1.0'::interval;?column?
----------00:00:01
(1 row)


But look at 0.1:


tschwarz=> select '0.1'::interval; interval
-------------00:00:00.10
(1 row)

tschwarz=> select -'0.1'::interval;  ?column?
---------------00:00:00.10
(1 row)

tschwarz=> select '-0.1'::interval; interval
-------------00:00:00.10   <---
(1 row)

tschwarz=> select -'-0.1'::interval;  ?column?
---------------00:00:00.10   <---
(1 row)



pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: [PATCHES] Double Backslash example patch
Next
From: Marko Zmak
Date:
Subject: TODO list