mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Added an option to disable the creation of savepoints in atomic.
This commit is contained in:
parent
189fb4e294
commit
107d9b1d97
4 changed files with 156 additions and 30 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue