未验证 提交 ecb3d055 编写于 作者: G Ganlin Zhao 提交者: GitHub

Merge pull request #13084 from taosdata/fix/TD-16034

fix(queyr): fix tail function parameter restriction
......@@ -621,8 +621,10 @@ static int32_t translateTail(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
SValueNode* pValue = (SValueNode*)pParamNode;
if (pValue->datum.i < ((i > 1) ? 0 : 1) || pValue->datum.i > 1000) {
return invaildFuncParaValueErrMsg(pErrBuf, len, pFunc->functionName);
if (pValue->datum.i < ((i > 1) ? 0 : 1) || pValue->datum.i > 100) {
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
"TAIL function second parameter should be in range [1, 100], "
"third parameter should be in range [0, 100]");
}
pValue->notReserved = true;
......
......@@ -2349,7 +2349,7 @@ static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SCo
case TSDB_DATA_TYPE_FLOAT: {
float v = *(float*)pv;
float delta = factor*(v - pDiffInfo->prev.d64); // direct previous may be null
if (delta < 0 && pDiffInfo->ignoreNegative) {
if ((delta < 0 && pDiffInfo->ignoreNegative) || isinf(delta) || isnan(delta)) { //check for overflow
colDataSetNull_f(pOutput->nullbitmap, pos);
} else {
colDataAppendFloat(pOutput, pos, &delta);
......@@ -2360,7 +2360,7 @@ static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SCo
case TSDB_DATA_TYPE_DOUBLE: {
double v = *(double*)pv;
double delta = factor*(v - pDiffInfo->prev.d64); // direct previous may be null
if (delta < 0 && pDiffInfo->ignoreNegative) {
if ((delta < 0 && pDiffInfo->ignoreNegative) || isinf(delta) || isnan(delta)) { //check for overflow
colDataSetNull_f(pOutput->nullbitmap, pos);
} else {
colDataAppendDouble(pOutput, pos, &delta);
......@@ -3530,7 +3530,12 @@ int32_t csumFunction(SqlFunctionCtx* pCtx) {
double v;
GET_TYPED_DATA(v, double, type, data);
pSumRes->dsum += v;
colDataAppend(pOutput, pos, (char *)&pSumRes->dsum, false);
//check for overflow
if (isinf(pSumRes->dsum) || isnan(pSumRes->dsum)) {
colDataAppendNULL(pOutput, pos);
} else {
colDataAppend(pOutput, pos, (char *)&pSumRes->dsum, false);
}
}
//TODO: remove this after pTsOutput is handled
......@@ -3604,7 +3609,12 @@ int32_t mavgFunction(SqlFunctionCtx* pCtx) {
pInfo->points[pInfo->pos] = v;
double result = pInfo->sum / pInfo->numOfPoints;
colDataAppend(pOutput, pos, (char *)&result, false);
//check for overflow
if (isinf(result) || isnan(result)) {
colDataAppendNULL(pOutput, pos);
} else {
colDataAppend(pOutput, pos, (char *)&result, false);
}
//TODO: remove this after pTsOutput is handled
if (pTsOutput != NULL) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册