Re: Extract epoch from Interval weird behavior
От | Tom Lane |
---|---|
Тема | Re: Extract epoch from Interval weird behavior |
Дата | |
Msg-id | 3621530.1649423446@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Extract epoch from Interval weird behavior (Peter Eisentraut <peter.eisentraut@enterprisedb.com>) |
Ответы |
Re: Extract epoch from Interval weird behavior
|
Список | pgsql-hackers |
Peter Eisentraut <peter.eisentraut@enterprisedb.com> writes: > We really wanted to avoid doing calculations in numeric as much as > possible. So we should figure out a different way to write this. The > attached patch works for me. It's a bit ugly since it hardcodes some > factors. Maybe we can rephrase it a bit more elegantly. I think it's fine but needs some commentary. Maybe about like "To do this calculation in integer arithmetic even though DAYS_PER_YEAR is fractional, multiply everything by 4 and then divide by 4 again at the end. This relies on DAYS_PER_YEAR being a multiple of 0.25 and on SECS_PER_DAY being a multiple of 4." BTW, it might be good to parenthesize as (... big calculation ...) * (SECS_PER_DAY/4) to eliminate any question of whether the value could overflow before the final division by 4. regards, tom lane
В списке pgsql-hackers по дате отправления: