From: | Mark Dilger <pgsql(at)markdilger(dot)com> |
---|---|
To: | Mark Dilger <pgsql(at)markdilger(dot)com> |
Cc: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
Subject: | Re: [SQL] Interval subtracting |
Date: | 2006-03-01 22:54:35 |
Message-ID: | 4406262B.4000509@markdilger.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches pgsql-sql |
Tom Lane wrote:
> Mark Dilger <pgsql(at)markdilger(dot)com> writes:
>
>>Am I correct that the second case should still have negative hours?
>
>
> Yes...
>
>
>>If so, then justify_hours(...) needs to examine the sign of the days
>>and months portion of the interval while performing its work.
>
>
> No, it should ignore the months part completely, IMHO. You are just
> confusing matters by using both functions in your examples, as then
> it's not clear which does what.
>
> regards, tom lane
I like the idea that a person has some justify-path by which they can get all
the signs to match. With the patch that I just posted, this is accomplished as
follows:
justify_days(justify_hours(...))
Regardless of the particular weirdness of the signs in the original interval.
But the patch also leaves open the possibility that you don't want the hours
touched, perhaps because you're dealing with a daylight savings time period and
can't accept the concept of a 24-hour day. In that case:
justify_days(...)
will get the sign on the months and days to match each other, though perhaps not
match the hours. In the event that you want to justify the hours, but can't
accept having the days justified (because you have a non-30 day month), then you
can call:
justify_hours(...)
and get the sign on the hours portion to match the overall intent of the
interval (positive or negative) without being forced to actually change the way
the days and months are being represented.
This overall design seems more flexible than Tom's recent post in which he
stated that justify_days should call justify_hours internally. I tend not to
agree. However, it wouldn't hurt to have a justify_interval(...) function which
does justify both in one shot.
mark
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2006-03-01 23:02:17 | Re: [SQL] Interval subtracting |
Previous Message | Andrew Dunstan | 2006-03-01 22:54:02 | Re: implement prepared queries in plperl |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2006-03-01 23:02:17 | Re: [SQL] Interval subtracting |
Previous Message | Andrew Dunstan | 2006-03-01 22:54:02 | Re: implement prepared queries in plperl |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2006-03-01 23:02:17 | Re: [SQL] Interval subtracting |
Previous Message | Tom Lane | 2006-03-01 22:45:47 | Re: [SQL] Interval subtracting |