summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2016-06-23 11:52:14 -0400
committerSimon Charette <charette.s@gmail.com>2016-08-08 12:01:43 -0400
commitb8e6e1b43b0bccec178dcc6708c5c8295abfb2e5 (patch)
treef3c146f02ecf6b0181d790cc67d83ad53cd629f9 /docs
parent46509cf13dbf049f75077981c29ef2c60b5a96ab (diff)
Fixed #26500 -- Added SKIP LOCKED support to select_for_update().
Thanks Tim for the review.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/databases.txt6
-rw-r--r--docs/ref/models/querysets.txt23
-rw-r--r--docs/releases/1.11.txt7
3 files changed, 24 insertions, 12 deletions
diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt
index 35a3dbcbe8..983b7525c3 100644
--- a/docs/ref/databases.txt
+++ b/docs/ref/databases.txt
@@ -569,9 +569,9 @@ both MySQL and Django will attempt to convert the values from UTC to local time.
Row locking with ``QuerySet.select_for_update()``
-------------------------------------------------
-MySQL does not support the ``NOWAIT`` option to the ``SELECT ... FOR UPDATE``
-statement. If ``select_for_update()`` is used with ``nowait=True`` then a
-``DatabaseError`` will be raised.
+MySQL does not support the ``NOWAIT`` and ``SKIP LOCKED`` options to the
+``SELECT ... FOR UPDATE`` statement. If ``select_for_update()`` is used with
+``nowait=True`` or ``skip_locked=True`` then a ``DatabaseError`` will be raised.
Automatic typecasting can cause unexpected results
--------------------------------------------------
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index 3f4fce1a26..8d2e3ebb3b 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -1528,7 +1528,7 @@ For example::
``select_for_update()``
~~~~~~~~~~~~~~~~~~~~~~~
-.. method:: select_for_update(nowait=False)
+.. method:: select_for_update(nowait=False, skip_locked=False)
Returns a queryset that will lock rows until the end of the transaction,
generating a ``SELECT ... FOR UPDATE`` SQL statement on supported databases.
@@ -1546,16 +1546,19 @@ selected rows, the query will block until the lock is released. If this is
not the behavior you want, call ``select_for_update(nowait=True)``. This will
make the call non-blocking. If a conflicting lock is already acquired by
another transaction, :exc:`~django.db.DatabaseError` will be raised when the
-queryset is evaluated.
+queryset is evaluated. You can also ignore locked rows by using
+``select_for_update(skip_locked=True)`` instead. The ``nowait`` and
+``skip_locked`` are mutually exclusive and attempts to call
+``select_for_update()`` with both options enabled will result in a
+:exc:`ValueError`.
Currently, the ``postgresql``, ``oracle``, and ``mysql`` database
-backends support ``select_for_update()``. However, MySQL has no support for the
-``nowait`` argument. Obviously, users of external third-party backends should
-check with their backend's documentation for specifics in those cases.
+backends support ``select_for_update()``. However, MySQL doesn't support the
+``nowait`` and ``skip_locked`` arguments.
-Passing ``nowait=True`` to ``select_for_update()`` using database backends that
-do not support ``nowait``, such as MySQL, will cause a
-:exc:`~django.db.DatabaseError` to be raised. This is in order to prevent code
+Passing ``nowait=True`` or ``skip_locked=True`` to ``select_for_update()``
+using database backends that do not support these options, such as MySQL, will
+cause a :exc:`~django.db.DatabaseError` to be raised. This prevents code from
unexpectedly blocking.
Evaluating a queryset with ``select_for_update()`` in autocommit mode on
@@ -1580,6 +1583,10 @@ raised if ``select_for_update()`` is used in autocommit mode.
``select_for_update()`` you should use
:class:`~django.test.TransactionTestCase`.
+.. versionchanged:: 1.11
+
+ The ``skip_locked`` argument was added.
+
``raw()``
~~~~~~~~~
diff --git a/docs/releases/1.11.txt b/docs/releases/1.11.txt
index 1c7509b062..128ef2c203 100644
--- a/docs/releases/1.11.txt
+++ b/docs/releases/1.11.txt
@@ -150,7 +150,9 @@ CSRF
Database backends
~~~~~~~~~~~~~~~~~
-* ...
+* Added the ``skip_locked`` argument to :meth:`.QuerySet.select_for_update()`
+ on PostgreSQL 9.5+ and Oracle to execute queries with
+ ``FOR UPDATE SKIP LOCKED``.
Email
~~~~~
@@ -297,6 +299,9 @@ Database backend API
support the :lookup:`time` lookup. It accepts a ``field_name`` and ``tzname``
arguments and returns the SQL necessary to cast a datetime value to time value.
+* To enable ``FOR UPDATE SKIP LOCKED`` support, set
+ ``DatabaseFeatures.has_select_for_update_skip_locked = True``.
+
Dropped support for PostgreSQL 9.2 and PostGIS 2.0
--------------------------------------------------