提交 3a848ccb 编写于 作者: H Haojun Liao

fix(query): fix the invalid return value check for percentile function.

上级 e0dbe221
...@@ -1662,6 +1662,8 @@ int32_t percentileFunction(SqlFunctionCtx* pCtx) { ...@@ -1662,6 +1662,8 @@ int32_t percentileFunction(SqlFunctionCtx* pCtx) {
int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
SVariant* pVal = &pCtx->param[1].param; SVariant* pVal = &pCtx->param[1].param;
terrno = 0;
double v = 0; double v = 0;
GET_TYPED_DATA(v, double, pVal->nType, &pVal->i); GET_TYPED_DATA(v, double, pVal->nType, &pVal->i);
...@@ -1675,8 +1677,8 @@ int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { ...@@ -1675,8 +1677,8 @@ int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
tMemBucketDestroy(pMemBucket); tMemBucketDestroy(pMemBucket);
if (ppInfo->result < 0) { if (terrno != TSDB_CODE_SUCCESS) {
return TSDB_CODE_NO_AVAIL_DISK; return terrno;
} }
return functionFinalize(pCtx, pBlock); return functionFinalize(pCtx, pBlock);
......
...@@ -92,6 +92,7 @@ static void resetPosInfo(SSlotInfo *pInfo) { ...@@ -92,6 +92,7 @@ static void resetPosInfo(SSlotInfo *pInfo) {
double findOnlyResult(tMemBucket *pMemBucket) { double findOnlyResult(tMemBucket *pMemBucket) {
ASSERT(pMemBucket->total == 1); ASSERT(pMemBucket->total == 1);
terrno = 0;
for (int32_t i = 0; i < pMemBucket->numOfSlots; ++i) { for (int32_t i = 0; i < pMemBucket->numOfSlots; ++i) {
tMemBucketSlot *pSlot = &pMemBucket->pSlots[i]; tMemBucketSlot *pSlot = &pMemBucket->pSlots[i];
...@@ -108,8 +109,10 @@ double findOnlyResult(tMemBucket *pMemBucket) { ...@@ -108,8 +109,10 @@ double findOnlyResult(tMemBucket *pMemBucket) {
int32_t *pageId = taosArrayGet(list, 0); int32_t *pageId = taosArrayGet(list, 0);
SFilePage *pPage = getBufPage(pMemBucket->pBuffer, *pageId); SFilePage *pPage = getBufPage(pMemBucket->pBuffer, *pageId);
if (pPage == NULL) { if (pPage == NULL) {
return -1; terrno = TSDB_CODE_NO_AVAIL_DISK;
return 0;
} }
ASSERT(pPage->num == 1); ASSERT(pPage->num == 1);
double v = 0; double v = 0;
...@@ -546,9 +549,7 @@ double getPercentile(tMemBucket *pMemBucket, double percent) { ...@@ -546,9 +549,7 @@ double getPercentile(tMemBucket *pMemBucket, double percent) {
// if only one elements exists, return it // if only one elements exists, return it
if (pMemBucket->total == 1) { if (pMemBucket->total == 1) {
if (findOnlyResult(pMemBucket) < 0) { return findOnlyResult(pMemBucket);
return -1;
}
} }
percent = fabs(percent); percent = fabs(percent);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册