Re: time interval behaviour seems odd

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tilo Schwarz <mail(at)tilo-schwarz(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: time interval behaviour seems odd
Date: 2003-12-17 21:31:49
Message-ID: 12291.1071696709@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tilo Schwarz <mail(at)tilo-schwarz(dot)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-like usage
*/
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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jonathan Gardner 2003-12-17 21:38:56 Re: TODO list
Previous Message Larry Rosenman 2003-12-17 21:13:00 Re: TODO list