From 88b2a20f047347da86f448fe09a56251d29e4168 Mon Sep 17 00:00:00 2001 From: Thomas Chaumeny Date: Sun, 9 Nov 2014 23:08:02 +0100 Subject: [PATCH] Simplified MySQL storage engine detection using INFORMATION_SCHEMA.ENGINES table Query the table introduced in MySQL 5.1; refs #23144. --- django/db/backends/mysql/base.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index 3a34aeb35d8..b2d9b649be0 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -194,15 +194,9 @@ class DatabaseFeatures(BaseDatabaseFeatures): def _mysql_storage_engine(self): "Internal method used in Django tests. Don't rely on this from your code" with self.connection.cursor() as cursor: - cursor.execute('CREATE TABLE INTROSPECT_TEST (X INT)') - # This command is MySQL specific; the second column - # will tell you the default table type of the created - # table. Since all Django's test tables will have the same - # table type, that's enough to evaluate the feature. - cursor.execute("SHOW TABLE STATUS WHERE Name='INTROSPECT_TEST'") + cursor.execute("SELECT ENGINE FROM INFORMATION_SCHEMA.ENGINES WHERE SUPPORT = 'DEFAULT'") result = cursor.fetchone() - cursor.execute('DROP TABLE INTROSPECT_TEST') - return result[1] + return result[0] @cached_property def can_introspect_foreign_keys(self):