提交 11c0839c 编写于 作者: S shenglian zhou

fix core dump and before correct value

上级 a6ebdf13
...@@ -4608,7 +4608,7 @@ static bool mavg_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pResIn ...@@ -4608,7 +4608,7 @@ static bool mavg_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pResIn
mavgInfo->pos = 0; mavgInfo->pos = 0;
mavgInfo->sum = 0; mavgInfo->sum = 0;
mavgInfo->numPointsK = (int32_t)pCtx->param[0].i64; mavgInfo->numPointsK = (int32_t)pCtx->param[0].i64;
mavgInfo->points = (double*)((char*)mavgInfo + sizeof(mavgInfo)); mavgInfo->points = (double*)((char*)mavgInfo + sizeof(SMovingAvgInfo));
return true; return true;
} }
...@@ -4621,6 +4621,7 @@ static void mavg_function(SQLFunctionCtx *pCtx) { ...@@ -4621,6 +4621,7 @@ static void mavg_function(SQLFunctionCtx *pCtx) {
int32_t i = (pCtx->order = TSDB_ORDER_ASC) ? 0 : pCtx->size -1; int32_t i = (pCtx->order = TSDB_ORDER_ASC) ? 0 : pCtx->size -1;
TSKEY* pTimestamp = pCtx->ptsOutputBuf; TSKEY* pTimestamp = pCtx->ptsOutputBuf;
char* pOutput = pCtx->pOutput;
TSKEY* tsList = GET_TS_LIST(pCtx); TSKEY* tsList = GET_TS_LIST(pCtx);
for (; i < pCtx->size && i >= 0; i += step) { for (; i < pCtx->size && i >= 0; i += step) {
...@@ -4647,10 +4648,10 @@ static void mavg_function(SQLFunctionCtx *pCtx) { ...@@ -4647,10 +4648,10 @@ static void mavg_function(SQLFunctionCtx *pCtx) {
mavgInfo->points[pos] = v; mavgInfo->points[pos] = v;
*pTimestamp = (tsList != NULL) ? tsList[i] : 0; *pTimestamp = (tsList != NULL) ? tsList[i] : 0;
SET_DOUBLE_VAL(pCtx->pOutput, mavgInfo->sum / mavgInfo->numPointsK) SET_DOUBLE_VAL(pOutput, mavgInfo->sum / mavgInfo->numPointsK)
++notNullElems; ++notNullElems;
pCtx->pOutput += pCtx->outputBytes; pOutput += pCtx->outputBytes;
pTimestamp++; pTimestamp++;
} }
...@@ -4700,12 +4701,13 @@ static void copySampleFuncRes(SQLFunctionCtx *pCtx, int32_t type) { ...@@ -4700,12 +4701,13 @@ static void copySampleFuncRes(SQLFunctionCtx *pCtx, int32_t type) {
SSampleFuncInfo *pRes = GET_ROWCELL_INTERBUF(pResInfo); SSampleFuncInfo *pRes = GET_ROWCELL_INTERBUF(pResInfo);
TSKEY* pTimestamp = pCtx->ptsOutputBuf; TSKEY* pTimestamp = pCtx->ptsOutputBuf;
char* pOutput = pCtx->pOutput;
for (int32_t i = 0; i < pRes->numSampled; ++i) { for (int32_t i = 0; i < pRes->numSampled; ++i) {
char* output = pCtx->pOutput;
tVariantDump(pRes->values + i, (char*)output, type, true); tVariantDump(pRes->values + i, (char*)pOutput, type, true);
*pTimestamp = *(pRes->timeStamps + i); *pTimestamp = *(pRes->timeStamps + i);
pCtx->pOutput += pCtx->outputBytes; pOutput += pCtx->outputBytes;
pTimestamp++; pTimestamp++;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册