forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit40c7fcb
committed
Improve the accuracy of numeric power() for integer exponents.
This makes the choice of result scale of numeric power() for integerexponents consistent with the choice for non-integer exponents, andwith the result scale of other numeric functions. Specifically, theresult scale will be at least as large as the scale of either input,and sufficient to ensure that the result has at least 16 significantdigits.Formerly, the result scale was based only on the scale of the firstinput, without taking into account the weight of the result. Forresults with negative weight, that could lead to results with very fewor even no non-zero significant digits (e.g., 10.0 ^ (-18) produced0.0000000000000000).Fix this by moving responsibility for the choice of result scale intopower_var_int(), which already has code to estimate the result weight.Per report by Adrian Klaver and suggested fix by Tom Lane.No back-patch -- arguably this is a bug fix, but one which is easy towork around, so it doesn't seem worth the risk of changing queryresults in stable branches.Discussion:https://postgr.es/m/12a40226-70ac-3a3b-3d3a-fdaf9e32d312%40aklaver.com1 parent7fd1ae9 commit40c7fcb
File tree
5 files changed
+420
-344
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
5 files changed
+420
-344
lines changedLines changed: 67 additions & 43 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
571 | 571 |
| |
572 | 572 |
| |
573 | 573 |
| |
574 |
| - | |
575 |
| - | |
| 574 | + | |
| 575 | + | |
576 | 576 |
| |
577 | 577 |
| |
578 | 578 |
| |
| |||
10335 | 10335 |
| |
10336 | 10336 |
| |
10337 | 10337 |
| |
10338 |
| - | |
10339 |
| - | |
10340 |
| - | |
10341 |
| - | |
10342 |
| - | |
10343 |
| - | |
10344 |
| - | |
| 10338 | + | |
| 10339 | + | |
10345 | 10340 |
| |
10346 | 10341 |
| |
10347 | 10342 |
| |
| |||
10475 | 10470 |
| |
10476 | 10471 |
| |
10477 | 10472 |
| |
| 10473 | + | |
| 10474 | + | |
10478 | 10475 |
| |
10479 | 10476 |
| |
10480 |
| - | |
| 10477 | + | |
| 10478 | + | |
10481 | 10479 |
| |
10482 | 10480 |
| |
10483 | 10481 |
| |
10484 | 10482 |
| |
| 10483 | + | |
10485 | 10484 |
| |
10486 | 10485 |
| |
10487 | 10486 |
| |
10488 | 10487 |
| |
10489 | 10488 |
| |
10490 | 10489 |
| |
| 10490 | + | |
| 10491 | + | |
| 10492 | + | |
| 10493 | + | |
| 10494 | + | |
| 10495 | + | |
| 10496 | + | |
| 10497 | + | |
| 10498 | + | |
| 10499 | + | |
| 10500 | + | |
| 10501 | + | |
| 10502 | + | |
| 10503 | + | |
| 10504 | + | |
| 10505 | + | |
| 10506 | + | |
| 10507 | + | |
| 10508 | + | |
| 10509 | + | |
| 10510 | + | |
| 10511 | + | |
| 10512 | + | |
| 10513 | + | |
| 10514 | + | |
| 10515 | + | |
| 10516 | + | |
| 10517 | + | |
| 10518 | + | |
| 10519 | + | |
| 10520 | + | |
| 10521 | + | |
| 10522 | + | |
| 10523 | + | |
| 10524 | + | |
| 10525 | + | |
| 10526 | + | |
| 10527 | + | |
| 10528 | + | |
| 10529 | + | |
| 10530 | + | |
| 10531 | + | |
| 10532 | + | |
| 10533 | + | |
| 10534 | + | |
| 10535 | + | |
| 10536 | + | |
| 10537 | + | |
| 10538 | + | |
| 10539 | + | |
| 10540 | + | |
| 10541 | + | |
| 10542 | + | |
10491 | 10543 |
| |
10492 | 10544 |
| |
10493 | 10545 |
| |
| |||
10532 | 10584 |
| |
10533 | 10585 |
| |
10534 | 10586 |
| |
10535 |
| - | |
10536 |
| - | |
| 10587 | + | |
| 10588 | + | |
| 10589 | + | |
10537 | 10590 |
| |
10538 |
| - | |
10539 |
| - | |
10540 |
| - | |
10541 |
| - | |
10542 |
| - | |
10543 |
| - | |
10544 |
| - | |
10545 |
| - | |
10546 |
| - | |
10547 |
| - | |
10548 |
| - | |
10549 |
| - | |
10550 |
| - | |
10551 |
| - | |
10552 |
| - | |
10553 |
| - | |
10554 |
| - | |
10555 |
| - | |
10556 |
| - | |
10557 |
| - | |
10558 |
| - | |
10559 |
| - | |
10560 |
| - | |
10561 |
| - | |
10562 |
| - | |
10563 |
| - | |
10564 |
| - | |
10565 |
| - | |
10566 |
| - | |
10567 |
| - | |
10568 | 10591 |
| |
10569 | 10592 |
| |
10570 | 10593 |
| |
10571 |
| - | |
| 10594 | + | |
| 10595 | + | |
10572 | 10596 |
| |
10573 | 10597 |
| |
10574 | 10598 |
| |
|
0 commit comments
Comments
(0)