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