From dd8aaaf366a6cc670e1e1f4cc1981708e6e09eb2 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Fri, 2 Jul 2021 13:04:32 +0800 Subject: [PATCH] bug fix for reading SDataRow VarT Values --- src/client/inc/tscUtil.h | 1 - src/client/src/tscUtil.c | 7 ++++--- src/tsdb/src/tsdbRead.c | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index 2291feb08a..6515c7c4e5 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -343,7 +343,6 @@ SNewVgroupInfo createNewVgroupInfo(SVgroupMsg *pVgroupMsg); typedef struct { // for SDataRow - STSchema* pTSchema; SSchema* pSchema; int16_t sversion; int32_t flen; diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 36d4ef7096..7e4a656622 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1674,7 +1674,7 @@ static FORCE_INLINE uint8_t tdRowTypeJudger(SSchema* pSchema, void* pData, int32 } tscDebug("nColsNull %d, nCols: %d, kvRowLen: %d, dataRowLen: %d", (int32_t)nColsNull, nCols, kvRowLength, - dataRowLength); + dataRowLength); if (kvRowLength < dataRowLength) { if (nColsNotNull) { @@ -1696,7 +1696,7 @@ SMemRow tdGenMemRowFromBuilder(SMemRowBuilder* pBuilder) { } uint16_t nColsNotNull = 0; - uint8_t memRowType = tdRowTypeJudger(pSchema, p, pBuilder->nCols, pBuilder->flen, &nColsNotNull); + uint8_t memRowType = tdRowTypeJudger(pSchema, p, pBuilder->nCols, pBuilder->flen, &nColsNotNull); SMemRow* memRow = (SMemRow)pBuilder->pDataBlock; memRowSetType(memRow, memRowType); @@ -1714,7 +1714,7 @@ SMemRow tdGenMemRowFromBuilder(SMemRowBuilder* pBuilder) { } pBuilder->buf = p; } else if (memRowType == SMEM_ROW_KV) { - ASSERT(nColsNotNull < pBuilder->nCols); + ASSERT(nColsNotNull <= pBuilder->nCols); SKVRow kvRow = (SKVRow)memRowBody(memRow); uint16_t tlen = TD_KV_ROW_HEAD_SIZE + sizeof(SColIdx) * nColsNotNull; kvRowSetLen(kvRow, tlen); @@ -1810,6 +1810,7 @@ static int32_t getRowExpandSize(STableMeta* pTableMeta) { if (IS_VAR_DATA_TYPE((pSchema + i)->type)) { result += TYPE_BYTES[TSDB_DATA_TYPE_BINARY]; } + result += sizeof(SColIdx); } result += TD_MEM_ROW_TYPE_SIZE; // add len of SMemRow flag return result; diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 195e9f8584..7f344dc646 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -1459,6 +1459,7 @@ static void copyOneRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity, int32_t i = 0; if (isDataRow(row)) { + SDataRow dataRow = memRowBody(row); int32_t j = 0; while (i < numOfCols && j < numOfRowCols) { SColumnInfoData* pColInfo = taosArrayGet(pQueryHandle->pColumns, i); @@ -1475,7 +1476,7 @@ static void copyOneRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity, if (pSchema->columns[j].colId == pColInfo->info.colId) { void* value = - tdGetRowDataOfCol(row, (int8_t)pColInfo->info.type, TD_MEM_ROW_HEAD_SIZE + pSchema->columns[j].offset); + tdGetRowDataOfCol(dataRow, (int8_t)pColInfo->info.type, TD_DATA_ROW_HEAD_SIZE + pSchema->columns[j].offset); switch (pColInfo->info.type) { case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: -- GitLab