Re: [SQL] Interval subtracting

Поиск
Список
Период
Сортировка
От Mark Dilger
Тема Re: [SQL] Interval subtracting
Дата
Msg-id 4406262B.4000509@markdilger.com
обсуждение исходный текст
Ответ на Re: [SQL] Interval subtracting  (Mark Dilger <pgsql@markdilger.com>)
Ответы Re: [SQL] Interval subtracting  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Tom Lane wrote:> Mark Dilger <pgsql@markdilger.com> writes:>>>Am I correct that the second case should still have
negativehours?>>> Yes...>>>>If so, then justify_hours(...) needs to examine the sign of the days>>and months portion of
theinterval while performing its work.>>> No, it should ignore the months part completely, IMHO.  You are just>
confusingmatters 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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [SQL] Interval subtracting
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [SQL] Interval subtracting