mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
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>
This commit is contained in:
@@ -92,7 +92,7 @@ static PGresult *db_postgres_do_exec(struct db_stmt *stmt)
|
||||
|
||||
switch (b->type) {
|
||||
case DB_BINDING_UNINITIALIZED:
|
||||
db_fatal("DB binding not initialized: position=%zu, "
|
||||
db_fatal(stmt->db, "DB binding not initialized: position=%zu, "
|
||||
"query=\"%s\n",
|
||||
i, stmt->query->query);
|
||||
case DB_BINDING_UINT64:
|
||||
@@ -172,7 +172,7 @@ static u64 db_postgres_column_u64(struct db_stmt *stmt, int col)
|
||||
size_t expected = sizeof(bin), actual = PQgetlength(res, stmt->row, col);
|
||||
|
||||
if (expected != actual)
|
||||
db_fatal(
|
||||
db_fatal(stmt->db,
|
||||
"u64 field doesn't match size: expected %zu, actual %zu\n",
|
||||
expected, actual);
|
||||
|
||||
@@ -187,7 +187,7 @@ static s64 db_postgres_column_int(struct db_stmt *stmt, int col)
|
||||
size_t expected = sizeof(bin), actual = PQgetlength(res, stmt->row, col);
|
||||
|
||||
if (expected != actual)
|
||||
db_fatal(
|
||||
db_fatal(stmt->db,
|
||||
"s32 field doesn't match size: expected %zu, actual %zu\n",
|
||||
expected, actual);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user