pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Force NO SCROLL for plpgsql's implicit cursors. 4+ messages / 1 participants [nested] [flat]
* pgsql: Force NO SCROLL for plpgsql's implicit cursors. @ 2021-06-08 22:40 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 4+ messages in thread From: Tom Lane @ 2021-06-08 22:40 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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.org Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/be90098907475f3cfff7dc6d590641b9c2dae081 Modified Files -------------- src/pl/plpgsql/src/pl_exec.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Force NO SCROLL for plpgsql's implicit cursors. @ 2021-06-08 22:40 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 4+ messages in thread From: Tom Lane @ 2021-06-08 22:40 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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.org Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/c5b28184132d30ce7f77b24b0e7f302a8f37f407 Modified Files -------------- src/pl/plpgsql/src/pl_exec.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Force NO SCROLL for plpgsql's implicit cursors. @ 2021-06-08 22:40 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 4+ messages in thread From: Tom Lane @ 2021-06-08 22:40 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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.org Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/18232330062026d3575ec5f387b70f63a856e0ea Modified Files -------------- src/pl/plpgsql/src/pl_exec.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Force NO SCROLL for plpgsql's implicit cursors. @ 2021-06-08 22:40 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 4+ messages in thread From: Tom Lane @ 2021-06-08 22:40 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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.org Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/5b7bf9f72ab5dc77c081d3af3e6c3b50a6dbe872 Modified Files -------------- src/pl/plpgsql/src/pl_exec.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2021-06-08 22:40 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-06-08 22:40 pgsql: Force NO SCROLL for plpgsql's implicit cursors. Tom Lane <tgl@sss.pgh.pa.us> 2021-06-08 22:40 pgsql: Force NO SCROLL for plpgsql's implicit cursors. Tom Lane <tgl@sss.pgh.pa.us> 2021-06-08 22:40 pgsql: Force NO SCROLL for plpgsql's implicit cursors. Tom Lane <tgl@sss.pgh.pa.us> 2021-06-08 22:40 pgsql: Force NO SCROLL for plpgsql's implicit cursors. Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox