constexpr const char CREATE_CION_TABLE[] = R"__cion(
PRAGMA user_version = 50;
PRAGMA journal_mode = PERSIST;
+PRAGMA foreign_keys = ON;
CREATE TABLE IF NOT EXISTS cion_uuid (
appid TEXT NOT NULL,
uuid TEXT NOT NULL,
);
)__cion";
+constexpr const char PRAGMA_FOREIGN_KEYS[] = "PRAGMA foreign_keys;";
+
bool CreateTable(const tizen_base::Database& db) {
try {
auto q = tizen_base::Database::Sql(CREATE_CION_TABLE);
return true;
}
+bool IsEnabledForeignKeys(const tizen_base::Database& db) {
+ try {
+ auto sql = tizen_base::Database::Sql(PRAGMA_FOREIGN_KEYS);
+ auto result = db.Exec(sql);
+ for (const auto& i : result)
+ return static_cast<int>(i.Get(0)) ? true : false;
+ } catch (const tizen_base::DbException& e) {
+ _E("Exception(%s) occurs", e.msg());
+ }
+
+ return false;
+}
+
} // namespace
bool CionModule::Startup(api::ToolBox* tools) {
_E("Fail to create table");
return false;
}
+
+ _W("foreign_keys: %s", IsEnabledForeignKeys(db) ? "ON" : "OFF");
} catch (const tizen_base::DbException& e) {
_E("runtime error(%s) occurs", e.msg());
unlink(DBPATH);
_E("Fail to create table");
return false;
}
+
+ _W("foreign_keys: %s", IsEnabledForeignKeys(db) ? "ON" : "OFF");
} catch (const tizen_base::DbException& e) {
_E("runtime error(%s) occurs", e.msg());
unlink(DBPATH);