pgsql: Allow committing inside cursor loop

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Allow committing inside cursor loop
Date: 2018-03-28 23:15:28
Message-ID: E1f1KHw-0007SU-AA@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(dot)kurbangaliev(at)postgrespro(dot)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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2018-03-29 05:10:46 Re: pgsql: Add documentation for the JIT feature.
Previous Message Peter Geoghegan 2018-03-28 23:09:41 Re: pgsql: Optimize btree insertions for common case of increasing values