Commit be90098
committed
Force NO SCROLL for plpgsql's implicit cursors.
Further thought about bug #17050 suggests that it's a good idea
to use CURSOR_OPT_NO_SCROLL for the implicit cursor opened by
a plpgsql FOR-over-query loop. This ensures that, if somebody
commits inside the loop, PersistHoldablePortal won't try to
rewind and re-read the cursor. While we'd have selected NO_SCROLL
anyway if FOR UPDATE/SHARE appears in the query, there are other
hazards with volatile functions; and in any case, it's silly to
expend effort storing rows that we know for certain won't be needed.
(While here, improve the comment in exec_run_select, which was a bit
confused about the rationale for when we can use parallel mode.
Cursor operations aren't a hazard for nameless portals.)
This wasn't an issue until v11, which introduced the possibility
of persisting such cursors. Hence, back-patch to v11.
Per bug #17050 from Алексей Булгаков.
Discussion: https://postgr.es/m/17050-f77aa827dc85247c@postgresql.org1 parent ba2c6d6 commit be90098
1 file changed
+14
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4561 | 4561 | | |
4562 | 4562 | | |
4563 | 4563 | | |
4564 | | - | |
| 4564 | + | |
4565 | 4565 | | |
4566 | 4566 | | |
4567 | 4567 | | |
| |||
5694 | 5694 | | |
5695 | 5695 | | |
5696 | 5696 | | |
5697 | | - | |
5698 | | - | |
5699 | | - | |
5700 | | - | |
| 5697 | + | |
| 5698 | + | |
| 5699 | + | |
| 5700 | + | |
| 5701 | + | |
| 5702 | + | |
5701 | 5703 | | |
5702 | 5704 | | |
5703 | | - | |
5704 | | - | |
| 5705 | + | |
| 5706 | + | |
| 5707 | + | |
| 5708 | + | |
| 5709 | + | |
| 5710 | + | |
| 5711 | + | |
5705 | 5712 | | |
5706 | 5713 | | |
5707 | 5714 | | |
| |||
0 commit comments