Merge pull request #27069 from taosdata/fix/TD-31277-3.0
fix: handle error code
This commit is contained in:
commit
f698610e44
|
@ -245,12 +245,12 @@ typedef struct SStoreSnapshotFn {
|
||||||
} SStoreSnapshotFn;
|
} SStoreSnapshotFn;
|
||||||
|
|
||||||
typedef struct SStoreMeta {
|
typedef struct SStoreMeta {
|
||||||
SMTbCursor* (*openTableMetaCursor)(void* pVnode); // metaOpenTbCursor
|
SMTbCursor* (*openTableMetaCursor)(void* pVnode); // metaOpenTbCursor
|
||||||
void (*closeTableMetaCursor)(SMTbCursor* pTbCur); // metaCloseTbCursor
|
void (*closeTableMetaCursor)(SMTbCursor* pTbCur); // metaCloseTbCursor
|
||||||
void (*pauseTableMetaCursor)(SMTbCursor* pTbCur); // metaPauseTbCursor
|
void (*pauseTableMetaCursor)(SMTbCursor* pTbCur); // metaPauseTbCursor
|
||||||
void (*resumeTableMetaCursor)(SMTbCursor* pTbCur, int8_t first, int8_t move); // metaResumeTbCursor
|
int32_t (*resumeTableMetaCursor)(SMTbCursor* pTbCur, int8_t first, int8_t move); // metaResumeTbCursor
|
||||||
int32_t (*cursorNext)(SMTbCursor* pTbCur, ETableType jumpTableType); // metaTbCursorNext
|
int32_t (*cursorNext)(SMTbCursor* pTbCur, ETableType jumpTableType); // metaTbCursorNext
|
||||||
int32_t (*cursorPrev)(SMTbCursor* pTbCur, ETableType jumpTableType); // metaTbCursorPrev
|
int32_t (*cursorPrev)(SMTbCursor* pTbCur, ETableType jumpTableType); // metaTbCursorPrev
|
||||||
|
|
||||||
int32_t (*getTableTags)(void* pVnode, uint64_t suid, SArray* uidList);
|
int32_t (*getTableTags)(void* pVnode, uint64_t suid, SArray* uidList);
|
||||||
int32_t (*getTableTagsByUid)(void* pVnode, int64_t suid, SArray* uidList);
|
int32_t (*getTableTagsByUid)(void* pVnode, int64_t suid, SArray* uidList);
|
||||||
|
|
|
@ -131,7 +131,7 @@ typedef SVCreateTSmaReq SSmaCfg;
|
||||||
SMTbCursor* metaOpenTbCursor(void* pVnode);
|
SMTbCursor* metaOpenTbCursor(void* pVnode);
|
||||||
void metaCloseTbCursor(SMTbCursor* pTbCur);
|
void metaCloseTbCursor(SMTbCursor* pTbCur);
|
||||||
void metaPauseTbCursor(SMTbCursor* pTbCur);
|
void metaPauseTbCursor(SMTbCursor* pTbCur);
|
||||||
void metaResumeTbCursor(SMTbCursor* pTbCur, int8_t first, int8_t move);
|
int32_t metaResumeTbCursor(SMTbCursor* pTbCur, int8_t first, int8_t move);
|
||||||
int32_t metaTbCursorNext(SMTbCursor* pTbCur, ETableType jumpTableType);
|
int32_t metaTbCursorNext(SMTbCursor* pTbCur, ETableType jumpTableType);
|
||||||
int32_t metaTbCursorPrev(SMTbCursor* pTbCur, ETableType jumpTableType);
|
int32_t metaTbCursorPrev(SMTbCursor* pTbCur, ETableType jumpTableType);
|
||||||
|
|
||||||
|
|
|
@ -231,6 +231,7 @@ _exit:
|
||||||
#if 1 // ===================================================
|
#if 1 // ===================================================
|
||||||
SMTbCursor *metaOpenTbCursor(void *pVnode) {
|
SMTbCursor *metaOpenTbCursor(void *pVnode) {
|
||||||
SMTbCursor *pTbCur = NULL;
|
SMTbCursor *pTbCur = NULL;
|
||||||
|
int32_t code;
|
||||||
|
|
||||||
pTbCur = (SMTbCursor *)taosMemoryCalloc(1, sizeof(*pTbCur));
|
pTbCur = (SMTbCursor *)taosMemoryCalloc(1, sizeof(*pTbCur));
|
||||||
if (pTbCur == NULL) {
|
if (pTbCur == NULL) {
|
||||||
|
@ -241,7 +242,12 @@ SMTbCursor *metaOpenTbCursor(void *pVnode) {
|
||||||
// tdbTbcMoveToFirst((TBC *)pTbCur->pDbc);
|
// tdbTbcMoveToFirst((TBC *)pTbCur->pDbc);
|
||||||
pTbCur->pMeta = pVnodeObj->pMeta;
|
pTbCur->pMeta = pVnodeObj->pMeta;
|
||||||
pTbCur->paused = 1;
|
pTbCur->paused = 1;
|
||||||
metaResumeTbCursor(pTbCur, 1, 0);
|
code = metaResumeTbCursor(pTbCur, 1, 0);
|
||||||
|
if (code) {
|
||||||
|
terrno = code;
|
||||||
|
taosMemoryFree(pTbCur);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
return pTbCur;
|
return pTbCur;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,28 +272,39 @@ void metaPauseTbCursor(SMTbCursor *pTbCur) {
|
||||||
pTbCur->paused = 1;
|
pTbCur->paused = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void metaResumeTbCursor(SMTbCursor *pTbCur, int8_t first, int8_t move) {
|
int32_t metaResumeTbCursor(SMTbCursor *pTbCur, int8_t first, int8_t move) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
|
|
||||||
if (pTbCur->paused) {
|
if (pTbCur->paused) {
|
||||||
metaReaderDoInit(&pTbCur->mr, pTbCur->pMeta, META_READER_LOCK);
|
metaReaderDoInit(&pTbCur->mr, pTbCur->pMeta, META_READER_LOCK);
|
||||||
|
|
||||||
(void)tdbTbcOpen(((SMeta *)pTbCur->pMeta)->pUidIdx, (TBC **)&pTbCur->pDbc, NULL);
|
code = tdbTbcOpen(((SMeta *)pTbCur->pMeta)->pUidIdx, (TBC **)&pTbCur->pDbc, NULL);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
(void)tdbTbcMoveToFirst((TBC *)pTbCur->pDbc);
|
code = tdbTbcMoveToFirst((TBC *)pTbCur->pDbc);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
} else {
|
} else {
|
||||||
int c = 1;
|
int c = 1;
|
||||||
(void)tdbTbcMoveTo(pTbCur->pDbc, pTbCur->pKey, pTbCur->kLen, &c);
|
code = tdbTbcMoveTo(pTbCur->pDbc, pTbCur->pKey, pTbCur->kLen, &c);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
if (move) tdbTbcMoveToNext(pTbCur->pDbc);
|
if (move) tdbTbcMoveToNext(pTbCur->pDbc);
|
||||||
} else if (c < 0) {
|
} else if (c < 0) {
|
||||||
(void)tdbTbcMoveToPrev(pTbCur->pDbc);
|
code = tdbTbcMoveToPrev(pTbCur->pDbc);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
} else {
|
} else {
|
||||||
(void)tdbTbcMoveToNext(pTbCur->pDbc);
|
code = tdbTbcMoveToNext(pTbCur->pDbc);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pTbCur->paused = 0;
|
pTbCur->paused = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t metaTbCursorNext(SMTbCursor *pTbCur, ETableType jumpTableType) {
|
int32_t metaTbCursorNext(SMTbCursor *pTbCur, ETableType jumpTableType) {
|
||||||
|
@ -592,6 +609,7 @@ STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, int lock) {
|
||||||
|
|
||||||
int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sver, STSchema **ppTSchema) {
|
int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sver, STSchema **ppTSchema) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
|
|
||||||
void *pData = NULL;
|
void *pData = NULL;
|
||||||
int nData = 0;
|
int nData = 0;
|
||||||
|
@ -607,7 +625,8 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv
|
||||||
skmDbKey.uid = suid ? suid : uid;
|
skmDbKey.uid = suid ? suid : uid;
|
||||||
skmDbKey.sver = INT32_MAX;
|
skmDbKey.sver = INT32_MAX;
|
||||||
|
|
||||||
(void)tdbTbcOpen(pMeta->pSkmDb, &pSkmDbC, NULL);
|
code = tdbTbcOpen(pMeta->pSkmDb, &pSkmDbC, NULL);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
metaRLock(pMeta);
|
metaRLock(pMeta);
|
||||||
|
|
||||||
if (tdbTbcMoveTo(pSkmDbC, &skmDbKey, sizeof(skmDbKey), &c) < 0) {
|
if (tdbTbcMoveTo(pSkmDbC, &skmDbKey, sizeof(skmDbKey), &c) < 0) {
|
||||||
|
|
|
@ -306,12 +306,13 @@ _err:
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tbUidList) {
|
int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tbUidList) {
|
||||||
void *pKey = NULL;
|
void *pKey = NULL;
|
||||||
int nKey = 0;
|
int nKey = 0;
|
||||||
void *pData = NULL;
|
void *pData = NULL;
|
||||||
int nData = 0;
|
int nData = 0;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
int32_t lino;
|
||||||
|
|
||||||
// check if super table exists
|
// check if super table exists
|
||||||
rc = tdbTbGet(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, &pData, &nData);
|
rc = tdbTbGet(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, &pData, &nData);
|
||||||
|
@ -323,7 +324,11 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb
|
||||||
// drop all child tables
|
// drop all child tables
|
||||||
TBC *pCtbIdxc = NULL;
|
TBC *pCtbIdxc = NULL;
|
||||||
|
|
||||||
(void)(void)tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL);
|
rc = tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL);
|
||||||
|
if (rc) {
|
||||||
|
return (terrno = rc);
|
||||||
|
}
|
||||||
|
|
||||||
rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = pReq->suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = pReq->suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
(void)tdbTbcClose(pCtbIdxc);
|
||||||
|
@ -379,20 +384,20 @@ _exit:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void metaGetSubtables(SMeta *pMeta, int64_t suid, SArray *uids) {
|
static int32_t metaGetSubtables(SMeta *pMeta, int64_t suid, SArray *uids) {
|
||||||
if (!uids) return;
|
if (!uids) return TSDB_CODE_INVALID_PARA;
|
||||||
|
|
||||||
int c = 0;
|
int c = 0;
|
||||||
void *pKey = NULL;
|
void *pKey = NULL;
|
||||||
int nKey = 0;
|
int nKey = 0;
|
||||||
TBC *pCtbIdxc = NULL;
|
TBC *pCtbIdxc = NULL;
|
||||||
|
|
||||||
(void)tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL);
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL));
|
||||||
int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
(void)tdbTbcClose(pCtbIdxc);
|
||||||
metaWLock(pMeta);
|
metaWLock(pMeta);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -405,12 +410,17 @@ static void metaGetSubtables(SMeta *pMeta, int64_t suid, SArray *uids) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)taosArrayPush(uids, &(((SCtbIdxKey *)pKey)->uid));
|
if (taosArrayPush(uids, &(((SCtbIdxKey *)pKey)->uid)) == NULL) {
|
||||||
|
tdbFree(pKey);
|
||||||
|
(void)tdbTbcClose(pCtbIdxc);
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
|
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
(void)tdbTbcClose(pCtbIdxc);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
|
@ -425,7 +435,7 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
int32_t c = -2;
|
int32_t c = -2;
|
||||||
|
|
||||||
(void)tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL));
|
||||||
ret = tdbTbcMoveTo(pUidIdxc, &pReq->suid, sizeof(tb_uid_t), &c);
|
ret = tdbTbcMoveTo(pUidIdxc, &pReq->suid, sizeof(tb_uid_t), &c);
|
||||||
if (ret < 0 || c) {
|
if (ret < 0 || c) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
(void)tdbTbcClose(pUidIdxc);
|
||||||
|
@ -442,7 +452,7 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
|
|
||||||
oversion = ((SUidIdxVal *)pData)[0].version;
|
oversion = ((SUidIdxVal *)pData)[0].version;
|
||||||
|
|
||||||
(void)tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL));
|
||||||
ret = tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = pReq->suid, .version = oversion}), sizeof(STbDbKey), &c);
|
ret = tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = pReq->suid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||||
if (!(ret == 0 && c == 0)) {
|
if (!(ret == 0 && c == 0)) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
(void)tdbTbcClose(pUidIdxc);
|
||||||
|
@ -486,7 +496,7 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
int16_t cid = pReq->schemaRow.pSchema[nCols - 1].colId;
|
int16_t cid = pReq->schemaRow.pSchema[nCols - 1].colId;
|
||||||
int8_t col_type = pReq->schemaRow.pSchema[nCols - 1].type;
|
int8_t col_type = pReq->schemaRow.pSchema[nCols - 1].type;
|
||||||
|
|
||||||
metaGetSubtables(pMeta, pReq->suid, uids);
|
TAOS_CHECK_RETURN(metaGetSubtables(pMeta, pReq->suid, uids));
|
||||||
(void)tsdbCacheNewSTableColumn(pTsdb, uids, cid, col_type);
|
(void)tsdbCacheNewSTableColumn(pTsdb, uids, cid, col_type);
|
||||||
} else if (deltaCol == -1) {
|
} else if (deltaCol == -1) {
|
||||||
int16_t cid = -1;
|
int16_t cid = -1;
|
||||||
|
@ -502,7 +512,7 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cid != -1) {
|
if (cid != -1) {
|
||||||
metaGetSubtables(pMeta, pReq->suid, uids);
|
TAOS_CHECK_RETURN(metaGetSubtables(pMeta, pReq->suid, uids));
|
||||||
(void)tsdbCacheDropSTableColumn(pTsdb, uids, cid, hasPrimaryKey);
|
(void)tsdbCacheDropSTableColumn(pTsdb, uids, cid, hasPrimaryKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -619,7 +629,7 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
* iterator all pTdDbc by uid and version
|
* iterator all pTdDbc by uid and version
|
||||||
*/
|
*/
|
||||||
TBC *pCtbIdxc = NULL;
|
TBC *pCtbIdxc = NULL;
|
||||||
(void)tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL);
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL));
|
||||||
int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
(void)tdbTbcClose(pCtbIdxc);
|
||||||
|
@ -756,7 +766,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
||||||
* iterator all pTdDbc by uid and version
|
* iterator all pTdDbc by uid and version
|
||||||
*/
|
*/
|
||||||
TBC *pCtbIdxc = NULL;
|
TBC *pCtbIdxc = NULL;
|
||||||
(void)tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL);
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL));
|
||||||
int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
(void)tdbTbcClose(pCtbIdxc);
|
||||||
|
@ -1424,7 +1434,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
// search uid index
|
// search uid index
|
||||||
TBC *pUidIdxc = NULL;
|
TBC *pUidIdxc = NULL;
|
||||||
|
|
||||||
(void)tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL));
|
||||||
(void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
(void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
(void)tdbTbcClose(pUidIdxc);
|
||||||
|
@ -1438,7 +1448,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
// search table.db
|
// search table.db
|
||||||
TBC *pTbDbc = NULL;
|
TBC *pTbDbc = NULL;
|
||||||
|
|
||||||
(void)tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL));
|
||||||
(void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
(void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
(void)tdbTbcClose(pUidIdxc);
|
||||||
|
@ -1689,7 +1699,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
||||||
// search uid index
|
// search uid index
|
||||||
TBC *pUidIdxc = NULL;
|
TBC *pUidIdxc = NULL;
|
||||||
|
|
||||||
(void)tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL));
|
||||||
(void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
(void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
(void)tdbTbcClose(pUidIdxc);
|
||||||
|
@ -1706,7 +1716,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
||||||
SDecoder dc2 = {0};
|
SDecoder dc2 = {0};
|
||||||
|
|
||||||
/* get ctbEntry */
|
/* get ctbEntry */
|
||||||
(void)tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL));
|
||||||
(void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
(void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
(void)tdbTbcClose(pUidIdxc);
|
||||||
|
@ -1869,7 +1879,7 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
||||||
// search uid index
|
// search uid index
|
||||||
TBC *pUidIdxc = NULL;
|
TBC *pUidIdxc = NULL;
|
||||||
|
|
||||||
(void)tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL));
|
||||||
(void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
(void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
(void)tdbTbcClose(pUidIdxc);
|
||||||
|
@ -1883,7 +1893,7 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
||||||
// search table.db
|
// search table.db
|
||||||
TBC *pTbDbc = NULL;
|
TBC *pTbDbc = NULL;
|
||||||
|
|
||||||
(void)tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL));
|
||||||
(void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
(void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
(void)tdbTbcClose(pUidIdxc);
|
||||||
|
@ -2018,7 +2028,7 @@ static int metaAddTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTb
|
||||||
* iterator all pTdDbc by uid and version
|
* iterator all pTdDbc by uid and version
|
||||||
*/
|
*/
|
||||||
TBC *pCtbIdxc = NULL;
|
TBC *pCtbIdxc = NULL;
|
||||||
(void)tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL);
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL));
|
||||||
int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
(void)tdbTbcClose(pCtbIdxc);
|
||||||
|
@ -2157,7 +2167,7 @@ static int metaDropTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterT
|
||||||
SArray *tagIdxList = taosArrayInit(512, sizeof(SMetaPair));
|
SArray *tagIdxList = taosArrayInit(512, sizeof(SMetaPair));
|
||||||
|
|
||||||
TBC *pTagIdxc = NULL;
|
TBC *pTagIdxc = NULL;
|
||||||
(void)tdbTbcOpen(pMeta->pTagIdx, &pTagIdxc, NULL);
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTagIdx, &pTagIdxc, NULL));
|
||||||
int rc =
|
int rc =
|
||||||
tdbTbcMoveTo(pTagIdxc, &(STagIdxKey){.suid = suid, .cid = INT32_MIN, .type = pCol->type}, sizeof(STagIdxKey), &c);
|
tdbTbcMoveTo(pTagIdxc, &(STagIdxKey){.suid = suid, .cid = INT32_MIN, .type = pCol->type}, sizeof(STagIdxKey), &c);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
|
@ -568,7 +568,7 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
|
||||||
if (pInfo->pCur == NULL) {
|
if (pInfo->pCur == NULL) {
|
||||||
pInfo->pCur = pAPI->metaFn.openTableMetaCursor(pInfo->readHandle.vnode);
|
pInfo->pCur = pAPI->metaFn.openTableMetaCursor(pInfo->readHandle.vnode);
|
||||||
} else {
|
} else {
|
||||||
pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 0);
|
(void)pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInfo->pSchema == NULL) {
|
if (pInfo->pSchema == NULL) {
|
||||||
|
@ -781,7 +781,7 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
|
||||||
if (pInfo->pCur == NULL) {
|
if (pInfo->pCur == NULL) {
|
||||||
pInfo->pCur = pAPI->metaFn.openTableMetaCursor(pInfo->readHandle.vnode);
|
pInfo->pCur = pAPI->metaFn.openTableMetaCursor(pInfo->readHandle.vnode);
|
||||||
} else {
|
} else {
|
||||||
pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 0);
|
(void)pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((ret = pAPI->metaFn.cursorNext(pInfo->pCur, TSDB_SUPER_TABLE)) == 0) {
|
while ((ret = pAPI->metaFn.cursorNext(pInfo->pCur, TSDB_SUPER_TABLE)) == 0) {
|
||||||
|
@ -1201,7 +1201,7 @@ static SSDataBlock* buildInfoSchemaTableMetaBlock(char* tableName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SSDataBlock* pBlock = NULL;
|
SSDataBlock* pBlock = NULL;
|
||||||
int32_t code = createDataBlock(&pBlock);
|
int32_t code = createDataBlock(&pBlock);
|
||||||
if (code) {
|
if (code) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1374,7 +1374,7 @@ static SSDataBlock* sysTableBuildUserTablesByUids(SOperatorInfo* pOperator) {
|
||||||
// table name
|
// table name
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(p->pDataBlock, 0);
|
SColumnInfoData* pColInfoData = taosArrayGet(p->pDataBlock, 0);
|
||||||
QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
|
QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
|
||||||
|
|
||||||
code = colDataSetVal(pColInfoData, numOfRows, n, false);
|
code = colDataSetVal(pColInfoData, numOfRows, n, false);
|
||||||
QUERY_CHECK_CODE(code, lino, _end);
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
@ -1581,7 +1581,7 @@ static SSDataBlock* sysTableBuildUserTables(SOperatorInfo* pOperator) {
|
||||||
firstMetaCursor = 1;
|
firstMetaCursor = 1;
|
||||||
}
|
}
|
||||||
if (!firstMetaCursor) {
|
if (!firstMetaCursor) {
|
||||||
pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 1);
|
(void)pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
blockDataCleanup(pInfo->pRes);
|
blockDataCleanup(pInfo->pRes);
|
||||||
|
@ -2034,7 +2034,7 @@ static void sysTableScanFillTbName(SOperatorInfo* pOperator, const SSysTableScan
|
||||||
if (pInfo->tbnameSlotId != -1) {
|
if (pInfo->tbnameSlotId != -1) {
|
||||||
SColumnInfoData* pColumnInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, pInfo->tbnameSlotId);
|
SColumnInfoData* pColumnInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, pInfo->tbnameSlotId);
|
||||||
QUERY_CHECK_NULL(pColumnInfoData, code, lino, _end, terrno);
|
QUERY_CHECK_NULL(pColumnInfoData, code, lino, _end, terrno);
|
||||||
char varTbName[TSDB_TABLE_FNAME_LEN - 1 + VARSTR_HEADER_SIZE] = {0};
|
char varTbName[TSDB_TABLE_FNAME_LEN - 1 + VARSTR_HEADER_SIZE] = {0};
|
||||||
STR_TO_VARSTR(varTbName, name);
|
STR_TO_VARSTR(varTbName, name);
|
||||||
|
|
||||||
code = colDataSetNItems(pColumnInfoData, 0, varTbName, pBlock->info.rows, true);
|
code = colDataSetNItems(pColumnInfoData, 0, varTbName, pBlock->info.rows, true);
|
||||||
|
@ -2151,8 +2151,8 @@ static SSDataBlock* sysTableScanFromMNode(SOperatorInfo* pOperator, SSysTableSca
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode* pScanPhyNode,
|
int32_t createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode* pScanPhyNode, const char* pUser,
|
||||||
const char* pUser, SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) {
|
SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) {
|
||||||
QRY_OPTR_CHECK(pOptrInfo);
|
QRY_OPTR_CHECK(pOptrInfo);
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
@ -2161,7 +2161,7 @@ int32_t createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNo
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
if (pInfo == NULL || pOperator == NULL) {
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
lino = __LINE__;
|
lino = __LINE__;
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2453,10 +2453,10 @@ static FORCE_INLINE int optSysBinarySearch(SArray* arr, int s, int e, uint64_t k
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t optSysIntersection(SArray* in, SArray* out) {
|
int32_t optSysIntersection(SArray* in, SArray* out) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
MergeIndex* mi = NULL;
|
MergeIndex* mi = NULL;
|
||||||
int32_t sz = (int32_t)taosArrayGetSize(in);
|
int32_t sz = (int32_t)taosArrayGetSize(in);
|
||||||
if (sz <= 0) {
|
if (sz <= 0) {
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
|
@ -2694,7 +2694,6 @@ static int32_t doBlockInfoScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes
|
||||||
int32_t slotId = pOperator->exprSupp.pExprInfo->base.resSchema.slotId;
|
int32_t slotId = pOperator->exprSupp.pExprInfo->base.resSchema.slotId;
|
||||||
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, slotId);
|
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||||
QUERY_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
QUERY_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
|
||||||
int32_t len = tSerializeBlockDistInfo(NULL, 0, &blockDistInfo);
|
int32_t len = tSerializeBlockDistInfo(NULL, 0, &blockDistInfo);
|
||||||
char* p = taosMemoryCalloc(1, len + VARSTR_HEADER_SIZE);
|
char* p = taosMemoryCalloc(1, len + VARSTR_HEADER_SIZE);
|
||||||
|
@ -2716,7 +2715,7 @@ static int32_t doBlockInfoScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes
|
||||||
if (slotId != 0) {
|
if (slotId != 0) {
|
||||||
SColumnInfoData* p1 = taosArrayGet(pBlock->pDataBlock, 0);
|
SColumnInfoData* p1 = taosArrayGet(pBlock->pDataBlock, 0);
|
||||||
QUERY_CHECK_NULL(p1, code, lino, _end, terrno);
|
QUERY_CHECK_NULL(p1, code, lino, _end, terrno);
|
||||||
int64_t v = 0;
|
int64_t v = 0;
|
||||||
colDataSetInt64(p1, 0, &v);
|
colDataSetInt64(p1, 0, &v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2778,11 +2777,12 @@ static int32_t initTableblockDistQueryCond(uint64_t uid, SQueryTableDataCond* pC
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t createDataBlockInfoScanOperator(SReadHandle* readHandle, SBlockDistScanPhysiNode* pBlockScanNode,
|
int32_t createDataBlockInfoScanOperator(SReadHandle* readHandle, SBlockDistScanPhysiNode* pBlockScanNode,
|
||||||
STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) {
|
STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo,
|
||||||
|
SOperatorInfo** pOptrInfo) {
|
||||||
QRY_OPTR_CHECK(pOptrInfo);
|
QRY_OPTR_CHECK(pOptrInfo);
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
SBlockDistInfo* pInfo = taosMemoryCalloc(1, sizeof(SBlockDistInfo));
|
SBlockDistInfo* pInfo = taosMemoryCalloc(1, sizeof(SBlockDistInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
if (pInfo == NULL || pOperator == NULL) {
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
|
|
Loading…
Reference in New Issue