未验证 提交 b7ec3a3c 编写于 作者: sangshuduo's avatar sangshuduo 提交者: GitHub

[TD-3357] <fix>: fix child table count if exists. (#5542)

Co-authored-by: NShuduo Sang <sdsang@taosdata.com>
上级 82a947a3
...@@ -2422,11 +2422,8 @@ static int createDatabases() { ...@@ -2422,11 +2422,8 @@ static int createDatabases() {
&g_Dbs.db[i].superTbls[j], g_Dbs.use_metric); &g_Dbs.db[i].superTbls[j], g_Dbs.use_metric);
} else { } else {
g_Dbs.db[i].superTbls[j].superTblExists = TBL_ALREADY_EXISTS; g_Dbs.db[i].superTbls[j].superTblExists = TBL_ALREADY_EXISTS;
ret = getSuperTableFromServer(taos, g_Dbs.db[i].dbName,
if (g_Dbs.db[i].superTbls[j].childTblExists != TBL_ALREADY_EXISTS) {
ret = getSuperTableFromServer(taos, g_Dbs.db[i].dbName,
&g_Dbs.db[i].superTbls[j]); &g_Dbs.db[i].superTbls[j]);
}
} }
if (0 != ret) { if (0 != ret) {
...@@ -2434,16 +2431,16 @@ static int createDatabases() { ...@@ -2434,16 +2431,16 @@ static int createDatabases() {
taos_close(taos); taos_close(taos);
return -1; return -1;
} }
} }
} }
taos_close(taos); taos_close(taos);
return 0; return 0;
} }
static void* createTable(void *sarg) static void* createTable(void *sarg)
{ {
threadInfo *winfo = (threadInfo *)sarg; threadInfo *winfo = (threadInfo *)sarg;
SSuperTable* superTblInfo = winfo->superTblInfo; SSuperTable* superTblInfo = winfo->superTblInfo;
int64_t lastPrintTime = taosGetTimestampMs(); int64_t lastPrintTime = taosGetTimestampMs();
...@@ -2463,19 +2460,19 @@ static void* createTable(void *sarg) ...@@ -2463,19 +2460,19 @@ static void* createTable(void *sarg)
int len = 0; int len = 0;
int batchNum = 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__, __func__, __LINE__,
winfo->start_table_from, winfo->end_table_to); winfo->start_table_from, winfo->end_table_to);
for (int i = winfo->start_table_from; i <= winfo->end_table_to; i++) { for (int i = winfo->start_table_from; i <= winfo->end_table_to; i++) {
if (0 == g_Dbs.use_metric) { if (0 == g_Dbs.use_metric) {
snprintf(buffer, buff_len, snprintf(buffer, buff_len,
"create table if not exists %s.%s%d %s;", "create table if not exists %s.%s%d %s;",
winfo->db_name, winfo->db_name,
g_args.tb_prefix, i, g_args.tb_prefix, i,
winfo->cols); winfo->cols);
} else { } else {
if (0 == len) { if (0 == len) {
batchNum = 0; batchNum = 0;
memset(buffer, 0, buff_len); memset(buffer, 0, buff_len);
len += snprintf(buffer + len, len += snprintf(buffer + len,
...@@ -2494,7 +2491,7 @@ static void* createTable(void *sarg) ...@@ -2494,7 +2491,7 @@ static void* createTable(void *sarg)
free(buffer); free(buffer);
return NULL; return NULL;
} }
len += snprintf(buffer + len, len += snprintf(buffer + len,
superTblInfo->maxSqlLen - len, superTblInfo->maxSqlLen - len,
"if not exists %s.%s%d using %s.%s tags %s ", "if not exists %s.%s%d using %s.%s tags %s ",
...@@ -2505,7 +2502,7 @@ static void* createTable(void *sarg) ...@@ -2505,7 +2502,7 @@ static void* createTable(void *sarg)
batchNum++; batchNum++;
if ((batchNum < superTblInfo->batchCreateTableNum) if ((batchNum < superTblInfo->batchCreateTableNum)
&& ((superTblInfo->maxSqlLen - len) && ((superTblInfo->maxSqlLen - len)
>= (superTblInfo->lenOfTagOfOneRow + 256))) { >= (superTblInfo->lenOfTagOfOneRow + 256))) {
continue; continue;
} }
...@@ -2514,8 +2511,8 @@ static void* createTable(void *sarg) ...@@ -2514,8 +2511,8 @@ static void* createTable(void *sarg)
len = 0; len = 0;
verbosePrint("%s() LN%d %s\n", __func__, __LINE__, buffer); verbosePrint("%s() LN%d %s\n", __func__, __LINE__, buffer);
if (0 != queryDbExec(winfo->taos, buffer, NO_INSERT_TYPE)){ if (0 != queryDbExec(winfo->taos, buffer, NO_INSERT_TYPE)){
errorPrint( "queryDbExec() failed. buffer:\n%s\n", buffer);
free(buffer); free(buffer);
errorPrint( "queryDbExec() failed. buffer:\n%s\n", buffer);
return NULL; return NULL;
} }
...@@ -2578,7 +2575,7 @@ static int startMultiThreadCreateChildTable( ...@@ -2578,7 +2575,7 @@ static int startMultiThreadCreateChildTable(
if (t_info->taos == NULL) { if (t_info->taos == NULL) {
errorPrint( "Failed to connect to TDengine, reason:%s\n", taos_errstr(NULL)); errorPrint( "Failed to connect to TDengine, reason:%s\n", taos_errstr(NULL));
free(pids); free(pids);
free(infos); free(infos);
return -1; return -1;
} }
...@@ -4530,7 +4527,6 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) { ...@@ -4530,7 +4527,6 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
recOfBatch += batchPerTbl; recOfBatch += batchPerTbl;
startTime += batchPerTbl * superTblInfo->timeStampStep; startTime += batchPerTbl * superTblInfo->timeStampStep;
pThreadInfo->totalInsertRows += batchPerTbl; pThreadInfo->totalInsertRows += batchPerTbl;
verbosePrint("[%d] %s() LN%d batchPerTbl=%d recOfBatch=%d\n", verbosePrint("[%d] %s() LN%d batchPerTbl=%d recOfBatch=%d\n",
pThreadInfo->threadID, __func__, __LINE__, pThreadInfo->threadID, __func__, __LINE__,
batchPerTbl, recOfBatch); batchPerTbl, recOfBatch);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册