fix: too long multiple command line

This commit is contained in:
Alex Duan 2023-12-07 19:24:19 +08:00
parent 4379b21696
commit bd3fd91a50
1 changed files with 6 additions and 1 deletions

View File

@ -1091,7 +1091,12 @@ void shellSourceFile(const char *file) {
char *line = taosMemoryMalloc(TSDB_MAX_ALLOWED_SQL_LEN + 1);
while ((read_len = taosGetsFile(pFile, TSDB_MAX_ALLOWED_SQL_LEN, line)) != -1) {
if (read_len >= TSDB_MAX_ALLOWED_SQL_LEN) continue;
if ( cmd_len + read_len >= TSDB_MAX_ALLOWED_SQL_LEN) {
printf("read command line too long over 1M, ignore this line. cmd_len = %d read_len=%d \n", (int32_t)cmd_len, read_len);
cmd_len = 0;
memset(line, 0, TSDB_MAX_ALLOWED_SQL_LEN + 1);
continue;
}
line[--read_len] = '\0';
if (read_len == 0 || shellIsCommentLine(line)) { // line starts with #