From ec8efe02e10d371959b4e97f30f8530aebe9ae4f Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 28 Aug 2019 22:38:32 +0200 Subject: [PATCH] db: Switch to indirect `db_last_insert_id` version We are about to delete all the `sqlite3`-specific code from `db.c` and this is one of the last uses of the old interface. Signed-off-by: Christian Decker --- wallet/invoices.c | 3 +-- wallet/wallet.c | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/wallet/invoices.c b/wallet/invoices.c index 6a0e1553d..371c8ceed 100644 --- a/wallet/invoices.c +++ b/wallet/invoices.c @@ -304,8 +304,7 @@ bool invoices_create(struct invoices *invoices, db_exec_prepared_v2(stmt); - pinvoice->id = db_last_insert_id(invoices->db); - tal_free(stmt); + pinvoice->id = db_last_insert_id_v2(take(stmt)); /* Install expiration trigger. */ if (!invoices->expiration_timer || diff --git a/wallet/wallet.c b/wallet/wallet.c index 263eb00e9..d775c9f61 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -1353,8 +1353,8 @@ void wallet_channel_insert(struct wallet *w, struct channel *chan) db_bind_text(stmt, 1, type_to_string(tmpctx, struct wireaddr_internal, &chan->peer->addr)); - db_exec_prepared_v2(take(stmt)); - chan->peer->dbid = db_last_insert_id(w->db); + db_exec_prepared_v2(stmt); + chan->peer->dbid = db_last_insert_id_v2(take(stmt)); } /* Insert a stub, that we update, unifies INSERT and UPDATE paths */ @@ -1567,8 +1567,8 @@ void wallet_htlc_save_in(struct wallet *wallet, db_bind_timeabs(stmt, 10, in->received_time); - db_exec_prepared_v2(take(stmt)); - in->dbid = db_last_insert_id(wallet->db); + db_exec_prepared_v2(stmt); + in->dbid = db_last_insert_id_v2(take(stmt)); } void wallet_htlc_save_out(struct wallet *wallet,