From 6ace40b36106a177fdc08b60f55f8937584073b0 Mon Sep 17 00:00:00 2001 From: localvar Date: Wed, 18 Dec 2019 14:54:15 +0800 Subject: [PATCH] improve error message of multiple file import --- src/kit/shell/src/shellImport.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/kit/shell/src/shellImport.c b/src/kit/shell/src/shellImport.c index b96b971ab5..3292aa8e04 100644 --- a/src/kit/shell/src/shellImport.c +++ b/src/kit/shell/src/shellImport.c @@ -167,9 +167,11 @@ static void shellSourceFile(TAOS *con, char *fptr) { return; } - fprintf(stdout, "start to dispose file:%s\n", fname); + fprintf(stdout, "begin import file:%s\n", fname); + int lineNo = 0; while ((read_len = getline(&line, &line_len, f)) != -1) { + ++lineNo; if (read_len >= MAX_COMMAND_SIZE) continue; line[--read_len] = '\0'; @@ -186,7 +188,10 @@ static void shellSourceFile(TAOS *con, char *fptr) { memcpy(cmd + cmd_len, line, read_len); if (taos_query(con, cmd)) { - taos_error(con); + fprintf(stderr, "DB error: %s: %s (%d)\n", taos_errstr(con), fname, lineNo); + /* free local resouce: allocated memory/metric-meta refcnt */ + TAOS_RES *pRes = taos_use_result(con); + taos_free_result(pRes); } memset(cmd, 0, MAX_COMMAND_SIZE);