summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Chaumeny <t.chaumeny@gmail.com>2014-11-09 23:08:02 +0100
committerTim Graham <timograham@gmail.com>2014-11-10 18:16:14 +0100
commit88b2a20f047347da86f448fe09a56251d29e4168 (patch)
tree06f15d794d98d3f8cc2bbd0d0d309e321fafd018
parentb748a8bc670af10c37560836c353ce911eaeecc0 (diff)
Simplified MySQL storage engine detection using INFORMATION_SCHEMA.ENGINES table
Query the table introduced in MySQL 5.1; refs #23144.
-rw-r--r--django/db/backends/mysql/base.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index 3a34aeb35d..b2d9b649be 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):