[td-225]fix bugs in empty super table query.
This commit is contained in:
parent
6f524d20ac
commit
7cbff7c2c2
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
/*
|
||||
|
|
|
@ -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;
|
||||
|
@ -5876,6 +5875,14 @@ static int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQ
|
|||
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) {
|
||||
goto _error;
|
||||
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue