提交 821b9ea4 编写于 作者: S Shengliang Guan

minor changes

上级 bcad6bb5
...@@ -345,18 +345,18 @@ typedef struct { ...@@ -345,18 +345,18 @@ typedef struct {
int32_t maxStreams; int32_t maxStreams;
int32_t accessState; // Configured only by command int32_t accessState; // Configured only by command
int64_t maxStorage; // In unit of GB int64_t maxStorage; // In unit of GB
} SCreateAcctMsg, SAlterAcctMsg; } SCreateAcctReq, SAlterAcctReq;
typedef struct { typedef struct {
char user[TSDB_USER_LEN]; char user[TSDB_USER_LEN];
} SDropUserMsg, SDropAcctMsg; } SDropUserReq, SDropAcctReq;
typedef struct { typedef struct {
int8_t type; int8_t type;
char user[TSDB_USER_LEN]; char user[TSDB_USER_LEN];
char pass[TSDB_PASSWORD_LEN]; char pass[TSDB_PASSWORD_LEN];
int8_t superUser; // denote if it is a super user or not int8_t superUser; // denote if it is a super user or not
} SCreateUserMsg, SAlterUserMsg; } SCreateUserReq, SAlterUserReq;
typedef struct { typedef struct {
int32_t contLen; int32_t contLen;
......
...@@ -25,10 +25,10 @@ static SSdbRaw *mndAcctActionEncode(SAcctObj *pAcct); ...@@ -25,10 +25,10 @@ static SSdbRaw *mndAcctActionEncode(SAcctObj *pAcct);
static SSdbRow *mndAcctActionDecode(SSdbRaw *pRaw); static SSdbRow *mndAcctActionDecode(SSdbRaw *pRaw);
static int32_t mndAcctActionInsert(SSdb *pSdb, SAcctObj *pAcct); static int32_t mndAcctActionInsert(SSdb *pSdb, SAcctObj *pAcct);
static int32_t mndAcctActionDelete(SSdb *pSdb, SAcctObj *pAcct); static int32_t mndAcctActionDelete(SSdb *pSdb, SAcctObj *pAcct);
static int32_t mndAcctActionUpdate(SSdb *pSdb, SAcctObj *pOldAcct, SAcctObj *pNewAcct); static int32_t mndAcctActionUpdate(SSdb *pSdb, SAcctObj *pOld, SAcctObj *pNew);
static int32_t mndProcessCreateAcctMsg(SMnodeMsg *pMnodeMsg); static int32_t mndProcessCreateAcctReq(SMnodeMsg *pMsg);
static int32_t mndProcessAlterAcctMsg(SMnodeMsg *pMnodeMsg); static int32_t mndProcessAlterAcctReq(SMnodeMsg *pMsg);
static int32_t mndProcessDropAcctMsg(SMnodeMsg *pMnodeMsg); static int32_t mndProcessDropAcctReq(SMnodeMsg *pMsg);
int32_t mndInitAcct(SMnode *pMnode) { int32_t mndInitAcct(SMnode *pMnode) {
SSdbTable table = {.sdbType = SDB_ACCT, SSdbTable table = {.sdbType = SDB_ACCT,
...@@ -40,9 +40,9 @@ int32_t mndInitAcct(SMnode *pMnode) { ...@@ -40,9 +40,9 @@ int32_t mndInitAcct(SMnode *pMnode) {
.updateFp = (SdbUpdateFp)mndAcctActionUpdate, .updateFp = (SdbUpdateFp)mndAcctActionUpdate,
.deleteFp = (SdbDeleteFp)mndAcctActionDelete}; .deleteFp = (SdbDeleteFp)mndAcctActionDelete};
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_ACCT, mndProcessCreateAcctMsg); mndSetMsgHandle(pMnode, TDMT_MND_CREATE_ACCT, mndProcessCreateAcctReq);
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_ACCT, mndProcessAlterAcctMsg); mndSetMsgHandle(pMnode, TDMT_MND_ALTER_ACCT, mndProcessAlterAcctReq);
mndSetMsgHandle(pMnode, TDMT_MND_DROP_ACCT, mndProcessDropAcctMsg); mndSetMsgHandle(pMnode, TDMT_MND_DROP_ACCT, mndProcessDropAcctReq);
return sdbSetTable(pMnode->pSdb, table); return sdbSetTable(pMnode->pSdb, table);
} }
...@@ -176,29 +176,29 @@ static int32_t mndAcctActionDelete(SSdb *pSdb, SAcctObj *pAcct) { ...@@ -176,29 +176,29 @@ static int32_t mndAcctActionDelete(SSdb *pSdb, SAcctObj *pAcct) {
return 0; return 0;
} }
static int32_t mndAcctActionUpdate(SSdb *pSdb, SAcctObj *pOldAcct, SAcctObj *pNewAcct) { static int32_t mndAcctActionUpdate(SSdb *pSdb, SAcctObj *pOld, SAcctObj *pNew) {
mTrace("acct:%s, perform update action, old_row:%p new_row:%p", pOldAcct->acct, pOldAcct, pNewAcct); mTrace("acct:%s, perform update action, old_row:%p new_row:%p", pOld->acct, pOld, pNew);
pOldAcct->updateTime = pNewAcct->updateTime; pOld->updateTime = pNew->updateTime;
pOldAcct->status = pNewAcct->status; pOld->status = pNew->status;
memcpy(&pOldAcct->cfg, &pNewAcct->cfg, sizeof(SAcctCfg)); memcpy(&pOld->cfg, &pNew->cfg, sizeof(SAcctCfg));
return 0; return 0;
} }
static int32_t mndProcessCreateAcctMsg(SMnodeMsg *pMnodeMsg) { static int32_t mndProcessCreateAcctReq(SMnodeMsg *pMsg) {
terrno = TSDB_CODE_MND_MSG_NOT_PROCESSED; terrno = TSDB_CODE_MND_MSG_NOT_PROCESSED;
mError("failed to process create acct msg since %s", terrstr()); mError("failed to process create acct request since %s", terrstr());
return -1; return -1;
} }
static int32_t mndProcessAlterAcctMsg(SMnodeMsg *pMnodeMsg) { static int32_t mndProcessAlterAcctReq(SMnodeMsg *pMsg) {
terrno = TSDB_CODE_MND_MSG_NOT_PROCESSED; terrno = TSDB_CODE_MND_MSG_NOT_PROCESSED;
mError("failed to process create acct msg since %s", terrstr()); mError("failed to process create acct request since %s", terrstr());
return -1; return -1;
} }
static int32_t mndProcessDropAcctMsg(SMnodeMsg *pMnodeMsg) { static int32_t mndProcessDropAcctReq(SMnodeMsg *pMsg) {
terrno = TSDB_CODE_MND_MSG_NOT_PROCESSED; terrno = TSDB_CODE_MND_MSG_NOT_PROCESSED;
mError("failed to process create acct msg since %s", terrstr()); mError("failed to process create acct request since %s", terrstr());
return -1; return -1;
} }
\ No newline at end of file
...@@ -28,11 +28,11 @@ static SSdbRaw *mndUserActionEncode(SUserObj *pUser); ...@@ -28,11 +28,11 @@ static SSdbRaw *mndUserActionEncode(SUserObj *pUser);
static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw); static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw);
static int32_t mndUserActionInsert(SSdb *pSdb, SUserObj *pUser); static int32_t mndUserActionInsert(SSdb *pSdb, SUserObj *pUser);
static int32_t mndUserActionDelete(SSdb *pSdb, SUserObj *pUser); static int32_t mndUserActionDelete(SSdb *pSdb, SUserObj *pUser);
static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pOldUser, SUserObj *pNewUser); static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pOld, SUserObj *pNew);
static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass, SMnodeMsg *pMsg); static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass, SMnodeMsg *pMsg);
static int32_t mndProcessCreateUserMsg(SMnodeMsg *pMsg); static int32_t mndProcessCreateUserReq(SMnodeMsg *pMsg);
static int32_t mndProcessAlterUserMsg(SMnodeMsg *pMsg); static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg);
static int32_t mndProcessDropUserMsg(SMnodeMsg *pMsg); static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg);
static int32_t mndGetUserMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta); static int32_t mndGetUserMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta);
static int32_t mndRetrieveUsers(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows); static int32_t mndRetrieveUsers(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows);
static void mndCancelGetNextUser(SMnode *pMnode, void *pIter); static void mndCancelGetNextUser(SMnode *pMnode, void *pIter);
...@@ -47,9 +47,9 @@ int32_t mndInitUser(SMnode *pMnode) { ...@@ -47,9 +47,9 @@ int32_t mndInitUser(SMnode *pMnode) {
.updateFp = (SdbUpdateFp)mndUserActionUpdate, .updateFp = (SdbUpdateFp)mndUserActionUpdate,
.deleteFp = (SdbDeleteFp)mndUserActionDelete}; .deleteFp = (SdbDeleteFp)mndUserActionDelete};
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_USER, mndProcessCreateUserMsg); mndSetMsgHandle(pMnode, TDMT_MND_CREATE_USER, mndProcessCreateUserReq);
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_USER, mndProcessAlterUserMsg); mndSetMsgHandle(pMnode, TDMT_MND_ALTER_USER, mndProcessAlterUserReq);
mndSetMsgHandle(pMnode, TDMT_MND_DROP_USER, mndProcessDropUserMsg); mndSetMsgHandle(pMnode, TDMT_MND_DROP_USER, mndProcessDropUserReq);
mndAddShowMetaHandle(pMnode, TSDB_MGMT_TABLE_USER, mndGetUserMeta); mndAddShowMetaHandle(pMnode, TSDB_MGMT_TABLE_USER, mndGetUserMeta);
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_USER, mndRetrieveUsers); mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_USER, mndRetrieveUsers);
...@@ -192,10 +192,10 @@ static int32_t mndUserActionDelete(SSdb *pSdb, SUserObj *pUser) { ...@@ -192,10 +192,10 @@ static int32_t mndUserActionDelete(SSdb *pSdb, SUserObj *pUser) {
return 0; return 0;
} }
static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pOldUser, SUserObj *pNewUser) { static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pOld, SUserObj *pNew) {
mTrace("user:%s, perform update action, old_row:%p new_row:%p", pOldUser->user, pOldUser, pNewUser); mTrace("user:%s, perform update action, old_row:%p new_row:%p", pOld->user, pOld, pNew);
memcpy(pOldUser->pass, pNewUser->pass, TSDB_PASSWORD_LEN); memcpy(pOld->pass, pNew->pass, TSDB_PASSWORD_LEN);
pOldUser->updateTime = pNewUser->updateTime; pOld->updateTime = pNew->updateTime;
return 0; return 0;
} }
...@@ -247,9 +247,9 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass, ...@@ -247,9 +247,9 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass,
return 0; return 0;
} }
static int32_t mndProcessCreateUserMsg(SMnodeMsg *pMsg) { static int32_t mndProcessCreateUserReq(SMnodeMsg *pMsg) {
SMnode *pMnode = pMsg->pMnode; SMnode *pMnode = pMsg->pMnode;
SCreateUserMsg *pCreate = pMsg->rpcMsg.pCont; SCreateUserReq *pCreate = pMsg->rpcMsg.pCont;
mDebug("user:%s, start to create", pCreate->user); mDebug("user:%s, start to create", pCreate->user);
...@@ -291,15 +291,15 @@ static int32_t mndProcessCreateUserMsg(SMnodeMsg *pMsg) { ...@@ -291,15 +291,15 @@ static int32_t mndProcessCreateUserMsg(SMnodeMsg *pMsg) {
return TSDB_CODE_MND_ACTION_IN_PROGRESS; return TSDB_CODE_MND_ACTION_IN_PROGRESS;
} }
static int32_t mndUpdateUser(SMnode *pMnode, SUserObj *pOldUser, SUserObj *pNewUser, SMnodeMsg *pMsg) { static int32_t mndUpdateUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SMnodeMsg *pMsg) {
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg); STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg);
if (pTrans == NULL) { if (pTrans == NULL) {
mError("user:%s, failed to update since %s", pOldUser->user, terrstr()); mError("user:%s, failed to update since %s", pOld->user, terrstr());
return -1; return -1;
} }
mDebug("trans:%d, used to update user:%s", pTrans->id, pOldUser->user); mDebug("trans:%d, used to update user:%s", pTrans->id, pOld->user);
SSdbRaw *pRedoRaw = mndUserActionEncode(pNewUser); SSdbRaw *pRedoRaw = mndUserActionEncode(pNew);
if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) { if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) {
mError("trans:%d, failed to append redo log since %s", pTrans->id, terrstr()); mError("trans:%d, failed to append redo log since %s", pTrans->id, terrstr());
mndTransDrop(pTrans); mndTransDrop(pTrans);
...@@ -317,9 +317,9 @@ static int32_t mndUpdateUser(SMnode *pMnode, SUserObj *pOldUser, SUserObj *pNewU ...@@ -317,9 +317,9 @@ static int32_t mndUpdateUser(SMnode *pMnode, SUserObj *pOldUser, SUserObj *pNewU
return 0; return 0;
} }
static int32_t mndProcessAlterUserMsg(SMnodeMsg *pMsg) { static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg) {
SMnode *pMnode = pMsg->pMnode; SMnode *pMnode = pMsg->pMnode;
SAlterUserMsg *pAlter = pMsg->rpcMsg.pCont; SAlterUserReq *pAlter = pMsg->rpcMsg.pCont;
mDebug("user:%s, start to alter", pAlter->user); mDebug("user:%s, start to alter", pAlter->user);
...@@ -394,9 +394,9 @@ static int32_t mndDropUser(SMnode *pMnode, SMnodeMsg *pMsg, SUserObj *pUser) { ...@@ -394,9 +394,9 @@ static int32_t mndDropUser(SMnode *pMnode, SMnodeMsg *pMsg, SUserObj *pUser) {
return 0; return 0;
} }
static int32_t mndProcessDropUserMsg(SMnodeMsg *pMsg) { static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg) {
SMnode *pMnode = pMsg->pMnode; SMnode *pMnode = pMsg->pMnode;
SDropUserMsg *pDrop = pMsg->rpcMsg.pCont; SDropUserReq *pDrop = pMsg->rpcMsg.pCont;
mDebug("user:%s, start to drop", pDrop->user); mDebug("user:%s, start to drop", pDrop->user);
......
...@@ -26,9 +26,9 @@ class DndTestAcct : public ::testing::Test { ...@@ -26,9 +26,9 @@ class DndTestAcct : public ::testing::Test {
Testbase DndTestAcct::test; Testbase DndTestAcct::test;
TEST_F(DndTestAcct, 01_CreateAcct) { TEST_F(DndTestAcct, 01_CreateAcct) {
int32_t contLen = sizeof(SCreateAcctMsg); int32_t contLen = sizeof(SCreateAcctReq);
SCreateAcctMsg* pReq = (SCreateAcctMsg*)rpcMallocCont(contLen); SCreateAcctReq* pReq = (SCreateAcctReq*)rpcMallocCont(contLen);
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_ACCT, pReq, contLen); SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_ACCT, pReq, contLen);
ASSERT_NE(pMsg, nullptr); ASSERT_NE(pMsg, nullptr);
...@@ -36,9 +36,9 @@ TEST_F(DndTestAcct, 01_CreateAcct) { ...@@ -36,9 +36,9 @@ TEST_F(DndTestAcct, 01_CreateAcct) {
} }
TEST_F(DndTestAcct, 02_AlterAcct) { TEST_F(DndTestAcct, 02_AlterAcct) {
int32_t contLen = sizeof(SCreateAcctMsg); int32_t contLen = sizeof(SCreateAcctReq);
SAlterAcctMsg* pReq = (SAlterAcctMsg*)rpcMallocCont(contLen); SAlterAcctReq* pReq = (SAlterAcctReq*)rpcMallocCont(contLen);
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_ALTER_ACCT, pReq, contLen); SRpcMsg* pMsg = test.SendMsg(TDMT_MND_ALTER_ACCT, pReq, contLen);
ASSERT_NE(pMsg, nullptr); ASSERT_NE(pMsg, nullptr);
...@@ -46,9 +46,9 @@ TEST_F(DndTestAcct, 02_AlterAcct) { ...@@ -46,9 +46,9 @@ TEST_F(DndTestAcct, 02_AlterAcct) {
} }
TEST_F(DndTestAcct, 03_DropAcct) { TEST_F(DndTestAcct, 03_DropAcct) {
int32_t contLen = sizeof(SDropAcctMsg); int32_t contLen = sizeof(SDropAcctReq);
SDropAcctMsg* pReq = (SDropAcctMsg*)rpcMallocCont(contLen); SDropAcctReq* pReq = (SDropAcctReq*)rpcMallocCont(contLen);
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_ACCT, pReq, contLen); SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_ACCT, pReq, contLen);
ASSERT_NE(pMsg, nullptr); ASSERT_NE(pMsg, nullptr);
......
...@@ -52,9 +52,9 @@ Testbase DndTestTrans::test; ...@@ -52,9 +52,9 @@ Testbase DndTestTrans::test;
TEST_F(DndTestTrans, 01_CreateUser_Crash) { TEST_F(DndTestTrans, 01_CreateUser_Crash) {
{ {
int32_t contLen = sizeof(SCreateUserMsg); int32_t contLen = sizeof(SCreateUserReq);
SCreateUserMsg* pReq = (SCreateUserMsg*)rpcMallocCont(contLen); SCreateUserReq* pReq = (SCreateUserReq*)rpcMallocCont(contLen);
strcpy(pReq->user, "u1"); strcpy(pReq->user, "u1");
strcpy(pReq->pass, "p1"); strcpy(pReq->pass, "p1");
......
...@@ -45,9 +45,9 @@ TEST_F(DndTestUser, 01_ShowUser) { ...@@ -45,9 +45,9 @@ TEST_F(DndTestUser, 01_ShowUser) {
TEST_F(DndTestUser, 02_Create_User) { TEST_F(DndTestUser, 02_Create_User) {
{ {
int32_t contLen = sizeof(SCreateUserMsg); int32_t contLen = sizeof(SCreateUserReq);
SCreateUserMsg* pReq = (SCreateUserMsg*)rpcMallocCont(contLen); SCreateUserReq* pReq = (SCreateUserReq*)rpcMallocCont(contLen);
strcpy(pReq->user, ""); strcpy(pReq->user, "");
strcpy(pReq->pass, "p1"); strcpy(pReq->pass, "p1");
...@@ -57,9 +57,9 @@ TEST_F(DndTestUser, 02_Create_User) { ...@@ -57,9 +57,9 @@ TEST_F(DndTestUser, 02_Create_User) {
} }
{ {
int32_t contLen = sizeof(SCreateUserMsg); int32_t contLen = sizeof(SCreateUserReq);
SCreateUserMsg* pReq = (SCreateUserMsg*)rpcMallocCont(contLen); SCreateUserReq* pReq = (SCreateUserReq*)rpcMallocCont(contLen);
strcpy(pReq->user, "u1"); strcpy(pReq->user, "u1");
strcpy(pReq->pass, ""); strcpy(pReq->pass, "");
...@@ -69,9 +69,9 @@ TEST_F(DndTestUser, 02_Create_User) { ...@@ -69,9 +69,9 @@ TEST_F(DndTestUser, 02_Create_User) {
} }
{ {
int32_t contLen = sizeof(SCreateUserMsg); int32_t contLen = sizeof(SCreateUserReq);
SCreateUserMsg* pReq = (SCreateUserMsg*)rpcMallocCont(contLen); SCreateUserReq* pReq = (SCreateUserReq*)rpcMallocCont(contLen);
strcpy(pReq->user, "root"); strcpy(pReq->user, "root");
strcpy(pReq->pass, "1"); strcpy(pReq->pass, "1");
...@@ -81,9 +81,9 @@ TEST_F(DndTestUser, 02_Create_User) { ...@@ -81,9 +81,9 @@ TEST_F(DndTestUser, 02_Create_User) {
} }
{ {
int32_t contLen = sizeof(SCreateUserMsg); int32_t contLen = sizeof(SCreateUserReq);
SCreateUserMsg* pReq = (SCreateUserMsg*)rpcMallocCont(contLen); SCreateUserReq* pReq = (SCreateUserReq*)rpcMallocCont(contLen);
strcpy(pReq->user, "u1"); strcpy(pReq->user, "u1");
strcpy(pReq->pass, "p1"); strcpy(pReq->pass, "p1");
...@@ -101,9 +101,9 @@ TEST_F(DndTestUser, 02_Create_User) { ...@@ -101,9 +101,9 @@ TEST_F(DndTestUser, 02_Create_User) {
TEST_F(DndTestUser, 03_Alter_User) { TEST_F(DndTestUser, 03_Alter_User) {
{ {
int32_t contLen = sizeof(SAlterUserMsg); int32_t contLen = sizeof(SAlterUserReq);
SAlterUserMsg* pReq = (SAlterUserMsg*)rpcMallocCont(contLen); SAlterUserReq* pReq = (SAlterUserReq*)rpcMallocCont(contLen);
strcpy(pReq->user, ""); strcpy(pReq->user, "");
strcpy(pReq->pass, "p1"); strcpy(pReq->pass, "p1");
...@@ -113,9 +113,9 @@ TEST_F(DndTestUser, 03_Alter_User) { ...@@ -113,9 +113,9 @@ TEST_F(DndTestUser, 03_Alter_User) {
} }
{ {
int32_t contLen = sizeof(SAlterUserMsg); int32_t contLen = sizeof(SAlterUserReq);
SAlterUserMsg* pReq = (SAlterUserMsg*)rpcMallocCont(contLen); SAlterUserReq* pReq = (SAlterUserReq*)rpcMallocCont(contLen);
strcpy(pReq->user, "u1"); strcpy(pReq->user, "u1");
strcpy(pReq->pass, ""); strcpy(pReq->pass, "");
...@@ -125,9 +125,9 @@ TEST_F(DndTestUser, 03_Alter_User) { ...@@ -125,9 +125,9 @@ TEST_F(DndTestUser, 03_Alter_User) {
} }
{ {
int32_t contLen = sizeof(SAlterUserMsg); int32_t contLen = sizeof(SAlterUserReq);
SAlterUserMsg* pReq = (SAlterUserMsg*)rpcMallocCont(contLen); SAlterUserReq* pReq = (SAlterUserReq*)rpcMallocCont(contLen);
strcpy(pReq->user, "u4"); strcpy(pReq->user, "u4");
strcpy(pReq->pass, "1"); strcpy(pReq->pass, "1");
...@@ -137,9 +137,9 @@ TEST_F(DndTestUser, 03_Alter_User) { ...@@ -137,9 +137,9 @@ TEST_F(DndTestUser, 03_Alter_User) {
} }
{ {
int32_t contLen = sizeof(SAlterUserMsg); int32_t contLen = sizeof(SAlterUserReq);
SAlterUserMsg* pReq = (SAlterUserMsg*)rpcMallocCont(contLen); SAlterUserReq* pReq = (SAlterUserReq*)rpcMallocCont(contLen);
strcpy(pReq->user, "u1"); strcpy(pReq->user, "u1");
strcpy(pReq->pass, "1"); strcpy(pReq->pass, "1");
...@@ -151,9 +151,9 @@ TEST_F(DndTestUser, 03_Alter_User) { ...@@ -151,9 +151,9 @@ TEST_F(DndTestUser, 03_Alter_User) {
TEST_F(DndTestUser, 04_Drop_User) { TEST_F(DndTestUser, 04_Drop_User) {
{ {
int32_t contLen = sizeof(SDropUserMsg); int32_t contLen = sizeof(SDropUserReq);
SDropUserMsg* pReq = (SDropUserMsg*)rpcMallocCont(contLen); SDropUserReq* pReq = (SDropUserReq*)rpcMallocCont(contLen);
strcpy(pReq->user, ""); strcpy(pReq->user, "");
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_USER, pReq, contLen); SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_USER, pReq, contLen);
...@@ -162,9 +162,9 @@ TEST_F(DndTestUser, 04_Drop_User) { ...@@ -162,9 +162,9 @@ TEST_F(DndTestUser, 04_Drop_User) {
} }
{ {
int32_t contLen = sizeof(SDropUserMsg); int32_t contLen = sizeof(SDropUserReq);
SDropUserMsg* pReq = (SDropUserMsg*)rpcMallocCont(contLen); SDropUserReq* pReq = (SDropUserReq*)rpcMallocCont(contLen);
strcpy(pReq->user, "u4"); strcpy(pReq->user, "u4");
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_USER, pReq, contLen); SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_USER, pReq, contLen);
...@@ -173,9 +173,9 @@ TEST_F(DndTestUser, 04_Drop_User) { ...@@ -173,9 +173,9 @@ TEST_F(DndTestUser, 04_Drop_User) {
} }
{ {
int32_t contLen = sizeof(SDropUserMsg); int32_t contLen = sizeof(SDropUserReq);
SDropUserMsg* pReq = (SDropUserMsg*)rpcMallocCont(contLen); SDropUserReq* pReq = (SDropUserReq*)rpcMallocCont(contLen);
strcpy(pReq->user, "u1"); strcpy(pReq->user, "u1");
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_USER, pReq, contLen); SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_USER, pReq, contLen);
...@@ -192,9 +192,9 @@ TEST_F(DndTestUser, 04_Drop_User) { ...@@ -192,9 +192,9 @@ TEST_F(DndTestUser, 04_Drop_User) {
TEST_F(DndTestUser, 05_Create_Drop_Alter_User) { TEST_F(DndTestUser, 05_Create_Drop_Alter_User) {
{ {
int32_t contLen = sizeof(SCreateUserMsg); int32_t contLen = sizeof(SCreateUserReq);
SCreateUserMsg* pReq = (SCreateUserMsg*)rpcMallocCont(contLen); SCreateUserReq* pReq = (SCreateUserReq*)rpcMallocCont(contLen);
strcpy(pReq->user, "u1"); strcpy(pReq->user, "u1");
strcpy(pReq->pass, "p1"); strcpy(pReq->pass, "p1");
...@@ -204,9 +204,9 @@ TEST_F(DndTestUser, 05_Create_Drop_Alter_User) { ...@@ -204,9 +204,9 @@ TEST_F(DndTestUser, 05_Create_Drop_Alter_User) {
} }
{ {
int32_t contLen = sizeof(SCreateUserMsg); int32_t contLen = sizeof(SCreateUserReq);
SCreateUserMsg* pReq = (SCreateUserMsg*)rpcMallocCont(contLen); SCreateUserReq* pReq = (SCreateUserReq*)rpcMallocCont(contLen);
strcpy(pReq->user, "u2"); strcpy(pReq->user, "u2");
strcpy(pReq->pass, "p2"); strcpy(pReq->pass, "p2");
...@@ -235,9 +235,9 @@ TEST_F(DndTestUser, 05_Create_Drop_Alter_User) { ...@@ -235,9 +235,9 @@ TEST_F(DndTestUser, 05_Create_Drop_Alter_User) {
CheckBinary("root", TSDB_USER_LEN); CheckBinary("root", TSDB_USER_LEN);
{ {
int32_t contLen = sizeof(SAlterUserMsg); int32_t contLen = sizeof(SAlterUserReq);
SAlterUserMsg* pReq = (SAlterUserMsg*)rpcMallocCont(contLen); SAlterUserReq* pReq = (SAlterUserReq*)rpcMallocCont(contLen);
strcpy(pReq->user, "u1"); strcpy(pReq->user, "u1");
strcpy(pReq->pass, "p2"); strcpy(pReq->pass, "p2");
...@@ -266,9 +266,9 @@ TEST_F(DndTestUser, 05_Create_Drop_Alter_User) { ...@@ -266,9 +266,9 @@ TEST_F(DndTestUser, 05_Create_Drop_Alter_User) {
CheckBinary("root", TSDB_USER_LEN); CheckBinary("root", TSDB_USER_LEN);
{ {
int32_t contLen = sizeof(SDropUserMsg); int32_t contLen = sizeof(SDropUserReq);
SDropUserMsg* pReq = (SDropUserMsg*)rpcMallocCont(contLen); SDropUserReq* pReq = (SDropUserReq*)rpcMallocCont(contLen);
strcpy(pReq->user, "u1"); strcpy(pReq->user, "u1");
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_USER, pReq, contLen); SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_USER, pReq, contLen);
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
#include "tmsg.h" #include "tmsg.h"
SCreateUserMsg* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen); SCreateUserReq* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen);
SCreateAcctMsg* buildAcctManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen); SCreateAcctReq* buildAcctManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen);
SDropUserMsg* buildDropUserMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen); SDropUserReq* buildDropUserMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen);
SShowMsg* buildShowMsg(SShowInfo* pShowInfo, SParseBasicCtx* pParseCtx, char* msgBuf, int32_t msgLen); SShowMsg* buildShowMsg(SShowInfo* pShowInfo, SParseBasicCtx* pParseCtx, char* msgBuf, int32_t msgLen);
SCreateDbMsg* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, SParseBasicCtx *pCtx, SMsgBuf* pMsgBuf); SCreateDbMsg* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, SParseBasicCtx *pCtx, SMsgBuf* pMsgBuf);
SCreateStbMsg* buildCreateTableMsg(SCreateTableSql* pCreateTableSql, int32_t* len, SParseBasicCtx* pParseCtx, SMsgBuf* pMsgBuf); SCreateStbMsg* buildCreateTableMsg(SCreateTableSql* pCreateTableSql, int32_t* len, SParseBasicCtx* pParseCtx, SMsgBuf* pMsgBuf);
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
#include "astGenerator.h" #include "astGenerator.h"
#include "parserUtil.h" #include "parserUtil.h"
SCreateUserMsg* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen) { SCreateUserReq* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen) {
SCreateUserMsg* pMsg = (SCreateUserMsg*)calloc(1, sizeof(SCreateUserMsg)); SCreateUserReq* pMsg = (SCreateUserReq*)calloc(1, sizeof(SCreateUserReq));
if (pMsg == NULL) { if (pMsg == NULL) {
// tscError("0x%" PRIx64 " failed to malloc for query msg", id); // tscError("0x%" PRIx64 " failed to malloc for query msg", id);
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
...@@ -25,8 +25,8 @@ SCreateUserMsg* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, in ...@@ -25,8 +25,8 @@ SCreateUserMsg* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, in
return pMsg; return pMsg;
} }
SCreateAcctMsg* buildAcctManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen) { SCreateAcctReq* buildAcctManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen) {
SCreateAcctMsg *pCreateMsg = (SCreateAcctMsg *) calloc(1, sizeof(SCreateAcctMsg)); SCreateAcctReq *pCreateMsg = (SCreateAcctReq *) calloc(1, sizeof(SCreateAcctReq));
if (pCreateMsg == NULL) { if (pCreateMsg == NULL) {
qError("0x%" PRIx64 " failed to malloc for query msg", id); qError("0x%" PRIx64 " failed to malloc for query msg", id);
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
...@@ -64,24 +64,24 @@ SCreateAcctMsg* buildAcctManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, in ...@@ -64,24 +64,24 @@ SCreateAcctMsg* buildAcctManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, in
} }
} }
*outputLen = sizeof(SCreateAcctMsg); *outputLen = sizeof(SCreateAcctReq);
return pCreateMsg; return pCreateMsg;
} }
SDropUserMsg* buildDropUserMsg(SSqlInfo* pInfo, int32_t *msgLen, int64_t id, char* msgBuf, int32_t msgBufLen) { SDropUserReq* buildDropUserMsg(SSqlInfo* pInfo, int32_t *msgLen, int64_t id, char* msgBuf, int32_t msgBufLen) {
SToken* pName = taosArrayGet(pInfo->pMiscInfo->a, 0); SToken* pName = taosArrayGet(pInfo->pMiscInfo->a, 0);
if (pName->n >= TSDB_USER_LEN) { if (pName->n >= TSDB_USER_LEN) {
return NULL; return NULL;
} }
SDropUserMsg* pMsg = calloc(1, sizeof(SDropUserMsg)); SDropUserReq* pMsg = calloc(1, sizeof(SDropUserReq));
if (pMsg == NULL) { if (pMsg == NULL) {
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
return NULL; return NULL;
} }
strncpy(pMsg->user, pName->z, pName->n); strncpy(pMsg->user, pName->z, pName->n);
*msgLen = sizeof(SDropUserMsg); *msgLen = sizeof(SDropUserReq);
return pMsg; return pMsg;
} }
......
...@@ -1210,13 +1210,13 @@ int32_t tscBuildCreateDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -1210,13 +1210,13 @@ int32_t tscBuildCreateDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int32_t tscBuildAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) { int32_t tscBuildAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SSqlCmd *pCmd = &pSql->cmd; SSqlCmd *pCmd = &pSql->cmd;
pCmd->payloadLen = sizeof(SCreateAcctMsg); pCmd->payloadLen = sizeof(SCreateAcctReq);
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) { if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) {
tscError("0x%"PRIx64" failed to malloc for query msg", pSql->self); tscError("0x%"PRIx64" failed to malloc for query msg", pSql->self);
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
SCreateAcctMsg *pAlterMsg = (SCreateAcctMsg *)pCmd->payload; SCreateAcctReq *pAlterMsg = (SCreateAcctReq *)pCmd->payload;
SStrToken *pName = &pInfo->pMiscInfo->user.user; SStrToken *pName = &pInfo->pMiscInfo->user.user;
SStrToken *pPwd = &pInfo->pMiscInfo->user.passwd; SStrToken *pPwd = &pInfo->pMiscInfo->user.passwd;
...@@ -1255,14 +1255,14 @@ int32_t tscBuildAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -1255,14 +1255,14 @@ int32_t tscBuildAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int32_t tscBuildUserMsg(SSqlObj *pSql, SSqlInfo *pInfo) { int32_t tscBuildUserMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SSqlCmd *pCmd = &pSql->cmd; SSqlCmd *pCmd = &pSql->cmd;
pCmd->payloadLen = sizeof(SCreateUserMsg); pCmd->payloadLen = sizeof(SCreateUserReq);
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) { if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) {
tscError("0x%"PRIx64" failed to malloc for query msg", pSql->self); tscError("0x%"PRIx64" failed to malloc for query msg", pSql->self);
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
SCreateUserMsg *pAlterMsg = (SCreateUserMsg *)pCmd->payload; SCreateUserReq *pAlterMsg = (SCreateUserReq *)pCmd->payload;
SUserInfo *pUser = &pInfo->pMiscInfo->user; SUserInfo *pUser = &pInfo->pMiscInfo->user;
strncpy(pAlterMsg->user, pUser->user.z, pUser->user.n); strncpy(pAlterMsg->user, pUser->user.z, pUser->user.n);
...@@ -1369,7 +1369,7 @@ int32_t tscBuildDropUserAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -1369,7 +1369,7 @@ int32_t tscBuildDropUserAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
char user[TSDB_USER_LEN] = {0}; char user[TSDB_USER_LEN] = {0};
tstrncpy(user, pCmd->payload, TSDB_USER_LEN); tstrncpy(user, pCmd->payload, TSDB_USER_LEN);
pCmd->payloadLen = sizeof(SDropUserMsg); pCmd->payloadLen = sizeof(SDropUserReq);
pCmd->msgType = (pInfo->type == TSDB_SQL_DROP_USER)? TDMT_MND_DROP_USER:TDMT_MND_DROP_ACCT; pCmd->msgType = (pInfo->type == TSDB_SQL_DROP_USER)? TDMT_MND_DROP_USER:TDMT_MND_DROP_ACCT;
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) { if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) {
...@@ -1377,7 +1377,7 @@ int32_t tscBuildDropUserAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -1377,7 +1377,7 @@ int32_t tscBuildDropUserAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
SDropUserMsg *pDropMsg = (SDropUserMsg *)pCmd->payload; SDropUserReq *pDropMsg = (SDropUserReq *)pCmd->payload;
tstrncpy(pDropMsg->user, user, tListLen(user)); tstrncpy(pDropMsg->user, user, tListLen(user));
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册