diff options
| author | Tim Graham <timograham@gmail.com> | 2017-11-18 07:43:58 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-11-20 10:08:58 -0500 |
| commit | 205290f5105e429a84c299f2fc19124df838f3c0 (patch) | |
| tree | d4b8c1caf75ba50e41fb6bf93ba154dfae1ef8aa /django | |
| parent | 385e06d8c05ad4e5089295a3bafad2b922fd2763 (diff) | |
[2.0.x] Fixed #28804 -- Fixed "Unknown system variable 'transaction_isolation'" on MariaDB.
Regression in 967450a3bf940c43db891fe1e2ef3bcf73456ff8.
Backport of e3c852cbd609484b272f563f3c21066fb12ef7f8 from master
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/backends/mysql/base.py | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index 7690629209..7ab3bc8d0d 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -228,9 +228,6 @@ class DatabaseWrapper(BaseDatabaseWrapper): isolation_level, ', '.join("'%s'" % s for s in sorted(self.isolation_levels)) )) - # The variable assignment form of setting transaction isolation - # levels will be used, e.g. "set transaction_isolation='repeatable-read'". - isolation_level = isolation_level.replace(' ', '-') self.isolation_level = isolation_level kwargs.update(options) return kwargs @@ -238,10 +235,6 @@ class DatabaseWrapper(BaseDatabaseWrapper): def get_new_connection(self, conn_params): return Database.connect(**conn_params) - @cached_property - def transaction_isolation_variable(self): - return 'tx_isolation' if self.mysql_version < (5, 7, 20) else 'transaction_isolation' - def init_connection_state(self): assignments = [] if self.features.is_sql_auto_is_null_enabled: @@ -249,14 +242,14 @@ class DatabaseWrapper(BaseDatabaseWrapper): # a recently inserted row will return when the field is tested # for NULL. Disabling this brings this aspect of MySQL in line # with SQL standards. - assignments.append('SQL_AUTO_IS_NULL = 0') + assignments.append('SET SQL_AUTO_IS_NULL = 0') if self.isolation_level: - assignments.append("%s = '%s'" % (self.transaction_isolation_variable, self.isolation_level)) + assignments.append('SET SESSION TRANSACTION ISOLATION LEVEL %s' % self.isolation_level.upper()) if assignments: with self.cursor() as cursor: - cursor.execute('SET ' + ', '.join(assignments)) + cursor.execute('; '.join(assignments)) def create_cursor(self, name=None): cursor = self.connection.cursor() |
