Merge pull request #7072 from taosdata/fix/TD-5584
[TD-5631]<fix>fix functionCompatList array overflow access
This commit is contained in:
commit
bdc83f0210
|
@ -240,6 +240,7 @@ typedef struct {
|
||||||
int32_t minRows;
|
int32_t minRows;
|
||||||
int32_t firstSeekTimeUs;
|
int32_t firstSeekTimeUs;
|
||||||
uint32_t numOfRowsInMemTable;
|
uint32_t numOfRowsInMemTable;
|
||||||
|
uint32_t numOfSmallBlocks;
|
||||||
SArray *dataBlockInfos;
|
SArray *dataBlockInfos;
|
||||||
} STableBlockDist;
|
} STableBlockDist;
|
||||||
|
|
||||||
|
|
|
@ -4018,6 +4018,7 @@ static void mergeTableBlockDist(SResultRowCellInfo* pResInfo, const STableBlockD
|
||||||
|
|
||||||
pDist->numOfTables += pSrc->numOfTables;
|
pDist->numOfTables += pSrc->numOfTables;
|
||||||
pDist->numOfRowsInMemTable += pSrc->numOfRowsInMemTable;
|
pDist->numOfRowsInMemTable += pSrc->numOfRowsInMemTable;
|
||||||
|
pDist->numOfSmallBlocks += pSrc->numOfSmallBlocks;
|
||||||
pDist->numOfFiles += pSrc->numOfFiles;
|
pDist->numOfFiles += pSrc->numOfFiles;
|
||||||
pDist->totalSize += pSrc->totalSize;
|
pDist->totalSize += pSrc->totalSize;
|
||||||
pDist->totalRows += pSrc->totalRows;
|
pDist->totalRows += pSrc->totalRows;
|
||||||
|
@ -4130,18 +4131,19 @@ void generateBlockDistResult(STableBlockDist *pTableBlockDist, char* result) {
|
||||||
|
|
||||||
uint64_t totalLen = pTableBlockDist->totalSize;
|
uint64_t totalLen = pTableBlockDist->totalSize;
|
||||||
int32_t rowSize = pTableBlockDist->rowSize;
|
int32_t rowSize = pTableBlockDist->rowSize;
|
||||||
|
int32_t smallBlocks = pTableBlockDist->numOfSmallBlocks;
|
||||||
double compRatio = (totalRows>0) ? ((double)(totalLen)/(rowSize*totalRows)) : 1;
|
double compRatio = (totalRows>0) ? ((double)(totalLen)/(rowSize*totalRows)) : 1;
|
||||||
int sz = sprintf(result + VARSTR_HEADER_SIZE,
|
int sz = sprintf(result + VARSTR_HEADER_SIZE,
|
||||||
"summary: \n\t "
|
"summary: \n\t "
|
||||||
"5th=[%d], 10th=[%d], 20th=[%d], 30th=[%d], 40th=[%d], 50th=[%d]\n\t "
|
"5th=[%d], 10th=[%d], 20th=[%d], 30th=[%d], 40th=[%d], 50th=[%d]\n\t "
|
||||||
"60th=[%d], 70th=[%d], 80th=[%d], 90th=[%d], 95th=[%d], 99th=[%d]\n\t "
|
"60th=[%d], 70th=[%d], 80th=[%d], 90th=[%d], 95th=[%d], 99th=[%d]\n\t "
|
||||||
"Min=[%"PRId64"(Rows)] Max=[%"PRId64"(Rows)] Avg=[%"PRId64"(Rows)] Stddev=[%.2f] \n\t "
|
"Min=[%"PRId64"(Rows)] Max=[%"PRId64"(Rows)] Avg=[%"PRId64"(Rows)] Stddev=[%.2f] \n\t "
|
||||||
"Rows=[%"PRIu64"], Blocks=[%"PRId64"], Size=[%.3f(Kb)] Comp=[%.2f]\n\t "
|
"Rows=[%"PRIu64"], Blocks=[%"PRId64"], SmallBlocks=[%d], Size=[%.3f(Kb)] Comp=[%.2f]\n\t "
|
||||||
"RowsInMem=[%d] \n\t",
|
"RowsInMem=[%d] \n\t",
|
||||||
percentiles[0], percentiles[1], percentiles[2], percentiles[3], percentiles[4], percentiles[5],
|
percentiles[0], percentiles[1], percentiles[2], percentiles[3], percentiles[4], percentiles[5],
|
||||||
percentiles[6], percentiles[7], percentiles[8], percentiles[9], percentiles[10], percentiles[11],
|
percentiles[6], percentiles[7], percentiles[8], percentiles[9], percentiles[10], percentiles[11],
|
||||||
min, max, avg, stdDev,
|
min, max, avg, stdDev,
|
||||||
totalRows, totalBlocks, totalLen/1024.0, compRatio,
|
totalRows, totalBlocks, smallBlocks, totalLen/1024.0, compRatio,
|
||||||
pTableBlockDist->numOfRowsInMemTable);
|
pTableBlockDist->numOfRowsInMemTable);
|
||||||
varDataSetLen(result, sz);
|
varDataSetLen(result, sz);
|
||||||
UNUSED(sz);
|
UNUSED(sz);
|
||||||
|
@ -4184,8 +4186,8 @@ int32_t functionCompatList[] = {
|
||||||
4, -1, -1, 1, 1, 1, 1, 1, 1, -1,
|
4, -1, -1, 1, 1, 1, 1, 1, 1, -1,
|
||||||
// tag, colprj, tagprj, arithmetic, diff, first_dist, last_dist, stddev_dst, interp rate irate
|
// tag, colprj, tagprj, arithmetic, diff, first_dist, last_dist, stddev_dst, interp rate irate
|
||||||
1, 1, 1, 1, -1, 1, 1, 1, 5, 1, 1,
|
1, 1, 1, 1, -1, 1, 1, 1, 5, 1, 1,
|
||||||
// tid_tag, blk_info
|
// tid_tag, derivative, blk_info
|
||||||
6, 7
|
6, 8, 7,
|
||||||
};
|
};
|
||||||
|
|
||||||
SAggFunctionInfo aAggs[] = {{
|
SAggFunctionInfo aAggs[] = {{
|
||||||
|
|
|
@ -583,6 +583,7 @@ void blockDistInfoToBinary(STableBlockDist* pDist, struct SBufferWriter* bw) {
|
||||||
tbufWriteInt32(bw, pDist->maxRows);
|
tbufWriteInt32(bw, pDist->maxRows);
|
||||||
tbufWriteInt32(bw, pDist->minRows);
|
tbufWriteInt32(bw, pDist->minRows);
|
||||||
tbufWriteUint32(bw, pDist->numOfRowsInMemTable);
|
tbufWriteUint32(bw, pDist->numOfRowsInMemTable);
|
||||||
|
tbufWriteUint32(bw, pDist->numOfSmallBlocks);
|
||||||
tbufWriteUint64(bw, taosArrayGetSize(pDist->dataBlockInfos));
|
tbufWriteUint64(bw, taosArrayGetSize(pDist->dataBlockInfos));
|
||||||
|
|
||||||
// compress the binary string
|
// compress the binary string
|
||||||
|
@ -621,6 +622,7 @@ void blockDistInfoFromBinary(const char* data, int32_t len, STableBlockDist* pDi
|
||||||
pDist->maxRows = tbufReadInt32(&br);
|
pDist->maxRows = tbufReadInt32(&br);
|
||||||
pDist->minRows = tbufReadInt32(&br);
|
pDist->minRows = tbufReadInt32(&br);
|
||||||
pDist->numOfRowsInMemTable = tbufReadUint32(&br);
|
pDist->numOfRowsInMemTable = tbufReadUint32(&br);
|
||||||
|
pDist->numOfSmallBlocks = tbufReadUint32(&br);
|
||||||
int64_t numSteps = tbufReadUint64(&br);
|
int64_t numSteps = tbufReadUint64(&br);
|
||||||
|
|
||||||
bool comp = tbufReadUint8(&br);
|
bool comp = tbufReadUint8(&br);
|
||||||
|
|
|
@ -2435,6 +2435,7 @@ int32_t tsdbGetFileBlocksDistInfo(TsdbQueryHandleT* queryHandle, STableBlockDist
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int32_t numOfBlocks = 0;
|
int32_t numOfBlocks = 0;
|
||||||
int32_t numOfTables = (int32_t)taosArrayGetSize(pQueryHandle->pTableCheckInfo);
|
int32_t numOfTables = (int32_t)taosArrayGetSize(pQueryHandle->pTableCheckInfo);
|
||||||
|
int defaultRows = TSDB_DEFAULT_BLOCK_ROWS(pCfg->maxRowsPerFileBlock);
|
||||||
STimeWindow win = TSWINDOW_INITIALIZER;
|
STimeWindow win = TSWINDOW_INITIALIZER;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -2494,6 +2495,7 @@ int32_t tsdbGetFileBlocksDistInfo(TsdbQueryHandleT* queryHandle, STableBlockDist
|
||||||
pTableBlockInfo->totalRows += numOfRows;
|
pTableBlockInfo->totalRows += numOfRows;
|
||||||
if (numOfRows > pTableBlockInfo->maxRows) pTableBlockInfo->maxRows = numOfRows;
|
if (numOfRows > pTableBlockInfo->maxRows) pTableBlockInfo->maxRows = numOfRows;
|
||||||
if (numOfRows < pTableBlockInfo->minRows) pTableBlockInfo->minRows = numOfRows;
|
if (numOfRows < pTableBlockInfo->minRows) pTableBlockInfo->minRows = numOfRows;
|
||||||
|
if (numOfRows < defaultRows) pTableBlockInfo->numOfSmallBlocks+=1;
|
||||||
int32_t stepIndex = (numOfRows-1)/TSDB_BLOCK_DIST_STEP_ROWS;
|
int32_t stepIndex = (numOfRows-1)/TSDB_BLOCK_DIST_STEP_ROWS;
|
||||||
SFileBlockInfo *blockInfo = (SFileBlockInfo*)taosArrayGet(pTableBlockInfo->dataBlockInfos, stepIndex);
|
SFileBlockInfo *blockInfo = (SFileBlockInfo*)taosArrayGet(pTableBlockInfo->dataBlockInfos, stepIndex);
|
||||||
blockInfo->numBlocksOfStep++;
|
blockInfo->numBlocksOfStep++;
|
||||||
|
|
Loading…
Reference in New Issue