fix crush autocomplite

Исправлено падение после автозавершения после слова "create".
This commit is contained in:
lsv 2025-08-14 15:02:08 +05:00 committed by lsv
parent 295b7f97d1
commit 825e80fb4f
2 changed files with 4 additions and 1 deletions

View file

@ -329,6 +329,7 @@ typedef struct
static const pgsql_thing_t words_after_create[] = {
{"AGGREGATE", NULL, &Query_for_list_of_aggregates},
{"PUBLICATION", NULL, NULL},
{"CAST", NULL, NULL}, /* Casts have complex structures for names, so
* skip it */

View file

@ -384,6 +384,8 @@ static char *complete_create_command(char *text)
if (pg_strncasecmp(text, words_after_create[i].name, string_length) == 0)
size += strlen(words_after_create[i].name);
}
if (size == 0)
return NULL;
r = calloc(size + i*2 + 1, 1);
for (i = 0; words_after_create[i].name != NULL; i++)
@ -394,7 +396,7 @@ static char *complete_create_command(char *text)
strcat(r," \t");
}
}
r[strlen(r)-1] = '\0'; /* Chop of trailing space */
r[strlen(r)-1] = '\0'; /* Chop of trailing space */
return r;
}