提交 e9fba684 编写于 作者: G Ganlin Zhao

fix mem leak

上级 c3d26dc7
...@@ -2492,13 +2492,15 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) { ...@@ -2492,13 +2492,15 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
memcpy(pInfo->buf, data, bytes); memcpy(pInfo->buf, data, bytes);
*(TSKEY*)(pInfo->buf + bytes) = cts; *(TSKEY*)(pInfo->buf + bytes) = cts;
//handle selectivity //handle selectivity
STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY)); if (pCtx->subsidiaries.num > 0) {
if (!pInfo->hasResult) { STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY));
saveTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); if (!pInfo->hasResult) {
pInfo->hasResult = true; saveTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos);
} else { } else {
copyTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); copyTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos);
}
} }
pInfo->hasResult = true;
//DO_UPDATE_TAG_COLUMNS(pCtx, ts); //DO_UPDATE_TAG_COLUMNS(pCtx, ts);
pResInfo->numOfRes = 1; pResInfo->numOfRes = 1;
break; break;
...@@ -2532,13 +2534,15 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) { ...@@ -2532,13 +2534,15 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
memcpy(pInfo->buf, data, bytes); memcpy(pInfo->buf, data, bytes);
*(TSKEY*)(pInfo->buf + bytes) = cts; *(TSKEY*)(pInfo->buf + bytes) = cts;
//handle selectivity //handle selectivity
STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY)); if (pCtx->subsidiaries.num > 0) {
if (!pInfo->hasResult) { STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY));
saveTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); if (!pInfo->hasResult) {
pInfo->hasResult = true; saveTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos);
} else { } else {
copyTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); copyTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos);
}
} }
pInfo->hasResult = true;
//DO_UPDATE_TAG_COLUMNS(pCtx, ts); //DO_UPDATE_TAG_COLUMNS(pCtx, ts);
pResInfo->numOfRes = 1; pResInfo->numOfRes = 1;
break; break;
...@@ -2594,13 +2598,15 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { ...@@ -2594,13 +2598,15 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
memcpy(pInfo->buf, data, bytes); memcpy(pInfo->buf, data, bytes);
*(TSKEY*)(pInfo->buf + bytes) = cts; *(TSKEY*)(pInfo->buf + bytes) = cts;
//handle selectivity //handle selectivity
STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY)); if (pCtx->subsidiaries.num > 0) {
if (!pInfo->hasResult) { STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY));
saveTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); if (!pInfo->hasResult) {
pInfo->hasResult = true; saveTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos);
} else { } else {
copyTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); copyTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos);
}
} }
pInfo->hasResult = true;
//DO_UPDATE_TAG_COLUMNS(pCtx, ts); //DO_UPDATE_TAG_COLUMNS(pCtx, ts);
pResInfo->numOfRes = 1; pResInfo->numOfRes = 1;
} }
...@@ -2624,13 +2630,15 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { ...@@ -2624,13 +2630,15 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
memcpy(pInfo->buf, data, bytes); memcpy(pInfo->buf, data, bytes);
*(TSKEY*)(pInfo->buf + bytes) = cts; *(TSKEY*)(pInfo->buf + bytes) = cts;
//handle selectivity //handle selectivity
STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY)); if (pCtx->subsidiaries.num > 0) {
if (!pInfo->hasResult) { STuplePos* pTuplePos = (STuplePos*)(pInfo->buf + bytes + sizeof(TSKEY));
saveTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); if (!pInfo->hasResult) {
pInfo->hasResult = true; saveTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos);
} else { } else {
copyTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos); copyTupleData(pCtx, i, pCtx->pSrcBlock, pTuplePos);
}
} }
pInfo->hasResult = true;
pResInfo->numOfRes = 1; pResInfo->numOfRes = 1;
//DO_UPDATE_TAG_COLUMNS(pCtx, ts); //DO_UPDATE_TAG_COLUMNS(pCtx, ts);
} }
...@@ -2664,12 +2672,15 @@ static void firstLastTransferInfo(SqlFunctionCtx* pCtx, SFirstLastRes* pInput, S ...@@ -2664,12 +2672,15 @@ static void firstLastTransferInfo(SqlFunctionCtx* pCtx, SFirstLastRes* pInput, S
memcpy(pOutput->buf, pInput->buf, pOutput->bytes); memcpy(pOutput->buf, pInput->buf, pOutput->bytes);
//handle selectivity //handle selectivity
STuplePos* pTuplePos = (STuplePos*)(pOutput->buf + pOutput->bytes + sizeof(TSKEY)); STuplePos* pTuplePos = (STuplePos*)(pOutput->buf + pOutput->bytes + sizeof(TSKEY));
if (!pOutput->hasResult) { if (pCtx->subsidiaries.num > 0) {
saveTupleData(pCtx, start, pCtx->pSrcBlock, pTuplePos); if (!pOutput->hasResult) {
pOutput->hasResult = true; saveTupleData(pCtx, start, pCtx->pSrcBlock, pTuplePos);
} else { } else {
copyTupleData(pCtx, start, pCtx->pSrcBlock, pTuplePos); copyTupleData(pCtx, start, pCtx->pSrcBlock, pTuplePos);
}
} }
pOutput->hasResult = true;
return; return;
} }
...@@ -3086,7 +3097,9 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData ...@@ -3086,7 +3097,9 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData
pItem->uid = uid; pItem->uid = uid;
// save the data of this tuple // save the data of this tuple
saveTupleData(pCtx, rowIndex, pSrcBlock, &pItem->tuplePos); if (pCtx->subsidiaries.num > 0) {
saveTupleData(pCtx, rowIndex, pSrcBlock, &pItem->tuplePos);
}
// allocate the buffer and keep the data of this row into the new allocated buffer // allocate the buffer and keep the data of this row into the new allocated buffer
pEntryInfo->numOfRes++; pEntryInfo->numOfRes++;
...@@ -3105,7 +3118,10 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData ...@@ -3105,7 +3118,10 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData
pItem->uid = uid; pItem->uid = uid;
// save the data of this tuple by over writing the old data // save the data of this tuple by over writing the old data
copyTupleData(pCtx, rowIndex, pSrcBlock, &pItem->tuplePos); if (pCtx->subsidiaries.num > 0) {
copyTupleData(pCtx, rowIndex, pSrcBlock, &pItem->tuplePos);
}
taosheapadjust((void*)pItems, sizeof(STopBotResItem), 0, pEntryInfo->numOfRes - 1, (const void*)&type, taosheapadjust((void*)pItems, sizeof(STopBotResItem), 0, pEntryInfo->numOfRes - 1, (const void*)&type,
topBotResComparFn, NULL, !isTopQuery); topBotResComparFn, NULL, !isTopQuery);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册