From be7e2755e5f187af7bd9902576379421c2a06e2a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 12 Feb 2013 08:01:33 +0200 Subject: 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). --- common/schema/embedded/order/driver.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'common/schema/embedded/order/driver.cxx') 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 } -- cgit v1.1