Commit Graph

9 Commits

Author SHA1 Message Date
Rusty Russell 939a7b2b18 db/postgres: avoid memleak.
```
"label": "db/db_postgres.c:294:char[]",
"backtrace": [
  "ccan/ccan/tal/tal.c:442 (tal_alloc_)",
  "ccan/ccan/tal/tal.c:471 (tal_alloc_arr_)",
  "ccan/ccan/tal/str/str.c:91 (tal_vfmt_)",
  "ccan/ccan/tal/str/str.c:44 (tal_fmt_)",
  "db/db_postgres.c:294 (db_postgres_delete_columns)",
  "wallet/db.c:1546 (migrate_payments_scids_as_integers)",
  "wallet/db.c:986 (db_migrate)",
  "wallet/db.c:1019 (db_setup)",
  "wallet/wallet.c:101 (wallet_new)",
  "lightningd/lightningd.c:1023 (main)",
  "../csu/libc-start.c:308 (__libc_start_main)"
],
"parents": [
  "db/utils.c:317:struct db",
  "lightningd/lightningd.c:107:struct lightningd"
]
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-22 15:19:46 +02:00
Rusty Russell d7c1325e38 wallet: use scid not string for failchannel (now failscid) in payments table.
And remove the now-unused string-based helper functions.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-22 15:19:46 +02:00
Rusty Russell 33a6b18891 db/bindings: rename db_bind_short_channel_id to db_bind_short_channel_id_str, add db_bind_scid.
Although it's deprecated already (because it stores as string), it's
better to make the name explicit.  And create a new helper which stores as BIGINT.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-22 15:19:46 +02:00
Rusty Russell e853cdc3ff db: fix sqlite3 code which manipulates columns.
Because it used internal routines, it didn't pass operations through the
db hook!  So make it use the generic routines, with the twist that they
are not translated.

And when we use this in a migration hook, we're actually in a
transaction.

This, in turn, introduces an issue: we need to be outside a transaction
to "PRAGMA foreign_keys = OFF", but completing the transaction when
there is a db hook actually enters the io loop, freeing the tmpctx!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-12 14:00:41 +02:00
Rusty Russell d7aa2749c3 db: fix migrations which write to db.
valgrind noticed that this was uninitialized when I tried a complex
migration.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-12 14:00:41 +02:00
Rusty Russell bef2a47ab7 db: fix renaming/deleting cols of DBs when there are UNIQUE(x, b, c) constraints.
Get stricter with recognizing real column defs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-12 14:00:41 +02:00
Rusty Russell 2971b2af79 bkpr: insert obscure 60s pop references.
The initial snapshots on an already-running lightningd are expected to
be unbalanced, but this shouldn't cause users to long for the green,
green grass of home.

This controls the Art of Noise.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-08-01 09:01:08 -07:00
Vincenzo Palazzo 6a146bed26 db: small code cleanup
Changelog-None: db: small code cleanup

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-03-11 16:43:15 +10:30
niftynei ce12d2b8a9 database: pull out database code into a new module
We're going to reuse the database controllers for the accounting plugin
2022-03-05 15:03:34 +10:30