fix unit test

This commit is contained in:
yihaoDeng 2024-08-30 18:34:09 +08:00
parent a1db09a360
commit 0417c8facc
3 changed files with 12 additions and 6 deletions

View File

@ -569,10 +569,11 @@ static int32_t idxMayMergeTempToFinalRslt(SArray* result, TFileValue* tfv, SIdxT
indexFatal("failed to merge result since %s", tstrerror(code)); indexFatal("failed to merge result since %s", tstrerror(code));
} }
} else { } else {
return TSDB_CODE_INVALID_PARA; return 0;
} }
} else { } else {
if (taosArrayPush(result, &tfv) == NULL) { if (taosArrayPush(result, &tfv) == NULL) {
return TSDB_CODE_OUT_OF_MEMORY;
} }
} }
return code; return code;
@ -736,6 +737,9 @@ _exception:
idxPost(sIdx); idxPost(sIdx);
} }
idxReleaseRef(sIdx->refId); idxReleaseRef(sIdx->refId);
if (code != 0) {
indexError("failed to merge since %s", tstrerror(code));
}
return code; return code;
} }

View File

@ -133,9 +133,10 @@ TFileCache* tfileCacheCreate(SIndex* idx, const char* path) {
int32_t sz = idxSerialCacheKey(&key, buf); int32_t sz = idxSerialCacheKey(&key, buf);
code = taosHashPut(tcache->tableCache, buf, sz, &reader, sizeof(void*)); code = taosHashPut(tcache->tableCache, buf, sz, &reader, sizeof(void*));
if (code != 0) { if (code != 0) {
tfileReaderRef(reader); tfileReaderDestroy(reader);
goto End; goto End;
} }
tfileReaderRef(reader);
} }
taosArrayDestroyEx(files, tfileDestroyFileName); taosArrayDestroyEx(files, tfileDestroyFileName);
return tcache; return tcache;
@ -172,6 +173,7 @@ TFileReader* tfileCacheGet(TFileCache* tcache, ICacheKey* key) {
return *reader; return *reader;
} }
int32_t tfileCachePut(TFileCache* tcache, ICacheKey* key, TFileReader* reader) { int32_t tfileCachePut(TFileCache* tcache, ICacheKey* key, TFileReader* reader) {
int32_t code = 0; int32_t code = 0;
@ -192,9 +194,7 @@ int32_t tfileCachePut(TFileCache* tcache, ICacheKey* key, TFileReader* reader) {
} }
code = taosHashPut(tcache->tableCache, buf, sz, &reader, sizeof(void*)); code = taosHashPut(tcache->tableCache, buf, sz, &reader, sizeof(void*));
if (code == 0) { tfileReaderRef(reader);
tfileReaderRef(reader);
}
return code; return code;
} }
int32_t tfileReaderCreate(IFileCtx* ctx, TFileReader** pReader) { int32_t tfileReaderCreate(IFileCtx* ctx, TFileReader** pReader) {

View File

@ -214,7 +214,9 @@ int32_t idxTRsltMergeTo(SIdxTRslt *tr, SArray *result) {
if (taosArrayGetSize(tr->total) == 0 || taosArrayGetSize(tr->add) == 0) { if (taosArrayGetSize(tr->total) == 0 || taosArrayGetSize(tr->add) == 0) {
SArray *t = taosArrayGetSize(tr->total) == 0 ? tr->add : tr->total; SArray *t = taosArrayGetSize(tr->total) == 0 ? tr->add : tr->total;
(void)taosArrayAddAll(result, t); if (taosArrayAddAll(result, t) == NULL) {
return TSDB_CODE_OUT_OF_MEMORY;
}
} else { } else {
SArray *arrs = taosArrayInit(2, sizeof(void *)); SArray *arrs = taosArrayInit(2, sizeof(void *));
if (arrs == NULL) { if (arrs == NULL) {