fix(query): fix bugs caused by refactor.
This commit is contained in:
parent
cc4018e7ea
commit
6124666488
|
@ -2063,6 +2063,7 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
|
|||
tscError("setResultDataPtr paras error");
|
||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
if (numOfRows == 0) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -2199,9 +2200,9 @@ int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableR
|
|||
pResultInfo->precision = pRsp->precision;
|
||||
|
||||
// decompress data if needed
|
||||
if (pRsp->compressed) {
|
||||
int32_t payloadLen = htonl(pRsp->payloadLen);
|
||||
int32_t payloadLen = htonl(pRsp->payloadLen);
|
||||
|
||||
if (pRsp->compressed) {
|
||||
if (pResultInfo->decompBuf == NULL) {
|
||||
pResultInfo->decompBuf = taosMemoryMalloc(payloadLen);
|
||||
pResultInfo->decompBufSize = payloadLen;
|
||||
|
@ -2220,21 +2221,23 @@ int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableR
|
|||
}
|
||||
}
|
||||
|
||||
int32_t compLen = *(int32_t*)pRsp->data;
|
||||
int32_t rawLen = *(int32_t*)(pRsp->data + sizeof(int32_t));
|
||||
if (payloadLen > 0) {
|
||||
int32_t compLen = *(int32_t*)pRsp->data;
|
||||
int32_t rawLen = *(int32_t*)(pRsp->data + sizeof(int32_t));
|
||||
|
||||
char* pStart = (char*)pRsp->data + sizeof(int32_t) * 2;
|
||||
char* pStart = (char*)pRsp->data + sizeof(int32_t) * 2;
|
||||
|
||||
if (pRsp->compressed && compLen < rawLen) {
|
||||
int32_t len = tsDecompressString(pStart, compLen, 1, pResultInfo->decompBuf, rawLen, ONE_STAGE_COMP, NULL, 0);
|
||||
ASSERT(len == rawLen);
|
||||
if (pRsp->compressed && compLen < rawLen) {
|
||||
int32_t len = tsDecompressString(pStart, compLen, 1, pResultInfo->decompBuf, rawLen, ONE_STAGE_COMP, NULL, 0);
|
||||
ASSERT(len == rawLen);
|
||||
|
||||
pResultInfo->pData = pResultInfo->decompBuf;
|
||||
pResultInfo->payloadLen = rawLen;
|
||||
} else {
|
||||
pResultInfo->pData = pStart;
|
||||
pResultInfo->payloadLen = htonl(pRsp->compLen);
|
||||
ASSERT(pRsp->compLen == pRsp->payloadLen);
|
||||
pResultInfo->pData = pResultInfo->decompBuf;
|
||||
pResultInfo->payloadLen = rawLen;
|
||||
} else {
|
||||
pResultInfo->pData = pStart;
|
||||
pResultInfo->payloadLen = htonl(pRsp->compLen);
|
||||
ASSERT(pRsp->compLen == pRsp->payloadLen);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO handle the compressed case
|
||||
|
|
|
@ -904,15 +904,15 @@ TEST(clientCase, projection_query_stables) {
|
|||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
ASSERT_NE(pConn, nullptr);
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||
taos_free_result(pRes);
|
||||
TAOS_RES* pRes = taos_query(pConn, "explain select * from dbvg.st where tbname='ct1'");
|
||||
// taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "select * from st2");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
||||
taos_free_result(pRes);
|
||||
ASSERT_TRUE(false);
|
||||
}
|
||||
// pRes = taos_query(pConn, "select * from st2");
|
||||
// if (taos_errno(pRes) != 0) {
|
||||
// printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
||||
// taos_free_result(pRes);
|
||||
// ASSERT_TRUE(false);
|
||||
// }
|
||||
|
||||
TAOS_ROW pRow = NULL;
|
||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||
|
|
|
@ -70,7 +70,6 @@ char* qExplainGetTimerangeTargetStr(int32_t target) {
|
|||
return targetName[target];
|
||||
}
|
||||
|
||||
|
||||
void qExplainFreeResNode(SExplainResNode *resNode) {
|
||||
if (NULL == resNode) {
|
||||
return;
|
||||
|
@ -1942,7 +1941,7 @@ int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) {
|
|||
|
||||
pBlock->info.rows = rowNum;
|
||||
|
||||
int32_t rspSize = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock);
|
||||
int32_t rspSize = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock) + sizeof(int32_t)*2;
|
||||
|
||||
SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)taosMemoryCalloc(1, rspSize);
|
||||
if (NULL == rsp) {
|
||||
|
@ -1954,10 +1953,14 @@ int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) {
|
|||
rsp->completed = 1;
|
||||
rsp->numOfRows = htobe64((int64_t)rowNum);
|
||||
|
||||
int32_t len = blockEncode(pBlock, rsp->data, taosArrayGetSize(pBlock->pDataBlock));
|
||||
int32_t len = blockEncode(pBlock, rsp->data + sizeof(int32_t)*2, taosArrayGetSize(pBlock->pDataBlock));
|
||||
|
||||
rsp->compLen = htonl(len);
|
||||
rsp->payloadLen = rsp->compLen;
|
||||
rsp->compressed = 0;
|
||||
|
||||
((int32_t*)rsp->data)[0] = len;
|
||||
((int32_t*)rsp->data)[1] = len;
|
||||
|
||||
blockDataDestroy(pBlock);
|
||||
|
||||
|
|
Loading…
Reference in New Issue