diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index e55abdd2dda8e214df45f27d582b8fc695a5483b..4869f656450c471504cd89bc6c4537d8df9b149b 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -440,6 +440,7 @@ void tscRestoreFuncForSTableQuery(SQueryInfo *pQueryInfo); int32_t tscCreateResPointerInfo(SSqlRes *pRes, SQueryInfo *pQueryInfo); void tscSetResRawPtr(SSqlRes* pRes, SQueryInfo* pQueryInfo); +void destroyTableNameList(SSqlCmd* pCmd); void tscResetSqlCmd(SSqlCmd *pCmd, bool removeMeta); diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index f5fee0b62261e3c615046de5cbd94e78eb89368f..6f74101164afec276a8d21d73f64a96d1987ec73 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -1420,7 +1420,8 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int32_t numOfRow STableMeta * pTableMeta = pTableMetaInfo->pTableMeta; STableComInfo tinfo = tscGetTableInfo(pTableMeta); - tfree(pCmd->pTableNameList); + destroyTableNameList(pCmd); + pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks); if (pCmd->pTableBlockHashList == NULL) { diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 51ebdaccb8ba93ce51024453b74a04ed998ab9da..386352bdc741035168aa0158ef41dcea6c7a7a90 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -415,6 +415,20 @@ void tscFreeQueryInfo(SSqlCmd* pCmd, bool removeMeta) { tfree(pCmd->pQueryInfo); } +void destroyTableNameList(SSqlCmd* pCmd) { + if (pCmd->numOfTables == 0) { + assert(pCmd->pTableNameList == NULL); + return; + } + + for(int32_t i = 0; i < pCmd->numOfTables; ++i) { + tfree(pCmd->pTableNameList[i]); + } + + pCmd->numOfTables = 0; + tfree(pCmd->pTableNameList); +} + void tscResetSqlCmd(SSqlCmd* pCmd, bool removeMeta) { pCmd->command = 0; pCmd->numOfCols = 0; @@ -424,14 +438,7 @@ void tscResetSqlCmd(SSqlCmd* pCmd, bool removeMeta) { pCmd->parseFinished = 0; pCmd->autoCreated = 0; - for(int32_t i = 0; i < pCmd->numOfTables; ++i) { - if (pCmd->pTableNameList && pCmd->pTableNameList[i]) { - tfree(pCmd->pTableNameList[i]); - } - } - - pCmd->numOfTables = 0; - tfree(pCmd->pTableNameList); + destroyTableNameList(pCmd); pCmd->pTableBlockHashList = tscDestroyBlockHashTable(pCmd->pTableBlockHashList, removeMeta); pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks); @@ -840,6 +847,8 @@ static void extractTableNameList(SSqlCmd* pCmd, bool freeBlockMap) { int32_t i = 0; while(p1) { STableDataBlocks* pBlocks = *p1; + tfree(pCmd->pTableNameList[i]); + pCmd->pTableNameList[i++] = tNameDup(&pBlocks->tableName); p1 = taosHashIterate(pCmd->pTableBlockHashList, p1); }