forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit8f93bd8
committed
Fix roundoff problems in float8_timestamptz() and make_interval().
When converting a float value to integer microseconds, we should be carefulto round the value to the nearest integer, typically with rint(); simplyassigning to an int64 variable will truncate, causing apparently off-by-onevalues in cases that should work. Most places in the datetime code gotthis right, but not these two.float8_timestamptz() is new as of commite511d87 (9.6). Previousversions effectively depended on interval_mul() to do roundoff correctly,which it does, so this fixes an accuracy regression in 9.6.The problem in make_interval() dates to its introduction in 9.4. Asidefrom being careful to round not truncate, let's incorporate the hours andminutes inputs into the result with exact integer arithmetic, rather thanrisk introducing roundoff error where there need not have been any.float8_timestamptz() problem reported by Erik Nordström, though this isnot his proposed patch. make_interval() problem found by me.Discussion:https://postgr.es/m/CAHuQZDS76jTYk3LydPbKpNfw9KbACmD=49dC4BrzHcfPv6yA1A@mail.gmail.com1 parenta507b86 commit8f93bd8
1 file changed
+7
-5
lines changedLines changed: 7 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
788 | 788 |
| |
789 | 789 |
| |
790 | 790 |
| |
791 |
| - | |
| 791 | + | |
792 | 792 |
| |
793 | 793 |
| |
794 | 794 |
| |
| |||
1623 | 1623 |
| |
1624 | 1624 |
| |
1625 | 1625 |
| |
1626 |
| - | |
1627 |
| - | |
1628 | 1626 |
| |
1629 |
| - | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
1630 | 1630 |
| |
1631 |
| - | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
1632 | 1634 |
| |
1633 | 1635 |
| |
1634 | 1636 |
| |
|
0 commit comments
Comments
(0)