- Notifications
You must be signed in to change notification settings - Fork5
Commit1d35232
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 parente3ec072 commit1d35232
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 | |
|---|---|---|---|
| |||
6073 | 6073 | | |
6074 | 6074 | | |
6075 | 6075 | | |
| 6076 | + | |
6076 | 6077 | | |
6077 | 6078 | | |
6078 | 6079 | | |
6079 | 6080 | | |
| 6081 | + | |
6080 | 6082 | | |
6081 | 6083 | | |
6082 | 6084 | | |
| |||
6110 | 6112 | | |
6111 | 6113 | | |
6112 | 6114 | | |
6113 | | - | |
| 6115 | + | |
6114 | 6116 | | |
6115 | 6117 | | |
6116 | 6118 | | |
6117 | 6119 | | |
6118 | 6120 | | |
6119 | 6121 | | |
6120 | | - | |
| 6122 | + | |
6121 | 6123 | | |
6122 | 6124 | | |
6123 | 6125 | | |
6124 | 6126 | | |
6125 | | - | |
| 6127 | + | |
6126 | 6128 | | |
6127 | 6129 | | |
6128 | | - | |
| 6130 | + | |
6129 | 6131 | | |
| 6132 | + | |
| 6133 | + | |
| 6134 | + | |
| 6135 | + | |
| 6136 | + | |
| 6137 | + | |
| 6138 | + | |
| 6139 | + | |
| 6140 | + | |
| 6141 | + | |
| 6142 | + | |
| 6143 | + | |
| 6144 | + | |
| 6145 | + | |
| 6146 | + | |
| 6147 | + | |
| 6148 | + | |
| 6149 | + | |
| 6150 | + | |
| 6151 | + | |
6130 | 6152 | | |
6131 | 6153 | | |
6132 | 6154 | | |
| |||
| 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)