diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 4431a2c48bf81ff9f4d46e377774ce44be4b3bc3..f7eac3a9d90e3a2672d142b4f1b7f6250d24fcec 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -196,6 +196,8 @@ struct SMetaEntry { STSma *tsma; } smaEntry; }; + + uint8_t *pBuf; }; struct SMetaReader { diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 2c260531da38a73ab7062581971c94e1ef281529..d218f49e142d886053d17d2505dfccfbf6407dbe 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -523,7 +523,8 @@ _err: } static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq) { - SMetaEntry entry = {0}; + SMetaEntry ctbEntry = {0}; + SMetaEntry stbEntry = {0}; void *pVal = NULL; int nVal = 0; int ret; @@ -555,35 +556,46 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA oversion = *(int64_t *)pData; // search table.db - TDBC *pTbDbc = NULL; + TDBC *pTbDbc = NULL; + SDecoder dc = {0}; + /* get ctbEntry */ tdbDbcOpen(pMeta->pTbDb, &pTbDbc, &pMeta->txn); tdbDbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c); ASSERT(c == 0); tdbDbcGet(pTbDbc, NULL, NULL, &pData, &nData); - // get table entry - SDecoder dc = {0}; - tDecoderInit(&dc, pData, nData); - metaDecodeEntry(&dc, &entry); + ctbEntry.pBuf = taosMemoryMalloc(nData); + memcpy(ctbEntry.pBuf, pData, nData); + tDecoderInit(&dc, ctbEntry.pBuf, nData); + metaDecodeEntry(&dc, &ctbEntry); + tDecoderClear(&dc); - if (entry.type != TSDB_CHILD_TABLE) { - terrno = TSDB_CODE_VND_INVALID_TABLE_ACTION; - goto _err; - } + /* get stbEntry*/ - // do actual job { - // TODO + // get table entry + // SDecoder dc = {0}; + // tDecoderInit(&dc, pData, nData); + // metaDecodeEntry(&dc, &ctbEntry); + + // if (ctbEntry.type != TSDB_CHILD_TABLE) { + // terrno = TSDB_CODE_VND_INVALID_TABLE_ACTION; + // goto _err; + // } + + // // do actual job + // { + // // TODO + // } } - tDecoderClear(&dc); + // tDecoderClear(&dc); tdbDbcClose(pTbDbc); tdbDbcClose(pUidIdxc); return 0; _err: - tDecoderClear(&dc); tdbDbcClose(pTbDbc); tdbDbcClose(pUidIdxc); return -1; diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 43d68fc9fdf90f58fa895909e50e385491d90ff7..43ff04a2876a79229a3cdb3774d57343c580225b 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -199,7 +199,7 @@ void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) { int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { int32_t ret = TAOS_SYNC_PROPOSE_OTHER_ERROR; - + if (syncEnvIsStart()) { SSyncNode *pSyncNode = syncNodeAcquire(pVnode->sync); assert(pSyncNode != NULL); @@ -462,7 +462,11 @@ _exit: static int vnodeProcessAlterTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) { SVAlterTbReq vAlterTbReq = {0}; + SVAlterTbRsp vAlterTbRsp = {0}; SDecoder dc = {0}; + int rcode = 0; + int ret; + SEncoder ec = {0}; pRsp->msgType = TDMT_VND_ALTER_TABLE_RSP; pRsp->pCont = NULL; @@ -473,19 +477,27 @@ static int vnodeProcessAlterTbReq(SVnode *pVnode, int64_t version, void *pReq, i // decode if (tDecodeSVAlterTbReq(&dc, &vAlterTbReq) < 0) { - pRsp->code = TSDB_CODE_INVALID_MSG; + vAlterTbRsp.code = TSDB_CODE_INVALID_MSG; tDecoderClear(&dc); - return -1; + rcode = -1; + goto _exit; } // process if (metaAlterTable(pVnode->pMeta, version, &vAlterTbReq) < 0) { - pRsp->code = terrno; + vAlterTbRsp.code = TSDB_CODE_INVALID_MSG; tDecoderClear(&dc); - return -1; + rcode = -1; + goto _exit; } - tDecoderClear(&dc); + +_exit: + tEncodeSize(tEncodeSVAlterTbRsp, &vAlterTbRsp, pRsp->contLen, ret); + pRsp->pCont = rpcMallocCont(pRsp->contLen); + tEncoderInit(&ec, pRsp->pCont, pRsp->contLen); + tEncodeSVAlterTbRsp(&ec, &vAlterTbRsp); + tEncoderClear(&ec); return 0; }