diff --git a/src/client/inc/tscSubquery.h b/src/client/inc/tscSubquery.h index 07e05803979c93f00312e17da0fbd6822b2a522b..7876069ccee841485fae9069d1116c13f385ce7b 100644 --- a/src/client/inc/tscSubquery.h +++ b/src/client/inc/tscSubquery.h @@ -28,7 +28,7 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql); void tscSetupOutputColumnIndex(SSqlObj* pSql); void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code); -SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pState, int32_t index); +SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index); void tscHandleMasterJoinQuery(SSqlObj* pSql); diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 5ccb2aee8c62a8ad200115c6ca5b534f6a357275..e47583b1a2037b53291cdb89de046d27db0e9356 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -166,7 +166,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ } // todo handle failed to create sub query -SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pState, int32_t index) { +SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index) { SJoinSupporter* pSupporter = calloc(1, sizeof(SJoinSupporter)); if (pSupporter == NULL) { return NULL; @@ -1300,11 +1300,11 @@ void tscHandleMasterJoinQuery(SSqlObj* pSql) { int32_t code = TSDB_CODE_SUCCESS; // todo add test - SSubqueryState *pState = calloc(1, sizeof(SSubqueryState)); - if (pState == NULL) { - code = TSDB_CODE_TSC_OUT_OF_MEMORY; - goto _error; - } +// SSubqueryState *pState = calloc(1, sizeof(SSubqueryState)); +// if (pState == NULL) { +// code = TSDB_CODE_TSC_OUT_OF_MEMORY; +// goto _error; +// } pSql->subState.numOfSub = pQueryInfo->numOfTables; @@ -1312,7 +1312,7 @@ void tscHandleMasterJoinQuery(SSqlObj* pSql) { tscDebug("%p start subquery, total:%d", pSql, pQueryInfo->numOfTables); for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) { - SJoinSupporter *pSupporter = tscCreateJoinSupporter(pSql, pState, i); + SJoinSupporter *pSupporter = tscCreateJoinSupporter(pSql, i); if (pSupporter == NULL) { // failed to create support struct, abort current query tscError("%p tableIndex:%d, failed to allocate join support object, abort further query", pSql, i); @@ -1357,8 +1357,8 @@ void tscHandleMasterJoinQuery(SSqlObj* pSql) { tscQueueAsyncRes(pSql); } -static void doCleanupSubqueries(SSqlObj *pSql, int32_t numOfSubs, SSubqueryState* pState) { - assert(numOfSubs <= pSql->subState.numOfSub && numOfSubs >= 0 && pState != NULL); +static void doCleanupSubqueries(SSqlObj *pSql, int32_t numOfSubs) { + assert(numOfSubs <= pSql->subState.numOfSub && numOfSubs >= 0); for(int32_t i = 0; i < numOfSubs; ++i) { SSqlObj* pSub = pSql->pSubs[i]; @@ -1371,8 +1371,6 @@ static void doCleanupSubqueries(SSqlObj *pSql, int32_t numOfSubs, SSubqueryState taos_free_result(pSub); } - - free(pState); } int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { @@ -1410,10 +1408,8 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { pSql->pSubs = calloc(pSql->subState.numOfSub, POINTER_BYTES); tscDebug("%p retrieved query data from %d vnode(s)", pSql, pSql->subState.numOfSub); - SSubqueryState *pState = calloc(1, sizeof(SSubqueryState)); - if (pSql->pSubs == NULL || pState == NULL) { - taosTFree(pState); + if (pSql->pSubs == NULL) { taosTFree(pSql->pSubs); pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; tscLocalReducerEnvDestroy(pMemoryBuf, pDesc, pModel, pSql->subState.numOfSub); @@ -1470,13 +1466,13 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; tscLocalReducerEnvDestroy(pMemoryBuf, pDesc, pModel, pSql->subState.numOfSub); - doCleanupSubqueries(pSql, i, pState); + doCleanupSubqueries(pSql, i); return pRes->code; // free all allocated resource } if (pRes->code == TSDB_CODE_TSC_QUERY_CANCELLED) { tscLocalReducerEnvDestroy(pMemoryBuf, pDesc, pModel, pSql->subState.numOfSub); - doCleanupSubqueries(pSql, i, pState); + doCleanupSubqueries(pSql, i); return pRes->code; }