forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit8e26b86
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 parentae25435 commit8e26b86
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 | |
---|---|---|---|
| |||
10227 | 10227 |
| |
10228 | 10228 |
| |
10229 | 10229 |
| |
| 10230 | + | |
| 10231 | + | |
| 10232 | + | |
| 10233 | + | |
| 10234 | + | |
10230 | 10235 |
| |
10231 | 10236 |
| |
10232 |
| - | |
10233 | 10237 |
| |
10234 | 10238 |
| |
10235 | 10239 |
| |
|
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2420 | 2420 |
| |
2421 | 2421 |
| |
2422 | 2422 |
| |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
2423 | 2429 |
| |
2424 | 2430 |
| |
2425 | 2431 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1114 | 1114 |
| |
1115 | 1115 |
| |
1116 | 1116 |
| |
| 1117 | + | |
1117 | 1118 |
| |
1118 | 1119 |
| |
1119 | 1120 |
| |
|
0 commit comments
Comments
(0)