aboutsummaryrefslogtreecommitdiff
path: root/common/schema/embedded/order/driver.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-02-12 08:01:33 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-02-12 08:01:33 +0200
commitbe7e2755e5f187af7bd9902576379421c2a06e2a (patch)
tree720de6a5f55241afbec0b803db864ee3eada0cdc /common/schema/embedded/order/driver.cxx
parent2baa7856aaa9e5f4ff3ec1d56e3e0ea317c15c7b (diff)
Disable constraint checking in MySQL
This test can either create tables or drop them in the "wrong" order, depending on the static initialization order. For MySQL we can create things but not drop (no IF EXISTS or similar support).
Diffstat (limited to 'common/schema/embedded/order/driver.cxx')
-rw-r--r--common/schema/embedded/order/driver.cxx12
1 files changed, 9 insertions, 3 deletions
diff --git a/common/schema/embedded/order/driver.cxx b/common/schema/embedded/order/driver.cxx
index 63d9c35..685693d 100644
--- a/common/schema/embedded/order/driver.cxx
+++ b/common/schema/embedded/order/driver.cxx
@@ -37,9 +37,13 @@ main (int argc, char* argv[])
{
connection_ptr c (db->connection ());
- // Temporarily disable foreign key constraints for SQLite.
+ // Temporarily disable foreign key constraints for MySQL and SQLite.
+ // For MySQL we can actually create the tables in any order. It is
+ // dropping them that's the problem (there is no IF EXISTS).
//
-#if defined(DATABASE_SQLITE)
+#if defined(DATABASE_MYSQL)
+ c->execute ("SET FOREIGN_KEY_CHECKS=0");
+#elif defined(DATABASE_SQLITE)
c->execute ("PRAGMA foreign_keys=OFF");
#endif
@@ -47,7 +51,9 @@ main (int argc, char* argv[])
schema_catalog::create_schema (*db);
t.commit ();
-#if defined(DATABASE_SQLITE)
+#if defined(DATABASE_MYSQL)
+ c->execute ("SET FOREIGN_KEY_CHECKS=1");
+#elif defined(DATABASE_SQLITE)
c->execute ("PRAGMA foreign_keys=ON");
#endif
}