From 94de43c53d90ad319fa49b338fc0f8fd02c3c550 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 8 Feb 2022 17:18:08 +0800 Subject: [PATCH] update stb --- include/common/tmsg.h | 8 ++-- source/dnode/mnode/impl/src/mndStb.c | 54 ++++++++++++------------ source/dnode/mnode/impl/test/stb/stb.cpp | 10 ++--- source/libs/parser/src/astToMsg.c | 2 +- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index bf00b97d13..d248b5471f 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -254,7 +254,7 @@ typedef struct { int8_t igExists; int32_t numOfTags; int32_t numOfColumns; - SSchema pSchema[]; + SSchema pSchemas[]; } SMCreateStbReq; typedef struct { @@ -264,9 +264,9 @@ typedef struct { typedef struct { char name[TSDB_TABLE_FNAME_LEN]; - int8_t alterType; - int32_t numOfColumns; - SSchema pSchema[]; + int8_t updateType; + int32_t numOfSchemas; + SSchema pSchemas[]; } SMUpdateStbReq; typedef struct { diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index ede212b5e2..ded8e2d9a0 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -33,10 +33,10 @@ static int32_t mndStbActionInsert(SSdb *pSdb, SStbObj *pStb); static int32_t mndStbActionDelete(SSdb *pSdb, SStbObj *pStb); static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew); static int32_t mndProcessMCreateStbReq(SMnodeMsg *pReq); -static int32_t mndProcessMAlterStbReq(SMnodeMsg *pReq); +static int32_t mndProcessMUpdateStbReq(SMnodeMsg *pReq); static int32_t mndProcessMDropStbReq(SMnodeMsg *pReq); static int32_t mndProcessVCreateStbRsp(SMnodeMsg *pRsp); -static int32_t mndProcessVAlterStbRsp(SMnodeMsg *pRsp); +static int32_t mndProcessVUpdateStbRsp(SMnodeMsg *pRsp); static int32_t mndProcessVDropStbRsp(SMnodeMsg *pRsp); static int32_t mndProcessStbMetaReq(SMnodeMsg *pReq); static int32_t mndGetStbMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta); @@ -53,10 +53,10 @@ int32_t mndInitStb(SMnode *pMnode) { .deleteFp = (SdbDeleteFp)mndStbActionDelete}; mndSetMsgHandle(pMnode, TDMT_MND_CREATE_STB, mndProcessMCreateStbReq); - mndSetMsgHandle(pMnode, TDMT_MND_ALTER_STB, mndProcessMAlterStbReq); + mndSetMsgHandle(pMnode, TDMT_MND_ALTER_STB, mndProcessMUpdateStbReq); mndSetMsgHandle(pMnode, TDMT_MND_DROP_STB, mndProcessMDropStbReq); mndSetMsgHandle(pMnode, TDMT_VND_CREATE_STB_RSP, mndProcessVCreateStbRsp); - mndSetMsgHandle(pMnode, TDMT_VND_ALTER_STB_RSP, mndProcessVAlterStbRsp); + mndSetMsgHandle(pMnode, TDMT_VND_ALTER_STB_RSP, mndProcessVUpdateStbRsp); mndSetMsgHandle(pMnode, TDMT_VND_DROP_STB_RSP, mndProcessVDropStbRsp); mndSetMsgHandle(pMnode, TDMT_MND_STB_META, mndProcessStbMetaReq); @@ -325,7 +325,7 @@ static int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate) { pCreate->numOfTags = htonl(pCreate->numOfTags); int32_t totalCols = pCreate->numOfColumns + pCreate->numOfTags; for (int32_t i = 0; i < totalCols; ++i) { - SSchema *pSchema = &pCreate->pSchema[i]; + SSchema *pSchema = &pCreate->pSchemas[i]; pSchema->bytes = htonl(pSchema->bytes); } @@ -346,7 +346,7 @@ static int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate) { int32_t maxColId = (TSDB_MAX_COLUMNS + TSDB_MAX_TAGS); for (int32_t i = 0; i < totalCols; ++i) { - SSchema *pSchema = &pCreate->pSchema[i]; + SSchema *pSchema = &pCreate->pSchemas[i]; if (pSchema->type < 0) { terrno = TSDB_CODE_MND_INVALID_STB_OPTION; return -1; @@ -483,8 +483,8 @@ static int32_t mndCreateStb(SMnode *pMnode, SMnodeMsg *pReq, SMCreateStbReq *pCr return -1; } - memcpy(stbObj.pColumns, pCreate->pSchema, stbObj.numOfColumns * sizeof(SSchema)); - memcpy(stbObj.pTags, pCreate->pSchema + stbObj.numOfColumns, stbObj.numOfTags * sizeof(SSchema)); + memcpy(stbObj.pColumns, pCreate->pSchemas, stbObj.numOfColumns * sizeof(SSchema)); + memcpy(stbObj.pTags, pCreate->pSchemas + stbObj.numOfColumns, stbObj.numOfTags * sizeof(SSchema)); for (int32_t i = 0; i < stbObj.numOfColumns; ++i) { stbObj.pColumns[i].colId = stbObj.nextColId; @@ -575,11 +575,11 @@ static int32_t mndProcessVCreateStbRsp(SMnodeMsg *pRsp) { return 0; } -static int32_t mndCheckAlterStbReq(SMUpdateStbReq *pUpdate) { - pUpdate->numOfColumns = htonl(pUpdate->numOfColumns); +static int32_t mndCheckUpdateStbReq(SMUpdateStbReq *pUpdate) { + pUpdate->numOfSchemas = htonl(pUpdate->numOfSchemas); - for (int32_t i = 0; i < pUpdate->numOfColumns; ++i) { - SSchema *pSchema = &pUpdate->pSchema[i]; + for (int32_t i = 0; i < pUpdate->numOfSchemas; ++i) { + SSchema *pSchema = &pUpdate->pSchemas[i]; pSchema->colId = htonl(pSchema->colId); pSchema->bytes = htonl(pSchema->bytes); @@ -916,27 +916,27 @@ static int32_t mndUpdateStb(SMnode *pMnode, SMnodeMsg *pReq, const SMUpdateStbRe int32_t code = -1; - switch (pUpdate->alterType) { + switch (pUpdate->updateType) { case TSDB_ALTER_TABLE_ADD_TAG_COLUMN: - code = mndAddSuperTableTag(pOld, &stbObj, pUpdate->pSchema, 1); + code = mndAddSuperTableTag(pOld, &stbObj, pUpdate->pSchemas, 1); break; case TSDB_ALTER_TABLE_DROP_TAG_COLUMN: - code = mndDropSuperTableTag(pOld, &stbObj, pUpdate->pSchema[0].name); + code = mndDropSuperTableTag(pOld, &stbObj, pUpdate->pSchemas[0].name); break; case TSDB_ALTER_TABLE_UPDATE_TAG_NAME: - code = mndUpdateStbTagName(pOld, &stbObj, pUpdate->pSchema[0].name, pUpdate->pSchema[1].name); + code = mndUpdateStbTagName(pOld, &stbObj, pUpdate->pSchemas[0].name, pUpdate->pSchemas[1].name); break; case TSDB_ALTER_TABLE_UPDATE_TAG_BYTES: - code = mndUpdateStbTagBytes(pOld, &stbObj, &pUpdate->pSchema[0]); + code = mndUpdateStbTagBytes(pOld, &stbObj, &pUpdate->pSchemas[0]); break; case TSDB_ALTER_TABLE_ADD_COLUMN: - code = mndAddSuperTableColumn(pOld, &stbObj, pUpdate->pSchema, 1); + code = mndAddSuperTableColumn(pOld, &stbObj, pUpdate->pSchemas, 1); break; case TSDB_ALTER_TABLE_DROP_COLUMN: - code = mndDropSuperTableColumn(pOld, &stbObj, pUpdate->pSchema[0].name); + code = mndDropSuperTableColumn(pOld, &stbObj, pUpdate->pSchemas[0].name); break; case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES: - code = mndUpdateStbColumnBytes(pOld, &stbObj, &pUpdate->pSchema[0]); + code = mndUpdateStbColumnBytes(pOld, &stbObj, &pUpdate->pSchemas[0]); break; default: terrno = TSDB_CODE_MND_INVALID_STB_OPTION; @@ -965,21 +965,21 @@ UPDATE_STB_OVER: return code; } -static int32_t mndProcessMAlterStbReq(SMnodeMsg *pReq) { +static int32_t mndProcessMUpdateStbReq(SMnodeMsg *pReq) { SMnode *pMnode = pReq->pMnode; SMUpdateStbReq *pUpdate = pReq->rpcMsg.pCont; - mDebug("stb:%s, start to alter", pUpdate->name); + mDebug("stb:%s, start to update", pUpdate->name); - if (mndCheckAlterStbReq(pUpdate) != 0) { - mError("stb:%s, failed to alter since %s", pUpdate->name, terrstr()); + if (mndCheckUpdateStbReq(pUpdate) != 0) { + mError("stb:%s, failed to update since %s", pUpdate->name, terrstr()); return -1; } SStbObj *pStb = mndAcquireStb(pMnode, pUpdate->name); if (pStb == NULL) { terrno = TSDB_CODE_MND_STB_NOT_EXIST; - mError("stb:%s, failed to alter since %s", pUpdate->name, terrstr()); + mError("stb:%s, failed to update since %s", pUpdate->name, terrstr()); return -1; } @@ -995,14 +995,14 @@ static int32_t mndProcessMAlterStbReq(SMnodeMsg *pReq) { mndReleaseStb(pMnode, pStb); if (code != 0) { - mError("stb:%s, failed to alter since %s", pUpdate->name, tstrerror(code)); + mError("stb:%s, failed to update since %s", pUpdate->name, tstrerror(code)); return code; } return TSDB_CODE_MND_ACTION_IN_PROGRESS; } -static int32_t mndProcessVAlterStbRsp(SMnodeMsg *pRsp) { +static int32_t mndProcessVUpdateStbRsp(SMnodeMsg *pRsp) { mndTransProcessRsp(pRsp); return 0; } diff --git a/source/dnode/mnode/impl/test/stb/stb.cpp b/source/dnode/mnode/impl/test/stb/stb.cpp index a0e2460334..d6577e5e40 100644 --- a/source/dnode/mnode/impl/test/stb/stb.cpp +++ b/source/dnode/mnode/impl/test/stb/stb.cpp @@ -67,35 +67,35 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { pReq->numOfColumns = htonl(cols); { - SSchema* pSchema = &pReq->pSchema[0]; + SSchema* pSchema = &pReq->pSchemas[0]; pSchema->bytes = htonl(8); pSchema->type = TSDB_DATA_TYPE_TIMESTAMP; strcpy(pSchema->name, "ts"); } { - SSchema* pSchema = &pReq->pSchema[1]; + SSchema* pSchema = &pReq->pSchemas[1]; pSchema->bytes = htonl(4); pSchema->type = TSDB_DATA_TYPE_INT; strcpy(pSchema->name, "col1"); } { - SSchema* pSchema = &pReq->pSchema[2]; + SSchema* pSchema = &pReq->pSchemas[2]; pSchema->bytes = htonl(2); pSchema->type = TSDB_DATA_TYPE_TINYINT; strcpy(pSchema->name, "tag1"); } { - SSchema* pSchema = &pReq->pSchema[3]; + SSchema* pSchema = &pReq->pSchemas[3]; pSchema->bytes = htonl(8); pSchema->type = TSDB_DATA_TYPE_BIGINT; strcpy(pSchema->name, "tag2"); } { - SSchema* pSchema = &pReq->pSchema[4]; + SSchema* pSchema = &pReq->pSchemas[4]; pSchema->bytes = htonl(16); pSchema->type = TSDB_DATA_TYPE_BINARY; strcpy(pSchema->name, "tag3"); diff --git a/source/libs/parser/src/astToMsg.c b/source/libs/parser/src/astToMsg.c index 697fd0c4cb..c7a1fd26a0 100644 --- a/source/libs/parser/src/astToMsg.c +++ b/source/libs/parser/src/astToMsg.c @@ -310,7 +310,7 @@ SMCreateStbReq* buildCreateStbMsg(SCreateTableSql* pCreateTableSql, int32_t* len pCreateStbMsg->numOfColumns = htonl(numOfCols); pCreateStbMsg->numOfTags = htonl(numOfTags); - pSchema = (SSchema*)pCreateStbMsg->pSchema; + pSchema = (SSchema*)pCreateStbMsg->pSchemas; for (int i = 0; i < numOfCols; ++i) { SField* pField = taosArrayGet(pCreateTableSql->colInfo.pColumns, i); pSchema->type = pField->type;