From 6eb9c5a5657d1fe77b55cc261450f3538d35a94d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 14:19:15 +0200 Subject: Adding upstream version 13.4. Signed-off-by: Daniel Baumann --- doc/src/sgml/html/plpython-transactions.html | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 doc/src/sgml/html/plpython-transactions.html (limited to 'doc/src/sgml/html/plpython-transactions.html') diff --git a/doc/src/sgml/html/plpython-transactions.html b/doc/src/sgml/html/plpython-transactions.html new file mode 100644 index 0000000..e55e6fc --- /dev/null +++ b/doc/src/sgml/html/plpython-transactions.html @@ -0,0 +1,31 @@ + +45.9. Transaction Management

45.9. Transaction Management

+ In a procedure called from the top level or an anonymous code block + (DO command) called from the top level it is possible to + control transactions. To commit the current transaction, call + plpy.commit(). To roll back the current transaction, + call plpy.rollback(). (Note that it is not possible to + run the SQL commands COMMIT or + ROLLBACK via plpy.execute or + similar. It has to be done using these functions.) After a transaction is + ended, a new transaction is automatically started, so there is no separate + function for that. +

+ Here is an example: +

+CREATE PROCEDURE transaction_test1()
+LANGUAGE plpythonu
+AS $$
+for i in range(0, 10):
+    plpy.execute("INSERT INTO test1 (a) VALUES (%d)" % i)
+    if i % 2 == 0:
+        plpy.commit()
+    else:
+        plpy.rollback()
+$$;
+
+CALL transaction_test1();
+

+

+ Transactions cannot be ended when an explicit subtransaction is active. +

\ No newline at end of file -- cgit v1.2.3