summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2018-03-24 10:05:06 -0400
committerPeter Eisentraut <peter_e@gmx.net>2018-03-28 13:31:27 -0400
commitd92bc83c48bdea9888e64cf1e2edbac9693099c9 (patch)
tree5cccf082581787b24af269613fb7b3cc4c4484d7 /doc/src
parentc2d4eb1b1fa252fd8c407e1519308017a18afed1 (diff)
PL/pgSQL: Nested CALL with transactions
So far, a nested CALL or DO in PL/pgSQL would not establish a context where transaction control statements were allowed. This fixes that by handling CALL and DO specially in PL/pgSQL, passing the atomic/nonatomic execution context through and doing the required management around transaction boundaries. Reviewed-by: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/plpgsql.sgml20
1 files changed, 17 insertions, 3 deletions
diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml
index 7ed926fd51e..b63b8496c7b 100644
--- a/doc/src/sgml/plpgsql.sgml
+++ b/doc/src/sgml/plpgsql.sgml
@@ -3463,9 +3463,9 @@ END LOOP <optional> <replaceable>label</replaceable> </optional>;
<title>Transaction Management</title>
<para>
- In procedures invoked by the <command>CALL</command> command from the top
- level as well as in anonymous code blocks (<command>DO</command> command)
- called from the top level, it is possible to end transactions using the
+ In procedures invoked by the <command>CALL</command> command
+ as well as in anonymous code blocks (<command>DO</command> command),
+ it is possible to end transactions using the
commands <command>COMMIT</command> and <command>ROLLBACK</command>. A new
transaction is started automatically after a transaction is ended using
these commands, so there is no separate <command>START
@@ -3496,6 +3496,20 @@ CALL transaction_test1();
</para>
<para>
+ Transaction control is only possible in <command>CALL</command> or
+ <command>DO</command> invocations from the top level or nested
+ <command>CALL</command> or <command>DO</command> invocations without any
+ other intervening command. For example, if the call stack is
+ <command>CALL proc1()</command> &rarr; <command>CALL proc2()</command>
+ &rarr; <command>CALL proc3()</command>, then the second and third
+ procedures can perform transaction control actions. But if the call stack
+ is <command>CALL proc1()</command> &rarr; <command>SELECT
+ func2()</command> &rarr; <command>CALL proc3()</command>, then the last
+ procedure cannot do transaction control, because of the
+ <command>SELECT</command> in between.
+ </para>
+
+ <para>
A transaction cannot be ended inside a loop over a query result, nor
inside a block with exception handlers.
</para>