Commit 7538708
committed
Avoid gratuitous inaccuracy in numeric width_bucket().
Multiply before dividing, not the reverse, so that cases that should
produce exact results do produce exact results. (width_bucket_float8
got this right already.) Even when the result is inexact, this avoids
making it more inexact, since only the division step introduces any
imprecision.
While at it, fix compute_bucket() to not uselessly repeat the sign
check already done by its caller, and avoid duplicating the
multiply/divide steps by adjusting variable usage.
Per complaint from Martin Visser. Although this seems like a bug fix,
I'm hesitant to risk changing width_bucket()'s results in stable
branches, so no back-patch.
Discussion: https://postgr.es/m/6FA5117D-6AED-4656-8FEF-B74AC18FAD85@brytlyt.com1 parent 8ce423b commit 7538708
File tree
3 files changed
+65
-15
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+65
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
592 | 592 | | |
593 | 593 | | |
594 | 594 | | |
595 | | - | |
| 595 | + | |
| 596 | + | |
596 | 597 | | |
597 | 598 | | |
598 | 599 | | |
| |||
1752 | 1753 | | |
1753 | 1754 | | |
1754 | 1755 | | |
1755 | | - | |
1756 | | - | |
| 1756 | + | |
| 1757 | + | |
1757 | 1758 | | |
1758 | 1759 | | |
1759 | 1760 | | |
| |||
1763 | 1764 | | |
1764 | 1765 | | |
1765 | 1766 | | |
1766 | | - | |
1767 | | - | |
| 1767 | + | |
| 1768 | + | |
1768 | 1769 | | |
1769 | 1770 | | |
1770 | 1771 | | |
| |||
1783 | 1784 | | |
1784 | 1785 | | |
1785 | 1786 | | |
1786 | | - | |
| 1787 | + | |
| 1788 | + | |
1787 | 1789 | | |
1788 | 1790 | | |
1789 | 1791 | | |
1790 | | - | |
| 1792 | + | |
| 1793 | + | |
1791 | 1794 | | |
1792 | 1795 | | |
1793 | 1796 | | |
| |||
1797 | 1800 | | |
1798 | 1801 | | |
1799 | 1802 | | |
1800 | | - | |
| 1803 | + | |
1801 | 1804 | | |
1802 | 1805 | | |
1803 | 1806 | | |
1804 | | - | |
1805 | | - | |
1806 | 1807 | | |
1807 | 1808 | | |
1808 | 1809 | | |
1809 | 1810 | | |
1810 | | - | |
1811 | | - | |
1812 | | - | |
| 1811 | + | |
1813 | 1812 | | |
1814 | 1813 | | |
1815 | | - | |
1816 | | - | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
1817 | 1818 | | |
1818 | 1819 | | |
1819 | 1820 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1385 | 1385 | | |
1386 | 1386 | | |
1387 | 1387 | | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
1388 | 1428 | | |
1389 | 1429 | | |
1390 | 1430 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
888 | 888 | | |
889 | 889 | | |
890 | 890 | | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
891 | 900 | | |
892 | 901 | | |
893 | 902 | | |
| |||
0 commit comments