fix(tsdb):fix invalid return code.

This commit is contained in:
Haojun Liao 2024-07-23 19:16:06 +08:00
parent eefee54c6a
commit 4d8064c950
4 changed files with 29 additions and 13 deletions

View File

@ -255,14 +255,13 @@ static int32_t mndStreamActionUpdate(SSdb *pSdb, SStreamObj *pOldStream, SStream
}
int32_t mndAcquireStream(SMnode *pMnode, char *streamName, SStreamObj **pStream) {
terrno = 0;
int32_t code = 0;
SSdb *pSdb = pMnode->pSdb;
(*pStream) = sdbAcquire(pSdb, SDB_STREAM, streamName);
if ((*pStream) == NULL && terrno == TSDB_CODE_SDB_OBJ_NOT_THERE) {
terrno = TSDB_CODE_MND_STREAM_NOT_EXIST;
code = TSDB_CODE_MND_STREAM_NOT_EXIST;
}
return terrno;
return code;
}
void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream) {
@ -754,19 +753,19 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
}
code = mndAcquireStream(pMnode, createReq.name, &pStream);
if (pStream != NULL || code == 0) {
if (pStream != NULL && code == 0) {
if (createReq.igExists) {
mInfo("stream:%s, already exist, ignore exist is set", createReq.name);
goto _OVER;
} else {
terrno = TSDB_CODE_MND_STREAM_ALREADY_EXIST;
code = TSDB_CODE_MND_STREAM_ALREADY_EXIST;
goto _OVER;
}
} else if (terrno != TSDB_CODE_MND_STREAM_NOT_EXIST) {
} else if (code != TSDB_CODE_MND_STREAM_NOT_EXIST) {
goto _OVER;
}
if ((terrno = grantCheck(TSDB_GRANT_STREAMS)) < 0) {
if ((code = grantCheck(TSDB_GRANT_STREAMS)) < 0) {
goto _OVER;
}

View File

@ -89,8 +89,8 @@ static int32_t saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* p
if (pVal == NULL) {
return TSDB_CODE_INVALID_PARA;
}
funcType = *(int32_t*) pVal;
funcType = *(int32_t*) pVal;
pVal = taosArrayGet(pReader->pFuncTypeList, i);
if (pVal == NULL) {
return TSDB_CODE_INVALID_PARA;
@ -471,6 +471,11 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
int32_t bytes = (slotIds[j] == -1) ? 1 : pr->pSchema->columns[slotIds[j]].bytes;
pRes[j] = taosMemoryCalloc(1, sizeof(SFirstLastRes) + bytes + pkBufLen + VARSTR_HEADER_SIZE);
if (pRes[j] == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _end;
}
SFirstLastRes* p = (SFirstLastRes*)varDataVal(pRes[j]);
p->ts = INT64_MIN;
}
@ -512,7 +517,12 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
for (int32_t j = 0; j < pr->rowKey.numOfPKs; j++) {
p.rowKey.pks[j].type = pr->pkColumn.type;
if (IS_VAR_DATA_TYPE(pr->pkColumn.type)) {
p.rowKey.pks[j].pData = taosMemoryCalloc(1, pr->pkColumn.bytes);
if (p.rowKey.pks[j].pData == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _end;
}
}
}
}
@ -538,7 +548,9 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
tb_uid_t uid = pTableList[i].uid;
code = tsdbCacheGetBatch(pr->pTsdb, uid, pRow, pr, ltype);
if (code) {
if (code == -1) {// fix the invalid return code
code = 0;
} else if (code != 0) {
goto _end;
}
@ -642,7 +654,11 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
tb_uid_t uid = pTableList[i].uid;
if ((code = tsdbCacheGetBatch(pr->pTsdb, uid, pRow, pr, ltype)) != 0) {
goto _end;
if (code == -1) {// fix the invalid return code
code = 0;
} else if (code != 0) {
goto _end;
}
}
if (TARRAY_SIZE(pRow) <= 0 || COL_VAL_IS_NONE(&((SLastCol*)TARRAY_DATA(pRow))[0].colVal)) {

View File

@ -252,7 +252,7 @@ int32_t l2ComressInitImpl_xz(char *lossyColumns, float fPrecision, double dPreci
}
int32_t l2CompressImpl_xz(const char *const input, const int32_t inputSize, char *const output, int32_t outputSize,
const char type, int8_t lvl) {
size_t len = FL2_compress(output + 1, outputSize - 1, input, inputSize, lvl);
size_t len = 0;//FL2_compress(output + 1, outputSize - 1, input, inputSize, lvl);
if (len > inputSize) {
output[0] = 0;
memcpy(output + 1, input, inputSize);
@ -264,7 +264,7 @@ int32_t l2CompressImpl_xz(const char *const input, const int32_t inputSize, char
int32_t l2DecompressImpl_xz(const char *const input, const int32_t compressedSize, char *const output,
int32_t outputSize, const char type) {
if (input[0] == 1) {
return FL2_decompress(output, outputSize, input + 1, compressedSize - 1);
return 0;//FL2_decompress(output, outputSize, input + 1, compressedSize - 1);
} else if (input[0] == 0) {
memcpy(output, input + 1, compressedSize - 1);
return compressedSize - 1;

View File

@ -16,6 +16,7 @@ endi
sql select last(f1) from tb1
if $rows != 1 then
print expect 1, actual $rows
return -1
endi
if $data00 != 6 then