@@ -92,22 +92,6 @@ static bool have_same_data_version(sqlite3 *a, sqlite3 *b)
92
92
return version_a == version_b ;
93
93
}
94
94
95
- #if !HAVE_SQLITE3_EXPANDED_SQL
96
- /* Prior to sqlite3 v3.14, we have to use tracing to dump statements */
97
- struct db_sqlite3_trace {
98
- struct db_sqlite3 * wrapper ;
99
- struct db_stmt * stmt ;
100
- };
101
-
102
- static void trace_sqlite3 (void * stmtv , const char * stmt )
103
- {
104
- struct db_sqlite3_trace * trace = (struct db_sqlite3_trace * )stmtv ;
105
- struct db_sqlite3 * wrapper = trace -> wrapper ;
106
- struct db_stmt * s = trace -> stmt ;
107
- db_sqlite3_changes_add (wrapper , s , stmt );
108
- }
109
- #endif
110
-
111
95
static const char * db_sqlite3_fmt_error (struct db_stmt * stmt )
112
96
{
113
97
return tal_fmt (stmt , "%s: %s: %s" , stmt -> location , stmt -> query -> query ,
@@ -269,49 +253,27 @@ static bool db_sqlite3_query(struct db_stmt *stmt)
269
253
static bool db_sqlite3_exec (struct db_stmt * stmt )
270
254
{
271
255
int err ;
272
- bool success ;
256
+ char * expanded_sql ;
273
257
struct db_sqlite3 * wrapper = (struct db_sqlite3 * ) stmt -> db -> conn ;
274
258
275
- #if !HAVE_SQLITE3_EXPANDED_SQL
276
- /* Register the tracing function if we don't have an explicit way of
277
- * expanding the statement. */
278
- struct db_sqlite3_trace trace ;
279
- trace .wrapper = wrapper ;
280
- trace .stmt = stmt ;
281
- sqlite3_trace (conn2sql (stmt -> db -> conn ), trace_sqlite3 , & trace );
282
- #endif
283
-
284
259
if (!db_sqlite3_query (stmt )) {
285
260
/* If the prepare step caused an error we hand it up. */
286
- success = false;
287
- goto done ;
261
+ return false;
288
262
}
289
263
290
264
err = sqlite3_step (stmt -> inner_stmt );
291
265
if (err != SQLITE_DONE ) {
292
266
tal_free (stmt -> error );
293
267
stmt -> error = db_sqlite3_fmt_error (stmt );
294
- success = false;
295
- goto done ;
268
+ return false;
296
269
}
297
270
298
- #if HAVE_SQLITE3_EXPANDED_SQL
299
271
/* Manually expand and call the callback */
300
- char * expanded_sql ;
301
272
expanded_sql = sqlite3_expanded_sql (stmt -> inner_stmt );
302
273
db_sqlite3_changes_add (wrapper , stmt , expanded_sql );
303
274
sqlite3_free (expanded_sql );
304
- #endif
305
- success = true;
306
-
307
- done :
308
- #if !HAVE_SQLITE3_EXPANDED_SQL
309
- /* Unregister the trace callback to avoid it accessing the potentially
310
- * stale pointer to stmt */
311
- sqlite3_trace (conn2sql (stmt -> db -> conn ), NULL , NULL );
312
- #endif
313
275
314
- return success ;
276
+ return true ;
315
277
}
316
278
317
279
static bool db_sqlite3_step (struct db_stmt * stmt )
0 commit comments