Skip to content

Commit

Permalink
db: fix renaming/deleting cols of DBs when there are UNIQUE(x, b, c) …
Browse files Browse the repository at this point in the history
…constraints.

Get stricter with recognizing real column defs.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and cdecker committed Sep 12, 2022
1 parent 2c3d4e4 commit bef2a47
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion db/db_sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
}
Expand Down

0 comments on commit bef2a47

Please sign in to comment.