Index: docs/topics/db/transactions.txt
===================================================================
--- docs/topics/db/transactions.txt (revision 10658)
+++ docs/topics/db/transactions.txt (working copy)
@@ -166,28 +166,37 @@
.. _information on MySQL transactions: http://dev.mysql.com/doc/refman/5.0/en/sql-syntax-transactions.html
-Transactions and savepoints in PostgreSQL 8
-===========================================
+Database exceptions within PostgreSQL transactions
+==================================================
-When a call to a PostgreSQL 8 cursor raises an exception, all subsequent SQL
+When a call to a PostgreSQL cursor raises an exception, all subsequent SQL
in the same transaction fails with the error "current transaction is aborted,
queries ignored until end of transaction block". Whilst simple use of save()
is unlikely to raise an exception in PostgreSQL, there are many more advanced
usage patterns which might: for example, saving objects with unique fields,
saving using the force_insert/force_update flag, or invoking custom SQL.
+There are three possible solutions to this issue:
-In any of these cases, you can wrap the command which may throw
-IntegrityError inside savepoints, which will then allow subsequent commands
-to proceed. Example::
+ * With any version of PostgreSQL, you can rollback to the start of the
+ transaction if you experience an IntegrityError.
- try:
- sid = transaction.savepoint()
- x.save()
- transaction.savepoint_commit(sid)
- except IntegrityError:
- transaction.savepoint_rollback(sid)
- raise
+ * With PostgreSQL 8 or later, you can wrap the command which may throw
+ IntegrityError inside savepoints, which will then allow subsequent
+ commands to proceed. Example::
-Savepoints are not implemented in PostgreSQL 7. If you experience an
-IntegrityError when using PostgreSQL 7, you will need to rollback to the
-start of the transaction.
+ try:
+ sid = transaction.savepoint()
+ x.save()
+ transaction.savepoint_commit(sid)
+ except IntegrityError:
+ transaction.savepoint_rollback(sid)
+ raise
+
+.. versionadded:: 1.1
+
+ * With PostgreSQL 8.2 or later, there is an advanced option to run
+ PostgreSQL with :ref:`database-level autocommit `.
+ With this option there is no constantly open transaction, so
+ savepoints are not required to continue after catching an exception.
+ Please see the documentation for that feature, which behaves
+ differently from the standard ``autocommit`` decorator.