diff options
author | June McEnroe <june@causal.agency> | 2019-12-18 00:59:05 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-12-18 00:59:05 -0500 |
commit | 162450118be816d81341d0e59eb88db56b8fc70c (patch) | |
tree | 598890ca14b45bb43679c735341d00d001c53bf4 /database.h | |
parent | Use sqlite3_bind_int (diff) | |
download | litterbox-162450118be816d81341d0e59eb88db56b8fc70c.tar.gz litterbox-162450118be816d81341d0e59eb88db56b8fc70c.zip |
Rewrite litterbox statements with functions
Diffstat (limited to '')
-rw-r--r-- | database.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/database.h b/database.h index fad5265..6efe9d0 100644 --- a/database.h +++ b/database.h @@ -100,9 +100,11 @@ static inline sqlite3 *dbFind(int flags) { } static inline sqlite3_stmt * -dbPrepare(sqlite3 *db, unsigned flags, const char *sql) { +dbPrepare(sqlite3 *db, bool persistent, const char *sql) { sqlite3_stmt *stmt; - int error = sqlite3_prepare_v3(db, sql, -1, flags, &stmt, NULL); + int error = sqlite3_prepare_v3( + db, sql, -1, (persistent ? SQLITE_PREPARE_PERSISTENT : 0), &stmt, NULL + ); if (error) errx(EX_SOFTWARE, "%s: %s", sqlite3_errmsg(db), sql); return stmt; } @@ -172,7 +174,7 @@ static inline int dbStep(sqlite3_stmt *stmt) { } static inline int dbVersion(sqlite3 *db) { - sqlite3_stmt *stmt = dbPrepare(db, 0, SQL(PRAGMA user_version;)); + sqlite3_stmt *stmt = dbPrepare(db, false, SQL(PRAGMA user_version;)); dbStep(stmt); int version = sqlite3_column_int(stmt, 0); sqlite3_finalize(stmt); |