aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/sqlite.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-02-28 12:46:00 -0500
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-02-28 12:46:00 -0500
commit5abd643c6d10f2cfa6e26652a9688a0263310094 (patch)
tree2fdb8bf147cb93430ba3ba79a473568e2584e497 /src/libstore/sqlite.cc
parente68e8e3cee53ce7debd7c54b0d122d94d1b102a2 (diff)
parentd381248ec0847cacd918480e83a99287f814456a (diff)
Merge branch 'path-info' into ca-drv-exotic
Diffstat (limited to 'src/libstore/sqlite.cc')
-rw-r--r--src/libstore/sqlite.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libstore/sqlite.cc b/src/libstore/sqlite.cc
index 353dff9fa..871f2f3be 100644
--- a/src/libstore/sqlite.cc
+++ b/src/libstore/sqlite.cc
@@ -41,6 +41,15 @@ SQLiteError::SQLiteError(const char *path, const char *errMsg, int errNo, int ex
throw SQLiteError(path, errMsg, err, exterr, offset, std::move(hf));
}
+static void traceSQL(void * x, const char * sql)
+{
+ // wacky delimiters:
+ // so that we're quite unambiguous without escaping anything
+ // notice instead of trace:
+ // so that this can be enabled without getting the firehose in our face.
+ notice("SQL<[%1%]>", sql);
+};
+
SQLite::SQLite(const Path & path, bool create)
{
// useSQLiteWAL also indicates what virtual file system we need. Using
@@ -58,6 +67,11 @@ SQLite::SQLite(const Path & path, bool create)
if (sqlite3_busy_timeout(db, 60 * 60 * 1000) != SQLITE_OK)
SQLiteError::throw_(db, "setting timeout");
+ if (getEnv("NIX_DEBUG_SQLITE_TRACES") == "1") {
+ // To debug sqlite statements; trace all of them
+ sqlite3_trace(db, &traceSQL, nullptr);
+ }
+
exec("pragma foreign_keys = 1");
}