forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit9ab94cc
committed
Fix corner-case loss of precision in numeric_power().
This fixes a loss of precision that occurs when the first input isvery close to 1, so that its logarithm is very small.Formerly, during the initial low-precision calculation to estimate theresult weight, the logarithm was computed to a local rscale that wascapped to NUMERIC_MAX_DISPLAY_SCALE (1000). However, the base may beas close as 1e-16383 to 1, hence its logarithm may be as small as1e-16383, and so the local rscale needs to be allowed to exceed 16383,otherwise all precision is lost, leading to a poor choice of rscalefor the full-precision calculation.Fix this by removing the cap on the local rscale during the initiallow-precision calculation, as we already do in the full-precisioncalculation. This doesn't change the fact that the initial calculationis a low-precision approximation, computing the logarithm to around 8significant digits, which is very fast, especially when the base isvery close to 1.Patch by me, reviewed by Alvaro Herrera.Discussion:https://postgr.es/m/CAEZATCV-Ceu%2BHpRMf416yUe4KKFv%3DtdgXQAe5-7S9tD%3D5E-T1g%40mail.gmail.com1 parentd6d68e2 commit9ab94cc
File tree
3 files changed
+12
-1
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+12
-1
lines changedLines changed: 5 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
9245 | 9245 |
| |
9246 | 9246 |
| |
9247 | 9247 |
| |
| 9248 | + | |
| 9249 | + | |
| 9250 | + | |
| 9251 | + | |
| 9252 | + | |
9248 | 9253 |
| |
9249 | 9254 |
| |
9250 |
| - | |
9251 | 9255 |
| |
9252 | 9256 |
| |
9253 | 9257 |
| |
|
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1774 | 1774 |
| |
1775 | 1775 |
| |
1776 | 1776 |
| |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
1777 | 1783 |
| |
1778 | 1784 |
| |
1779 | 1785 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
935 | 935 |
| |
936 | 936 |
| |
937 | 937 |
| |
| 938 | + | |
938 | 939 |
| |
939 | 940 |
| |
940 | 941 |
| |
|
0 commit comments
Comments
(0)