sql: if we use `dev-sqlfilename`, don't bother syncing it to disk.
What changed, and why it matters
This commit changes a developer-only test feature (`dev-sqlfilename`) so that when it is used, the SQLite database does not write changes to disk as carefully. This makes tests run faster but increases the risk of losing data if the program crashes. It only affects a special testing option, not normal operation.
No immediate action required. Ensure `dev-sqlfilename` remains documented as developer-only and is not used in production deployments. Consider adding a warning log when these durability settings are disabled.
Security signals we found
Disables SQLite synchronous commits and journaling
Developer-only option (`dev-sqlfilename`) limits exposure
No input validation or boundary changes
No privilege changes or network exposure
Evidence from the diff
The patch disables SQLite durability/safety settings (synchronous=OFF, journal_mode=OFF, temp_store=MEMORY) when the dev-sqlfilename option is in use. This is a performance optimization for developer/test scenarios, trading crash safety for speed. The change is gated behind the dev- prefixed option, indicating it is not intended for production use.
Changed components
plugins/sql.cSQLite setup path when `dev-sqlfilename` is usedInspect captured patch +11 / −0
diff --git a/plugins/sql.c b/plugins/sql.c
index c73eb678..cf0066d3 100644
--- a/plugins/sql.c
+++ b/plugins/sql.c
@@ -268,6 +268,17 @@ static struct sqlite3 *sqlite_setup(struct plugin *plugin)
if (err != SQLITE_OK)
plugin_err(plugin, "Could not set foreign_keys: %s", errmsg);
+ if (sql->dbfilename) {
+ err = sqlite3_exec(db,
+ "PRAGMA synchronous = OFF;"
+ "PRAGMA journal_mode = OFF;"
+ "PRAGMA temp_store = MEMORY;"
+ , NULL, NULL,
+ &errmsg);
+ if (err != SQLITE_OK)
+ plugin_err(plugin, "Could not disable sync: %s", errmsg);
+ }
+
return db;
}
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.