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:
@@ -6,6 +6,7 @@
|
||||
#include <ccan/strset/strset.h>
|
||||
#include <common/autodata.h>
|
||||
#include <common/utils.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/**
|
||||
* Macro to annotate a named SQL query.
|
||||
@@ -35,6 +36,10 @@ struct db {
|
||||
/* DB-specific context */
|
||||
void *conn;
|
||||
|
||||
/* function to log warnings, or fail (if fatal == true). vprintf-style */
|
||||
void (*errorfn)(void *arg, bool fatal, const char *fmt, va_list ap);
|
||||
void *errorfn_arg;
|
||||
|
||||
/* The configuration for the current database driver */
|
||||
const struct db_config *config;
|
||||
|
||||
@@ -183,9 +188,6 @@ struct db_config {
|
||||
const char **colnames, size_t num_cols);
|
||||
};
|
||||
|
||||
void db_fatal(const char *fmt, ...)
|
||||
PRINTF_FMT(1, 2);
|
||||
|
||||
/* Provide a way for DB backends to register themselves */
|
||||
AUTODATA_TYPE(db_backends, struct db_config);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user