提交 779cce77 编写于 作者: H Haojun Liao

[td-225] fix the taosd crashed by too many empty table with group by tbname query.

上级 1254aa77
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册