forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit7e1ce2b
committed
Prevent integer overflow when forming tuple width estimates.
It's at least theoretically possible to overflow int32 when adding upcolumn width estimates to make a row width estimate. (The bug exampleisn't terribly convincing as a real use-case, but perhaps wide joinswould provide a more plausible route to trouble.) This'd lead toassertion failures or silly planner behavior. To forestall it, makethe relevant functions compute their running sums in int64 arithmeticand then clamp to int32 range at the end. We can reasonably assumethat MaxAllocSize is a hard limit on actual tuple width, so clampingto that is simply a correction for dubious input values, and there'sno need to go as far as widening width variables to int64 everywhere.Per bug #18247 from RekGRpth. There've been no reports of this issuearising in practical cases, so I feel no need to back-patch.Richard Guo and Tom LaneDiscussion:https://postgr.es/m/18247-11ac477f02954422@postgresql.org1 parent2a607fb commit7e1ce2b
File tree
6 files changed
+52
-15
lines changed- src
- backend/optimizer
- path
- plan
- util
- include/optimizer
6 files changed
+52
-15
lines changedLines changed: 35 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
218 | 218 |
| |
219 | 219 |
| |
220 | 220 |
| |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
221 | 250 |
| |
222 | 251 |
| |
223 | 252 |
| |
| |||
6101 | 6130 |
| |
6102 | 6131 |
| |
6103 | 6132 |
| |
6104 |
| - | |
| 6133 | + | |
6105 | 6134 |
| |
6106 | 6135 |
| |
6107 | 6136 |
| |
| |||
6213 | 6242 |
| |
6214 | 6243 |
| |
6215 | 6244 |
| |
6216 |
| - | |
| 6245 | + | |
6217 | 6246 |
| |
6218 | 6247 |
| |
6219 | 6248 |
| |
| |||
6230 | 6259 |
| |
6231 | 6260 |
| |
6232 | 6261 |
| |
6233 |
| - | |
| 6262 | + | |
6234 | 6263 |
| |
6235 | 6264 |
| |
6236 | 6265 |
| |
| |||
6239 | 6268 |
| |
6240 | 6269 |
| |
6241 | 6270 |
| |
6242 |
| - | |
6243 |
| - | |
| 6271 | + | |
6244 | 6272 |
| |
6245 | 6273 |
| |
6246 | 6274 |
| |
| |||
6258 | 6286 |
| |
6259 | 6287 |
| |
6260 | 6288 |
| |
6261 |
| - | |
| 6289 | + | |
6262 | 6290 |
| |
6263 | 6291 |
| |
6264 | 6292 |
| |
| |||
6282 | 6310 |
| |
6283 | 6311 |
| |
6284 | 6312 |
| |
6285 |
| - | |
6286 |
| - | |
| 6313 | + | |
6287 | 6314 |
| |
6288 | 6315 |
| |
6289 | 6316 |
| |
|
Lines changed: 3 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4610 | 4610 |
| |
4611 | 4611 |
| |
4612 | 4612 |
| |
| 4613 | + | |
4613 | 4614 |
| |
4614 | 4615 |
| |
4615 | 4616 |
| |
| |||
4618 | 4619 |
| |
4619 | 4620 |
| |
4620 | 4621 |
| |
4621 |
| - | |
| 4622 | + | |
4622 | 4623 |
| |
| 4624 | + | |
4623 | 4625 |
| |
4624 | 4626 |
| |
4625 | 4627 |
| |
|
Lines changed: 4 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
375 | 375 |
| |
376 | 376 |
| |
377 | 377 |
| |
| 378 | + | |
378 | 379 |
| |
379 | 380 |
| |
380 | 381 |
| |
| |||
419 | 420 |
| |
420 | 421 |
| |
421 | 422 |
| |
422 |
| - | |
| 423 | + | |
423 | 424 |
| |
424 | 425 |
| |
425 | 426 |
| |
| |||
443 | 444 |
| |
444 | 445 |
| |
445 | 446 |
| |
| 447 | + | |
| 448 | + | |
446 | 449 |
| |
447 | 450 |
| |
448 | 451 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1137 | 1137 |
| |
1138 | 1138 |
| |
1139 | 1139 |
| |
1140 |
| - | |
| 1140 | + | |
1141 | 1141 |
| |
1142 | 1142 |
| |
1143 | 1143 |
| |
| |||
1167 | 1167 |
| |
1168 | 1168 |
| |
1169 | 1169 |
| |
1170 |
| - | |
| 1170 | + | |
1171 | 1171 |
| |
1172 | 1172 |
| |
1173 | 1173 |
| |
|
Lines changed: 7 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
22 | 22 |
| |
23 | 23 |
| |
24 | 24 |
| |
| 25 | + | |
25 | 26 |
| |
26 | 27 |
| |
27 | 28 |
| |
| |||
1092 | 1093 |
| |
1093 | 1094 |
| |
1094 | 1095 |
| |
| 1096 | + | |
1095 | 1097 |
| |
1096 | 1098 |
| |
1097 | 1099 |
| |
| |||
1144 | 1146 |
| |
1145 | 1147 |
| |
1146 | 1148 |
| |
1147 |
| - | |
| 1149 | + | |
1148 | 1150 |
| |
1149 | 1151 |
| |
1150 | 1152 |
| |
| |||
1165 | 1167 |
| |
1166 | 1168 |
| |
1167 | 1169 |
| |
1168 |
| - | |
| 1170 | + | |
1169 | 1171 |
| |
1170 | 1172 |
| |
1171 | 1173 |
| |
| |||
1181 | 1183 |
| |
1182 | 1184 |
| |
1183 | 1185 |
| |
1184 |
| - | |
| 1186 | + | |
1185 | 1187 |
| |
1186 | 1188 |
| |
1187 | 1189 |
| |
| |||
1221 | 1223 |
| |
1222 | 1224 |
| |
1223 | 1225 |
| |
| 1226 | + | |
| 1227 | + | |
1224 | 1228 |
| |
1225 | 1229 |
| |
1226 | 1230 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
90 | 90 |
| |
91 | 91 |
| |
92 | 92 |
| |
| 93 | + | |
93 | 94 |
| |
94 | 95 |
| |
95 | 96 |
| |
|
0 commit comments
Comments
(0)