refactor errno code
This commit is contained in:
parent
fa2da69e7c
commit
12fe64e5bb
|
@ -1222,7 +1222,7 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
|||
SMetaFltParam *param = arg;
|
||||
|
||||
SMetaEntry oStbEntry = {0};
|
||||
int32_t ret = -1;
|
||||
int32_t code = 0;
|
||||
char *buf = NULL;
|
||||
void *pData = NULL;
|
||||
int nData = 0;
|
||||
|
@ -1244,42 +1244,34 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
|||
|
||||
metaRLock(pMeta);
|
||||
|
||||
if ((ret = tdbTbGet(pMeta->pUidIdx, ¶m->suid, sizeof(tb_uid_t), &pData, &nData)) != 0) {
|
||||
goto END;
|
||||
}
|
||||
TAOS_CHECK_GOTO(tdbTbGet(pMeta->pUidIdx, ¶m->suid, sizeof(tb_uid_t), &pData, &nData), NULL, END);
|
||||
|
||||
tbDbKey.uid = param->suid;
|
||||
tbDbKey.version = ((SUidIdxVal *)pData)[0].version;
|
||||
|
||||
if((ret = tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData)) != 0) {
|
||||
goto END;
|
||||
}
|
||||
|
||||
|
||||
TAOS_CHECK_GOTO(tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData), NULL, END);
|
||||
|
||||
tDecoderInit(&dc, pData, nData);
|
||||
ret = metaDecodeEntry(&dc, &oStbEntry);
|
||||
if (ret != 0) {
|
||||
goto END;
|
||||
}
|
||||
|
||||
TAOS_CHECK_GOTO(metaDecodeEntry(&dc, &oStbEntry), NULL, END);
|
||||
|
||||
if (oStbEntry.stbEntry.schemaTag.pSchema == NULL || oStbEntry.stbEntry.schemaTag.pSchema == NULL) {
|
||||
ret = TSDB_CODE_INVALID_PARA;
|
||||
goto END;
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_INVALID_PARA, NULL, END);
|
||||
}
|
||||
ret = TSDB_CODE_INVALID_PARA;
|
||||
|
||||
code = TSDB_CODE_INVALID_PARA;
|
||||
for (int i = 0; i < oStbEntry.stbEntry.schemaTag.nCols; i++) {
|
||||
SSchema *schema = oStbEntry.stbEntry.schemaTag.pSchema + i;
|
||||
if (schema->colId == param->cid && param->type == schema->type && (IS_IDX_ON(schema))) {
|
||||
ret = 0;
|
||||
code = 0;
|
||||
} else {
|
||||
TAOS_CHECK_GOTO(code, NULL, END);
|
||||
}
|
||||
}
|
||||
if (ret != 0) {
|
||||
goto END;
|
||||
}
|
||||
|
||||
ret = tdbTbcOpen(pMeta->pTagIdx, &pCursor->pCur, NULL);
|
||||
if (ret != 0) {
|
||||
goto END;
|
||||
code = tdbTbcOpen(pMeta->pTagIdx, &pCursor->pCur, NULL);
|
||||
if (code != 0) {
|
||||
TAOS_CHECK_GOTO(terrno, NULL, END);
|
||||
}
|
||||
|
||||
int32_t maxSize = 0;
|
||||
|
@ -1298,13 +1290,11 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
|||
maxSize = 4 * nTagData + 1;
|
||||
buf = taosMemoryCalloc(1, maxSize);
|
||||
if (buf == NULL) {
|
||||
ret = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto END;
|
||||
TAOS_CHECK_GOTO(terrno, NULL, END);
|
||||
}
|
||||
|
||||
if (false == taosMbsToUcs4(tagData, nTagData, (TdUcs4 *)buf, maxSize, &maxSize)) {
|
||||
ret = terrno;
|
||||
goto END;
|
||||
TAOS_CHECK_GOTO(terrno, NULL, END);
|
||||
}
|
||||
|
||||
tagData = buf;
|
||||
|
@ -1315,18 +1305,12 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
|||
nTagData = tDataTypes[param->type].bytes;
|
||||
}
|
||||
}
|
||||
ret = metaCreateTagIdxKey(pCursor->suid, pCursor->cid, tagData, nTagData, pCursor->type,
|
||||
param->reverse ? INT64_MAX : INT64_MIN, &pKey, &nKey);
|
||||
|
||||
if (ret != 0) {
|
||||
goto END;
|
||||
}
|
||||
TAOS_CHECK_GOTO(metaCreateTagIdxKey(pCursor->suid, pCursor->cid, tagData, nTagData, pCursor->type,
|
||||
param->reverse ? INT64_MAX : INT64_MIN, &pKey, &nKey), NULL, END);
|
||||
|
||||
int cmp = 0;
|
||||
ret = tdbTbcMoveTo(pCursor->pCur, pKey, nKey, &cmp);
|
||||
if (ret != 0) {
|
||||
goto END;
|
||||
}
|
||||
TAOS_CHECK_GOTO(tdbTbcMoveTo(pCursor->pCur, pKey, nKey, &cmp), 0, END);
|
||||
|
||||
int count = 0;
|
||||
int32_t valid = 0;
|
||||
|
@ -1343,7 +1327,7 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
|||
|
||||
valid = tdbTbcGet(pCursor->pCur, (const void **)&entryKey, &nEntryKey, (const void **)&entryVal, &nEntryVal);
|
||||
if (valid < 0) {
|
||||
ret = valid;
|
||||
code = valid;
|
||||
}
|
||||
if (count > TRY_ERROR_LIMIT) {
|
||||
break;
|
||||
|
@ -1359,7 +1343,7 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
|||
count++;
|
||||
valid = param->reverse ? tdbTbcMoveToPrev(pCursor->pCur) : tdbTbcMoveToNext(pCursor->pCur);
|
||||
if (valid < 0) {
|
||||
ret = valid;
|
||||
code = valid;
|
||||
break;
|
||||
} else {
|
||||
continue;
|
||||
|
@ -1376,8 +1360,7 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
|||
tuid = *(tb_uid_t *)(p->data + tDataTypes[pCursor->type].bytes);
|
||||
}
|
||||
if (taosArrayPush(pUids, &tuid) == NULL) {
|
||||
ret = terrno;
|
||||
break;
|
||||
TAOS_CHECK_GOTO(terrno, NULL, END);
|
||||
}
|
||||
found = true;
|
||||
} else {
|
||||
|
@ -1388,7 +1371,7 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
|||
}
|
||||
valid = param->reverse ? tdbTbcMoveToPrev(pCursor->pCur) : tdbTbcMoveToNext(pCursor->pCur);
|
||||
if (valid < 0) {
|
||||
ret = valid;
|
||||
code = valid;
|
||||
break;
|
||||
}
|
||||
} while (1);
|
||||
|
@ -1405,7 +1388,7 @@ END:
|
|||
|
||||
taosMemoryFree(pCursor);
|
||||
|
||||
return ret;
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t metaGetTableTagByUid(SMeta *pMeta, int64_t suid, int64_t uid, void **tag, int32_t *len, bool lock) {
|
||||
|
|
Loading…
Reference in New Issue