mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 20:09:18 +01:00
db: print nice message and not just backtrace on bad column name.
Happens more than I expected! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
c45eb62b57
commit
8493ee5e1a
1 changed files with 7 additions and 3 deletions
10
db/utils.c
10
db/utils.c
|
@ -21,9 +21,13 @@ size_t db_query_colnum(const struct db_stmt *stmt,
|
|||
assert(stmt->query->colnames != NULL);
|
||||
|
||||
col = hash_djb2(colname) % stmt->query->num_colnames;
|
||||
/* Will crash on NULL, which is the Right Thing */
|
||||
while (!streq(stmt->query->colnames[col].sqlname,
|
||||
colname)) {
|
||||
for (;;) {
|
||||
const char *n = stmt->query->colnames[col].sqlname;
|
||||
if (!n)
|
||||
db_fatal("Unknown column name %s in query %s",
|
||||
colname, stmt->query->query);
|
||||
if (streq(n, colname))
|
||||
break;
|
||||
col = (col + 1) % stmt->query->num_colnames;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue