about summary refs log tree commit diff
path: root/src/libstore/sqlite.hh
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-02-28T12·59+0100
committerEelco Dolstra <edolstra@gmail.com>2017-02-28T12·59+0100
commitfd86dd93dd44a826235feb0fd82aabcdaa79a65b (patch)
treeeae160a900df505d78f7094d2b7b92aa409ea10c /src/libstore/sqlite.hh
parent34b12bad597a5d9f67408bebefc1bcb65c27bc4a (diff)
Improve SQLite busy handling
Diffstat (limited to 'src/libstore/sqlite.hh')
-rw-r--r--src/libstore/sqlite.hh6
1 files changed, 5 insertions, 1 deletions
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<typename T>
@@ -103,6 +106,7 @@ T retrySQLite(std::function<T()> fun)
         try {
             return fun();
         } catch (SQLiteBusy & e) {
+            handleSQLiteBusy(e);
         }
     }
 }