提交 3417cf46 编写于 作者: wmmhello's avatar wmmhello

fix:raw block datalen if json data

上级 1517b69c
...@@ -1612,11 +1612,13 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int ...@@ -1612,11 +1612,13 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
if (pResultInfo->convertJson == NULL) return TSDB_CODE_OUT_OF_MEMORY; if (pResultInfo->convertJson == NULL) return TSDB_CODE_OUT_OF_MEMORY;
char* p1 = pResultInfo->convertJson; char* p1 = pResultInfo->convertJson;
int32_t totalLen = 0;
int32_t len = sizeof(int32_t) + sizeof(uint64_t) + numOfCols * (sizeof(int16_t) + sizeof(int32_t)); int32_t len = sizeof(int32_t) + sizeof(uint64_t) + numOfCols * (sizeof(int16_t) + sizeof(int32_t));
memcpy(p1, p, len); memcpy(p1, p, len);
p += len; p += len;
p1 += len; p1 += len;
totalLen += len;
len = sizeof(int32_t) * numOfCols; len = sizeof(int32_t) * numOfCols;
int32_t* colLength = (int32_t*)p; int32_t* colLength = (int32_t*)p;
...@@ -1624,6 +1626,7 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int ...@@ -1624,6 +1626,7 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
memcpy(p1, p, len); memcpy(p1, p, len);
p += len; p += len;
p1 += len; p1 += len;
totalLen += len;
char* pStart = p; char* pStart = p;
char* pStart1 = p1; char* pStart1 = p1;
...@@ -1639,6 +1642,7 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int ...@@ -1639,6 +1642,7 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
memcpy(pStart1, pStart, len); memcpy(pStart1, pStart, len);
pStart += len; pStart += len;
pStart1 += len; pStart1 += len;
totalLen += len;
len = 0; len = 0;
for (int32_t j = 0; j < numOfRows; ++j) { for (int32_t j = 0; j < numOfRows; ++j) {
...@@ -1683,24 +1687,30 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int ...@@ -1683,24 +1687,30 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
len += varDataTLen(dst); len += varDataTLen(dst);
} }
colLen1 = len; colLen1 = len;
totalLen += colLen1;
colLength1[i] = htonl(len); colLength1[i] = htonl(len);
} else if (IS_VAR_DATA_TYPE(pResultInfo->fields[i].type)) { } else if (IS_VAR_DATA_TYPE(pResultInfo->fields[i].type)) {
len = numOfRows * sizeof(int32_t); len = numOfRows * sizeof(int32_t);
memcpy(pStart1, pStart, len); memcpy(pStart1, pStart, len);
pStart += len; pStart += len;
pStart1 += len; pStart1 += len;
totalLen += len;
totalLen += colLen;
memcpy(pStart1, pStart, colLen); memcpy(pStart1, pStart, colLen);
} else { } else {
len = BitmapLen(pResultInfo->numOfRows); len = BitmapLen(pResultInfo->numOfRows);
memcpy(pStart1, pStart, len); memcpy(pStart1, pStart, len);
pStart += len; pStart += len;
pStart1 += len; pStart1 += len;
totalLen += len;
totalLen += colLen;
memcpy(pStart1, pStart, colLen); memcpy(pStart1, pStart, colLen);
} }
pStart += colLen; pStart += colLen;
pStart1 += colLen1; pStart1 += colLen1;
} }
*(int32_t*)(pResultInfo->convertJson) = totalLen;
pResultInfo->pData = pResultInfo->convertJson; pResultInfo->pData = pResultInfo->convertJson;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册