Re: Interval->day proposal - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Interval->day proposal
Date
Msg-id 13781.1117636267@sss.pgh.pa.us
Whole thread Raw
In response to Re: Interval->day proposal  (Michael Glaesemann <grzm@myrealbox.com>)
List pgsql-hackers
Michael Glaesemann <grzm@myrealbox.com> writes:
> I've started working on this change, and one difference has shown up  
> immediately in the regression tests. v8.0.3 currently returns:

>    SELECT INTERVAL '10 years -11 month -12 days +13:14' AS "9 years...";
>                9 years...
>    ----------------------------------
> !  9 years 1 mon -11 days -10:46:00
>    (1 row)

> With my first round of changes,

>    SELECT INTERVAL '10 years -11 month -12 days +13:14' AS "9 years...";
>                9 years...
>    ----------------------------------
> !  9 years 1 mon -12 days +13:14:00
>    (1 row)

Right, because it is now possible for day and hour to have different signs.
Comes with the territory I think.

> These are equivalent in both CVS and my branch, as '1 day'::interval  
> = '24 hours'::interval. I haven't checked the SQL spec yet (and  
> intend to do so), but is there a canonical form for intervals that we  
> need to return?

AFAICS, the spec only allows one sign for the entire interval value,
so this behavior is already outside the spec.  As long as we don't
generate different field signs in cases where that was not already
present in the input, I don't think it's a spec violation.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Interval->day proposal
Next
From: Tom Lane
Date:
Subject: Re: Can we simplify win32 threading code