From b1241e5e0d2ab59fe9e166e6eb5ae9b320ddd684 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Fri, 6 Jan 2023 14:08:10 +0800 Subject: [PATCH] dynamic add/del idx --- source/dnode/mnode/impl/src/mndStb.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index d331655d96..4dcf475120 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -2631,7 +2631,19 @@ static int32_t mndCheckIndexReq(SCreateTagIndexReq *pReq) { int32_t mndAddIndexImpl(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb, bool needRsp, void *sql, int32_t len) { // impl later - return TSDB_CODE_SUCCESS; + int32_t code = -1; + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq, "create-stb-index"); + if (pTrans == NULL) goto _OVER; + + mInfo("trans:%d, used to add index to stb:%s", pTrans->id, pStb->name); + mndTransSetDbName(pTrans, pDb->name, pStb->name); + if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER; + + return code; + +_OVER: + mndTransDrop(pTrans); + return code; } static int32_t mndAddIndex(SMnode *pMnode, SRpcMsg *pReq, SCreateTagIndexReq *tagIdxReq, SDbObj *pDb, SStbObj *pOld) { bool needRsp = true;