Commit Graph

5 Commits

Author SHA1 Message Date
Rusty Russell
1ecf31bae7 db: remove #if DEVELOPER in favor of runtime flag inside db struct.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-21 20:08:24 +09:30
Rusty Russell
04f485aee0 db: add generic warn/error function.
This avoids the mess where we override db_fatal for teqsts, and keeps it
generic.

Also allows us to get rid of one #if DEVELOPER, and an ugly global for
bookkeeper.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-09 16:49:48 +09:30
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
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
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