From bef2a47ab7a1acb01582d33db406cf0b6e06b8ac Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 8 Sep 2022 10:26:32 +0930 Subject: [PATCH] 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 --- db/db_sqlite3.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/db_sqlite3.c b/db/db_sqlite3.c index 90f0a4aa2..22cc0be20 100644 --- a/db/db_sqlite3.c +++ b/db/db_sqlite3.c @@ -446,6 +446,7 @@ static bool colname_to_delete(const char **colnames, return false; } +/* Returns NULL if this doesn't look like a column definition */ static const char *find_column_name(const tal_t *ctx, const char *sqlpart, size_t *after) @@ -455,7 +456,7 @@ static const char *find_column_name(const tal_t *ctx, while (isspace(sqlpart[start])) start++; *after = strspn(sqlpart + start, "abcdefghijklmnopqrstuvwxyz_0123456789") + start; - if (*after == start) + if (*after == start || !cisspace(sqlpart[*after])) return NULL; return tal_strndup(ctx, sqlpart + start, *after - start); }