mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
db-fix: update NULL lease_satoshi fields to zero
Missed a DEFAULT in the db clause. Feb 15 16:02:12 citrine lightningd[902093]: Accessing a null column lease_satoshi/15 in query SELECT funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig, funding_tx_remote_sigs_received, lease_expiry, lease_commit_sig, lease_chan_max_msat, lease_chan_max_ppt, lease_blockheight_start, lease_fee, lease_satoshi FROM channel_funding_inflights WHERE channel_id = ? ORDER BY funding_feerate Fixes #6016
This commit is contained in:
parent
7079fb506f
commit
e315f30728
18
wallet/db.c
18
wallet/db.c
@ -67,6 +67,10 @@ static void migrate_payments_scids_as_integers(struct lightningd *ld,
|
||||
struct db *db,
|
||||
const struct migration_context *mc);
|
||||
|
||||
static void fillin_missing_lease_satoshi(struct lightningd *ld,
|
||||
struct db *db,
|
||||
const struct migration_context *mc);
|
||||
|
||||
/* Do not reorder or remove elements from this array, it is used to
|
||||
* migrate existing databases from a previous state, based on the
|
||||
* string indices */
|
||||
@ -948,6 +952,7 @@ static struct migration dbmigrations[] = {
|
||||
{SQL("ALTER TABLE channel_funding_inflights ADD COLUMN lease_satoshi BIGINT;"), NULL},
|
||||
{SQL("ALTER TABLE channels ADD require_confirm_inputs_remote INTEGER DEFAULT 0;"), NULL},
|
||||
{SQL("ALTER TABLE channels ADD require_confirm_inputs_local INTEGER DEFAULT 0;"), NULL},
|
||||
{NULL, fillin_missing_lease_satoshi},
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1578,3 +1583,16 @@ static void migrate_payments_scids_as_integers(struct lightningd *ld,
|
||||
if (!db->config->delete_columns(db, "payments", colnames, ARRAY_SIZE(colnames)))
|
||||
db_fatal("Could not delete payments.failchannel");
|
||||
}
|
||||
|
||||
static void fillin_missing_lease_satoshi(struct lightningd *ld,
|
||||
struct db *db,
|
||||
const struct migration_context *mc)
|
||||
{
|
||||
struct db_stmt *stmt;
|
||||
|
||||
stmt = db_prepare_v2(db, SQL("UPDATE channel_funding_inflights"
|
||||
" SET lease_satoshi = 0"
|
||||
" WHERE lease_satoshi IS NULL;"));
|
||||
db_exec_prepared_v2(stmt);
|
||||
tal_free(stmt);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user