@@ -92,22 +92,6 @@ static bool have_same_data_version(sqlite3 *a, sqlite3 *b)
9292 return version_a == version_b ;
9393}
9494
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-
11195static const char * db_sqlite3_fmt_error (struct db_stmt * stmt )
11296{
11397 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)
269253static bool db_sqlite3_exec (struct db_stmt * stmt )
270254{
271255 int err ;
272- bool success ;
256+ char * expanded_sql ;
273257 struct db_sqlite3 * wrapper = (struct db_sqlite3 * ) stmt -> db -> conn ;
274258
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-
284259 if (!db_sqlite3_query (stmt )) {
285260 /* If the prepare step caused an error we hand it up. */
286- success = false;
287- goto done ;
261+ return false;
288262 }
289263
290264 err = sqlite3_step (stmt -> inner_stmt );
291265 if (err != SQLITE_DONE ) {
292266 tal_free (stmt -> error );
293267 stmt -> error = db_sqlite3_fmt_error (stmt );
294- success = false;
295- goto done ;
268+ return false;
296269 }
297270
298- #if HAVE_SQLITE3_EXPANDED_SQL
299271 /* Manually expand and call the callback */
300- char * expanded_sql ;
301272 expanded_sql = sqlite3_expanded_sql (stmt -> inner_stmt );
302273 db_sqlite3_changes_add (wrapper , stmt , expanded_sql );
303274 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
313275
314- return success ;
276+ return true ;
315277}
316278
317279static bool db_sqlite3_step (struct db_stmt * stmt )
0 commit comments