help to prevent current data in file from causing TDengine crashed while min/max function is invoked.

This commit is contained in:
hjxilinx 2020-01-08 17:35:07 +08:00
parent d6828370a5
commit c0c5754b7a
1 changed files with 11 additions and 1 deletions

View File

@ -909,7 +909,17 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
tval = &pCtx->preAggVals.max; tval = &pCtx->preAggVals.max;
index = pCtx->preAggVals.maxIndex; index = pCtx->preAggVals.maxIndex;
} }
/**
* NOTE: work around the bug caused by invalid pre-calculated function.
* Here the selectivity + ts will not return correct value.
*
* The following codes of 3 lines will be removed later.
*/
if (index < 0 || index >= pCtx->size + pCtx->startOffset) {
index = 0;
}
TSKEY key = pCtx->ptsList[index]; TSKEY key = pCtx->ptsList[index];
if (pCtx->inputType >= TSDB_DATA_TYPE_TINYINT && pCtx->inputType <= TSDB_DATA_TYPE_BIGINT) { if (pCtx->inputType >= TSDB_DATA_TYPE_TINYINT && pCtx->inputType <= TSDB_DATA_TYPE_BIGINT) {