diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 6fba0efd97562b9f95b98d16a2c430cc9b9ce049..d7224871dae51beefabfca6d8fba38ed547c97d2 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -165,7 +165,7 @@ static void tscProcessAsyncRetrieveImpl(void *param, TAOS_RES *tres, int numOfRo SSqlRes *pRes = &pSql->res; if ((pRes->qhandle == 0 || numOfRows != 0) && pCmd->command < TSDB_SQL_LOCAL) { - if (pRes->qhandle == 0) { + if (pRes->qhandle == 0 && numOfRows != 0) { tscError("qhandle is NULL"); } else { pRes->code = numOfRows; diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index ec9908ae969bbcb8d65c8c59603899bcfe9bdcf8..d66203ecbee0359f8a3fb054690b59cdfebdecbc 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -2010,7 +2010,7 @@ bool hasMoreVnodesToTry(SSqlObj* pSql) { STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); assert(pRes->completed); - // for normal table, do not try any more if result are exhausted + // for normal table, no need to try any more if results are all retrieved from one vnode if (!UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo) || (pTableMetaInfo->vgroupList == NULL)) { return false; } @@ -2036,7 +2036,7 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) { int32_t totalVgroups = pTableMetaInfo->vgroupList->numOfVgroups; while (++pTableMetaInfo->vgroupIndex < totalVgroups) { - tscTrace("%p current vnode:%d exhausted, try next:%d. total vnode:%d. current numOfRes:%d", pSql, + tscTrace("%p results from vgroup index:%d completed, try next:%d. total vgroups:%d. current numOfRes:%d", pSql, pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups, pRes->numOfClauseTotal); /* diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 47ad633e34bd8b9d4051bc6888c27dba21924fcf..4b0ff36d360d15ebb6ecb567b7dacee09702815c 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -4234,7 +4234,6 @@ static void setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery) { } } - static SFillColInfo* taosCreateFillColInfo(SQuery* pQuery) { int32_t numOfCols = pQuery->numOfOutput; int32_t offset = 0; @@ -5875,6 +5874,14 @@ static int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQ sem_post(&pQInfo->dataReady); return TSDB_CODE_SUCCESS; } + + if (pQInfo->groupInfo.numOfTables == 0) { + qTrace("QInfo:%p no table qualified for tag filter, abort query", pQInfo); + setQueryStatus(pQuery, QUERY_COMPLETED); + + sem_post(&pQInfo->dataReady); + return TSDB_CODE_SUCCESS; + } // filter the qualified if ((code = doInitQInfo(pQInfo, pTSBuf, tsdb, vgId, isSTable)) != TSDB_CODE_SUCCESS) { @@ -6108,12 +6115,14 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi // todo handle the error /*int32_t ret =*/tsdbQuerySTableByTagCond(tsdb, id->uid, tagCond, pQueryMsg->tagCondLen, pQueryMsg->tagNameRelType, tbnameCond, &groupInfo, pGroupColIndex, numOfGroupByCols); - if (groupInfo.numOfTables == 0) { // no qualified tables no need to do query - code = TSDB_CODE_SUCCESS; - goto _over; - } +// if (groupInfo.numOfTables == 0) { // no qualified tables no need to do query +// code = TSDB_CODE_SUCCESS; +// qTrace("qmsg:%p no results to produce by tag filters, return directly", pQueryMsg); + +// goto _over; +// } } else { - groupInfo.numOfTables = taosArrayGetSize(pTableIdList); +// groupInfo.numOfTables = taosArrayGetSize(pTableIdList); SArray* pTableGroup = taosArrayInit(1, POINTER_BYTES); SArray* sa = taosArrayInit(groupInfo.numOfTables, sizeof(STableId)); @@ -6142,7 +6151,6 @@ _over: taosArrayDestroy(pTableIdList); // if failed to add ref for all meters in this query, abort current query - // atomic_fetch_add_32(&vnodeSelectReqNum, 1); return code; } @@ -6155,7 +6163,7 @@ void qTableQuery(qinfo_t qinfo) { SQInfo *pQInfo = (SQInfo *)qinfo; if (pQInfo == NULL || pQInfo->signature != pQInfo) { - qTrace("%p freed abort query", pQInfo); + qTrace("QInfo:%p has been freed, no need to execute", pQInfo); return; } @@ -6268,7 +6276,10 @@ static void buildTagQueryResult(SQInfo* pQInfo) { SQuery * pQuery = pRuntimeEnv->pQuery; size_t num = taosArrayGetSize(pQInfo->groupInfo.pGroupList); - assert(num == 1); // only one group + assert(num == 0 || num == 1); + if (num == 0) { + return; + } SArray* pa = taosArrayGetP(pQInfo->groupInfo.pGroupList, 0); num = taosArrayGetSize(pa);