db: Get old sqlite3_trace based db_changes working again

Seems I accidentally broke the fallback mechanism while working on the DB
abstraction.
This commit is contained in:
Christian Decker 2019-09-17 23:11:35 +02:00
parent c5f4c9cefb
commit ac1c894255

View File

@ -11,8 +11,8 @@
/* Prior to sqlite3 v3.14, we have to use tracing to dump statements */ /* Prior to sqlite3 v3.14, we have to use tracing to dump statements */
static void trace_sqlite3(void *stmtv, const char *stmt) static void trace_sqlite3(void *stmtv, const char *stmt)
{ {
struct db_stmt = (struct db_stmt*)stmtv; struct db_stmt *s = (struct db_stmt*)stmtv;
db_changes_add(stmt, stmt); db_changes_add(s, stmt);
} }
#endif #endif
@ -86,7 +86,7 @@ static bool db_sqlite3_exec(struct db_stmt *stmt)
#if !HAVE_SQLITE3_EXPANDED_SQL #if !HAVE_SQLITE3_EXPANDED_SQL
/* Register the tracing function if we don't have an explicit way of /* Register the tracing function if we don't have an explicit way of
* expanding the statement. */ * expanding the statement. */
sqlite3_trace(db->sql, trace_sqlite3, stmt); sqlite3_trace(stmt->db->conn, trace_sqlite3, stmt);
#endif #endif
if (!db_sqlite3_query(stmt)) { if (!db_sqlite3_query(stmt)) {
@ -110,7 +110,7 @@ static bool db_sqlite3_exec(struct db_stmt *stmt)
#else #else
/* Unregister the trace callback to avoid it accessing the potentially /* Unregister the trace callback to avoid it accessing the potentially
* stale pointer to stmt */ * stale pointer to stmt */
sqlite3_trace(db->sql, NULL, NULL); sqlite3_trace(stmt->db->conn, NULL, NULL);
#endif #endif
return true; return true;