forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit6762180
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 parentb6cf89b commit6762180
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 | |
---|---|---|---|
| |||
8476 | 8476 |
| |
8477 | 8477 |
| |
8478 | 8478 |
| |
| 8479 | + | |
| 8480 | + | |
| 8481 | + | |
| 8482 | + | |
| 8483 | + | |
8479 | 8484 |
| |
8480 | 8485 |
| |
8481 |
| - | |
8482 | 8486 |
| |
8483 | 8487 |
| |
8484 | 8488 |
| |
|
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1723 | 1723 |
| |
1724 | 1724 |
| |
1725 | 1725 |
| |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
1726 | 1732 |
| |
1727 | 1733 |
| |
1728 | 1734 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
922 | 922 |
| |
923 | 923 |
| |
924 | 924 |
| |
| 925 | + | |
925 | 926 |
| |
926 | 927 |
| |
927 | 928 |
| |
|
0 commit comments
Comments
(0)