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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2022-09-08 10:26:32 +09:30
committed by Christian Decker
parent 2c3d4e46fc
commit bef2a47ab7

View File

@@ -446,6 +446,7 @@ static bool colname_to_delete(const char **colnames,
return false; return false;
} }
/* Returns NULL if this doesn't look like a column definition */
static const char *find_column_name(const tal_t *ctx, static const char *find_column_name(const tal_t *ctx,
const char *sqlpart, const char *sqlpart,
size_t *after) size_t *after)
@@ -455,7 +456,7 @@ static const char *find_column_name(const tal_t *ctx,
while (isspace(sqlpart[start])) while (isspace(sqlpart[start]))
start++; start++;
*after = strspn(sqlpart + start, "abcdefghijklmnopqrstuvwxyz_0123456789") + start; *after = strspn(sqlpart + start, "abcdefghijklmnopqrstuvwxyz_0123456789") + start;
if (*after == start) if (*after == start || !cisspace(sqlpart[*after]))
return NULL; return NULL;
return tal_strndup(ctx, sqlpart + start, *after - start); return tal_strndup(ctx, sqlpart + start, *after - start);
} }