forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit25bf13f
committed
Fix power_var_int() for large integer exponents.
The code for raising a NUMERIC value to an integer power wasn't verycareful about large powers. It got an outright wrong answer for anexponent of INT_MIN, due to failure to consider overflow of the Abs(exp)operation; which is fixable by using an unsigned rather than signedexponent value after that point. Also, even though the number ofiterations of the power-computation loop is pretty limited, it's easy forthe repeated squarings to result in ridiculously enormous intermediatevalues, which can take unreasonable amounts of time/memory to process,or even overflow the internal "weight" field and so produce a wrong answer.We can forestall misbehaviors of that sort by bailing out as soon as theweight value exceeds what will fit in int16, since then the final answermust overflow (if exp > 0) or underflow (if exp < 0) the packed numericformat.Per off-list report from Pavel Stehule. Back-patch to all supportedbranches.1 parent5724f49 commit25bf13f
File tree
3 files changed
+54
-4
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+54
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5645 | 5645 | | |
5646 | 5646 | | |
5647 | 5647 | | |
| 5648 | + | |
5648 | 5649 | | |
5649 | 5650 | | |
5650 | 5651 | | |
5651 | 5652 | | |
| 5653 | + | |
5652 | 5654 | | |
5653 | 5655 | | |
5654 | 5656 | | |
| |||
5682 | 5684 | | |
5683 | 5685 | | |
5684 | 5686 | | |
5685 | | - | |
| 5687 | + | |
5686 | 5688 | | |
5687 | 5689 | | |
5688 | 5690 | | |
5689 | 5691 | | |
5690 | 5692 | | |
5691 | 5693 | | |
5692 | | - | |
| 5694 | + | |
5693 | 5695 | | |
5694 | 5696 | | |
5695 | 5697 | | |
5696 | 5698 | | |
5697 | | - | |
| 5699 | + | |
5698 | 5700 | | |
5699 | 5701 | | |
5700 | | - | |
| 5702 | + | |
5701 | 5703 | | |
| 5704 | + | |
| 5705 | + | |
| 5706 | + | |
| 5707 | + | |
| 5708 | + | |
| 5709 | + | |
| 5710 | + | |
| 5711 | + | |
| 5712 | + | |
| 5713 | + | |
| 5714 | + | |
| 5715 | + | |
| 5716 | + | |
| 5717 | + | |
| 5718 | + | |
| 5719 | + | |
| 5720 | + | |
| 5721 | + | |
| 5722 | + | |
| 5723 | + | |
5702 | 5724 | | |
5703 | 5725 | | |
5704 | 5726 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1390 | 1390 | | |
1391 | 1391 | | |
1392 | 1392 | | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
828 | 828 | | |
829 | 829 | | |
830 | 830 | | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
0 commit comments
Comments
(0)