Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/sqlite.cpp
Show First 20 Lines • Show All 513 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void SQLiteBatch::CloseCursor() { | void SQLiteBatch::CloseCursor() { | ||||
sqlite3_reset(m_cursor_stmt); | sqlite3_reset(m_cursor_stmt); | ||||
m_cursor_init = false; | m_cursor_init = false; | ||||
} | } | ||||
bool SQLiteBatch::TxnBegin() { | bool SQLiteBatch::TxnBegin() { | ||||
if (!m_database.m_db || sqlite3_get_autocommit(m_database.m_db) == 0) { | |||||
return false; | return false; | ||||
} | } | ||||
int res = sqlite3_exec(m_database.m_db, "BEGIN TRANSACTION", nullptr, | |||||
nullptr, nullptr); | |||||
if (res != SQLITE_OK) { | |||||
LogPrintf("SQLiteBatch: Failed to begin the transaction\n"); | |||||
} | |||||
return res == SQLITE_OK; | |||||
} | |||||
bool SQLiteBatch::TxnCommit() { | bool SQLiteBatch::TxnCommit() { | ||||
if (!m_database.m_db || sqlite3_get_autocommit(m_database.m_db) != 0) { | |||||
return false; | return false; | ||||
} | } | ||||
int res = sqlite3_exec(m_database.m_db, "COMMIT TRANSACTION", nullptr, | |||||
nullptr, nullptr); | |||||
if (res != SQLITE_OK) { | |||||
LogPrintf("SQLiteBatch: Failed to commit the transaction\n"); | |||||
} | |||||
return res == SQLITE_OK; | |||||
} | |||||
bool SQLiteBatch::TxnAbort() { | bool SQLiteBatch::TxnAbort() { | ||||
if (!m_database.m_db || sqlite3_get_autocommit(m_database.m_db) != 0) { | |||||
return false; | return false; | ||||
} | } | ||||
int res = sqlite3_exec(m_database.m_db, "ROLLBACK TRANSACTION", nullptr, | |||||
nullptr, nullptr); | |||||
if (res != SQLITE_OK) { | |||||
LogPrintf("SQLiteBatch: Failed to abort the transaction\n"); | |||||
} | |||||
return res == SQLITE_OK; | |||||
} | |||||
bool ExistsSQLiteDatabase(const fs::path &path) { | bool ExistsSQLiteDatabase(const fs::path &path) { | ||||
return false; | return false; | ||||
} | } | ||||
std::unique_ptr<SQLiteDatabase> | std::unique_ptr<SQLiteDatabase> | ||||
MakeSQLiteDatabase(const fs::path &path, const DatabaseOptions &options, | MakeSQLiteDatabase(const fs::path &path, const DatabaseOptions &options, | ||||
DatabaseStatus &status, bilingual_str &error) { | DatabaseStatus &status, bilingual_str &error) { | ||||
return std::make_unique<SQLiteDatabase>(path, path / DATABASE_FILENAME); | return std::make_unique<SQLiteDatabase>(path, path / DATABASE_FILENAME); | ||||
} | } | ||||
std::string SQLiteDatabaseVersion() { | std::string SQLiteDatabaseVersion() { | ||||
return std::string(sqlite3_libversion()); | return std::string(sqlite3_libversion()); | ||||
} | } |