|
@ -554,6 +554,13 @@ sqlite3_stmt *db_select_prepare_(const char *location, struct db *db, const char |
|
|
return stmt; |
|
|
return stmt; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void db_stmt_free(struct db_stmt *stmt) |
|
|
|
|
|
{ |
|
|
|
|
|
if (stmt->inner_stmt) |
|
|
|
|
|
stmt->db->config->stmt_free_fn(stmt); |
|
|
|
|
|
assert(stmt->inner_stmt == NULL); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
struct db_stmt *db_prepare_v2_(const char *location, struct db *db, |
|
|
struct db_stmt *db_prepare_v2_(const char *location, struct db *db, |
|
|
const char *query_id) |
|
|
const char *query_id) |
|
|
{ |
|
|
{ |
|
@ -586,12 +593,11 @@ struct db_stmt *db_prepare_v2_(const char *location, struct db *db, |
|
|
stmt->location = location; |
|
|
stmt->location = location; |
|
|
stmt->error = NULL; |
|
|
stmt->error = NULL; |
|
|
stmt->db = db; |
|
|
stmt->db = db; |
|
|
return stmt; |
|
|
stmt->inner_stmt = NULL; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void db_stmt_free(struct db_stmt *stmt) |
|
|
tal_add_destructor(stmt, db_stmt_free); |
|
|
{ |
|
|
|
|
|
stmt->db->config->stmt_free_fn(stmt); |
|
|
return stmt; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#define db_prepare_v2(db,query) \ |
|
|
#define db_prepare_v2(db,query) \ |
|
@ -882,7 +888,7 @@ static void db_migrate(struct lightningd *ld, struct db *db, struct log *log) |
|
|
struct db_stmt *stmt = |
|
|
struct db_stmt *stmt = |
|
|
db_prepare_v2(db, dbmigrations[current].sql); |
|
|
db_prepare_v2(db, dbmigrations[current].sql); |
|
|
db_exec_prepared_v2(stmt); |
|
|
db_exec_prepared_v2(stmt); |
|
|
db_stmt_free(stmt); |
|
|
tal_free(stmt); |
|
|
} |
|
|
} |
|
|
if (dbmigrations[current].func) |
|
|
if (dbmigrations[current].func) |
|
|
dbmigrations[current].func(ld, db); |
|
|
dbmigrations[current].func(ld, db); |
|
@ -1281,7 +1287,7 @@ void migrate_pr2342_feerate_per_channel(struct lightningd *ld, struct db *db) |
|
|
db_bind_int(stmt, 1, ld->config.fee_per_satoshi); |
|
|
db_bind_int(stmt, 1, ld->config.fee_per_satoshi); |
|
|
|
|
|
|
|
|
db_exec_prepared_v2(stmt); |
|
|
db_exec_prepared_v2(stmt); |
|
|
db_stmt_free(stmt); |
|
|
tal_free(stmt); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void sqlite3_bind_timeabs(sqlite3_stmt *stmt, int col, struct timeabs t) |
|
|
void sqlite3_bind_timeabs(sqlite3_stmt *stmt, int col, struct timeabs t) |
|
|