From c0c5754b7a54f180ca90e8e8e5ed71154fd8f7ea Mon Sep 17 00:00:00 2001 From: hjxilinx Date: Wed, 8 Jan 2020 17:35:07 +0800 Subject: [PATCH] help to prevent current data in file from causing TDengine crashed while min/max function is invoked. --- src/client/src/tscFunctionImpl.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/client/src/tscFunctionImpl.c b/src/client/src/tscFunctionImpl.c index d317006e48..29f6f2dd26 100644 --- a/src/client/src/tscFunctionImpl.c +++ b/src/client/src/tscFunctionImpl.c @@ -909,7 +909,17 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, tval = &pCtx->preAggVals.max; 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]; if (pCtx->inputType >= TSDB_DATA_TYPE_TINYINT && pCtx->inputType <= TSDB_DATA_TYPE_BIGINT) { -- GitLab