From ad95b27cf25618ad77f362394297d4a070de70be Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sun, 19 May 2024 10:28:24 +0800 Subject: [PATCH] fix(query): fix bugs caused by refactor. --- source/libs/command/src/command.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index 8f3263cbeb..75ce4c9819 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -25,8 +25,16 @@ extern SConfig* tsCfg; +#define PAYLOAD_PREFIX_LEN ((sizeof(int32_t))<<1) + +#define SET_PAYLOAD_LEN(_p, _compLen, _fullLen) \ + do { \ + ((int32_t*)(_p))[0] = (_compLen); \ + ((int32_t*)(_p))[1] = (_fullLen); \ + } while (0); + static int32_t buildRetrieveTableRsp(SSDataBlock* pBlock, int32_t numOfCols, SRetrieveTableRsp** pRsp) { - size_t rspSize = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); + size_t rspSize = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock) + PAYLOAD_PREFIX_LEN; *pRsp = taosMemoryCalloc(1, rspSize); if (NULL == *pRsp) { return TSDB_CODE_OUT_OF_MEMORY; @@ -36,12 +44,16 @@ static int32_t buildRetrieveTableRsp(SSDataBlock* pBlock, int32_t numOfCols, SRe (*pRsp)->completed = 1; (*pRsp)->precision = 0; (*pRsp)->compressed = 0; - (*pRsp)->compLen = 0; - (*pRsp)->payloadLen = 0; + (*pRsp)->numOfRows = htobe64((int64_t)pBlock->info.rows); (*pRsp)->numOfCols = htonl(numOfCols); - int32_t len = blockEncode(pBlock, (*pRsp)->data, numOfCols); + int32_t len = blockEncode(pBlock, (*pRsp)->data + sizeof(int32_t)*2, numOfCols); + SET_PAYLOAD_LEN((*pRsp)->data, len, len); + + int32_t payloadLen = len + PAYLOAD_PREFIX_LEN; + (*pRsp)->payloadLen = htonl(payloadLen); + (*pRsp)->compLen = htonl(payloadLen); return TSDB_CODE_SUCCESS; }