enh: clear void functions
This commit is contained in:
parent
eaad483616
commit
45f5c947ea
|
@ -98,7 +98,7 @@ int metaReaderGetTableEntryByUidCache(SMetaReader *pReader, tb_uid_t uid) {
|
||||||
SMeta *pMeta = pReader->pMeta;
|
SMeta *pMeta = pReader->pMeta;
|
||||||
|
|
||||||
SMetaInfo info;
|
SMetaInfo info;
|
||||||
int32_t code = metaGetInfo(pMeta, uid, &info, pReader);
|
int32_t code = metaGetInfo(pMeta, uid, &info, pReader);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return terrno = (TSDB_CODE_NOT_FOUND == code ? TSDB_CODE_PAR_TABLE_NOT_EXIST : code);
|
return terrno = (TSDB_CODE_NOT_FOUND == code ? TSDB_CODE_PAR_TABLE_NOT_EXIST : code);
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ void metaCloseTbCursor(SMTbCursor *pTbCur) {
|
||||||
if (!pTbCur->paused) {
|
if (!pTbCur->paused) {
|
||||||
metaReaderClear(&pTbCur->mr);
|
metaReaderClear(&pTbCur->mr);
|
||||||
if (pTbCur->pDbc) {
|
if (pTbCur->pDbc) {
|
||||||
(void)tdbTbcClose((TBC *)pTbCur->pDbc);
|
tdbTbcClose((TBC *)pTbCur->pDbc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taosMemoryFree(pTbCur);
|
taosMemoryFree(pTbCur);
|
||||||
|
@ -270,7 +270,7 @@ void metaCloseTbCursor(SMTbCursor *pTbCur) {
|
||||||
void metaPauseTbCursor(SMTbCursor *pTbCur) {
|
void metaPauseTbCursor(SMTbCursor *pTbCur) {
|
||||||
if (!pTbCur->paused) {
|
if (!pTbCur->paused) {
|
||||||
metaReaderClear(&pTbCur->mr);
|
metaReaderClear(&pTbCur->mr);
|
||||||
(void)tdbTbcClose((TBC *)pTbCur->pDbc);
|
tdbTbcClose((TBC *)pTbCur->pDbc);
|
||||||
pTbCur->paused = 1;
|
pTbCur->paused = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -463,7 +463,7 @@ void metaCloseCtbCursor(SMCtbCursor *pCtbCur) {
|
||||||
if (!pCtbCur->paused) {
|
if (!pCtbCur->paused) {
|
||||||
if (pCtbCur->pMeta && pCtbCur->lock) metaULock(pCtbCur->pMeta);
|
if (pCtbCur->pMeta && pCtbCur->lock) metaULock(pCtbCur->pMeta);
|
||||||
if (pCtbCur->pCur) {
|
if (pCtbCur->pCur) {
|
||||||
(void)tdbTbcClose(pCtbCur->pCur);
|
tdbTbcClose(pCtbCur->pCur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tdbFree(pCtbCur->pKey);
|
tdbFree(pCtbCur->pKey);
|
||||||
|
@ -474,7 +474,7 @@ void metaCloseCtbCursor(SMCtbCursor *pCtbCur) {
|
||||||
|
|
||||||
void metaPauseCtbCursor(SMCtbCursor *pCtbCur) {
|
void metaPauseCtbCursor(SMCtbCursor *pCtbCur) {
|
||||||
if (!pCtbCur->paused) {
|
if (!pCtbCur->paused) {
|
||||||
(void)tdbTbcClose((TBC *)pCtbCur->pCur);
|
tdbTbcClose((TBC *)pCtbCur->pCur);
|
||||||
if (pCtbCur->lock) {
|
if (pCtbCur->lock) {
|
||||||
metaULock(pCtbCur->pMeta);
|
metaULock(pCtbCur->pMeta);
|
||||||
}
|
}
|
||||||
|
@ -582,7 +582,7 @@ void metaCloseStbCursor(SMStbCursor *pStbCur) {
|
||||||
if (pStbCur) {
|
if (pStbCur) {
|
||||||
if (pStbCur->pMeta) metaULock(pStbCur->pMeta);
|
if (pStbCur->pMeta) metaULock(pStbCur->pMeta);
|
||||||
if (pStbCur->pCur) {
|
if (pStbCur->pCur) {
|
||||||
(void)tdbTbcClose(pStbCur->pCur);
|
tdbTbcClose(pStbCur->pCur);
|
||||||
|
|
||||||
tdbFree(pStbCur->pKey);
|
tdbFree(pStbCur->pKey);
|
||||||
tdbFree(pStbCur->pVal);
|
tdbFree(pStbCur->pVal);
|
||||||
|
@ -616,17 +616,17 @@ STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, int lock) {
|
||||||
return pTSchema;
|
return pTSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t metaGetTbTSchemaNotNull(SMeta *pMeta, tb_uid_t uid, int32_t sver, int lock, STSchema** ppTSchema) {
|
int32_t metaGetTbTSchemaNotNull(SMeta *pMeta, tb_uid_t uid, int32_t sver, int lock, STSchema **ppTSchema) {
|
||||||
*ppTSchema = metaGetTbTSchema(pMeta, uid, sver, lock);
|
*ppTSchema = metaGetTbTSchema(pMeta, uid, sver, lock);
|
||||||
if(*ppTSchema == NULL) {
|
if (*ppTSchema == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t metaGetTbTSchemaMaybeNull(SMeta *pMeta, tb_uid_t uid, int32_t sver, int lock, STSchema** ppTSchema) {
|
int32_t metaGetTbTSchemaMaybeNull(SMeta *pMeta, tb_uid_t uid, int32_t sver, int lock, STSchema **ppTSchema) {
|
||||||
*ppTSchema = metaGetTbTSchema(pMeta, uid, sver, lock);
|
*ppTSchema = metaGetTbTSchema(pMeta, uid, sver, lock);
|
||||||
if(*ppTSchema == NULL && terrno == TSDB_CODE_OUT_OF_MEMORY) {
|
if (*ppTSchema == NULL && terrno == TSDB_CODE_OUT_OF_MEMORY) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -656,14 +656,14 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv
|
||||||
|
|
||||||
if (tdbTbcMoveTo(pSkmDbC, &skmDbKey, sizeof(skmDbKey), &c) < 0) {
|
if (tdbTbcMoveTo(pSkmDbC, &skmDbKey, sizeof(skmDbKey), &c) < 0) {
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
(void)tdbTbcClose(pSkmDbC);
|
tdbTbcClose(pSkmDbC);
|
||||||
code = TSDB_CODE_NOT_FOUND;
|
code = TSDB_CODE_NOT_FOUND;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
(void)tdbTbcClose(pSkmDbC);
|
tdbTbcClose(pSkmDbC);
|
||||||
code = TSDB_CODE_FAILED;
|
code = TSDB_CODE_FAILED;
|
||||||
metaError("meta/query: incorrect c: %" PRId32 ".", c);
|
metaError("meta/query: incorrect c: %" PRId32 ".", c);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
|
@ -679,7 +679,7 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv
|
||||||
|
|
||||||
if (((SSkmDbKey *)pKey)->uid != skmDbKey.uid) {
|
if (((SSkmDbKey *)pKey)->uid != skmDbKey.uid) {
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
(void)tdbTbcClose(pSkmDbC);
|
tdbTbcClose(pSkmDbC);
|
||||||
code = TSDB_CODE_NOT_FOUND;
|
code = TSDB_CODE_NOT_FOUND;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
@ -687,7 +687,7 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv
|
||||||
sver = ((SSkmDbKey *)pKey)->sver;
|
sver = ((SSkmDbKey *)pKey)->sver;
|
||||||
|
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
(void)tdbTbcClose(pSkmDbC);
|
tdbTbcClose(pSkmDbC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -817,7 +817,7 @@ void metaCloseSmaCursor(SMSmaCursor *pSmaCur) {
|
||||||
if (pSmaCur) {
|
if (pSmaCur) {
|
||||||
if (pSmaCur->pMeta) metaULock(pSmaCur->pMeta);
|
if (pSmaCur->pMeta) metaULock(pSmaCur->pMeta);
|
||||||
if (pSmaCur->pCur) {
|
if (pSmaCur->pCur) {
|
||||||
(void)tdbTbcClose(pSmaCur->pCur);
|
tdbTbcClose(pSmaCur->pCur);
|
||||||
pSmaCur->pCur = NULL;
|
pSmaCur->pCur = NULL;
|
||||||
|
|
||||||
tdbFree(pSmaCur->pKey);
|
tdbFree(pSmaCur->pKey);
|
||||||
|
@ -1144,7 +1144,7 @@ int32_t metaFilterCreateTime(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
||||||
|
|
||||||
END:
|
END:
|
||||||
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
||||||
if (pCursor->pCur) (void)tdbTbcClose(pCursor->pCur);
|
if (pCursor->pCur) tdbTbcClose(pCursor->pCur);
|
||||||
taosMemoryFree(pCursor);
|
taosMemoryFree(pCursor);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1216,7 +1216,7 @@ int32_t metaFilterTableName(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
||||||
|
|
||||||
END:
|
END:
|
||||||
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
||||||
if (pCursor->pCur) (void)tdbTbcClose(pCursor->pCur);
|
if (pCursor->pCur) tdbTbcClose(pCursor->pCur);
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
taosMemoryFree(pKey);
|
taosMemoryFree(pKey);
|
||||||
|
|
||||||
|
@ -1245,7 +1245,7 @@ int32_t metaFilterTtl(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
||||||
|
|
||||||
END:
|
END:
|
||||||
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
||||||
if (pCursor->pCur) (void)tdbTbcClose(pCursor->pCur);
|
if (pCursor->pCur) tdbTbcClose(pCursor->pCur);
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
taosMemoryFree(pKey);
|
taosMemoryFree(pKey);
|
||||||
|
|
||||||
|
@ -1422,7 +1422,7 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
||||||
|
|
||||||
END:
|
END:
|
||||||
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
||||||
if (pCursor->pCur) (void)tdbTbcClose(pCursor->pCur);
|
if (pCursor->pCur) tdbTbcClose(pCursor->pCur);
|
||||||
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
tdbFree(pData);
|
tdbFree(pData);
|
||||||
|
|
|
@ -59,7 +59,7 @@ _exit:
|
||||||
|
|
||||||
void metaSnapReaderClose(SMetaSnapReader** ppReader) {
|
void metaSnapReaderClose(SMetaSnapReader** ppReader) {
|
||||||
if (ppReader && *ppReader) {
|
if (ppReader && *ppReader) {
|
||||||
(void)tdbTbcClose((*ppReader)->pTbc);
|
tdbTbcClose((*ppReader)->pTbc);
|
||||||
taosMemoryFree(*ppReader);
|
taosMemoryFree(*ppReader);
|
||||||
*ppReader = NULL;
|
*ppReader = NULL;
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ static void destroySTableInfoForChildTable(void* data) {
|
||||||
|
|
||||||
static int32_t MoveToSnapShotVersion(SSnapContext* ctx) {
|
static int32_t MoveToSnapShotVersion(SSnapContext* ctx) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
(void)tdbTbcClose((TBC*)ctx->pCur);
|
tdbTbcClose((TBC*)ctx->pCur);
|
||||||
code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
return TAOS_GET_TERRNO(code);
|
return TAOS_GET_TERRNO(code);
|
||||||
|
@ -239,7 +239,7 @@ static int32_t MoveToSnapShotVersion(SSnapContext* ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t MoveToPosition(SSnapContext* ctx, int64_t ver, int64_t uid) {
|
static int32_t MoveToPosition(SSnapContext* ctx, int64_t ver, int64_t uid) {
|
||||||
(void)tdbTbcClose((TBC*)ctx->pCur);
|
tdbTbcClose((TBC*)ctx->pCur);
|
||||||
int32_t code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
int32_t code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
return TAOS_GET_TERRNO(code);
|
return TAOS_GET_TERRNO(code);
|
||||||
|
@ -254,7 +254,7 @@ static int32_t MoveToPosition(SSnapContext* ctx, int64_t ver, int64_t uid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t MoveToFirst(SSnapContext* ctx) {
|
static int32_t MoveToFirst(SSnapContext* ctx) {
|
||||||
(void)tdbTbcClose((TBC*)ctx->pCur);
|
tdbTbcClose((TBC*)ctx->pCur);
|
||||||
int32_t code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
int32_t code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
return TAOS_GET_TERRNO(code);
|
return TAOS_GET_TERRNO(code);
|
||||||
|
@ -455,7 +455,7 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroySnapContext(SSnapContext* ctx) {
|
void destroySnapContext(SSnapContext* ctx) {
|
||||||
(void)tdbTbcClose((TBC*)ctx->pCur);
|
tdbTbcClose((TBC*)ctx->pCur);
|
||||||
taosArrayDestroy(ctx->idList);
|
taosArrayDestroy(ctx->idList);
|
||||||
taosHashCleanup(ctx->idVersion);
|
taosHashCleanup(ctx->idVersion);
|
||||||
taosHashCleanup(ctx->suidInfo);
|
taosHashCleanup(ctx->suidInfo);
|
||||||
|
|
|
@ -366,7 +366,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb
|
||||||
|
|
||||||
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);
|
tdbTbcClose(pCtbIdxc);
|
||||||
metaWLock(pMeta);
|
metaWLock(pMeta);
|
||||||
goto _drop_super_table;
|
goto _drop_super_table;
|
||||||
}
|
}
|
||||||
|
@ -383,12 +383,12 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb
|
||||||
|
|
||||||
if (taosArrayPush(tbUidList, &(((SCtbIdxKey *)pKey)->uid)) == NULL) {
|
if (taosArrayPush(tbUidList, &(((SCtbIdxKey *)pKey)->uid)) == NULL) {
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
|
|
||||||
(void)tsdbCacheDropSubTables(pMeta->pVnode->pTsdb, tbUidList, pReq->suid);
|
(void)tsdbCacheDropSubTables(pMeta->pVnode->pTsdb, tbUidList, pReq->suid);
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ static int32_t metaGetSubtables(SMeta *pMeta, int64_t suid, SArray *uids) {
|
||||||
TAOS_CHECK_RETURN(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);
|
tdbTbcClose(pCtbIdxc);
|
||||||
metaWLock(pMeta);
|
metaWLock(pMeta);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -451,14 +451,14 @@ static int32_t metaGetSubtables(SMeta *pMeta, int64_t suid, SArray *uids) {
|
||||||
|
|
||||||
if (taosArrayPush(uids, &(((SCtbIdxKey *)pKey)->uid)) == NULL) {
|
if (taosArrayPush(uids, &(((SCtbIdxKey *)pKey)->uid)) == NULL) {
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
|
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,14 +477,14 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
TAOS_CHECK_RETURN(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);
|
tdbTbcClose(pUidIdxc);
|
||||||
|
|
||||||
return terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
return terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData);
|
ret = tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
|
|
||||||
return terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
return terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
||||||
}
|
}
|
||||||
|
@ -494,8 +494,8 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
TAOS_CHECK_RETURN(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);
|
tdbTbcClose(pUidIdxc);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
|
|
||||||
metaError("meta/table: invalide ret: %" PRId32 " or c: %" PRId32 "alter stb failed.", ret, c);
|
metaError("meta/table: invalide ret: %" PRId32 " or c: %" PRId32 "alter stb failed.", ret, c);
|
||||||
return terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
return terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
||||||
|
@ -503,15 +503,15 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
|
|
||||||
ret = tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
ret = tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
|
|
||||||
return terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
return terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((oStbEntry.pBuf = taosMemoryMalloc(nData)) == NULL) {
|
if ((oStbEntry.pBuf = taosMemoryMalloc(nData)) == NULL) {
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
memcpy(oStbEntry.pBuf, pData, nData);
|
memcpy(oStbEntry.pBuf, pData, nData);
|
||||||
|
@ -538,8 +538,8 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
if (uids == NULL) {
|
if (uids == NULL) {
|
||||||
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
if (deltaCol == 1) {
|
if (deltaCol == 1) {
|
||||||
|
@ -600,8 +600,8 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
_exit:
|
_exit:
|
||||||
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
|
@ -692,7 +692,7 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
|
|
||||||
code = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
code = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -702,7 +702,7 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
pCtbIdxc = NULL;
|
pCtbIdxc = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -737,7 +737,7 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
metaDestroyTagIdxKey(pTagIdxKey);
|
metaDestroyTagIdxKey(pTagIdxKey);
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -768,7 +768,7 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
tdbFree(pData);
|
tdbFree(pData);
|
||||||
|
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
_err:
|
_err:
|
||||||
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
||||||
|
@ -841,7 +841,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
||||||
|
|
||||||
code = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
code = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -852,7 +852,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
pCtbIdxc = NULL;
|
pCtbIdxc = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -888,7 +888,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
metaDestroyTagIdxKey(pTagIdxKey);
|
metaDestroyTagIdxKey(pTagIdxKey);
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -916,7 +916,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
||||||
tDeleteSColCmprWrapper(cmpr);
|
tDeleteSColCmprWrapper(cmpr);
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -942,7 +942,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
tdbFree(pData);
|
tdbFree(pData);
|
||||||
|
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
_err:
|
_err:
|
||||||
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
||||||
|
@ -1214,7 +1214,7 @@ static int32_t metaFilterTableByHash(SMeta *pMeta, SArray *uidList) {
|
||||||
|
|
||||||
code = tdbTbcMoveToFirst(pCur);
|
code = tdbTbcMoveToFirst(pCur);
|
||||||
if (code) {
|
if (code) {
|
||||||
(void)tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1248,7 +1248,7 @@ static int32_t metaFilterTableByHash(SMeta *pMeta, SArray *uidList) {
|
||||||
}
|
}
|
||||||
tdbFree(pData);
|
tdbFree(pData);
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
(void)tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1534,7 +1534,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
TAOS_CHECK_RETURN(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);
|
tdbTbcClose(pUidIdxc);
|
||||||
metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c);
|
metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c);
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -1548,8 +1548,8 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
TAOS_CHECK_RETURN(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);
|
tdbTbcClose(pUidIdxc);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c);
|
metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c);
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -1563,8 +1563,8 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
tDecoderInit(&dc, entry.pBuf, nData);
|
tDecoderInit(&dc, entry.pBuf, nData);
|
||||||
ret = metaDecodeEntry(&dc, &entry);
|
ret = metaDecodeEntry(&dc, &entry);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
metaError("meta/table: invalide ret: %" PRId32 " alt tb column failed.", ret);
|
metaError("meta/table: invalide ret: %" PRId32 " alt tb column failed.", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1760,16 +1760,16 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
if (pNewSchema) taosMemoryFree(pNewSchema);
|
if (pNewSchema) taosMemoryFree(pNewSchema);
|
||||||
if (freeColCmpr) taosMemoryFree(entry.colCmpr.pColCmpr);
|
if (freeColCmpr) taosMemoryFree(entry.colCmpr.pColCmpr);
|
||||||
|
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
if (entry.pBuf) taosMemoryFree(entry.pBuf);
|
if (entry.pBuf) taosMemoryFree(entry.pBuf);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
|
|
||||||
return terrno != 0 ? terrno : TSDB_CODE_FAILED;
|
return terrno != 0 ? terrno : TSDB_CODE_FAILED;
|
||||||
|
@ -1807,7 +1807,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
||||||
TAOS_CHECK_RETURN(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);
|
tdbTbcClose(pUidIdxc);
|
||||||
metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c);
|
metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c);
|
||||||
return terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
return terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
||||||
}
|
}
|
||||||
|
@ -1824,8 +1824,8 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
||||||
TAOS_CHECK_RETURN(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);
|
tdbTbcClose(pUidIdxc);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c);
|
metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c);
|
||||||
return terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
return terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
||||||
}
|
}
|
||||||
|
@ -1954,8 +1954,8 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
||||||
taosMemoryFree((void *)ctbEntry.ctbEntry.pTags);
|
taosMemoryFree((void *)ctbEntry.ctbEntry.pTags);
|
||||||
if (ctbEntry.pBuf) taosMemoryFree(ctbEntry.pBuf);
|
if (ctbEntry.pBuf) taosMemoryFree(ctbEntry.pBuf);
|
||||||
if (stbEntry.pBuf) tdbFree(stbEntry.pBuf);
|
if (stbEntry.pBuf) tdbFree(stbEntry.pBuf);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
|
@ -1963,8 +1963,8 @@ _err:
|
||||||
tDecoderClear(&dc2);
|
tDecoderClear(&dc2);
|
||||||
if (ctbEntry.pBuf) taosMemoryFree(ctbEntry.pBuf);
|
if (ctbEntry.pBuf) taosMemoryFree(ctbEntry.pBuf);
|
||||||
if (stbEntry.pBuf) tdbFree(stbEntry.pBuf);
|
if (stbEntry.pBuf) tdbFree(stbEntry.pBuf);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1995,7 +1995,7 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
||||||
TAOS_CHECK_RETURN(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);
|
tdbTbcClose(pUidIdxc);
|
||||||
metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c);
|
metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c);
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -2009,8 +2009,8 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
||||||
TAOS_CHECK_RETURN(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);
|
tdbTbcClose(pUidIdxc);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c);
|
metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c);
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -2025,8 +2025,8 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
||||||
ret = metaDecodeEntry(&dc, &entry);
|
ret = metaDecodeEntry(&dc, &entry);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
metaError("meta/table: invalide ret: %" PRId32 " alt tb options failed.", ret);
|
metaError("meta/table: invalide ret: %" PRId32 " alt tb options failed.", ret);
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -2063,8 +2063,8 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
||||||
|
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
|
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
if (entry.pBuf) taosMemoryFree(entry.pBuf);
|
if (entry.pBuf) taosMemoryFree(entry.pBuf);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2144,7 +2144,7 @@ static int metaAddTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTb
|
||||||
TAOS_CHECK_RETURN(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);
|
tdbTbcClose(pCtbIdxc);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -2181,14 +2181,14 @@ static int metaAddTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTb
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
metaDestroyTagIdxKey(pTagIdxKey);
|
metaDestroyTagIdxKey(pTagIdxKey);
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
(void)tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn);
|
(void)tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn);
|
||||||
metaDestroyTagIdxKey(pTagIdxKey);
|
metaDestroyTagIdxKey(pTagIdxKey);
|
||||||
pTagIdxKey = NULL;
|
pTagIdxKey = NULL;
|
||||||
}
|
}
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
|
@ -2302,7 +2302,7 @@ static int metaDropTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterT
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(void)tdbTbcClose(pTagIdxc);
|
tdbTbcClose(pTagIdxc);
|
||||||
|
|
||||||
metaWLock(pMeta);
|
metaWLock(pMeta);
|
||||||
for (int i = 0; i < taosArrayGetSize(tagIdxList); i++) {
|
for (int i = 0; i < taosArrayGetSize(tagIdxList); i++) {
|
||||||
|
|
|
@ -389,10 +389,7 @@ static int32_t tqMetaTransformInfo(TDB* pMetaDB, TTB* pOld, TTB* pNew) {
|
||||||
END:
|
END:
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
int32_t ret = tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
if (ret != 0) {
|
|
||||||
tqError("failed to close tbc, ret:%d", ret);
|
|
||||||
}
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,10 +461,7 @@ static int32_t tqMetaRestoreCheckInfo(STQ* pTq) {
|
||||||
END:
|
END:
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
int32_t ret = tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
if (ret != 0) {
|
|
||||||
tqError("failed to close tbc, ret:%d", ret);
|
|
||||||
}
|
|
||||||
tDeleteSTqCheckInfo(&info);
|
tDeleteSTqCheckInfo(&info);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,10 +77,7 @@ _err:
|
||||||
}
|
}
|
||||||
|
|
||||||
void tqSnapReaderClose(STqSnapReader** ppReader) {
|
void tqSnapReaderClose(STqSnapReader** ppReader) {
|
||||||
int32_t ret = tdbTbcClose((*ppReader)->pCur);
|
tdbTbcClose((*ppReader)->pCur);
|
||||||
if (ret != 0){
|
|
||||||
tqError("vgId:%d, vnode snapshot tq reader close failed since %s", TD_VID((*ppReader)->pTq->pVnode), tstrerror(ret));
|
|
||||||
}
|
|
||||||
taosMemoryFree(*ppReader);
|
taosMemoryFree(*ppReader);
|
||||||
*ppReader = NULL;
|
*ppReader = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,12 +97,8 @@ int32_t streamTaskSnapReaderClose(SStreamTaskReader* pReader) {
|
||||||
int32_t vgId = TD_VID(pReader->pTq->pVnode);
|
int32_t vgId = TD_VID(pReader->pTq->pVnode);
|
||||||
|
|
||||||
taosArrayDestroy(pReader->tdbTbList);
|
taosArrayDestroy(pReader->tdbTbList);
|
||||||
code = tdbTbcClose(pReader->pCur);
|
tdbTbcClose(pReader->pCur);
|
||||||
if (code) {
|
tqInfo("vgId:%d, vnode stream-task snapshot reader closed", vgId);
|
||||||
tqError("vgId:%d failed to close stream meta reader, code:%s", vgId, tstrerror(code));
|
|
||||||
} else {
|
|
||||||
tqInfo("vgId:%d, vnode stream-task snapshot reader closed", vgId);
|
|
||||||
}
|
|
||||||
|
|
||||||
taosMemoryFree(pReader);
|
taosMemoryFree(pReader);
|
||||||
return code;
|
return code;
|
||||||
|
@ -146,7 +142,7 @@ NextTbl:
|
||||||
}
|
}
|
||||||
if (except == 1) {
|
if (except == 1) {
|
||||||
if (pReader->pos + 1 < taosArrayGetSize(pReader->tdbTbList)) {
|
if (pReader->pos + 1 < taosArrayGetSize(pReader->tdbTbList)) {
|
||||||
(void)tdbTbcClose(pReader->pCur);
|
tdbTbcClose(pReader->pCur);
|
||||||
|
|
||||||
pReader->pos += 1;
|
pReader->pos += 1;
|
||||||
pPair = taosArrayGet(pReader->tdbTbList, pReader->pos);
|
pPair = taosArrayGet(pReader->tdbTbList, pReader->pos);
|
||||||
|
|
|
@ -191,11 +191,7 @@ int32_t streamMetaCheckBackendCompatible(SStreamMeta* pMeta) {
|
||||||
if (code) {
|
if (code) {
|
||||||
stError("vgId:%d failed to open stream meta file cursor, not perform compatible check, code:%s", pMeta->vgId,
|
stError("vgId:%d failed to open stream meta file cursor, not perform compatible check, code:%s", pMeta->vgId,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
code = tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
if (code) {
|
|
||||||
stError("vgId:%d failed to close meta file cursor, code:%s", pMeta->vgId, tstrerror(code));
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,10 +219,7 @@ int32_t streamMetaCheckBackendCompatible(SStreamMeta* pMeta) {
|
||||||
|
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
code = tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
if (code != 0) {
|
|
||||||
stError("vgId:%d failed to close meta file cursor, code:%s", pMeta->vgId, tstrerror(code));
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -977,10 +970,7 @@ int64_t streamMetaGetLatestCheckpointId(SStreamMeta* pMeta) {
|
||||||
code = tdbTbcMoveToFirst(pCur);
|
code = tdbTbcMoveToFirst(pCur);
|
||||||
if (code) {
|
if (code) {
|
||||||
stError("failed to move stream meta file cursor, the latest checkpointId is 0, vgId:%d", pMeta->vgId);
|
stError("failed to move stream meta file cursor, the latest checkpointId is 0, vgId:%d", pMeta->vgId);
|
||||||
int32_t ret = tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
if (ret != 0) {
|
|
||||||
stError("vgId:%d failed to close meta file cursor, code:%s", pMeta->vgId, tstrerror(ret));
|
|
||||||
}
|
|
||||||
return checkpointId;
|
return checkpointId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1003,11 +993,7 @@ int64_t streamMetaGetLatestCheckpointId(SStreamMeta* pMeta) {
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
|
|
||||||
int32_t ret = tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
if (ret != 0) {
|
|
||||||
stError("vgId:%d failed to close meta file cursor, code:%s", pMeta->vgId, tstrerror(ret));
|
|
||||||
}
|
|
||||||
|
|
||||||
return checkpointId;
|
return checkpointId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1047,10 +1033,7 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) {
|
||||||
if (code) {
|
if (code) {
|
||||||
stError("vgId:%d failed to open stream meta cursor, code:%s, not load any stream tasks", vgId, tstrerror(terrno));
|
stError("vgId:%d failed to open stream meta cursor, code:%s, not load any stream tasks", vgId, tstrerror(terrno));
|
||||||
taosArrayDestroy(pRecycleList);
|
taosArrayDestroy(pRecycleList);
|
||||||
int32_t ret = tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
if (ret != 0) {
|
|
||||||
stError("vgId:%d failed to close meta file cursor, code:%s", pMeta->vgId, tstrerror(ret));
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1137,9 +1120,7 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) {
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
|
|
||||||
if (tdbTbcClose(pCur) < 0) {
|
tdbTbcClose(pCur);
|
||||||
stError("vgId:%d failed to close meta-file cursor, code:%s, continue", vgId, tstrerror(terrno));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taosArrayGetSize(pRecycleList) > 0) {
|
if (taosArrayGetSize(pRecycleList) > 0) {
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pRecycleList); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pRecycleList); ++i) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ int32_t tdbTbTraversal(TTB *pTb, void *data,
|
||||||
|
|
||||||
// TBC
|
// TBC
|
||||||
int32_t tdbTbcOpen(TTB *pTb, TBC **ppTbc, TXN *pTxn);
|
int32_t tdbTbcOpen(TTB *pTb, TBC **ppTbc, TXN *pTxn);
|
||||||
int32_t tdbTbcClose(TBC *pTbc);
|
void tdbTbcClose(TBC *pTbc);
|
||||||
int32_t tdbTbcIsValid(TBC *pTbc);
|
int32_t tdbTbcIsValid(TBC *pTbc);
|
||||||
int32_t tdbTbcMoveTo(TBC *pTbc, const void *pKey, int kLen, int *c);
|
int32_t tdbTbcMoveTo(TBC *pTbc, const void *pKey, int kLen, int *c);
|
||||||
int32_t tdbTbcMoveToFirst(TBC *pTbc);
|
int32_t tdbTbcMoveToFirst(TBC *pTbc);
|
||||||
|
|
|
@ -172,12 +172,11 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbBtreeClose(SBTree *pBt) {
|
void tdbBtreeClose(SBTree *pBt) {
|
||||||
if (pBt) {
|
if (pBt) {
|
||||||
tdbFree(pBt->pBuf);
|
tdbFree(pBt->pBuf);
|
||||||
tdbOsFree(pBt);
|
tdbOsFree(pBt);
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, int vLen, TXN *pTxn) {
|
int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, int vLen, TXN *pTxn) {
|
||||||
|
@ -201,7 +200,7 @@ int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, in
|
||||||
// move to the position to insert
|
// move to the position to insert
|
||||||
ret = tdbBtcMoveTo(&btc, pKey, kLen, &c);
|
ret = tdbBtcMoveTo(&btc, pKey, kLen, &c);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
tdbError("tdb/btree-insert: btc move to failed with ret: %d.", ret);
|
tdbError("tdb/btree-insert: btc move to failed with ret: %d.", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -213,7 +212,7 @@ int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, in
|
||||||
btc.idx++;
|
btc.idx++;
|
||||||
} else if (c == 0) {
|
} else if (c == 0) {
|
||||||
// dup key not allowed with insert
|
// dup key not allowed with insert
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
tdbError("tdb/btree-insert: dup key. pKey: %p, kLen: %d, btc: %p, pTxn: %p", pKey, kLen, &btc, pTxn);
|
tdbError("tdb/btree-insert: dup key. pKey: %p, kLen: %d, btc: %p, pTxn: %p", pKey, kLen, &btc, pTxn);
|
||||||
return TSDB_CODE_DUP_KEY;
|
return TSDB_CODE_DUP_KEY;
|
||||||
}
|
}
|
||||||
|
@ -221,12 +220,12 @@ int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, in
|
||||||
|
|
||||||
ret = tdbBtcUpsert(&btc, pKey, kLen, pVal, vLen, 1);
|
ret = tdbBtcUpsert(&btc, pKey, kLen, pVal, vLen, 1);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
tdbError("tdb/btree-insert: btc upsert failed with ret: %d.", ret);
|
tdbError("tdb/btree-insert: btc upsert failed with ret: %d.", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,20 +249,20 @@ int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn) {
|
||||||
// move the cursor
|
// move the cursor
|
||||||
ret = tdbBtcMoveTo(&btc, pKey, kLen, &c);
|
ret = tdbBtcMoveTo(&btc, pKey, kLen, &c);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
tdbError("tdb/btree-delete: btc move to failed with ret: %d.", ret);
|
tdbError("tdb/btree-delete: btc move to failed with ret: %d.", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btc.idx < 0 || c != 0) {
|
if (btc.idx < 0 || c != 0) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
return TSDB_CODE_NOT_FOUND;
|
return TSDB_CODE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete the key
|
// delete the key
|
||||||
ret = tdbBtcDelete(&btc);
|
ret = tdbBtcDelete(&btc);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -278,7 +277,7 @@ int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn) {
|
||||||
btc.coder.ofps = NULL;
|
btc.coder.ofps = NULL;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,20 +350,20 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL
|
||||||
|
|
||||||
ret = tdbBtcMoveTo(&btc, pKey, kLen, &cret);
|
ret = tdbBtcMoveTo(&btc, pKey, kLen, &cret);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
tdbError("tdb/btree-pget: btc move to failed with ret: %d.", ret);
|
tdbError("tdb/btree-pget: btc move to failed with ret: %d.", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btc.idx < 0 || cret) {
|
if (btc.idx < 0 || cret) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
return TSDB_CODE_NOT_FOUND;
|
return TSDB_CODE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
pCell = tdbPageGetCell(btc.pPage, btc.idx);
|
pCell = tdbPageGetCell(btc.pPage, btc.idx);
|
||||||
ret = tdbBtreeDecodeCell(btc.pPage, pCell, &cd, btc.pTxn, pBt);
|
ret = tdbBtreeDecodeCell(btc.pPage, pCell, &cd, btc.pTxn, pBt);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
tdbError("tdb/btree-pget: decode cell failed with ret: %d.", ret);
|
tdbError("tdb/btree-pget: decode cell failed with ret: %d.", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -372,7 +371,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL
|
||||||
if (ppKey) {
|
if (ppKey) {
|
||||||
pTKey = tdbRealloc(*ppKey, cd.kLen);
|
pTKey = tdbRealloc(*ppKey, cd.kLen);
|
||||||
if (pTKey == NULL) {
|
if (pTKey == NULL) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
tdbError("tdb/btree-pget: realloc pTKey failed.");
|
tdbError("tdb/btree-pget: realloc pTKey failed.");
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -384,7 +383,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL
|
||||||
if (ppVal) {
|
if (ppVal) {
|
||||||
pTVal = tdbRealloc(*ppVal, cd.vLen);
|
pTVal = tdbRealloc(*ppVal, cd.vLen);
|
||||||
if (pTVal == NULL) {
|
if (pTVal == NULL) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
tdbError("tdb/btree-pget: realloc pTVal failed.");
|
tdbError("tdb/btree-pget: realloc pTVal failed.");
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -405,7 +404,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL
|
||||||
|
|
||||||
tdbTrace("tdb pget end, btc decoder: %p/0x%x, local decoder:%p", &btc.coder, btc.coder.freeKV, &cd);
|
tdbTrace("tdb pget end, btc decoder: %p/0x%x, local decoder:%p", &btc.coder, btc.coder.freeKV, &cd);
|
||||||
|
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -604,7 +603,11 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
||||||
if (i < nOlds - 1) {
|
if (i < nOlds - 1) {
|
||||||
((SPgno *)pDivCell[i])[0] = ((SIntHdr *)pOlds[i]->pData)->pgno;
|
((SPgno *)pDivCell[i])[0] = ((SIntHdr *)pOlds[i]->pData)->pgno;
|
||||||
((SIntHdr *)pOlds[i]->pData)->pgno = 0;
|
((SIntHdr *)pOlds[i]->pData)->pgno = 0;
|
||||||
(void)tdbPageInsertCell(pOlds[i], TDB_PAGE_TOTAL_CELLS(pOlds[i]), pDivCell[i], szDivCell[i], 1);
|
ret = tdbPageInsertCell(pOlds[i], TDB_PAGE_TOTAL_CELLS(pOlds[i]), pDivCell[i], szDivCell[i], 1);
|
||||||
|
if (ret < 0) {
|
||||||
|
tdbError("tdb/btree-balance: insert cell failed with ret: %d.", ret);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rPgno = ((SIntHdr *)pOlds[nOlds - 1]->pData)->pgno;
|
rPgno = ((SIntHdr *)pOlds[nOlds - 1]->pData)->pgno;
|
||||||
|
@ -791,15 +794,31 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
||||||
iarg.pBt = pBt;
|
iarg.pBt = pBt;
|
||||||
iarg.flags = TDB_BTREE_PAGE_GET_FLAGS(pOlds[0]);
|
iarg.flags = TDB_BTREE_PAGE_GET_FLAGS(pOlds[0]);
|
||||||
for (int i = 0; i < nOlds; i++) {
|
for (int i = 0; i < nOlds; i++) {
|
||||||
(void)tdbPageCreate(pOlds[0]->pageSize, &pOldsCopy[i], tdbDefaultMalloc, NULL);
|
ret = tdbPageCreate(pOlds[0]->pageSize, &pOldsCopy[i], tdbDefaultMalloc, NULL);
|
||||||
(void)tdbBtreeInitPage(pOldsCopy[i], &iarg, 0);
|
if (ret < 0) {
|
||||||
(void)tdbPageCopy(pOlds[i], pOldsCopy[i], 0);
|
tdbError("tdb/btree-balance: create page failed with ret: %d.", ret);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
ret = tdbBtreeInitPage(pOldsCopy[i], &iarg, 0);
|
||||||
|
if (ret < 0) {
|
||||||
|
tdbError("tdb/btree-balance: init page failed with ret: %d.", ret);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
ret = tdbPageCopy(pOlds[i], pOldsCopy[i], 0);
|
||||||
|
if (ret < 0) {
|
||||||
|
tdbError("tdb/btree-balance: copy page failed with ret: %d.", ret);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
pOlds[i]->nOverflow = 0;
|
pOlds[i]->nOverflow = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
iNew = 0;
|
iNew = 0;
|
||||||
nNewCells = 0;
|
nNewCells = 0;
|
||||||
(void)tdbBtreeInitPage(pNews[iNew], &iarg, 0);
|
ret = tdbBtreeInitPage(pNews[iNew], &iarg, 0);
|
||||||
|
if (ret < 0) {
|
||||||
|
tdbError("tdb/btree-balance: init page failed with ret: %d.", ret);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
for (int iOld = 0; iOld < nOlds; iOld++) {
|
for (int iOld = 0; iOld < nOlds; iOld++) {
|
||||||
SPage *pPage;
|
SPage *pPage;
|
||||||
|
@ -818,7 +837,11 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nNewCells < infoNews[iNew].cnt) {
|
if (nNewCells < infoNews[iNew].cnt) {
|
||||||
(void)tdbPageInsertCell(pNews[iNew], nNewCells, pCell, szCell, 0);
|
ret = tdbPageInsertCell(pNews[iNew], nNewCells, pCell, szCell, 0);
|
||||||
|
if (ret < 0) {
|
||||||
|
tdbError("tdb/btree-balance: insert cell failed with ret: %d.", ret);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
nNewCells++;
|
nNewCells++;
|
||||||
|
|
||||||
// insert parent page
|
// insert parent page
|
||||||
|
@ -837,7 +860,11 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
||||||
pgno = TDB_PAGE_PGNO(pNews[iNew]);
|
pgno = TDB_PAGE_PGNO(pNews[iNew]);
|
||||||
(void)tdbBtreeEncodeCell(pParent, cd.pKey, cd.kLen, (void *)&pgno, sizeof(SPgno), pNewCell, &szNewCell,
|
(void)tdbBtreeEncodeCell(pParent, cd.pKey, cd.kLen, (void *)&pgno, sizeof(SPgno), pNewCell, &szNewCell,
|
||||||
pTxn, pBt);
|
pTxn, pBt);
|
||||||
(void)tdbPageInsertCell(pParent, sIdx++, pNewCell, szNewCell, 0);
|
ret = tdbPageInsertCell(pParent, sIdx++, pNewCell, szNewCell, 0);
|
||||||
|
if (ret) {
|
||||||
|
tdbError("tdb/btree-balance: insert cell failed with ret: %d.", ret);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
tdbOsFree(pNewCell);
|
tdbOsFree(pNewCell);
|
||||||
|
|
||||||
if (TDB_CELLDECODER_FREE_VAL(&cd)) {
|
if (TDB_CELLDECODER_FREE_VAL(&cd)) {
|
||||||
|
@ -850,7 +877,11 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
||||||
iNew++;
|
iNew++;
|
||||||
nNewCells = 0;
|
nNewCells = 0;
|
||||||
if (iNew < nNews) {
|
if (iNew < nNews) {
|
||||||
(void)tdbBtreeInitPage(pNews[iNew], &iarg, 0);
|
ret = tdbBtreeInitPage(pNews[iNew], &iarg, 0);
|
||||||
|
if (ret < 0) {
|
||||||
|
tdbError("tdb/btree-balance: init page failed with ret: %d.", ret);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -869,13 +900,21 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
((SPgno *)pCell)[0] = TDB_PAGE_PGNO(pNews[iNew]);
|
((SPgno *)pCell)[0] = TDB_PAGE_PGNO(pNews[iNew]);
|
||||||
(void)tdbPageInsertCell(pParent, sIdx++, pCell, szCell, 0);
|
ret = tdbPageInsertCell(pParent, sIdx++, pCell, szCell, 0);
|
||||||
|
if (ret) {
|
||||||
|
tdbError("tdb/btree-balance: insert cell failed with ret: %d.", ret);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
// move to next new page
|
// move to next new page
|
||||||
iNew++;
|
iNew++;
|
||||||
nNewCells = 0;
|
nNewCells = 0;
|
||||||
if (iNew < nNews) {
|
if (iNew < nNews) {
|
||||||
(void)tdbBtreeInitPage(pNews[iNew], &iarg, 0);
|
ret = tdbBtreeInitPage(pNews[iNew], &iarg, 0);
|
||||||
|
if (ret < 0) {
|
||||||
|
tdbError("tdb/btree-balance: init page failed with ret: %d.", ret);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -892,26 +931,39 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
||||||
pIntHdr->pgno = TDB_PAGE_PGNO(pNews[nNews - 1]);
|
pIntHdr->pgno = TDB_PAGE_PGNO(pNews[nNews - 1]);
|
||||||
} else {
|
} else {
|
||||||
((SPgno *)pDivCell[nOlds - 1])[0] = TDB_PAGE_PGNO(pNews[nNews - 1]);
|
((SPgno *)pDivCell[nOlds - 1])[0] = TDB_PAGE_PGNO(pNews[nNews - 1]);
|
||||||
(void)tdbPageInsertCell(pParent, sIdx, pDivCell[nOlds - 1], szDivCell[nOlds - 1], 0);
|
ret = tdbPageInsertCell(pParent, sIdx, pDivCell[nOlds - 1], szDivCell[nOlds - 1], 0);
|
||||||
|
if (ret) {
|
||||||
|
tdbError("tdb/btree-balance: insert cell failed with ret: %d.", ret);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < nOlds; i++) {
|
for (int i = 0; i < nOlds; i++) {
|
||||||
(void)tdbPageDestroy(pOldsCopy[i], tdbDefaultFree, NULL);
|
tdbPageDestroy(pOldsCopy[i], tdbDefaultFree, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TDB_BTREE_PAGE_IS_ROOT(pParent) && TDB_PAGE_TOTAL_CELLS(pParent) == 0) {
|
if (TDB_BTREE_PAGE_IS_ROOT(pParent) && TDB_PAGE_TOTAL_CELLS(pParent) == 0) {
|
||||||
i8 flags = TDB_BTREE_ROOT | TDB_BTREE_PAGE_IS_LEAF(pNews[0]);
|
i8 flags = TDB_BTREE_ROOT | TDB_BTREE_PAGE_IS_LEAF(pNews[0]);
|
||||||
// copy content to the parent page
|
// copy content to the parent page
|
||||||
(void)tdbBtreeInitPage(pParent, &(SBtreeInitPageArg){.flags = flags, .pBt = pBt}, 0);
|
ret = tdbBtreeInitPage(pParent, &(SBtreeInitPageArg){.flags = flags, .pBt = pBt}, 0);
|
||||||
(void)tdbPageCopy(pNews[0], pParent, 1);
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
ret = tdbPageCopy(pNews[0], pParent, 1);
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
if (!TDB_BTREE_PAGE_IS_LEAF(pNews[0])) {
|
if (!TDB_BTREE_PAGE_IS_LEAF(pNews[0])) {
|
||||||
((SIntHdr *)(pParent->pData))->pgno = ((SIntHdr *)(pNews[0]->pData))->pgno;
|
((SIntHdr *)(pParent->pData))->pgno = ((SIntHdr *)(pNews[0]->pData))->pgno;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)tdbPagerInsertFreePage(pBt->pPager, pNews[0], pTxn);
|
ret = tdbPagerInsertFreePage(pBt->pPager, pNews[0], pTxn);
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
|
@ -1986,7 +2038,11 @@ int tdbBtcMoveToNext(SBTC *pBtc) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)tdbBtcMoveUpward(pBtc);
|
ret = tdbBtcMoveUpward(pBtc);
|
||||||
|
if (ret < 0) {
|
||||||
|
tdbError("tdb/btc-move-to-next: btc move upward failed with ret: %d.", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
pBtc->idx++;
|
pBtc->idx++;
|
||||||
|
|
||||||
if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) {
|
if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) {
|
||||||
|
@ -2015,6 +2071,7 @@ int tdbBtcMoveToNext(SBTC *pBtc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbBtcMoveToPrev(SBTC *pBtc) {
|
int tdbBtcMoveToPrev(SBTC *pBtc) {
|
||||||
|
int32_t ret = 0;
|
||||||
if (pBtc->idx < 0) return TSDB_CODE_FAILED;
|
if (pBtc->idx < 0) return TSDB_CODE_FAILED;
|
||||||
|
|
||||||
pBtc->idx--;
|
pBtc->idx--;
|
||||||
|
@ -2029,7 +2086,11 @@ int tdbBtcMoveToPrev(SBTC *pBtc) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)tdbBtcMoveUpward(pBtc);
|
ret = tdbBtcMoveUpward(pBtc);
|
||||||
|
if (ret < 0) {
|
||||||
|
tdbError("tdb/btc-move-to-prev: btc move upward failed with ret: %d.", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
pBtc->idx--;
|
pBtc->idx--;
|
||||||
if (pBtc->idx >= 0) {
|
if (pBtc->idx >= 0) {
|
||||||
break;
|
break;
|
||||||
|
@ -2040,7 +2101,11 @@ int tdbBtcMoveToPrev(SBTC *pBtc) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) break;
|
if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) break;
|
||||||
|
|
||||||
(void)tdbBtcMoveDownward(pBtc);
|
ret = tdbBtcMoveDownward(pBtc);
|
||||||
|
if (ret < 0) {
|
||||||
|
tdbError("tdb/btc-move-to-prev: btc move downward failed with ret: %d.", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) {
|
if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) {
|
||||||
pBtc->idx = TDB_PAGE_TOTAL_CELLS(pBtc->pPage) - 1;
|
pBtc->idx = TDB_PAGE_TOTAL_CELLS(pBtc->pPage) - 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2162,6 +2227,9 @@ int tdbBtcDelete(SBTC *pBtc) {
|
||||||
bool destroyOfps = false;
|
bool destroyOfps = false;
|
||||||
if (!pBtc->pPage->pPager->ofps) {
|
if (!pBtc->pPage->pPager->ofps) {
|
||||||
pBtc->pPage->pPager->ofps = taosArrayInit(8, sizeof(SPage *));
|
pBtc->pPage->pPager->ofps = taosArrayInit(8, sizeof(SPage *));
|
||||||
|
if (pBtc->pPage->pPager->ofps == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
destroyOfps = true;
|
destroyOfps = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2184,7 +2252,11 @@ int tdbBtcDelete(SBTC *pBtc) {
|
||||||
if (idx == nCells - 1) {
|
if (idx == nCells - 1) {
|
||||||
if (idx) {
|
if (idx) {
|
||||||
pBtc->idx--;
|
pBtc->idx--;
|
||||||
(void)tdbBtcGet(pBtc, &pKey, &nKey, NULL, NULL);
|
ret = tdbBtcGet(pBtc, &pKey, &nKey, NULL, NULL);
|
||||||
|
if (ret) {
|
||||||
|
tdbError("tdb/btc-delete: btc get failed with ret: %d.", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// loop to update the interial page
|
// loop to update the interial page
|
||||||
pgno = TDB_PAGE_PGNO(pBtc->pPage);
|
pgno = TDB_PAGE_PGNO(pBtc->pPage);
|
||||||
|
@ -2432,7 +2504,11 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
|
||||||
|
|
||||||
// compare first cell
|
// compare first cell
|
||||||
pBtc->idx = lidx;
|
pBtc->idx = lidx;
|
||||||
(void)tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL);
|
ret = tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL);
|
||||||
|
if (ret < 0) {
|
||||||
|
tdbError("tdb/btc-move-to: btc get failed with ret: %d.", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
c = pBt->kcmpr(pKey, kLen, pTKey, tkLen);
|
c = pBt->kcmpr(pKey, kLen, pTKey, tkLen);
|
||||||
if (c <= 0) {
|
if (c <= 0) {
|
||||||
ridx = lidx - 1;
|
ridx = lidx - 1;
|
||||||
|
@ -2442,7 +2518,11 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
|
||||||
// compare last cell
|
// compare last cell
|
||||||
if (lidx <= ridx) {
|
if (lidx <= ridx) {
|
||||||
pBtc->idx = ridx;
|
pBtc->idx = ridx;
|
||||||
(void)tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL);
|
ret = tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL);
|
||||||
|
if (ret < 0) {
|
||||||
|
tdbError("tdb/btc-move-to: btc get failed with ret: %d.", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
c = pBt->kcmpr(pKey, kLen, pTKey, tkLen);
|
c = pBt->kcmpr(pKey, kLen, pTKey, tkLen);
|
||||||
if (c >= 0) {
|
if (c >= 0) {
|
||||||
lidx = ridx + 1;
|
lidx = ridx + 1;
|
||||||
|
@ -2457,7 +2537,11 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
|
||||||
if (lidx > ridx) break;
|
if (lidx > ridx) break;
|
||||||
|
|
||||||
pBtc->idx = (lidx + ridx) >> 1;
|
pBtc->idx = (lidx + ridx) >> 1;
|
||||||
(void)tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL);
|
ret = tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL);
|
||||||
|
if (ret < 0) {
|
||||||
|
tdbError("tdb/btc-move-to: btc get failed with ret: %d.", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
c = pBt->kcmpr(pKey, kLen, pTKey, tkLen);
|
c = pBt->kcmpr(pKey, kLen, pTKey, tkLen);
|
||||||
if (c < 0) {
|
if (c < 0) {
|
||||||
// pKey < cd.pKey
|
// pKey < cd.pKey
|
||||||
|
@ -2491,18 +2575,18 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbBtcClose(SBTC *pBtc) {
|
void tdbBtcClose(SBTC *pBtc) {
|
||||||
if (pBtc->iPage < 0) {
|
if (pBtc->iPage < 0) {
|
||||||
if (pBtc->freeTxn) {
|
if (pBtc->freeTxn) {
|
||||||
tdbTxnClose(pBtc->pTxn);
|
tdbTxnClose(pBtc->pTxn);
|
||||||
}
|
}
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (NULL == pBtc->pPage) {
|
if (NULL == pBtc->pPage) {
|
||||||
tdbError("tdb/btc-close: null ptr pPage.");
|
tdbError("tdb/btc-close: null ptr pPage.");
|
||||||
return TSDB_CODE_FAILED;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tdbPagerReturnPage(pBtc->pBt->pPager, pBtc->pPage, pBtc->pTxn);
|
tdbPagerReturnPage(pBtc->pBt->pPager, pBtc->pPage, pBtc->pTxn);
|
||||||
|
@ -2528,7 +2612,7 @@ int tdbBtcClose(SBTC *pBtc) {
|
||||||
tdbTxnClose(pBtc->pTxn);
|
tdbTxnClose(pBtc->pTxn);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbBtcIsValid(SBTC *pBtc) {
|
int tdbBtcIsValid(SBTC *pBtc) {
|
||||||
|
|
|
@ -149,7 +149,7 @@ static int tdbPCacheAlterImpl(SPCache *pCache, int32_t nPage) {
|
||||||
SPage *pPage = *ppPage;
|
SPage *pPage = *ppPage;
|
||||||
*ppPage = pPage->pFreeNext;
|
*ppPage = pPage->pFreeNext;
|
||||||
pCache->aPage[pPage->id] = NULL;
|
pCache->aPage[pPage->id] = NULL;
|
||||||
(void)tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||||
pCache->nFree--;
|
pCache->nFree--;
|
||||||
} else {
|
} else {
|
||||||
ppPage = &(*ppPage)->pFreeNext;
|
ppPage = &(*ppPage)->pFreeNext;
|
||||||
|
@ -209,7 +209,7 @@ static void tdbPCacheFreePage(SPCache *pCache, SPage *pPage) {
|
||||||
tdbTrace("pcache/free2 page: %p/%d, pgno:%d, ", pPage, pPage->id, TDB_PAGE_PGNO(pPage));
|
tdbTrace("pcache/free2 page: %p/%d, pgno:%d, ", pPage, pPage->id, TDB_PAGE_PGNO(pPage));
|
||||||
|
|
||||||
tdbPCacheRemovePageFromHash(pCache, pPage);
|
tdbPCacheRemovePageFromHash(pCache, pPage);
|
||||||
(void)tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ void tdbPCacheRelease(SPCache *pCache, SPage *pPage, TXN *pTxn) {
|
||||||
tdbPCacheRemovePageFromHash(pCache, pPage);
|
tdbPCacheRemovePageFromHash(pCache, pPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)tdbPageDestroy(pPage, pTxn->xFree, pTxn->xArg);
|
tdbPageDestroy(pPage, pTxn->xFree, pTxn->xArg);
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
@ -432,7 +432,7 @@ static void tdbPCacheUnpinPage(SPCache *pCache, SPage *pPage) {
|
||||||
tdbTrace("pcache destroy page: %p/%d/%d", pPage, TDB_PAGE_PGNO(pPage), pPage->id);
|
tdbTrace("pcache destroy page: %p/%d/%d", pPage, TDB_PAGE_PGNO(pPage), pPage->id);
|
||||||
|
|
||||||
tdbPCacheRemovePageFromHash(pCache, pPage);
|
tdbPCacheRemovePageFromHash(pCache, pPage);
|
||||||
(void)tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,14 +518,14 @@ static int tdbPCacheCloseImpl(SPCache *pCache) {
|
||||||
// free free page
|
// free free page
|
||||||
for (SPage *pPage = pCache->pFree; pPage;) {
|
for (SPage *pPage = pCache->pFree; pPage;) {
|
||||||
SPage *pPageT = pPage->pFreeNext;
|
SPage *pPageT = pPage->pFreeNext;
|
||||||
(void)tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||||
pPage = pPageT;
|
pPage = pPageT;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t iBucket = 0; iBucket < pCache->nHash; iBucket++) {
|
for (int32_t iBucket = 0; iBucket < pCache->nHash; iBucket++) {
|
||||||
for (SPage *pPage = pCache->pgHash[iBucket]; pPage;) {
|
for (SPage *pPage = pCache->pgHash[iBucket]; pPage;) {
|
||||||
SPage *pPageT = pPage->pHashNext;
|
SPage *pPageT = pPage->pHashNext;
|
||||||
(void)tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||||
pPage = pPageT;
|
pPage = pPageT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,19 +79,19 @@ int tdbPageCreate(int pageSize, SPage **ppPage, void *(*xMalloc)(void *, size_t)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg) {
|
void tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg) {
|
||||||
u8 *ptr;
|
u8 *ptr;
|
||||||
|
|
||||||
tdbTrace("tdb/page-destroy: %p/%d %p", pPage, pPage->id, xFree);
|
tdbTrace("tdb/page-destroy: %p/%d %p", pPage, pPage->id, xFree);
|
||||||
|
|
||||||
if (pPage->isDirty) {
|
if (pPage->isDirty) {
|
||||||
tdbError("tdb/page-destroy: dirty page: %" PRIu8 ".", pPage->isDirty);
|
tdbError("tdb/page-destroy: dirty page: %" PRIu8 ".", pPage->isDirty);
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xFree) {
|
if (!xFree) {
|
||||||
tdbError("tdb/page-destroy: null xFree.");
|
tdbError("tdb/page-destroy: null xFree.");
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int iOvfl = 0; iOvfl < pPage->nOverflow; iOvfl++) {
|
for (int iOvfl = 0; iOvfl < pPage->nOverflow; iOvfl++) {
|
||||||
|
@ -102,7 +102,7 @@ int tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg)
|
||||||
ptr = pPage->pData;
|
ptr = pPage->pData;
|
||||||
xFree(arg, ptr);
|
xFree(arg, ptr);
|
||||||
|
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdbPageZero(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int, TXN *, SBTree *pBt)) {
|
void tdbPageZero(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int, TXN *, SBTree *pBt)) {
|
||||||
|
@ -156,6 +156,7 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl
|
||||||
int iOvfl;
|
int iOvfl;
|
||||||
int lidx; // local idx
|
int lidx; // local idx
|
||||||
SCell *pNewCell;
|
SCell *pNewCell;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (szCell > TDB_PAGE_MAX_FREE_BLOCK(pPage, pPage->pPageHdr - pPage->pData)) {
|
if (szCell > TDB_PAGE_MAX_FREE_BLOCK(pPage, pPage->pPageHdr - pPage->pData)) {
|
||||||
tdbError("tdb/page-insert-cell: invalid page, szCell: %d, max free: %lu", szCell,
|
tdbError("tdb/page-insert-cell: invalid page, szCell: %d, max free: %lu", szCell,
|
||||||
|
@ -194,7 +195,11 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl
|
||||||
iOvfl++;
|
iOvfl++;
|
||||||
} else {
|
} else {
|
||||||
// page must has enough space to hold the cell locally
|
// page must has enough space to hold the cell locally
|
||||||
(void)tdbPageAllocate(pPage, szCell, &pNewCell);
|
ret = tdbPageAllocate(pPage, szCell, &pNewCell);
|
||||||
|
if (ret) {
|
||||||
|
tdbError("tdb/page-insert-cell: allocate cell failed, idx: %d, szCell: %d", idx, szCell);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(pNewCell, pCell, szCell);
|
memcpy(pNewCell, pCell, szCell);
|
||||||
|
|
||||||
|
@ -220,7 +225,9 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbPageUpdateCell(SPage *pPage, int idx, SCell *pCell, int szCell, TXN *pTxn, SBTree *pBt) {
|
int tdbPageUpdateCell(SPage *pPage, int idx, SCell *pCell, int szCell, TXN *pTxn, SBTree *pBt) {
|
||||||
(void)tdbPageDropCell(pPage, idx, pTxn, pBt);
|
int ret = tdbPageDropCell(pPage, idx, pTxn, pBt);
|
||||||
|
if (ret) return ret;
|
||||||
|
|
||||||
return tdbPageInsertCell(pPage, idx, pCell, szCell, 0);
|
return tdbPageInsertCell(pPage, idx, pCell, szCell, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,6 +237,7 @@ int tdbPageDropCell(SPage *pPage, int idx, TXN *pTxn, SBTree *pBt) {
|
||||||
int szCell;
|
int szCell;
|
||||||
int nCells;
|
int nCells;
|
||||||
int iOvfl;
|
int iOvfl;
|
||||||
|
int ret;
|
||||||
|
|
||||||
nCells = TDB_PAGE_NCELLS(pPage);
|
nCells = TDB_PAGE_NCELLS(pPage);
|
||||||
|
|
||||||
|
@ -259,9 +267,12 @@ int tdbPageDropCell(SPage *pPage, int idx, TXN *pTxn, SBTree *pBt) {
|
||||||
lidx = idx - iOvfl;
|
lidx = idx - iOvfl;
|
||||||
pCell = TDB_PAGE_CELL_AT(pPage, lidx);
|
pCell = TDB_PAGE_CELL_AT(pPage, lidx);
|
||||||
szCell = (*pPage->xCellSize)(pPage, pCell, 1, pTxn, pBt);
|
szCell = (*pPage->xCellSize)(pPage, pCell, 1, pTxn, pBt);
|
||||||
(void)tdbPageFree(pPage, lidx, pCell, szCell);
|
ret = tdbPageFree(pPage, lidx, pCell, szCell);
|
||||||
|
if (ret) {
|
||||||
|
tdbError("tdb/page-drop-cell: free cell failed, idx: %d, lidx: %d, szCell: %d", idx, lidx, szCell);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
TDB_PAGE_NCELLS_SET(pPage, nCells - 1);
|
TDB_PAGE_NCELLS_SET(pPage, nCells - 1);
|
||||||
|
|
||||||
for (; iOvfl < pPage->nOverflow; iOvfl++) {
|
for (; iOvfl < pPage->nOverflow; iOvfl++) {
|
||||||
pPage->aiOvfl[iOvfl]--;
|
pPage->aiOvfl[iOvfl]--;
|
||||||
if (pPage->aiOvfl[iOvfl] <= 0) {
|
if (pPage->aiOvfl[iOvfl] <= 0) {
|
||||||
|
|
|
@ -802,7 +802,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) {
|
||||||
code = tdbTbcMoveToFirst(pCur);
|
code = tdbTbcMoveToFirst(pCur);
|
||||||
if (code) {
|
if (code) {
|
||||||
tdbError("tdb/remove-free-page: moveto first failed with ret: %d.", code);
|
tdbError("tdb/remove-free-page: moveto first failed with ret: %d.", code);
|
||||||
(void)tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -812,7 +812,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) {
|
||||||
code = tdbTbcGet(pCur, (const void **)&pKey, &nKey, NULL, NULL);
|
code = tdbTbcGet(pCur, (const void **)&pKey, &nKey, NULL, NULL);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
// tdbError("tdb/remove-free-page: tbc get failed with ret: %d.", code);
|
// tdbError("tdb/remove-free-page: tbc get failed with ret: %d.", code);
|
||||||
(void)tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -823,10 +823,10 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) {
|
||||||
code = tdbTbcDelete(pCur);
|
code = tdbTbcDelete(pCur);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
tdbError("tdb/remove-free-page: tbc delete failed with ret: %d.", code);
|
tdbError("tdb/remove-free-page: tbc delete failed with ret: %d.", code);
|
||||||
(void)tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
(void)tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1165,14 +1165,14 @@ int tdbPagerRestoreJournals(SPager *pPager) {
|
||||||
code = tdbPagerRestore(pPager, jname);
|
code = tdbPagerRestore(pPager, jname);
|
||||||
if (code) {
|
if (code) {
|
||||||
taosArrayDestroy(pTxnList);
|
taosArrayDestroy(pTxnList);
|
||||||
(void)tdbCloseDir(&pDir);
|
tdbCloseDir(&pDir);
|
||||||
tdbError("failed to restore file due to %s. jFileName:%s", tstrerror(code), jname);
|
tdbError("failed to restore file due to %s. jFileName:%s", tstrerror(code), jname);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pTxnList);
|
taosArrayDestroy(pTxnList);
|
||||||
(void)tdbCloseDir(&pDir);
|
tdbCloseDir(&pDir);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1195,7 +1195,7 @@ int tdbPagerRollback(SPager *pPager) {
|
||||||
jname[dirLen] = '/';
|
jname[dirLen] = '/';
|
||||||
memcpy(jname + dirLen + 1, name, strlen(name));
|
memcpy(jname + dirLen + 1, name, strlen(name));
|
||||||
if (tdbOsRemove(jname) < 0 && errno != ENOENT) {
|
if (tdbOsRemove(jname) < 0 && errno != ENOENT) {
|
||||||
(void)tdbCloseDir(&pDir);
|
tdbCloseDir(&pDir);
|
||||||
|
|
||||||
tdbError("failed to remove file due to %s. jFileName:%s", strerror(errno), name);
|
tdbError("failed to remove file due to %s. jFileName:%s", strerror(errno), name);
|
||||||
return terrno = TAOS_SYSTEM_ERROR(errno);
|
return terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
@ -1203,7 +1203,7 @@ int tdbPagerRollback(SPager *pPager) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)tdbCloseDir(&pDir);
|
tdbCloseDir(&pDir);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF
|
||||||
|
|
||||||
int tdbTbClose(TTB *pTb) {
|
int tdbTbClose(TTB *pTb) {
|
||||||
if (pTb) {
|
if (pTb) {
|
||||||
(void)tdbBtreeClose(pTb->pBt);
|
tdbBtreeClose(pTb->pBt);
|
||||||
tdbOsFree(pTb);
|
tdbOsFree(pTb);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -260,7 +260,7 @@ int32_t tdbTbTraversal(TTB *pTb, void *data,
|
||||||
}
|
}
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pValue);
|
tdbFree(pValue);
|
||||||
(void)tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -293,13 +293,11 @@ int tdbTbcUpsert(TBC *pTbc, const void *pKey, int nKey, const void *pData, int n
|
||||||
return tdbBtcUpsert(&pTbc->btc, pKey, nKey, pData, nData, insert);
|
return tdbBtcUpsert(&pTbc->btc, pKey, nKey, pData, nData, insert);
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbTbcClose(TBC *pTbc) {
|
void tdbTbcClose(TBC *pTbc) {
|
||||||
if (pTbc) {
|
if (pTbc) {
|
||||||
(void)tdbBtcClose(&pTbc->btc);
|
tdbBtcClose(&pTbc->btc);
|
||||||
tdbOsFree(pTbc);
|
tdbOsFree(pTbc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbTbcIsValid(TBC *pTbc) { return tdbBtcIsValid(&pTbc->btc); }
|
int tdbTbcIsValid(TBC *pTbc) { return tdbBtcIsValid(&pTbc->btc); }
|
||||||
|
|
|
@ -27,17 +27,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
extern int32_t tdbDebugFlag;
|
|
||||||
|
|
||||||
#define tdbFatal(...) do { if (tdbDebugFlag & DEBUG_FATAL) { taosPrintLog("TDB FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while(0)
|
|
||||||
#define tdbError(...) do { if (tdbDebugFlag & DEBUG_ERROR) { taosPrintLog("TDB ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while(0)
|
|
||||||
#define tdbWarn(...) do { if (tdbDebugFlag & DEBUG_WARN) { taosPrintLog("TDB WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while(0)
|
|
||||||
#define tdbInfo(...) do { if (tdbDebugFlag & DEBUG_INFO) { taosPrintLog("TDB ", DEBUG_INFO, 255, __VA_ARGS__); }} while(0)
|
|
||||||
#define tdbDebug(...) do { if (tdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("TDB ", DEBUG_DEBUG, tdbDebugFlag, __VA_ARGS__); }} while(0)
|
|
||||||
#define tdbTrace(...) do { if (tdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TDB ", DEBUG_TRACE, tdbDebugFlag, __VA_ARGS__); }} while(0)
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
typedef int8_t i8;
|
typedef int8_t i8;
|
||||||
typedef int16_t i16;
|
typedef int16_t i16;
|
||||||
typedef int32_t i32;
|
typedef int32_t i32;
|
||||||
|
@ -156,11 +145,11 @@ struct SBTC {
|
||||||
};
|
};
|
||||||
|
|
||||||
// SBTree
|
// SBTree
|
||||||
int tdbBtreeOpen(int keyLen, int valLen, SPager *pFile, char const *tbname, SPgno pgno, tdb_cmpr_fn_t kcmpr, TDB *pEnv,
|
int tdbBtreeOpen(int keyLen, int valLen, SPager *pFile, char const *tbname, SPgno pgno, tdb_cmpr_fn_t kcmpr, TDB *pEnv,
|
||||||
SBTree **ppBt);
|
SBTree **ppBt);
|
||||||
int tdbBtreeClose(SBTree *pBt);
|
void tdbBtreeClose(SBTree *pBt);
|
||||||
int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, int vLen, TXN *pTxn);
|
int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, int vLen, TXN *pTxn);
|
||||||
int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn);
|
int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn);
|
||||||
// int tdbBtreeUpsert(SBTree *pBt, const void *pKey, int nKey, const void *pData, int nData, TXN *pTxn);
|
// int tdbBtreeUpsert(SBTree *pBt, const void *pKey, int nKey, const void *pData, int nData, TXN *pTxn);
|
||||||
int tdbBtreeGet(SBTree *pBt, const void *pKey, int kLen, void **ppVal, int *vLen);
|
int tdbBtreeGet(SBTree *pBt, const void *pKey, int kLen, void **ppVal, int *vLen);
|
||||||
int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkLen, void **ppVal, int *vLen);
|
int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkLen, void **ppVal, int *vLen);
|
||||||
|
@ -173,19 +162,19 @@ typedef struct {
|
||||||
int tdbBtreeInitPage(SPage *pPage, void *arg, int init);
|
int tdbBtreeInitPage(SPage *pPage, void *arg, int init);
|
||||||
|
|
||||||
// SBTC
|
// SBTC
|
||||||
int tdbBtcOpen(SBTC *pBtc, SBTree *pBt, TXN *pTxn);
|
int tdbBtcOpen(SBTC *pBtc, SBTree *pBt, TXN *pTxn);
|
||||||
int tdbBtcClose(SBTC *pBtc);
|
void tdbBtcClose(SBTC *pBtc);
|
||||||
int tdbBtcIsValid(SBTC *pBtc);
|
int tdbBtcIsValid(SBTC *pBtc);
|
||||||
int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst);
|
int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst);
|
||||||
int tdbBtcMoveToFirst(SBTC *pBtc);
|
int tdbBtcMoveToFirst(SBTC *pBtc);
|
||||||
int tdbBtcMoveToLast(SBTC *pBtc);
|
int tdbBtcMoveToLast(SBTC *pBtc);
|
||||||
int tdbBtcMoveToNext(SBTC *pBtc);
|
int tdbBtcMoveToNext(SBTC *pBtc);
|
||||||
int tdbBtcMoveToPrev(SBTC *pBtc);
|
int tdbBtcMoveToPrev(SBTC *pBtc);
|
||||||
int tdbBtreeNext(SBTC *pBtc, void **ppKey, int *kLen, void **ppVal, int *vLen);
|
int tdbBtreeNext(SBTC *pBtc, void **ppKey, int *kLen, void **ppVal, int *vLen);
|
||||||
int tdbBtreePrev(SBTC *pBtc, void **ppKey, int *kLen, void **ppVal, int *vLen);
|
int tdbBtreePrev(SBTC *pBtc, void **ppKey, int *kLen, void **ppVal, int *vLen);
|
||||||
int tdbBtcGet(SBTC *pBtc, const void **ppKey, int *kLen, const void **ppVal, int *vLen);
|
int tdbBtcGet(SBTC *pBtc, const void **ppKey, int *kLen, const void **ppVal, int *vLen);
|
||||||
int tdbBtcDelete(SBTC *pBtc);
|
int tdbBtcDelete(SBTC *pBtc);
|
||||||
int tdbBtcUpsert(SBTC *pBtc, const void *pKey, int kLen, const void *pData, int nData, int insert);
|
int tdbBtcUpsert(SBTC *pBtc, const void *pKey, int kLen, const void *pData, int nData, int insert);
|
||||||
|
|
||||||
// tdbPager.c ====================================
|
// tdbPager.c ====================================
|
||||||
|
|
||||||
|
@ -339,7 +328,7 @@ static inline int tdbTryLockPage(tdb_spinlock_t *pLock) {
|
||||||
#define TDB_PAGE_OFFSET_SIZE(pPage) ((pPage)->pPageMethods->szOffset)
|
#define TDB_PAGE_OFFSET_SIZE(pPage) ((pPage)->pPageMethods->szOffset)
|
||||||
|
|
||||||
int tdbPageCreate(int pageSize, SPage **ppPage, void *(*xMalloc)(void *, size_t), void *arg);
|
int tdbPageCreate(int pageSize, SPage **ppPage, void *(*xMalloc)(void *, size_t), void *arg);
|
||||||
int tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg);
|
void tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg);
|
||||||
void tdbPageZero(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int, TXN *, SBTree *pBt));
|
void tdbPageZero(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int, TXN *, SBTree *pBt));
|
||||||
void tdbPageInit(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int, TXN *, SBTree *pBt));
|
void tdbPageInit(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int, TXN *, SBTree *pBt));
|
||||||
int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl);
|
int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl);
|
||||||
|
|
|
@ -27,6 +27,17 @@ extern "C" {
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "thash.h"
|
#include "thash.h"
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
extern int32_t tdbDebugFlag;
|
||||||
|
|
||||||
|
#define tdbFatal(...) do { if (tdbDebugFlag & DEBUG_FATAL) { taosPrintLog("TDB FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while(0)
|
||||||
|
#define tdbError(...) do { if (tdbDebugFlag & DEBUG_ERROR) { taosPrintLog("TDB ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while(0)
|
||||||
|
#define tdbWarn(...) do { if (tdbDebugFlag & DEBUG_WARN) { taosPrintLog("TDB WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while(0)
|
||||||
|
#define tdbInfo(...) do { if (tdbDebugFlag & DEBUG_INFO) { taosPrintLog("TDB ", DEBUG_INFO, 255, __VA_ARGS__); }} while(0)
|
||||||
|
#define tdbDebug(...) do { if (tdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("TDB ", DEBUG_DEBUG, tdbDebugFlag, __VA_ARGS__); }} while(0)
|
||||||
|
#define tdbTrace(...) do { if (tdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TDB ", DEBUG_TRACE, tdbDebugFlag, __VA_ARGS__); }} while(0)
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
// For memory -----------------
|
// For memory -----------------
|
||||||
#define tdbOsMalloc taosMemoryMalloc
|
#define tdbOsMalloc taosMemoryMalloc
|
||||||
#define tdbOsCalloc taosMemoryCalloc
|
#define tdbOsCalloc taosMemoryCalloc
|
||||||
|
@ -59,9 +70,16 @@ typedef TdFilePtr tdb_fd_t;
|
||||||
#define tdbReadDir taosReadDir
|
#define tdbReadDir taosReadDir
|
||||||
#define tdbGetDirEntryName taosGetDirEntryName
|
#define tdbGetDirEntryName taosGetDirEntryName
|
||||||
#define tdbDirEntryBaseName taosDirEntryBaseName
|
#define tdbDirEntryBaseName taosDirEntryBaseName
|
||||||
#define tdbCloseDir taosCloseDir
|
|
||||||
#define tdbOsRemove remove
|
static FORCE_INLINE void tdbCloseDir(TdDirPtr *ppDir) {
|
||||||
#define tdbOsFileSize(FD, PSIZE) taosFStatFile(FD, PSIZE, NULL)
|
int32_t ret = taosCloseDir(ppDir);
|
||||||
|
if (ret) {
|
||||||
|
tdbError("failed to close directory, reason:%s", tstrerror(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define tdbOsRemove remove
|
||||||
|
#define tdbOsFileSize(FD, PSIZE) taosFStatFile(FD, PSIZE, NULL)
|
||||||
|
|
||||||
/* directory */
|
/* directory */
|
||||||
#define tdbOsMkdir taosMkDir
|
#define tdbOsMkdir taosMkDir
|
||||||
|
|
Loading…
Reference in New Issue