diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index cdcea63c88082174438c747023402fd965ca13da..f710481d941f3736b240860642e14ec6502a6ddb 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -263,7 +263,7 @@ typedef struct SResRec { typedef struct { int64_t numOfRows; // num of results in current retrieved int64_t numOfTotal; // num of total results - int64_t numOfTotalInCurrentClause; // num of total result in current subclause + int64_t numOfClauseTotal; // num of total result in current subclause char * pRsp; int32_t rspType; int32_t rspLen; diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 82b0f852ab5b9d615051c2b2589ab4efda8af1a5..26de2a51a84d8a94bebc4a69c4a2260eb3353692 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -147,7 +147,7 @@ static void tscAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOfRows) { // local merge has handle this situation during super table non-projection query. if (pCmd->command != TSDB_SQL_RETRIEVE_LOCALMERGE) { - pRes->numOfTotalInCurrentClause += pRes->numOfRows; + pRes->numOfClauseTotal += pRes->numOfRows; } (*pSql->fetchFp)(param, tres, numOfRows); diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 260649050be5448a6c975abdf1b82582a9a17575..42476b99fd7ed68210a0216e5c0daf30b0d2038b 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -447,7 +447,7 @@ static int insertStmtExecute(STscStmt* stmt) { SSqlRes *pRes = &pSql->res; pRes->numOfRows = 0; pRes->numOfTotal = 0; - pRes->numOfTotalInCurrentClause = 0; + pRes->numOfClauseTotal = 0; pRes->qhandle = 0; diff --git a/src/client/src/tscSecondaryMerge.c b/src/client/src/tscSecondaryMerge.c index 38fce0630672590012271ac6474fd14e5832ebbc..fc397cbd013369c904b02f15504af97f70c84d4e 100644 --- a/src/client/src/tscSecondaryMerge.c +++ b/src/client/src/tscSecondaryMerge.c @@ -892,7 +892,7 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo // no interval query, no fill operation pRes->data = pLocalReducer->pFinalRes; pRes->numOfRows = pFinalDataPage->num; - pRes->numOfTotalInCurrentClause += pRes->numOfRows; + pRes->numOfClauseTotal += pRes->numOfRows; if (pQueryInfo->limit.offset > 0) { if (pQueryInfo->limit.offset < pRes->numOfRows) { @@ -903,23 +903,23 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo tColModelCompact(pLocalReducer->resColModel, pFinalDataPage, prevSize); pRes->numOfRows -= pQueryInfo->limit.offset; - pRes->numOfTotalInCurrentClause -= pQueryInfo->limit.offset; + pRes->numOfClauseTotal -= pQueryInfo->limit.offset; pQueryInfo->limit.offset = 0; } else { pQueryInfo->limit.offset -= pRes->numOfRows; pRes->numOfRows = 0; - pRes->numOfTotalInCurrentClause = 0; + pRes->numOfClauseTotal = 0; } } - if (pQueryInfo->limit.limit >= 0 && pRes->numOfTotalInCurrentClause > pQueryInfo->limit.limit) { + if (pQueryInfo->limit.limit >= 0 && pRes->numOfClauseTotal > pQueryInfo->limit.limit) { /* impose the limitation of output rows on the final result */ int32_t prevSize = pFinalDataPage->num; - int32_t overFlow = pRes->numOfTotalInCurrentClause - pQueryInfo->limit.limit; + int32_t overFlow = pRes->numOfClauseTotal - pQueryInfo->limit.limit; assert(overFlow < pRes->numOfRows); - pRes->numOfTotalInCurrentClause = pQueryInfo->limit.limit; + pRes->numOfClauseTotal = pQueryInfo->limit.limit; pRes->numOfRows -= overFlow; pFinalDataPage->num -= overFlow; @@ -962,7 +962,7 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo pRes->data = pLocalReducer->pFinalRes; pRes->numOfRows = newRows; - pRes->numOfTotalInCurrentClause += newRows; + pRes->numOfClauseTotal += newRows; pQueryInfo->limit.offset = 0; break; @@ -987,13 +987,13 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo } if (pRes->numOfRows > 0) { - if (pQueryInfo->limit.limit >= 0 && pRes->numOfTotalInCurrentClause > pQueryInfo->limit.limit) { - int32_t overFlow = pRes->numOfTotalInCurrentClause - pQueryInfo->limit.limit; + if (pQueryInfo->limit.limit >= 0 && pRes->numOfClauseTotal > pQueryInfo->limit.limit) { + int32_t overFlow = pRes->numOfClauseTotal - pQueryInfo->limit.limit; pRes->numOfRows -= overFlow; assert(pRes->numOfRows >= 0); - pRes->numOfTotalInCurrentClause = pQueryInfo->limit.limit; + pRes->numOfClauseTotal = pQueryInfo->limit.limit; pFinalDataPage->num -= overFlow; /* set remain data to be discarded, and reset the interpolation information */ @@ -1214,7 +1214,7 @@ static bool saveGroupResultInfo(SSqlObj *pSql) { // pRes->pGroupRec = realloc(pRes->pGroupRec, pRes->numOfGroups*sizeof(SResRec)); // pRes->pGroupRec[pRes->numOfGroups-1].numOfRows = pRes->numOfRows; - // pRes->pGroupRec[pRes->numOfGroups-1].numOfTotalInCurrentClause = pRes->numOfTotalInCurrentClause; + // pRes->pGroupRec[pRes->numOfGroups-1].numOfClauseTotal = pRes->numOfClauseTotal; return false; } @@ -1249,7 +1249,6 @@ bool doGenerateFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool no } tColModelCompact(pModel, pResBuf, pModel->capacity); -// memcpy(pLocalReducer->pBufForInterpo, pResBuf->data, pLocalReducer->nResultBufSize); #ifdef _DEBUG_VIEW printf("final result before interpo:\n"); @@ -1258,15 +1257,16 @@ bool doGenerateFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool no #endif SFillInfo* pFillInfo = pLocalReducer->pFillInfo; + if (pFillInfo != NULL) { + STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); + STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); - STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); - STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); - - TSKEY ekey = taosGetRevisedEndKey(pQueryInfo->window.ekey, pFillInfo->order, pFillInfo->slidingTime, - pQueryInfo->slidingTimeUnit, tinfo.precision); + TSKEY ekey = taosGetRevisedEndKey(pQueryInfo->window.ekey, pFillInfo->order, pFillInfo->slidingTime, + pQueryInfo->slidingTimeUnit, tinfo.precision); - taosFillSetStartInfo(pFillInfo, pResBuf->num, ekey); - taosFillCopyInputDataFromOneFilePage(pFillInfo, pResBuf); + taosFillSetStartInfo(pFillInfo, pResBuf->num, ekey); + taosFillCopyInputDataFromOneFilePage(pFillInfo, pResBuf); + } doInterpolateResult(pSql, pLocalReducer, noMoreCurrentGroupRes); return true; @@ -1284,7 +1284,7 @@ void resetOutputBuf(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer) { // static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalReducer *pLocalReducer) { // In handling data in other groups, we need to reset the interpolation information for a new group data pRes->numOfRows = 0; - pRes->numOfTotalInCurrentClause = 0; + pRes->numOfClauseTotal = 0; SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 87292f4fe659adf2c0d54ad08143fbcf2ba36126..b26fe4f04798f58f6a3af5ccf3f75820412fff44 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -242,7 +242,7 @@ int taos_query_imp(STscObj *pObj, SSqlObj *pSql) { pRes->numOfRows = 1; pRes->numOfTotal = 0; - pRes->numOfTotalInCurrentClause = 0; + pRes->numOfClauseTotal = 0; pCmd->curSql = NULL; if (NULL != pCmd->pTableList) { @@ -421,7 +421,7 @@ int taos_fetch_block_impl(TAOS_RES *res, TAOS_ROW *rows) { // secondary merge has handle this situation if (pCmd->command != TSDB_SQL_RETRIEVE_LOCALMERGE) { - pRes->numOfTotalInCurrentClause += pRes->numOfRows; + pRes->numOfClauseTotal += pRes->numOfRows; } SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); @@ -504,8 +504,8 @@ int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) { pSql->cmd.command = pQueryInfo->command; pCmd->clauseIndex++; - pRes->numOfTotal += pRes->numOfTotalInCurrentClause; - pRes->numOfTotalInCurrentClause = 0; + pRes->numOfTotal += pRes->numOfClauseTotal; + pRes->numOfClauseTotal = 0; pRes->rspType = 0; pSql->numOfSubs = 0; @@ -804,7 +804,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) { pRes->numOfRows = 1; pRes->numOfTotal = 0; - pRes->numOfTotalInCurrentClause = 0; + pRes->numOfClauseTotal = 0; tscTrace("%p Valid SQL: %s pObj:%p", pSql, sql, pObj); @@ -935,7 +935,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { SSqlRes *pRes = &pSql->res; pRes->numOfTotal = 0; // the number of getting table meta from server - pRes->numOfTotalInCurrentClause = 0; + pRes->numOfClauseTotal = 0; pRes->code = 0; diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 6f9ad6d8507f11656795f3b5f9359338449ec86c..def92522890cbc393a789d3342132e58ece3ba52 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -771,7 +771,7 @@ static void joinRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) { } SSqlRes* pRes1 = &pParentSql->pSubs[i]->res; - pRes1->numOfTotalInCurrentClause += pRes1->numOfRows; + pRes1->numOfClauseTotal += pRes1->numOfRows; } // data has retrieved to client, build the join results @@ -1834,7 +1834,7 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) { pRes->tsrow[i] = pRes1->tsrow[pIndex->columnIndex]; } - pRes->numOfTotalInCurrentClause++; + pRes->numOfClauseTotal++; break; } else { // continue retrieve data from vnode if (!tscHashRemainDataInSubqueryResultSet(pSql)) { diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 9163e0f11fa2cf68ea1818c7b7ee586e8881b323..6405dfe411e1763507fad1060df52d39b1a57b30 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1989,7 +1989,7 @@ int32_t tscInvalidSQLErrMsg(char* msg, const char* additionalInfo, const char* s bool tscHasReachLimitation(SQueryInfo* pQueryInfo, SSqlRes* pRes) { assert(pQueryInfo != NULL && pQueryInfo->clauseLimit != 0); - return (pQueryInfo->clauseLimit > 0 && pRes->numOfTotalInCurrentClause >= pQueryInfo->clauseLimit); + return (pQueryInfo->clauseLimit > 0 && pRes->numOfClauseTotal >= pQueryInfo->clauseLimit); } char* tscGetErrorMsgPayload(SSqlCmd* pCmd) { return pCmd->payload; } @@ -2037,7 +2037,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, - pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups, pRes->numOfTotalInCurrentClause); + pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups, pRes->numOfClauseTotal); /* * update the limit and offset value for the query on the next vnode, @@ -2045,11 +2045,11 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) { * * NOTE: * if the pRes->offset is larger than 0, the start returned position has not reached yet. - * Therefore, the pRes->numOfRows, as well as pRes->numOfTotalInCurrentClause, must be 0. + * Therefore, the pRes->numOfRows, as well as pRes->numOfClauseTotal, must be 0. * The pRes->offset value will be updated by virtual node, during query execution. */ if (pQueryInfo->clauseLimit >= 0) { - pQueryInfo->limit.limit = pQueryInfo->clauseLimit - pRes->numOfTotalInCurrentClause; + pQueryInfo->limit.limit = pQueryInfo->clauseLimit - pRes->numOfClauseTotal; } pQueryInfo->limit.offset = pRes->offset; @@ -2092,7 +2092,7 @@ void tscTryQueryNextClause(SSqlObj* pSql, void (*queryFp)()) { pSql->cmd.command = pQueryInfo->command; //backup the total number of result first - int64_t num = pRes->numOfTotal + pRes->numOfTotalInCurrentClause; + int64_t num = pRes->numOfTotal + pRes->numOfClauseTotal; tscFreeSqlResult(pSql); pRes->numOfTotal = num;