From fd86dd93dd44a826235feb0fd82aabcdaa79a65b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 28 Feb 2017 13:59:11 +0100 Subject: Improve SQLite busy handling --- src/libstore/sqlite.hh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/libstore/sqlite.hh') diff --git a/src/libstore/sqlite.hh b/src/libstore/sqlite.hh index 4d347a2e56ab..14a7a0dd8996 100644 --- a/src/libstore/sqlite.hh +++ b/src/libstore/sqlite.hh @@ -30,8 +30,9 @@ struct SQLiteStmt { sqlite3 * db = 0; sqlite3_stmt * stmt = 0; + std::string sql; SQLiteStmt() { } - SQLiteStmt(sqlite3 * db, const std::string & s) { create(db, s); } + SQLiteStmt(sqlite3 * db, const std::string & sql) { create(db, sql); } void create(sqlite3 * db, const std::string & s); ~SQLiteStmt(); operator sqlite3_stmt * () { return stmt; } @@ -94,6 +95,8 @@ MakeError(SQLiteBusy, SQLiteError); [[noreturn]] void throwSQLiteError(sqlite3 * db, const format & f); +void handleSQLiteBusy(const SQLiteBusy & e); + /* Convenience function for retrying a SQLite transaction when the database is busy. */ template @@ -103,6 +106,7 @@ T retrySQLite(std::function fun) try { return fun(); } catch (SQLiteBusy & e) { + handleSQLiteBusy(e); } } } -- cgit 1.4.1