summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-03-04 15:57:04 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-03-11 14:48:55 +0100
commit4b31a6a9e698a26e3e359e2ccf3da1505d114cf1 (patch)
tree04aa2cfbefad45e173ea8e351839e40aad82b3a7 /docs
parente264f67174622f66503e4748e2f71c72a4a5064b (diff)
Added support for savepoints in SQLite.
Technically speaking they aren't usable yet.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/databases.txt3
-rw-r--r--docs/topics/db/transactions.txt35
2 files changed, 26 insertions, 12 deletions
diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt
index 4dafb3774f..78c1bb3dda 100644
--- a/docs/ref/databases.txt
+++ b/docs/ref/databases.txt
@@ -424,8 +424,7 @@ Savepoints
Both the Django ORM and MySQL (when using the InnoDB :ref:`storage engine
<mysql-storage-engines>`) support database :ref:`savepoints
-<topics-db-transactions-savepoints>`, but this feature wasn't available in
-Django until version 1.4 when such support was added.
+<topics-db-transactions-savepoints>`.
If you use the MyISAM storage engine please be aware of the fact that you will
receive database-generated errors if you try to use the :ref:`savepoint-related
diff --git a/docs/topics/db/transactions.txt b/docs/topics/db/transactions.txt
index 93c4a3b11d..e2c8e4e3f5 100644
--- a/docs/topics/db/transactions.txt
+++ b/docs/topics/db/transactions.txt
@@ -251,11 +251,11 @@ the transaction middleware, and only modify selected functions as needed.
Savepoints
==========
-A savepoint is a marker within a transaction that enables you to roll back part
-of a transaction, rather than the full transaction. Savepoints are available
-with the PostgreSQL 8, Oracle and MySQL (when using the InnoDB storage engine)
-backends. Other backends provide the savepoint functions, but they're empty
-operations -- they don't actually do anything.
+A savepoint is a marker within a transaction that enables you to roll back
+part of a transaction, rather than the full transaction. Savepoints are
+available with the SQLite (≥ 3.6.8), PostgreSQL, Oracle and MySQL (when using
+the InnoDB storage engine) backends. Other backends provide the savepoint
+functions, but they're empty operations -- they don't actually do anything.
Savepoints aren't especially useful if you are using the default
``autocommit`` behavior of Django. However, if you are using
@@ -314,6 +314,21 @@ The following example demonstrates the use of savepoints::
Database-specific notes
=======================
+Savepoints in SQLite
+--------------------
+
+While SQLite ≥ 3.6.8 supports savepoints, a flaw in the design of the
+:mod:`sqlite3` makes them hardly usable.
+
+When autocommit is enabled, savepoints don't make sense. When it's disabled,
+:mod:`sqlite3` commits implicitly before savepoint-related statement. (It
+commits before any statement other than ``SELECT``, ``INSERT``, ``UPDATE``,
+``DELETE`` and ``REPLACE``.)
+
+As a consequence, savepoints are only usable if you start a transaction
+manually while in autocommit mode, and Django doesn't provide an API to
+achieve that.
+
Transactions in MySQL
---------------------
@@ -363,11 +378,11 @@ itself.
Savepoint rollback
~~~~~~~~~~~~~~~~~~
-If you are using PostgreSQL 8 or later, you can use :ref:`savepoints
-<topics-db-transactions-savepoints>` to control the extent of a rollback.
-Before performing a database operation that could fail, you can set or update
-the savepoint; that way, if the operation fails, you can roll back the single
-offending operation, rather than the entire transaction. For example::
+You can use :ref:`savepoints <topics-db-transactions-savepoints>` to control
+the extent of a rollback. Before performing a database operation that could
+fail, you can set or update the savepoint; that way, if the operation fails,
+you can roll back the single offending operation, rather than the entire
+transaction. For example::
a.save() # Succeeds, and never undone by savepoint rollback
try: