From b6f2b4e1e924965d55e656992a48cc3cd19e64a2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 28 Mar 2011 11:21:46 +0200 Subject: Add schema creation flag to create_database() --- common/threads/driver.cxx | 2 +- libcommon/common/common.cxx | 10 +++++++++- libcommon/common/common.hxx | 5 ++++- mysql/native/driver.cxx | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/common/threads/driver.cxx b/common/threads/driver.cxx index 212ff60..9aab254 100644 --- a/common/threads/driver.cxx +++ b/common/threads/driver.cxx @@ -114,7 +114,7 @@ struct task void test (int argc, char* argv[], size_t max_connections) { - auto_ptr db (create_database (argc, argv, max_connections)); + auto_ptr db (create_database (argc, argv, true, max_connections)); vector > threads; vector > tasks; diff --git a/libcommon/common/common.cxx b/libcommon/common/common.cxx index 1ed65e3..a6fa4e1 100644 --- a/libcommon/common/common.cxx +++ b/libcommon/common/common.cxx @@ -34,7 +34,14 @@ namespace sqlite = odb::sqlite; #endif auto_ptr -create_database (int& argc, char* argv[], size_t max_connections) +create_database (int& argc, + char* argv[], +#if defined(DATABASE_SQLITE) + bool schema, +#else + bool, +#endif + size_t max_connections) { if (argc > 1 && argv[1] == string ("--help")) { @@ -71,6 +78,7 @@ create_database (int& argc, char* argv[], size_t max_connections) // Create the database schema. // + if (schema) { transaction t (db->begin ()); schema_catalog::create_schema (*db); diff --git a/libcommon/common/common.hxx b/libcommon/common/common.hxx index 23e9d80..6ace845 100644 --- a/libcommon/common/common.hxx +++ b/libcommon/common/common.hxx @@ -16,7 +16,10 @@ #include LIBCOMMON_EXPORT std::auto_ptr -create_database (int& argc, char* argv[], std::size_t max_connections = 0); +create_database (int& argc, + char* argv[], + bool create_schema = true, + std::size_t max_connections = 0); // This function returns an accurate result only if the result iterator // hasn't been advanced. diff --git a/mysql/native/driver.cxx b/mysql/native/driver.cxx index 8854566..437a160 100644 --- a/mysql/native/driver.cxx +++ b/mysql/native/driver.cxx @@ -23,7 +23,7 @@ main (int argc, char* argv[]) { try { - auto_ptr db (create_database (argc, argv)); + auto_ptr db (create_database (argc, argv, false)); // Create the database schema. // -- cgit v1.1