Added an option to disable the creation of savepoints in atomic.

This commit is contained in:
Aymeric Augustin 2013-03-08 15:44:41 +01:00
parent 189fb4e294
commit 107d9b1d97
4 changed files with 156 additions and 30 deletions

View file

@ -89,7 +89,7 @@ Controlling transactions explicitly
Django provides a single API to control database transactions.
.. function:: atomic(using=None)
.. function:: atomic(using=None, savepoint=True)
This function creates an atomic block for writes to the database.
(Atomicity is the defining property of database transactions.)
@ -164,6 +164,14 @@ Django provides a single API to control database transactions.
- releases or rolls back to the savepoint when exiting an inner block;
- commits or rolls back the transaction when exiting the outermost block.
You can disable the creation of savepoints for inner blocks by setting the
``savepoint`` argument to ``False``. If an exception occurs, Django will
perform the rollback when exiting the first parent block with a savepoint
if there is one, and the outermost block otherwise. Atomicity is still
guaranteed by the outer transaction. This option should only be used if
the overhead of savepoints is noticeable. It has the drawback of breaking
the error handling described above.
.. admonition:: Performance considerations
Open transactions have a performance cost for your database server. To