Merge pull request #13688 from taosdata/feature/3_liaohj
fix(query): fix invalid write.
This commit is contained in:
commit
a80529e810
|
@ -294,7 +294,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, in
|
||||||
|
|
||||||
int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows) {
|
int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows) {
|
||||||
ASSERT(pColumnInfoData != NULL && pSource != NULL && pColumnInfoData->info.type == pSource->info.type);
|
ASSERT(pColumnInfoData != NULL && pSource != NULL && pColumnInfoData->info.type == pSource->info.type);
|
||||||
if (numOfRows == 0) {
|
if (numOfRows <= 0) {
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,6 +322,7 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p
|
||||||
pColumnInfoData->varmeta.length = pSource->varmeta.length;
|
pColumnInfoData->varmeta.length = pSource->varmeta.length;
|
||||||
} else {
|
} else {
|
||||||
char* tmp = taosMemoryRealloc(pColumnInfoData->nullbitmap, BitmapLen(numOfRows));
|
char* tmp = taosMemoryRealloc(pColumnInfoData->nullbitmap, BitmapLen(numOfRows));
|
||||||
|
printf("----------------%d\n", BitmapLen(numOfRows));
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -1239,6 +1240,9 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pSrc->pData == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
colDataAssign(pDst, pSrc, pDataBlock->info.rows);
|
colDataAssign(pDst, pSrc, pDataBlock->info.rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1819,7 +1819,7 @@ void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep, bool needFree);
|
static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep);
|
||||||
|
|
||||||
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, bool needFree) {
|
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, bool needFree) {
|
||||||
if (pFilterNode == NULL) {
|
if (pFilterNode == NULL) {
|
||||||
|
@ -1840,30 +1840,29 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, bool needFree) {
|
||||||
bool keep = filterExecute(filter, pBlock, &rowRes, NULL, param1.numOfCols);
|
bool keep = filterExecute(filter, pBlock, &rowRes, NULL, param1.numOfCols);
|
||||||
filterFreeInfo(filter);
|
filterFreeInfo(filter);
|
||||||
|
|
||||||
extractQualifiedTupleByFilterResult(pBlock, rowRes, keep, needFree);
|
extractQualifiedTupleByFilterResult(pBlock, rowRes, keep);
|
||||||
blockDataUpdateTsWindow(pBlock, 0);
|
blockDataUpdateTsWindow(pBlock, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep, bool needFree) {
|
void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep) {
|
||||||
if (keep) {
|
if (keep) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rowRes != NULL) {
|
if (rowRes != NULL) {
|
||||||
SSDataBlock* px = createOneDataBlock(pBlock, false);
|
SSDataBlock* px = createOneDataBlock(pBlock, true);
|
||||||
blockDataEnsureCapacity(px, pBlock->info.rows);
|
|
||||||
|
|
||||||
int32_t totalRows = pBlock->info.rows;
|
int32_t totalRows = pBlock->info.rows;
|
||||||
|
|
||||||
for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) {
|
for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) {
|
||||||
SColumnInfoData* pDst = taosArrayGet(px->pDataBlock, i);
|
SColumnInfoData* pSrc = taosArrayGet(px->pDataBlock, i);
|
||||||
SColumnInfoData* pSrc = taosArrayGet(pBlock->pDataBlock, i);
|
SColumnInfoData* pDst = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
|
|
||||||
// it is a reserved column for scalar function, and no data in this column yet.
|
// it is a reserved column for scalar function, and no data in this column yet.
|
||||||
if (pSrc->pData == NULL) {
|
if (pDst->pData == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
colInfoDataCleanup(pDst, pBlock->info.rows);
|
||||||
|
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
for (int32_t j = 0; j < totalRows; ++j) {
|
for (int32_t j = 0; j < totalRows; ++j) {
|
||||||
if (rowRes[j] == 0) {
|
if (rowRes[j] == 0) {
|
||||||
|
@ -1883,20 +1882,8 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowR
|
||||||
} else {
|
} else {
|
||||||
ASSERT(pBlock->info.rows == numOfRows);
|
ASSERT(pBlock->info.rows == numOfRows);
|
||||||
}
|
}
|
||||||
|
|
||||||
SColumnInfoData tmp = *pSrc;
|
|
||||||
*pSrc = *pDst;
|
|
||||||
*pDst = tmp;
|
|
||||||
|
|
||||||
if (!needFree) {
|
|
||||||
if (IS_VAR_DATA_TYPE(pDst->info.type)) { // this elements do not need free
|
|
||||||
pDst->varmeta.offset = NULL;
|
|
||||||
} else {
|
|
||||||
pDst->nullbitmap = NULL;
|
|
||||||
}
|
|
||||||
pDst->pData = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
blockDataDestroy(px); // fix memory leak
|
blockDataDestroy(px); // fix memory leak
|
||||||
} else {
|
} else {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
@ -2137,11 +2124,6 @@ static int32_t compressQueryColData(SColumnInfoData* pColRes, int32_t numOfRows,
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t doFillTimeIntervalGapsInResults(struct SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t capacity) {
|
int32_t doFillTimeIntervalGapsInResults(struct SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t capacity) {
|
||||||
// for(int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
|
||||||
// SColumnInfoData* pColInfoData = taosArrayGet(pOutput->pDataBlock, i);
|
|
||||||
// p[i] = pColInfoData->pData + (pColInfoData->info.bytes * pOutput->info.rows);
|
|
||||||
// }
|
|
||||||
|
|
||||||
int32_t numOfRows = (int32_t)taosFillResultDataBlock(pFillInfo, pBlock, capacity - pBlock->info.rows);
|
int32_t numOfRows = (int32_t)taosFillResultDataBlock(pFillInfo, pBlock, capacity - pBlock->info.rows);
|
||||||
pBlock->info.rows += numOfRows;
|
pBlock->info.rows += numOfRows;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue