diff --git a/src/system/detail/inc/vnodeQueryImpl.h b/src/system/detail/inc/vnodeQueryImpl.h index 71318ca7971c8343e41866275660ac81e8dfda0f..92d38888cb8e197093d1e4efc7e70838a0e2adbf 100644 --- a/src/system/detail/inc/vnodeQueryImpl.h +++ b/src/system/detail/inc/vnodeQueryImpl.h @@ -162,7 +162,7 @@ void disableFunctForSuppleScan(STableQuerySupportObj* pSupporter, int32_t ord void enableFunctForMasterScan(SQueryRuntimeEnv* pRuntimeEnv, int32_t order); int32_t mergeMetersResultToOneGroups(STableQuerySupportObj* pSupporter); -void copyFromWindowResToSData(SQInfo* pQInfo, SWindowResult* result); +void copyFromWindowResToSData(SQInfo* pQInfo, SWindowResult* result, int32_t numOfWindowRes); SBlockInfo getBlockInfo(SQueryRuntimeEnv *pRuntimeEnv); SBlockInfo getBlockBasicInfo(SQueryRuntimeEnv *pRuntimeEnv, void* pBlock, int32_t type); diff --git a/src/system/detail/src/vnodeQueryImpl.c b/src/system/detail/src/vnodeQueryImpl.c index 9c6230c7e7d202e79fb64a31795105358238734d..ec83eba049c37d8bf970a4dc5e60f871174c0f0a 100644 --- a/src/system/detail/src/vnodeQueryImpl.c +++ b/src/system/detail/src/vnodeQueryImpl.c @@ -7698,7 +7698,7 @@ static int32_t getNumOfSubset(STableQuerySupportObj *pSupporter) { return totalSubset; } -static int32_t doCopyToSData(STableQuerySupportObj *pSupporter, SWindowResult *result, int32_t orderType) { +static int32_t doCopyToSData(STableQuerySupportObj *pSupporter, SWindowResult *result, int32_t numOfWindowRes, int32_t orderType) { SQueryRuntimeEnv *pRuntimeEnv = &pSupporter->runtimeEnv; SQuery * pQuery = pRuntimeEnv->pQuery; @@ -7717,7 +7717,7 @@ static int32_t doCopyToSData(STableQuerySupportObj *pSupporter, SWindowResult *r step = -1; } - for (int32_t i = startIdx; (i < totalSubset) && (i >= 0); i += step) { + for (int32_t i = startIdx; (i < totalSubset && i < numOfWindowRes) && (i >= 0); i += step) { if (result[i].numOfRows == 0) { pSupporter->offset = 0; pSupporter->subgroupIdx += 1; @@ -7772,12 +7772,12 @@ static int32_t doCopyToSData(STableQuerySupportObj *pSupporter, SWindowResult *r * @param pQInfo * @param result */ -void copyFromWindowResToSData(SQInfo *pQInfo, SWindowResult *result) { +void copyFromWindowResToSData(SQInfo *pQInfo, SWindowResult *result, int32_t numOfWindowRes) { SQuery * pQuery = &pQInfo->query; STableQuerySupportObj *pSupporter = pQInfo->pTableQuerySupporter; int32_t orderType = (pQuery->pGroupbyExpr != NULL) ? pQuery->pGroupbyExpr->orderType : TSQL_SO_ASC; - int32_t numOfResult = doCopyToSData(pSupporter, result, orderType); + int32_t numOfResult = doCopyToSData(pSupporter, result, numOfWindowRes, orderType); pQuery->pointsRead += numOfResult; assert(pQuery->pointsRead <= pQuery->pointsToRead); diff --git a/src/system/detail/src/vnodeQueryProcess.c b/src/system/detail/src/vnodeQueryProcess.c index 766419dd2213df05935183ce646966c17d3734ff..1589c1d5e2260812e155fff6b11236a0891fe6a4 100644 --- a/src/system/detail/src/vnodeQueryProcess.c +++ b/src/system/detail/src/vnodeQueryProcess.c @@ -664,7 +664,7 @@ static void vnodeSTableSeqProcessor(SQInfo *pQInfo) { * we need to return it to client in the first place. */ if (pSupporter->subgroupIdx > 0) { - copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult); + copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult, pRuntimeEnv->windowResInfo.size); pQInfo->pointsRead += pQuery->pointsRead; if (pQuery->pointsRead > 0) { @@ -815,7 +815,7 @@ static void vnodeSTableSeqProcessor(SQInfo *pQInfo) { pQInfo->pTableQuerySupporter->subgroupIdx = 0; pQuery->pointsRead = 0; - copyFromWindowResToSData(pQInfo, pWindowResInfo->pResult); + copyFromWindowResToSData(pQInfo, pWindowResInfo->pResult, pWindowResInfo->size); } pQInfo->pointsRead += pQuery->pointsRead; @@ -917,7 +917,7 @@ static void vnodeMultiMeterQueryProcessor(SQInfo *pQInfo) { displayInterResult(pQuery->sdata, pQuery, pQuery->sdata[0]->len); #endif } else { - copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult); + copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult, pRuntimeEnv->windowResInfo.size); } pQInfo->pointsRead += pQuery->pointsRead; @@ -975,7 +975,7 @@ static void vnodeMultiMeterQueryProcessor(SQInfo *pQInfo) { #endif } } else { // not a interval query - copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult); + copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult, pRuntimeEnv->windowResInfo.size); } // handle the limitation of output buffer @@ -1136,7 +1136,7 @@ static void vnodeSingleTableIntervalProcessor(SQInfo *pQInfo) { if (pQuery->intervalTime > 0) { pSupporter->subgroupIdx = 0; // always start from 0 pQuery->pointsRead = 0; - copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult); + copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult, pRuntimeEnv->windowResInfo.size); clearFirstNTimeWindow(pRuntimeEnv, pSupporter->subgroupIdx); } @@ -1172,7 +1172,7 @@ static void vnodeSingleTableIntervalProcessor(SQInfo *pQInfo) { if (isGroupbyNormalCol(pQuery->pGroupbyExpr)) {//todo refactor with merge interval time result pSupporter->subgroupIdx = 0; pQuery->pointsRead = 0; - copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult); + copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult, pRuntimeEnv->windowResInfo.size); clearFirstNTimeWindow(pRuntimeEnv, pSupporter->subgroupIdx); } @@ -1249,7 +1249,7 @@ void vnodeSingleTableQuery(SSchedMsg *pMsg) { pSupporter->subgroupIdx = 0; // always start from 0 if (pRuntimeEnv->windowResInfo.size > 0) { - copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult); + copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult, pRuntimeEnv->windowResInfo.size); pQInfo->pointsRead += pQuery->pointsRead; clearFirstNTimeWindow(pRuntimeEnv, pSupporter->subgroupIdx);