summary refs log tree commit diff
path: root/database.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--database.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/database.h b/database.h
index 6efe9d0..1dcc71b 100644
--- a/database.h
+++ b/database.h
@@ -44,6 +44,8 @@ enum Type {
 	Topic,
 };
 
+static bool verbose;
+
 static inline void dbExec(sqlite3 *db, const char *sql) {
 	int error = sqlite3_exec(db, sql, NULL, NULL, NULL);
 	if (error) errx(EX_SOFTWARE, "%s: %s", sqlite3_errmsg(db), sql);
@@ -173,6 +175,16 @@ static inline int dbStep(sqlite3_stmt *stmt) {
 	);
 }
 
+static inline void dbRun(sqlite3_stmt *stmt) {
+	dbStep(stmt);
+	if (verbose && sqlite3_changes(sqlite3_db_handle(stmt))) {
+		char *sql = sqlite3_expanded_sql(stmt);
+		if (sql) fprintf(stderr, "%s\n", sql);
+		sqlite3_free(sql);
+	}
+	sqlite3_reset(stmt);
+}
+
 static inline int dbVersion(sqlite3 *db) {
 	sqlite3_stmt *stmt = dbPrepare(db, false, SQL(PRAGMA user_version;));
 	dbStep(stmt);
e='2018-11-21 02:30:41 +0100'>2018-11-21git: use xz compressed archive for downloadChristian Hesse 2018-10-12git: update to v2.19.1Christian Hesse 2018-09-11ui-ssdiff: ban strcat()Christian Hesse 2018-09-11ui-ssdiff: ban strncpy()Christian Hesse 2018-09-11ui-shared: ban strcat()Christian Hesse 2018-09-11ui-patch: ban sprintf()Christian Hesse 2018-09-11ui-log: ban strncpy()Christian Hesse 2018-09-11ui-log: ban strcpy()Christian Hesse 2018-09-11parsing: ban sprintf()Christian Hesse 2018-09-11parsing: ban strncpy()Christian Hesse 2018-08-28filters: generate anchor links from markdownChristian Hesse 2018-08-03Bump version.Jason A. Donenfeld 2018-08-03clone: fix directory traversalJason A. Donenfeld 2018-08-03config: record repo.snapshot-prefix in the per-repo configKonstantin Ryabitsev