Re: time interval behaviour seems odd - Mailing list pgsql-hackers

From Tom Lane
Subject Re: time interval behaviour seems odd
Date
Msg-id 12291.1071696709@sss.pgh.pa.us
Whole thread Raw
In response to time interval behaviour seems odd  (Tilo Schwarz <mail@tilo-schwarz.de>)
Responses Re: time interval behaviour seems odd  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tilo Schwarz <mail@tilo-schwarz.de> writes:
> while trying to create a query this afternoon dealing with intervals, I 
> noticed the following behaviour and I wondered, if it is intended.

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

This appears to be intentional --- the comment in DecodeInterval says
                       /*                        * Only a signed integer? Then must assume a                        *
timezone-likeusage                        */                       type = DTK_HOUR;
 

whereas nearby code selects DTK_SECOND scaling for the cases of
fractional or unsigned numbers.  I'm not sure *why* it's intentional,
and am hesitant to change it without knowing what the rationale was.
There may be cases involving multiple fields that need the existing
behavior...

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

This is incontestably a bug.  Will fix for 7.4.1.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Larry Rosenman
Date:
Subject: Re: TODO list
Next
From: "Jonathan Gardner"
Date:
Subject: Re: TODO list