Allow committing inside cursor loop
Previously, committing or aborting inside a cursor loop was prohibited
because that would close and remove the cursor. To allow that,
automatically convert such cursors to holdable cursors so they survive
commits or rollbacks. Portals now have a new state "auto-held", which
means they have been converted automatically from pinned. An auto-held
portal is kept on transaction commit or rollback, but is still removed
when returning to the main loop on error.
This supports all languages that have cursor loop constructs: PL/pgSQL,
PL/Python, PL/Perl.
Reviewed-by: Ildus Kurbangaliev <i.kurbangaliev@postgrespro.ru>
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/056a5a3f63f1a29d9266165ee6e25c6a51ddd63c
Modified Files
--------------
doc/src/sgml/plperl.sgml | 5 -
doc/src/sgml/plpgsql.sgml | 37 +++++-
doc/src/sgml/plpython.sgml | 4 +-
src/backend/tcop/postgres.c | 2 +
src/backend/utils/mmgr/portalmem.c | 138 ++++++++++++++++-----
src/include/utils/portal.h | 5 +-
src/pl/plperl/expected/plperl_transaction.out | 71 ++++++++++-
src/pl/plperl/plperl.c | 10 +-
src/pl/plperl/sql/plperl_transaction.sql | 43 +++++++
.../plpgsql/src/expected/plpgsql_transaction.out | 108 +++++++++++++++-
src/pl/plpgsql/src/pl_exec.c | 18 +--
src/pl/plpgsql/src/sql/plpgsql_transaction.sql | 67 ++++++++++
src/pl/plpython/expected/plpython_transaction.out | 67 +++++++++-
src/pl/plpython/plpy_plpymodule.c | 10 +-
src/pl/plpython/sql/plpython_transaction.sql | 36 ++++++
15 files changed, 534 insertions(+), 87 deletions(-)