- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit00011a6
committed
Fix failure in WHERE CURRENT OF after rewinding the referenced cursor.
In a case where we have multiple relation-scan nodes in a cursor plan,such as a scan of an inheritance tree, it's possible to fetch from agiven scan node, then rewind the cursor and fetch some row from anearlier scan node. In such a case, execCurrent.c mistakenly thoughtthat the later scan node was still active, because ExecReScan hadn'tdone anything to make it look not-active. We'd get some sort offailure in the case of a SeqScan node, because the node's scan tupleslot would be pointing at a HeapTuple whose t_self gets reset toinvalid by heapam.c. But it seems possible that for other relationscan node types we'd actually return a valid tuple TID to the caller,resulting in updating or deleting a tuple that shouldn't have beenconsidered current. To fix, forcibly clear the ScanTupleSlot inExecScanReScan.Another issue here, which seems only latent at the moment but couldeasily become a live bug in future, is that rewinding a cursor doesnot necessarily lead to *immediately* applying ExecReScan to everyscan-level node in the plan tree. Upper-level nodes will think thatthey can postpone that call if their child node is already markedwith chgParam flags. I don't see a way for that to happen today ina plan tree that's simple enough for execCurrent.c's search_plan_treeto understand, but that's one heck of a fragile assumption. So, addsome logic in search_plan_tree to detect chgParam flags being set onnodes that it descended to/through, and assume that that means weshould consider lower scan nodes to be logically reset even if theirReScan call hasn't actually happened yet.Per bug #15395 from Matvey Arye. This has been broken for a long time,so back-patch to all supported branches.Discussion:https://postgr.es/m/153764171023.14986.280404050547008575@wrigleys.postgresql.org1 parentdabdc7e commit00011a6
File tree
4 files changed
+146
-16
lines changed- src
- backend/executor
- test/regress
- expected
- sql
4 files changed
+146
-16
lines changedLines changed: 46 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
23 | 23 |
| |
24 | 24 |
| |
25 | 25 |
| |
26 |
| - | |
| 26 | + | |
| 27 | + | |
27 | 28 |
| |
28 | 29 |
| |
29 | 30 |
| |
| |||
156 | 157 |
| |
157 | 158 |
| |
158 | 159 |
| |
| 160 | + | |
159 | 161 |
| |
160 |
| - | |
| 162 | + | |
| 163 | + | |
161 | 164 |
| |
162 | 165 |
| |
163 | 166 |
| |
| |||
177 | 180 |
| |
178 | 181 |
| |
179 | 182 |
| |
180 |
| - | |
181 |
| - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
182 | 189 |
| |
183 | 190 |
| |
184 | 191 |
| |
| |||
288 | 295 |
| |
289 | 296 |
| |
290 | 297 |
| |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
291 | 305 |
| |
292 | 306 |
| |
293 |
| - | |
| 307 | + | |
| 308 | + | |
294 | 309 |
| |
| 310 | + | |
| 311 | + | |
295 | 312 |
| |
296 | 313 |
| |
297 | 314 |
| |
| |||
308 | 325 |
| |
309 | 326 |
| |
310 | 327 |
| |
311 |
| - | |
| 328 | + | |
312 | 329 |
| |
313 | 330 |
| |
314 | 331 |
| |
| |||
319 | 336 |
| |
320 | 337 |
| |
321 | 338 |
| |
322 |
| - | |
323 | 339 |
| |
324 | 340 |
| |
325 | 341 |
| |
326 | 342 |
| |
327 | 343 |
| |
328 |
| - | |
| 344 | + | |
| 345 | + | |
329 | 346 |
| |
330 | 347 |
| |
331 | 348 |
| |
332 | 349 |
| |
333 | 350 |
| |
334 | 351 |
| |
335 | 352 |
| |
336 |
| - | |
| 353 | + | |
337 | 354 |
| |
338 | 355 |
| |
339 | 356 |
| |
| |||
342 | 359 |
| |
343 | 360 |
| |
344 | 361 |
| |
345 |
| - | |
346 | 362 |
| |
347 | 363 |
| |
348 | 364 |
| |
349 | 365 |
| |
350 | 366 |
| |
351 |
| - | |
| 367 | + | |
| 368 | + | |
352 | 369 |
| |
353 | 370 |
| |
354 | 371 |
| |
355 | 372 |
| |
356 | 373 |
| |
357 | 374 |
| |
358 | 375 |
| |
359 |
| - | |
| 376 | + | |
360 | 377 |
| |
361 | 378 |
| |
362 | 379 |
| |
| |||
365 | 382 |
| |
366 | 383 |
| |
367 | 384 |
| |
368 |
| - | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
369 | 389 |
| |
370 | 390 |
| |
371 | 391 |
| |
372 | 392 |
| |
373 | 393 |
| |
374 |
| - | |
375 |
| - | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
376 | 398 |
| |
377 | 399 |
| |
378 | 400 |
| |
379 | 401 |
| |
380 | 402 |
| |
381 |
| - | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
382 | 412 |
|
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
337 | 337 |
| |
338 | 338 |
| |
339 | 339 |
| |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
340 | 346 |
| |
341 | 347 |
| |
342 | 348 |
| |
|
Lines changed: 70 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1269 | 1269 |
| |
1270 | 1270 |
| |
1271 | 1271 |
| |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
1272 | 1342 |
| |
1273 | 1343 |
| |
1274 | 1344 |
| |
|
Lines changed: 24 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
472 | 472 |
| |
473 | 473 |
| |
474 | 474 |
| |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
475 | 499 |
| |
476 | 500 |
| |
477 | 501 |
| |
|
0 commit comments
Comments
(0)