From 9040eabe45571bbd3211ecc894dd3de6fbd42b89 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 16 May 2022 13:03:39 +0000 Subject: [PATCH] more alter table --- source/dnode/vnode/src/meta/metaTable.c | 43 +++++++++++++++++-------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index d218f49e14..063c6a9eb1 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -572,30 +572,45 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA tDecoderClear(&dc); /* get stbEntry*/ + tdbDbGet(pMeta->pUidIdx, &ctbEntry.ctbEntry.suid, sizeof(tb_uid_t), &pVal, &nVal); + tdbDbGet(pMeta->pTbDb, &((STbDbKey){.uid = ctbEntry.ctbEntry.suid, .version = *(int64_t *)pVal}), sizeof(STbDbKey), + (void **)&stbEntry.pBuf, &nVal); + tdbFree(pVal); + tDecoderInit(&dc, stbEntry.pBuf, nVal); + metaDecodeEntry(&dc, &stbEntry); + tDecoderClear(&dc); - { - // get table entry - // SDecoder dc = {0}; - // tDecoderInit(&dc, pData, nData); - // metaDecodeEntry(&dc, &ctbEntry); + SSchemaWrapper *pTagSchema = &stbEntry.stbEntry.schemaTag; + SColumn *pColumn = NULL; + int32_t iCol = 0; + for (;;) { + pColumn = NULL; - // if (ctbEntry.type != TSDB_CHILD_TABLE) { - // terrno = TSDB_CODE_VND_INVALID_TABLE_ACTION; - // goto _err; - // } + if (iCol >= pTagSchema->nCols) break; + pColumn = &pTagSchema->pSchema[iCol]; - // // do actual job - // { - // // TODO - // } + if (strcmp(pColumn->name, pAlterTbReq->tagName) == 0) break; + iCol++; } - // tDecoderClear(&dc); + if (pColumn == NULL) { + terrno = TSDB_CODE_VND_TABLE_COL_NOT_EXISTS; + goto _err; + } + + { + // TODO: + } + + if (ctbEntry.pBuf) taosMemoryFree(ctbEntry.pBuf); + if (stbEntry.pBuf) tdbFree(stbEntry.pBuf); tdbDbcClose(pTbDbc); tdbDbcClose(pUidIdxc); return 0; _err: + if (ctbEntry.pBuf) taosMemoryFree(ctbEntry.pBuf); + if (stbEntry.pBuf) tdbFree(stbEntry.pBuf); tdbDbcClose(pTbDbc); tdbDbcClose(pUidIdxc); return -1;