summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2012-05-26 23:19:13 +0300
committerAnssi Kääriäinen <akaariai@gmail.com>2012-07-01 19:36:43 +0300
commitf572ee0c65ec5eac9edb0cb3e35c96ec86d89ffb (patch)
treef2b3ebd0d6df09cdf29b6c9e10ee0e5210e44ee8 /django
parentda573fbb4172fb962c9f021fc0c03cf91b13e746 (diff)
Fixed #16047 -- Restore autocommit state correctly on psycopg2
When the postgresql_psycopg2 backend was used with DB-level autocommit mode enabled, after entering transaction management and then leaving it, the isolation level was never set back to autocommit mode. Thanks brodie for report and working on this issue.
Diffstat (limited to 'django')
-rw-r--r--django/db/backends/__init__.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
index dab9b7e213..05ef7bf62a 100644
--- a/django/db/backends/__init__.py
+++ b/django/db/backends/__init__.py
@@ -109,16 +109,18 @@ class BaseDatabaseWrapper(object):
over to the surrounding block, as a commit will commit all changes, even
those from outside. (Commits are on connection level.)
"""
- self._leave_transaction_management(self.is_managed())
if self.transaction_state:
del self.transaction_state[-1]
else:
- raise TransactionManagementError("This code isn't under transaction "
- "management")
+ raise TransactionManagementError(
+ "This code isn't under transaction management")
+ # We will pass the next status (after leaving the previous state
+ # behind) to subclass hook.
+ self._leave_transaction_management(self.is_managed())
if self._dirty:
self.rollback()
- raise TransactionManagementError("Transaction managed block ended with "
- "pending COMMIT/ROLLBACK")
+ raise TransactionManagementError(
+ "Transaction managed block ended with pending COMMIT/ROLLBACK")
self._dirty = False
def validate_thread_sharing(self):
@@ -176,6 +178,8 @@ class BaseDatabaseWrapper(object):
"""
if self.transaction_state:
return self.transaction_state[-1]
+ # Note that this setting isn't documented, and is only used here, and
+ # in enter_transaction_management()
return settings.TRANSACTIONS_MANAGED
def managed(self, flag=True):