fixes #4

Manually merged
andreacavalli merged 1 commits from :fork into fork 2019-12-15 18:36:21 +01:00

View File

@ -51,7 +51,9 @@ Status SqliteDb::init(CSlice path, bool *was_created) {
// If database does not exist, delete all other files which may left // If database does not exist, delete all other files which may left
// from older database // from older database
if (path != ":memory:") { if (path == ":memory:") {
*was_created = false;
} else {
bool is_db_exists = stat(path).is_ok(); bool is_db_exists = stat(path).is_ok();
if (!is_db_exists) { if (!is_db_exists) {
@ -65,7 +67,7 @@ Status SqliteDb::init(CSlice path, bool *was_created) {
sqlite3 *db; sqlite3 *db;
CHECK(sqlite3_threadsafe() != 0); CHECK(sqlite3_threadsafe() != 0);
int rc = sqlite3_open_v2(path.c_str(), &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_SHAREDCACHE, int rc = sqlite3_open_v2(path.c_str(), &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
nullptr); nullptr);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
auto res = Status::Error(PSLICE() << "Failed to open database: " << detail::RawSqliteDb::last_error(db)); auto res = Status::Error(PSLICE() << "Failed to open database: " << detail::RawSqliteDb::last_error(db));