fix: change the pre-allocated column check

This commit is contained in:
slzhou 2023-12-21 16:36:56 +08:00
parent d2b0ef75a5
commit a802d35af4
1 changed files with 4 additions and 4 deletions

View File

@ -3274,21 +3274,21 @@ static int32_t blockRowToBuf(SSDataBlock* pBlock, int32_t rowIdx, char* buf) {
isNull[i] = 0; isNull[i] = 0;
char* pData = colDataGetData(pCol, rowIdx); char* pData = colDataGetData(pCol, rowIdx);
if (pCol->info.type == TSDB_DATA_TYPE_JSON) { if (pCol->info.type == TSDB_DATA_TYPE_JSON) {
if (colDataGetLength(pCol, blockDataGetNumOfRows(pBlock)) != 0) { if (pCol->pData) {
int32_t dataLen = getJsonValueLen(pData); int32_t dataLen = getJsonValueLen(pData);
memcpy(pStart, pData, dataLen); memcpy(pStart, pData, dataLen);
pStart += dataLen; pStart += dataLen;
} else { } else {
// the column that is pre-allocated, has no data and has offset // the column that is pre-allocated has no data and has offset
*pStart = 0; *pStart = 0;
pStart += 1; pStart += 1;
} }
} else if (IS_VAR_DATA_TYPE(pCol->info.type)) { } else if (IS_VAR_DATA_TYPE(pCol->info.type)) {
if (colDataGetLength(pCol, blockDataGetNumOfRows(pBlock)) != 0) { if (pCol->pData) {
varDataCopy(pStart, pData); varDataCopy(pStart, pData);
pStart += varDataTLen(pData); pStart += varDataTLen(pData);
} else { } else {
// the column that is pre-allocated, has no data and has offset // the column that is pre-allocated has no data and has offset
*(VarDataLenT*)(pStart) = 0; *(VarDataLenT*)(pStart) = 0;
pStart += VARSTR_HEADER_SIZE; pStart += VARSTR_HEADER_SIZE;
} }