From 66e16868159b6d24e9e9966a4a94b1d43e54bc1e Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Tue, 2 Mar 2021 12:53:29 +0800 Subject: [PATCH] [TD-3119] when only dbs.sql, dumpin error --- src/kit/taosdump/taosdump.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index e45c176c79..e2105ad18b 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -2109,13 +2109,15 @@ static void taosGetDirectoryFileList(char *inputDir) if (fileStat.st_mode & S_IFDIR) { taosCheckTablesSQLFile(inputDir); tsSqlFileNum = taosGetFilesNum(inputDir, "sql"); - int totalSQLFileNum = tsSqlFileNum; + int tsSqlFileNumOfTbls = tsSqlFileNum; if (tsDbSqlFile[0] != 0) { - tsSqlFileNum--; + tsSqlFileNumOfTbls--; } taosMallocSQLFiles(); - taosParseDirectory(inputDir, "sql", tsDumpInSqlFiles, tsSqlFileNum); - fprintf(stdout, "\nstart to dispose %d files in %s\n", totalSQLFileNum, inputDir); + if (0 != tsSqlFileNumOfTbls) { + taosParseDirectory(inputDir, "sql", tsDumpInSqlFiles, tsSqlFileNumOfTbls); + } + fprintf(stdout, "\nstart to dispose %d files in %s\n", tsSqlFileNum, inputDir); } else { fprintf(stderr, "ERROR: %s is not a directory\n", inputDir); @@ -2268,7 +2270,10 @@ int taosDumpIn(struct arguments *arguments) { taosGetDirectoryFileList(arguments->inpath); + int32_t tsSqlFileNumOfTbls = tsSqlFileNum; if (tsDbSqlFile[0] != 0) { + tsSqlFileNumOfTbls--; + fp = taosOpenDumpInFile(tsDbSqlFile); if (NULL == fp) { fprintf(stderr, "failed to open input file %s\n", tsDbSqlFile); @@ -2281,7 +2286,9 @@ int taosDumpIn(struct arguments *arguments) { taosDumpInOneFile(taos, fp, tsfCharset, arguments->encode, tsDbSqlFile); } - taosStartDumpInWorkThreads(taos, arguments); + if (0 != tsSqlFileNumOfTbls) { + taosStartDumpInWorkThreads(taos, arguments); + } taos_close(taos); taosFreeSQLFiles(); -- GitLab