From 3f8318b895bab95240080c93adf3a1c9b3ff112d Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Thu, 23 Sep 2021 11:00:23 +0800 Subject: [PATCH] [TD-10416]: taosdump if no any arguments given. (#8022) * [TD-10416]: taosdump if no any arguments given. * fix database specified scenario. --- src/kit/taosdump/taosdump.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index b0235a7dca..5d0f426506 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -346,7 +346,7 @@ static int64_t taosDumpTableData(FILE *fp, char *tbName, TAOS* taos, char* dbName, int precision, char *jsonAvroSchema); -static int taosCheckParam(struct arguments *arguments); +static int checkParam(); static void taosFreeDbInfos(); struct arguments g_args = { @@ -2178,17 +2178,23 @@ static int64_t taosDumpTableData(FILE *fp, char *tbName, return totalRows; } -static int taosCheckParam(struct arguments *arguments) { +static int checkParam() { if (g_args.all_databases && g_args.databases) { - fprintf(stderr, "conflict option --all-databases and --databases\n"); + errorPrint("%s", "conflict option --all-databases and --databases\n"); return -1; } if (g_args.start_time > g_args.end_time) { - fprintf(stderr, "start time is larger than end time\n"); + errorPrint("%s", "start time is larger than end time\n"); return -1; } + if (g_args.arg_list_len == 0) { + if ((!g_args.all_databases) && (!g_args.databases) && (!g_args.isDumpIn)) { + errorPrint("%s", "taosdump requires parameters\n"); + return -1; + } + } /* if (g_args.isDumpIn && (strcmp(g_args.outpath, DEFAULT_DUMP_FILE) != 0)) { fprintf(stderr, "duplicate parameter input and output file path\n"); @@ -2768,7 +2774,7 @@ int main(int argc, char *argv[]) { } } printf("==============================\n"); - if (taosCheckParam(&g_args) < 0) { + if (checkParam(&g_args) < 0) { exit(EXIT_FAILURE); } -- GitLab