Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b68afd0

Browse files
committedApr 22, 2025··
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 68f3649 Signed-off-by: Vincenzo Palazzo <[email protected]>
1 parent 030a114 commit b68afd0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
 

‎wallet/db.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,15 +2043,16 @@ static void migrate_convert_old_channel_keyidx(struct lightningd *ld,
20432043

20442044
stmt = db_prepare_v2(db, SQL("UPDATE addresses"
20452045
" SET addrtype = ?"
2046-
" FROM channels "
2047-
" WHERE addresses.keyidx = channels.shutdown_keyidx_local"
2048-
" AND channels.state != ?"
2049-
" AND channels.state != ?"
2046+
" WHERE keyidx IN (SELECT shutdown_keyidx_local FROM channels"
2047+
" WHERE channels.state != ?"
2048+
" AND channels.state != ?"
2049+
" AND channels.state != ?)"
20502050
" AND channels.state != ?"));
20512051
db_bind_int(stmt, wallet_addrtype_in_db(ADDR_ALL));
20522052
/* If we might have already seen onchain funds, we need to rescan */
20532053
db_bind_int(stmt, channel_state_in_db(FUNDING_SPEND_SEEN));
20542054
db_bind_int(stmt, channel_state_in_db(ONCHAIN));
20552055
db_bind_int(stmt, channel_state_in_db(CLOSED));
2056+
db_bind_int(stmt, channel_state_in_db(FUNDING_SPEND_SEEN));
20562057
db_exec_prepared_v2(take(stmt));
20572058
}

0 commit comments

Comments
 (0)
Please sign in to comment.