From e6c203bc848bba839d9f2e5c8607a00528b91ba1 Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Tue, 22 Apr 2025 23:32:57 +0200 Subject: [PATCH] db: replace UPDATE FROM syntax for SQLite compat Introduced the use of UPDATE FROM syntax in SQLite queries, which is not supported in versions prior to 3.33.0. This causes issues on systems with older SQLite versions, as reported in issue #8231. Rewrite the query in migrate_convert_old_channel_keyidx() to use a subquery with IN clause instead of UPDATE FROM, ensuring compatibility with older SQLite versions. Changelog-Fixed: db: replace UPDATE FROM syntax for SQLite compat Fixes 68f3649d6b9fc65ece3f1dc3e2f7e6a053170ea5 Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Vincenzo Palazzo --- wallet/db.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/wallet/db.c b/wallet/db.c index 1bcb91496f3a..9c908765fc27 100644 --- a/wallet/db.c +++ b/wallet/db.c @@ -2043,11 +2043,10 @@ static void migrate_convert_old_channel_keyidx(struct lightningd *ld, stmt = db_prepare_v2(db, SQL("UPDATE addresses" " SET addrtype = ?" - " FROM channels " - " WHERE addresses.keyidx = channels.shutdown_keyidx_local" - " AND channels.state != ?" - " AND channels.state != ?" - " AND channels.state != ?")); + " WHERE keyidx IN (SELECT shutdown_keyidx_local FROM channels" + " WHERE state != ?" + " AND state != ?" + " AND state != ?)")); db_bind_int(stmt, wallet_addrtype_in_db(ADDR_ALL)); /* If we might have already seen onchain funds, we need to rescan */ db_bind_int(stmt, channel_state_in_db(FUNDING_SPEND_SEEN));