From b7ec3a3c700ed66fa567aba359ad1364605c756d Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Wed, 24 Mar 2021 11:08:20 +0800 Subject: [PATCH] [TD-3357] : fix child table count if exists. (#5542) Co-authored-by: Shuduo Sang --- src/kit/taosdemo/taosdemo.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index fe39085981..252773e3ac 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -2422,11 +2422,8 @@ static int createDatabases() { &g_Dbs.db[i].superTbls[j], g_Dbs.use_metric); } else { g_Dbs.db[i].superTbls[j].superTblExists = TBL_ALREADY_EXISTS; - - if (g_Dbs.db[i].superTbls[j].childTblExists != TBL_ALREADY_EXISTS) { - ret = getSuperTableFromServer(taos, g_Dbs.db[i].dbName, + ret = getSuperTableFromServer(taos, g_Dbs.db[i].dbName, &g_Dbs.db[i].superTbls[j]); - } } if (0 != ret) { @@ -2434,16 +2431,16 @@ static int createDatabases() { taos_close(taos); return -1; } - } + } } taos_close(taos); return 0; } -static void* createTable(void *sarg) -{ - threadInfo *winfo = (threadInfo *)sarg; +static void* createTable(void *sarg) +{ + threadInfo *winfo = (threadInfo *)sarg; SSuperTable* superTblInfo = winfo->superTblInfo; int64_t lastPrintTime = taosGetTimestampMs(); @@ -2463,19 +2460,19 @@ static void* createTable(void *sarg) int len = 0; int batchNum = 0; - verbosePrint("%s() LN%d: Creating table from %d to %d\n", + verbosePrint("%s() LN%d: Creating table from %d to %d\n", __func__, __LINE__, winfo->start_table_from, winfo->end_table_to); for (int i = winfo->start_table_from; i <= winfo->end_table_to; i++) { if (0 == g_Dbs.use_metric) { - snprintf(buffer, buff_len, + snprintf(buffer, buff_len, "create table if not exists %s.%s%d %s;", winfo->db_name, g_args.tb_prefix, i, winfo->cols); } else { - if (0 == len) { + if (0 == len) { batchNum = 0; memset(buffer, 0, buff_len); len += snprintf(buffer + len, @@ -2494,7 +2491,7 @@ static void* createTable(void *sarg) free(buffer); return NULL; } - + len += snprintf(buffer + len, superTblInfo->maxSqlLen - len, "if not exists %s.%s%d using %s.%s tags %s ", @@ -2505,7 +2502,7 @@ static void* createTable(void *sarg) batchNum++; if ((batchNum < superTblInfo->batchCreateTableNum) - && ((superTblInfo->maxSqlLen - len) + && ((superTblInfo->maxSqlLen - len) >= (superTblInfo->lenOfTagOfOneRow + 256))) { continue; } @@ -2514,8 +2511,8 @@ static void* createTable(void *sarg) len = 0; verbosePrint("%s() LN%d %s\n", __func__, __LINE__, buffer); if (0 != queryDbExec(winfo->taos, buffer, NO_INSERT_TYPE)){ - errorPrint( "queryDbExec() failed. buffer:\n%s\n", buffer); free(buffer); + errorPrint( "queryDbExec() failed. buffer:\n%s\n", buffer); return NULL; } @@ -2578,7 +2575,7 @@ static int startMultiThreadCreateChildTable( if (t_info->taos == NULL) { errorPrint( "Failed to connect to TDengine, reason:%s\n", taos_errstr(NULL)); free(pids); - free(infos); + free(infos); return -1; } @@ -4530,7 +4527,6 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) { recOfBatch += batchPerTbl; startTime += batchPerTbl * superTblInfo->timeStampStep; pThreadInfo->totalInsertRows += batchPerTbl; - verbosePrint("[%d] %s() LN%d batchPerTbl=%d recOfBatch=%d\n", pThreadInfo->threadID, __func__, __LINE__, batchPerTbl, recOfBatch); -- GitLab