From 22466f91dccf440fa8b0aff3610ed51dbb25403b Mon Sep 17 00:00:00 2001 From: kola-er Date: Mon, 4 Nov 2019 22:44:10 +0100 Subject: [PATCH] [2.2.x] Fixed #30928 -- Clarified MySQL/MariaDB support of QuerySet.select_for_update() options. Thanks Par Andersson for reporting the issue. Backport of d94d7b113c21d7a0fd802fadb1adbbec8155e880 from master --- docs/ref/databases.txt | 15 +++++++++++---- docs/ref/models/querysets.txt | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt index 7a766bcf21..d525224dd6 100644 --- a/docs/ref/databases.txt +++ b/docs/ref/databases.txt @@ -612,10 +612,17 @@ 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``, ``SKIP LOCKED``, and ``OF`` options to -the ``SELECT ... FOR UPDATE`` statement. If ``select_for_update()`` is used -with ``nowait=True``, ``skip_locked=True``, or ``of`` then a -:exc:`~django.db.NotSupportedError` is raised. +MySQL does not support some options to the ``SELECT ... FOR UPDATE`` statement. +If ``select_for_update()`` is used with an unsupported option, then +a :exc:`~django.db.NotSupportedError` is raised. + +=============== ========== +Option MySQL +=============== ========== +``SKIP LOCKED`` X (≥8.0.1) +``NOWAIT`` X (≥8.0.1) +``OF`` +=============== ========== When using ``select_for_update()`` on MySQL, make sure you filter a queryset against at least set of fields contained in unique constraints or only against diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index 7880d0eed7..3ccd5958fd 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -1711,7 +1711,8 @@ them:: Currently, the ``postgresql``, ``oracle``, and ``mysql`` database backends support ``select_for_update()``. However, MySQL doesn't support the -``nowait``, ``skip_locked``, and ``of`` arguments. +``of`` argument and the ``nowait`` and ``skip_locked`` arguments are supported +only on MySQL 8.0.1+. Passing ``nowait=True``, ``skip_locked=True``, or ``of`` to ``select_for_update()`` using database backends that do not support these