drop table code
This commit is contained in:
parent
8d9cc366cf
commit
ac0fb0237e
|
@ -26,6 +26,7 @@ extern "C" {
|
||||||
typedef struct SSkipList2 SSkipList2;
|
typedef struct SSkipList2 SSkipList2;
|
||||||
typedef struct SSLCursor SSLCursor;
|
typedef struct SSLCursor SSLCursor;
|
||||||
typedef struct SSLCfg SSLCfg;
|
typedef struct SSLCfg SSLCfg;
|
||||||
|
typedef struct SSLNode SSLNode;
|
||||||
|
|
||||||
typedef int32_t (*tslCmprFn)(const void *pKey1, int32_t nKey1, const void *pKey2, int32_t nKey2);
|
typedef int32_t (*tslCmprFn)(const void *pKey1, int32_t nKey1, const void *pKey2, int32_t nKey2);
|
||||||
|
|
||||||
|
|
|
@ -103,8 +103,6 @@ typedef struct {
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
|
||||||
// int metaCreateTable(SMeta* pMeta, STbCfg* pTbCfg, STbDdlH* pHandle);
|
|
||||||
int metaDropTable(SMeta* pMeta, tb_uid_t uid);
|
|
||||||
SMSmaCursor* metaOpenSmaCursor(SMeta* pMeta, tb_uid_t uid);
|
SMSmaCursor* metaOpenSmaCursor(SMeta* pMeta, tb_uid_t uid);
|
||||||
void metaCloseSmaCursor(SMSmaCursor* pSmaCur);
|
void metaCloseSmaCursor(SMSmaCursor* pSmaCur);
|
||||||
int64_t metaSmaCursorNext(SMSmaCursor* pSmaCur);
|
int64_t metaSmaCursorNext(SMSmaCursor* pSmaCur);
|
||||||
|
|
|
@ -77,6 +77,7 @@ int metaCommit(SMeta* pMeta);
|
||||||
int metaCreateSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
int metaCreateSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
||||||
int metaDropSTable(SMeta* pMeta, int64_t verison, SVDropStbReq* pReq);
|
int metaDropSTable(SMeta* pMeta, int64_t verison, SVDropStbReq* pReq);
|
||||||
int metaCreateTable(SMeta* pMeta, int64_t version, SVCreateTbReq* pReq);
|
int metaCreateTable(SMeta* pMeta, int64_t version, SVCreateTbReq* pReq);
|
||||||
|
int metaDropTable(SMeta* pMeta, int64_t version, SVDropTbReq* pReq);
|
||||||
SSchemaWrapper* metaGetTableSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver, bool isinline);
|
SSchemaWrapper* metaGetTableSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver, bool isinline);
|
||||||
STSchema* metaGetTbTSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver);
|
STSchema* metaGetTbTSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver);
|
||||||
int metaGetTableEntryByName(SMetaReader* pReader, const char* name);
|
int metaGetTableEntryByName(SMetaReader* pReader, const char* name);
|
||||||
|
@ -189,7 +190,6 @@ struct STbUidStore {
|
||||||
|
|
||||||
#define TD_VID(PVNODE) (PVNODE)->config.vgId
|
#define TD_VID(PVNODE) (PVNODE)->config.vgId
|
||||||
|
|
||||||
|
|
||||||
static FORCE_INLINE bool vnodeIsRollup(SVnode* pVnode) {
|
static FORCE_INLINE bool vnodeIsRollup(SVnode* pVnode) {
|
||||||
SRetention* pRetention = &(pVnode->config.tsdbCfg.retentions[0]);
|
SRetention* pRetention = &(pVnode->config.tsdbCfg.retentions[0]);
|
||||||
return (pRetention->freq > 0 && pRetention->keep > 0);
|
return (pRetention->freq > 0 && pRetention->keep > 0);
|
||||||
|
|
|
@ -98,7 +98,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq) {
|
||||||
// ret = tdbDbcOpen(pMeta->pCtbIdx, &pDbc1);
|
// ret = tdbDbcOpen(pMeta->pCtbIdx, &pDbc1);
|
||||||
// tdbDbcMoveTo(pDbc1, &pReq->suid, sizeof(pReq->suid), NULL /*cmpr*/, 0 /*TDB_FORWARD_SEARCH*/);
|
// tdbDbcMoveTo(pDbc1, &pReq->suid, sizeof(pReq->suid), NULL /*cmpr*/, 0 /*TDB_FORWARD_SEARCH*/);
|
||||||
// tdbDbcGet(pDbc1, &pKey, &kLen, &pVal, vLen);
|
// tdbDbcGet(pDbc1, &pKey, &kLen, &pVal, vLen);
|
||||||
// tdbDbcDrop(pDbc1);
|
// tdbDbcDelete(pDbc1);
|
||||||
// // drop from pTagIdx
|
// // drop from pTagIdx
|
||||||
// // drop from pTtlIdx
|
// // drop from pTtlIdx
|
||||||
// }
|
// }
|
||||||
|
@ -166,18 +166,79 @@ _err:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaDropTable(SMeta *pMeta, tb_uid_t uid) {
|
int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq) {
|
||||||
#if 0
|
TDBC *pTbDbc = NULL;
|
||||||
if (metaRemoveTableFromIdx(pMeta, uid) < 0) {
|
TDBC *pUidIdxc = NULL;
|
||||||
// TODO: handle error
|
TDBC *pNameIdxc = NULL;
|
||||||
|
const void *pData;
|
||||||
|
int nData;
|
||||||
|
tb_uid_t uid;
|
||||||
|
int64_t tver;
|
||||||
|
SMetaEntry me = {0};
|
||||||
|
SCoder coder = {0};
|
||||||
|
int c, ret;
|
||||||
|
|
||||||
|
// search & delete the name idx
|
||||||
|
tdbDbcOpen(pMeta->pNameIdx, &pNameIdxc, &pMeta->txn);
|
||||||
|
ret = tdbDbcMoveTo(pNameIdxc, pReq->name, strlen(pReq->name) + 1, &c);
|
||||||
|
if (ret < 0 || c) {
|
||||||
|
tdbDbcClose(pNameIdxc);
|
||||||
|
terrno = TSDB_CODE_VND_TABLE_NOT_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metaRemoveTableFromIdx(pMeta, uid) < 0) {
|
ret = tdbDbcGet(pNameIdxc, NULL, NULL, &pData, &nData);
|
||||||
// TODO
|
if (ret < 0) {
|
||||||
|
ASSERT(0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
uid = *(tb_uid_t *)pData;
|
||||||
|
|
||||||
|
tdbDbcDelete(pNameIdxc);
|
||||||
|
tdbDbcClose(pNameIdxc);
|
||||||
|
|
||||||
|
// search & delete uid idx
|
||||||
|
tdbDbcOpen(pMeta->pUidIdx, &pUidIdxc, &pMeta->txn);
|
||||||
|
ret = tdbDbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||||
|
if (ret < 0 || c != 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = tdbDbcGet(pUidIdxc, NULL, NULL, &pData, &nData);
|
||||||
|
if (ret < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tver = *(int64_t *)pData;
|
||||||
|
tdbDbcDelete(pUidIdxc);
|
||||||
|
tdbDbcClose(pUidIdxc);
|
||||||
|
|
||||||
|
// search and get meta entry
|
||||||
|
tdbDbcOpen(pMeta->pTbDb, &pTbDbc, &pMeta->txn);
|
||||||
|
ret = tdbDbcMoveTo(pTbDbc, &(STbDbKey){.uid = uid, .version = tver}, sizeof(STbDbKey), &c);
|
||||||
|
if (ret < 0 || c != 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = tdbDbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||||
|
if (ret < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// tCoderInit(&coder, TD_LITTLE_ENDIAN, pData, nData, TD_DECODER);
|
||||||
|
// ret = metaDecodeEntry(&coder, &me);
|
||||||
|
// if (ret < 0) {
|
||||||
|
// ASSERT(0);
|
||||||
|
// return -1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
tCoderClear(&coder);
|
||||||
|
tdbDbcClose(pTbDbc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -445,14 +445,45 @@ static int vnodeProcessAlterTbReq(SVnode *pVnode, void *pReq, int32_t len, SRpcM
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||||
SVDropTbReq req = {0};
|
SVDropTbBatchReq req = {0};
|
||||||
SVDropTbReq rsp = {0};
|
SVDropTbBatchRsp rsp = {0};
|
||||||
|
SCoder coder = {0};
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
pRsp->msgType = TDMT_VND_CREATE_STB_RSP;
|
||||||
|
pRsp->pCont = NULL;
|
||||||
|
pRsp->contLen = 0;
|
||||||
|
pRsp->code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
// decode req
|
// decode req
|
||||||
|
tCoderInit(&coder, TD_LITTLE_ENDIAN, pReq, len, TD_DECODER);
|
||||||
|
ret = tDecodeSVDropTbBatchReq(&coder, &req);
|
||||||
|
if (ret < 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
pRsp->code = terrno;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
// process req
|
// process req
|
||||||
|
rsp.pArray = taosArrayInit(sizeof(SVDropTbRsp), req.nReqs);
|
||||||
|
for (int iReq = 0; iReq < req.nReqs; iReq++) {
|
||||||
|
SVDropTbReq *pDropTbReq = req.pReqs + iReq;
|
||||||
|
SVDropTbRsp dropTbRsp = {0};
|
||||||
|
|
||||||
// return rsp
|
/* code */
|
||||||
|
ret = metaDropTable(pVnode->pMeta, version, pDropTbReq);
|
||||||
|
if (ret < 0) {
|
||||||
|
dropTbRsp.code = TSDB_CODE_SUCCESS;
|
||||||
|
} else {
|
||||||
|
dropTbRsp.code = terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayPush(rsp.pArray, &dropTbRsp);
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
tCoderClear(&coder);
|
||||||
|
// encode rsp (TODO)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ int tdbDbcGet(TDBC *pDbc, const void **ppKey, int *pkLen, const void **ppVal, in
|
||||||
|
|
||||||
int tdbDbcPut(TDBC *pDbc, const void *pKey, int keyLen, const void *pVal, int valLen);
|
int tdbDbcPut(TDBC *pDbc, const void *pKey, int keyLen, const void *pVal, int valLen);
|
||||||
int tdbDbcUpdate(TDBC *pDbc, const void *pKey, int kLen, const void *pVal, int vLen);
|
int tdbDbcUpdate(TDBC *pDbc, const void *pKey, int kLen, const void *pVal, int vLen);
|
||||||
int tdbDbcDrop(TDBC *pDbc);
|
int tdbDbcDelete(TDBC *pDbc);
|
||||||
int tdbDbcNext(TDBC *pDbc, void **ppKey, int *kLen, void **ppVal, int *vLen);
|
int tdbDbcNext(TDBC *pDbc, void **ppKey, int *kLen, void **ppVal, int *vLen);
|
||||||
|
|
||||||
// TXN
|
// TXN
|
||||||
|
|
|
@ -1394,7 +1394,7 @@ int tdbBtcGet(SBTC *pBtc, const void **ppKey, int *kLen, const void **ppVal, int
|
||||||
|
|
||||||
if (ppVal) {
|
if (ppVal) {
|
||||||
*ppVal = (void *)pBtc->coder.pVal;
|
*ppVal = (void *)pBtc->coder.pVal;
|
||||||
*kLen = pBtc->coder.vLen;
|
*vLen = pBtc->coder.vLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -136,11 +136,7 @@ int tdbDbcUpdate(TDBC *pDbc, const void *pKey, int kLen, const void *pVal, int v
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbDbcDrop(TDBC *pDbc) {
|
int tdbDbcDelete(TDBC *pDbc) { return tdbBtcDelete(&pDbc->btc); }
|
||||||
// TODO
|
|
||||||
ASSERT(0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tdbDbcNext(TDBC *pDbc, void **ppKey, int *kLen, void **ppVal, int *vLen) {
|
int tdbDbcNext(TDBC *pDbc, void **ppKey, int *kLen, void **ppVal, int *vLen) {
|
||||||
return tdbBtreeNext(&pDbc->btc, ppKey, kLen, ppVal, vLen);
|
return tdbBtreeNext(&pDbc->btc, ppKey, kLen, ppVal, vLen);
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
#include "tskiplist2.h"
|
#include "tskiplist2.h"
|
||||||
|
|
||||||
typedef struct SSLNode SSLNode;
|
|
||||||
struct SSLNode {
|
struct SSLNode {
|
||||||
int8_t level;
|
int8_t level;
|
||||||
SSLNode *forwards[];
|
SSLNode *forwards[];
|
||||||
|
|
Loading…
Reference in New Issue