]> granicus.if.org Git - postgresql/commit
Allow committing inside cursor loop
authorPeter Eisentraut <peter_e@gmx.net>
Wed, 28 Mar 2018 22:57:10 +0000 (18:57 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Wed, 28 Mar 2018 23:03:26 +0000 (19:03 -0400)
commit056a5a3f63f1a29d9266165ee6e25c6a51ddd63c
tree81a14413e9303f536c9c3f8c889bc2d265fa75c8
parenta2894cce544d120199a1a90469073796d055bb60
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>
15 files changed:
doc/src/sgml/plperl.sgml
doc/src/sgml/plpgsql.sgml
doc/src/sgml/plpython.sgml
src/backend/tcop/postgres.c
src/backend/utils/mmgr/portalmem.c
src/include/utils/portal.h
src/pl/plperl/expected/plperl_transaction.out
src/pl/plperl/plperl.c
src/pl/plperl/sql/plperl_transaction.sql
src/pl/plpgsql/src/expected/plpgsql_transaction.out
src/pl/plpgsql/src/pl_exec.c
src/pl/plpgsql/src/sql/plpgsql_transaction.sql
src/pl/plpython/expected/plpython_transaction.out
src/pl/plpython/plpy_plpymodule.c
src/pl/plpython/sql/plpython_transaction.sql