forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd844cd7
committed
Fix some anomalies with NO SCROLL cursors.
We have long forbidden fetching backwards from a NO SCROLL cursor,but the prohibition didn't extend to cases in which we rewind thequery altogether and then re-fetch forwards. I think the reason isthat this logic was mainly meant to protect plan nodes that can'tbe run in the reverse direction. However, re-reading the query outputis problematic if the query is volatile (which includes SELECT FORUPDATE, not just queries with volatile functions): the re-read canproduce different results, which confuses the cursor navigation logiccompletely. Another reason for disliking this approach is that somecode paths will either fetch backwards or rewind-and-fetch-forwardsdepending on the distance to the target row; so that seeminglyidentical use-cases may or may not draw the "cursor can only scanforward" error. Hence, let's clean things up by disallowing rewindas well as fetch-backwards in a NO SCROLL cursor.Ordinarily we'd only make such a definitional change in HEAD, butthere is a third reason to consider this change now. Commitba2c6d6created some new user-visible anomalies for non-scrollable cursorsWITH HOLD, in that navigation in the cursor result got confused if thecursor had been partially read before committing. The only good wayto resolve those anomalies is to forbid rewinding such a cursor, whichallows removal of the incorrect cursor state manipulations thatba2c6d6 added to PersistHoldablePortal.To minimize the behavioral change in the back branches (includingv14), refuse to rewind a NO SCROLL cursor only when it has a holdStore,ie has been held over from a previous transaction due to WITH HOLD.This should avoid breaking most applications that have been sloppyabout whether to declare cursors as scrollable. We'll enforce theprohibition across-the-board beginning in v15.Back-patch to v11, asba2c6d6 was.Discussion:https://postgr.es/m/3712911.1631207435@sss.pgh.pa.us1 parentb7056c0 commitd844cd7
File tree
4 files changed
+107
-11
lines changed- src
- backend
- commands
- tcop
- test/regress
- expected
- sql
4 files changed
+107
-11
lines changedLines changed: 20 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
375 | 375 |
| |
376 | 376 |
| |
377 | 377 |
| |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
378 | 387 |
| |
379 | 388 |
| |
380 | 389 |
| |
381 | 390 |
| |
382 | 391 |
| |
383 | 392 |
| |
384 | 393 |
| |
385 |
| - | |
386 |
| - | |
387 |
| - | |
388 |
| - | |
389 | 394 |
| |
390 | 395 |
| |
391 | 396 |
| |
| |||
443 | 448 |
| |
444 | 449 |
| |
445 | 450 |
| |
446 |
| - | |
447 |
| - | |
448 |
| - | |
449 |
| - | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
450 | 462 |
| |
451 | 463 |
| |
452 | 464 |
| |
|
Lines changed: 30 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1472 | 1472 |
| |
1473 | 1473 |
| |
1474 | 1474 |
| |
1475 |
| - | |
1476 |
| - | |
1477 |
| - | |
| 1475 | + | |
| 1476 | + | |
1478 | 1477 |
| |
1479 | 1478 |
| |
1480 | 1479 |
| |
| |||
1491 | 1490 |
| |
1492 | 1491 |
| |
1493 | 1492 |
| |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
1494 | 1502 |
| |
1495 | 1503 |
| |
1496 | 1504 |
| |
| |||
1668 | 1676 |
| |
1669 | 1677 |
| |
1670 | 1678 |
| |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
1671 | 1698 |
| |
1672 | 1699 |
| |
1673 | 1700 |
| |
|
Lines changed: 37 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
763 | 763 |
| |
764 | 764 |
| |
765 | 765 |
| |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
766 | 803 |
| |
767 | 804 |
| |
768 | 805 |
| |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
217 | 217 |
| |
218 | 218 |
| |
219 | 219 |
| |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
220 | 240 |
| |
221 | 241 |
| |
222 | 242 |
| |
|
0 commit comments
Comments
(0)