From 88e5fa75e64336fbee76b20dbc14556998667cab Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Wed, 26 Oct 2022 12:43:29 +0800 Subject: [PATCH] fix(query): fix interp crash issue TD-19858 --- source/libs/executor/src/timewindowoperator.c | 30 ++----------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 29b2edfcf5..a22371331a 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -2324,9 +2324,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pResBlock); pSliceInfo->current = taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); - if (pResBlock->info.rows >= pResBlock->info.capacity) { - break; - } } } @@ -2336,6 +2333,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { } if (ts == pSliceInfo->current) { + blockDataEnsureCapacity(pResBlock, pResBlock->info.rows + 1); for (int32_t j = 0; j < pOperator->exprSupp.numOfExprs; ++j) { SExprInfo* pExprInfo = &pOperator->exprSupp.pExprInfo[j]; @@ -2376,9 +2374,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pResBlock); pSliceInfo->current = taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); - if (pResBlock->info.rows >= pResBlock->info.capacity) { - break; - } } if (pSliceInfo->current > pSliceInfo->win.ekey) { @@ -2397,10 +2392,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { doSetOperatorCompleted(pOperator); break; } - - if (pResBlock->info.rows >= pResBlock->info.capacity) { - break; - } } } else if (ts < pSliceInfo->current) { // in case of interpolation window starts and ends between two datapoints, fill(prev) need to interpolate @@ -2418,9 +2409,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pResBlock); pSliceInfo->current = taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); - if (pResBlock->info.rows >= pResBlock->info.capacity) { - break; - } } if (pSliceInfo->current > pSliceInfo->win.ekey) { @@ -2442,9 +2430,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pResBlock); pSliceInfo->current = taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); - if (pResBlock->info.rows >= pResBlock->info.capacity) { - break; - } } if (pSliceInfo->current > pSliceInfo->win.ekey) { @@ -2466,13 +2451,11 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pResBlock); pSliceInfo->current = taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); - if (pResBlock->info.rows >= pResBlock->info.capacity) { - break; - } } // add current row if timestamp match if (ts == pSliceInfo->current && pSliceInfo->current <= pSliceInfo->win.ekey) { + blockDataEnsureCapacity(pResBlock, pResBlock->info.rows + 1); for (int32_t j = 0; j < pOperator->exprSupp.numOfExprs; ++j) { SExprInfo* pExprInfo = &pOperator->exprSupp.pExprInfo[j]; @@ -2509,9 +2492,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pResBlock); pSliceInfo->current = taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); - if (pResBlock->info.rows >= pResBlock->info.capacity) { - break; - } } if (pSliceInfo->current > pSliceInfo->win.ekey) { @@ -2527,9 +2507,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { pSliceInfo->current = taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); - if (pResBlock->info.rows >= pResBlock->info.capacity) { - break; - } } } @@ -2548,9 +2525,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pResBlock); pSliceInfo->current = taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); - if (pResBlock->info.rows >= pResBlock->info.capacity) { - break; - } } // restore the value