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