exit(1);
}
+ // Set an effectively infinite timeout for waiting for write locks;
+ // if we get SQLITE_LOCKED, we just exit out, so this is much better.
+ ret = sqlite3_busy_timeout(db, 3600000);
+ if (ret != SQLITE_OK) {
+ fprintf(stderr, "sqlite3_busy_timeout: %s\n", sqlite3_errmsg(db));
+ exit(1);
+ }
+
sqlite3_exec(db, R"(
CREATE TABLE IF NOT EXISTS state (state BLOB);
)",
sqlite3_exec(db, "CREATE UNIQUE INDEX only_one_state ON state (1);", nullptr, nullptr, nullptr); // Ignore errors.
sqlite3_exec(db, R"(
- CREATE TABLE IF NOT EXISTS settings (settings BLOB, uniqifier NOT NULL DEFAULT 1 UNIQUE);
+ CREATE TABLE IF NOT EXISTS settings (settings BLOB);
)",
nullptr, nullptr, nullptr); // Ignore errors.
ret = sqlite3_step(stmt);
if (ret == SQLITE_ROW) {
- fprintf(stderr, "INSERT step: %s\n", sqlite3_errmsg(db));
+ fprintf(stderr, "REPLACE step: %s\n", sqlite3_errmsg(db));
exit(1);
}
ret = sqlite3_finalize(stmt);
if (ret != SQLITE_OK) {
- fprintf(stderr, "INSERT finalize: %s\n", sqlite3_errmsg(db));
+ fprintf(stderr, "REPLACE finalize: %s\n", sqlite3_errmsg(db));
exit(1);
}