- Notifications
You must be signed in to change notification settings - Fork28
Commit3cb1b2a
committed
Rewrite list_qsort() to avoid trashing its input list.
The initial implementation of list_qsort(), from commitab72716,re-used the ListCells of the input list while not touching the Listheader. This meant that anybody who still had a pointer to theoriginal header would now be in possession of a corrupted list,a problem that seems sure to bite us eventually.One possible solution is to re-use the original List header as well,giving the function the semantics of update-in-place. However, thatdoesn't seem like a very good idea either given the way that thefunction is used in the planner: create_path functions aren't normallysupposed to modify their input lists. It doesn't look like there wouldbe a problem today, but it's not hard to foresee a time when modifyinga list of Paths in-place could have side-effects on some other appendpath.On the whole, and in view of the likelihood that this function mightbe used in other contexts in the future, it seems best to get rid ofthe micro-optimization of re-using the input list cells. Just builda new list.Discussion:https://postgr.es/m/16912.1515449066@sss.pgh.pa.us1 parent624e440 commit3cb1b2a
1 file changed
+40
-16
lines changedLines changed: 40 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1250 | 1250 |
| |
1251 | 1251 |
| |
1252 | 1252 |
| |
1253 |
| - | |
1254 |
| - | |
1255 |
| - | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
1256 | 1259 |
| |
1257 | 1260 |
| |
1258 | 1261 |
| |
1259 | 1262 |
| |
1260 |
| - | |
1261 |
| - | |
1262 | 1263 |
| |
1263 | 1264 |
| |
1264 |
| - | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
1265 | 1269 |
| |
| 1270 | + | |
1266 | 1271 |
| |
1267 | 1272 |
| |
1268 | 1273 |
| |
| 1274 | + | |
| 1275 | + | |
1269 | 1276 |
| |
1270 |
| - | |
1271 | 1277 |
| |
1272 | 1278 |
| |
1273 | 1279 |
| |
1274 | 1280 |
| |
1275 | 1281 |
| |
1276 |
| - | |
1277 |
| - | |
1278 |
| - | |
1279 |
| - | |
1280 |
| - | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
1281 | 1300 |
| |
1282 |
| - | |
1283 |
| - | |
| 1301 | + | |
| 1302 | + | |
1284 | 1303 |
| |
1285 |
| - | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
1286 | 1308 |
| |
1287 |
| - | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
1288 | 1312 |
| |
1289 | 1313 |
| |
1290 | 1314 |
| |
|
0 commit comments
Comments
(0)