[TD-61]
This commit is contained in:
parent
f1f30749e2
commit
63f825a7e6
|
@ -6,6 +6,7 @@ SET(CMAKE_VERBOSE_MAKEFILE ON)
|
||||||
|
|
||||||
SET(TD_CLUSTER FALSE)
|
SET(TD_CLUSTER FALSE)
|
||||||
SET(TD_ACCOUNT FALSE)
|
SET(TD_ACCOUNT FALSE)
|
||||||
|
SET(TD_GRANT FALSE)
|
||||||
SET(TD_COVER FALSE)
|
SET(TD_COVER FALSE)
|
||||||
SET(TD_PAGMODE_LITE FALSE)
|
SET(TD_PAGMODE_LITE FALSE)
|
||||||
SET(TD_GODLL FALSE)
|
SET(TD_GODLL FALSE)
|
||||||
|
|
|
@ -38,6 +38,10 @@ extern "C" {
|
||||||
#include "ttimer.h"
|
#include "ttimer.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
|
||||||
|
struct _vg_obj;
|
||||||
|
struct _db_obj;
|
||||||
|
struct _acctObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t mnodeId;
|
int32_t mnodeId;
|
||||||
uint32_t privateIp;
|
uint32_t privateIp;
|
||||||
|
@ -103,8 +107,6 @@ typedef struct {
|
||||||
int8_t dirty;
|
int8_t dirty;
|
||||||
} STableInfo;
|
} STableInfo;
|
||||||
|
|
||||||
struct _vg_obj;
|
|
||||||
|
|
||||||
typedef struct SSuperTableObj {
|
typedef struct SSuperTableObj {
|
||||||
STableInfo info;
|
STableInfo info;
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
|
@ -137,8 +139,6 @@ typedef struct {
|
||||||
SSuperTableObj *superTable;
|
SSuperTableObj *superTable;
|
||||||
} SChildTableObj;
|
} SChildTableObj;
|
||||||
|
|
||||||
struct _db_obj;
|
|
||||||
|
|
||||||
typedef struct _vg_obj {
|
typedef struct _vg_obj {
|
||||||
uint32_t vgId;
|
uint32_t vgId;
|
||||||
char dbName[TSDB_DB_NAME_LEN + 1];
|
char dbName[TSDB_DB_NAME_LEN + 1];
|
||||||
|
@ -170,10 +170,9 @@ typedef struct _db_obj {
|
||||||
int32_t numOfSuperTables;
|
int32_t numOfSuperTables;
|
||||||
SVgObj *pHead;
|
SVgObj *pHead;
|
||||||
SVgObj *pTail;
|
SVgObj *pTail;
|
||||||
|
struct _acctObj *pAcct;
|
||||||
} SDbObj;
|
} SDbObj;
|
||||||
|
|
||||||
struct _acctObj;
|
|
||||||
|
|
||||||
typedef struct _user_obj {
|
typedef struct _user_obj {
|
||||||
char user[TSDB_USER_LEN + 1];
|
char user[TSDB_USER_LEN + 1];
|
||||||
char pass[TSDB_KEY_LEN + 1];
|
char pass[TSDB_KEY_LEN + 1];
|
||||||
|
|
|
@ -28,6 +28,7 @@ void mgmtCleanUpDbs();
|
||||||
SDbObj *mgmtGetDb(char *db);
|
SDbObj *mgmtGetDb(char *db);
|
||||||
SDbObj *mgmtGetDbByTableId(char *db);
|
SDbObj *mgmtGetDbByTableId(char *db);
|
||||||
bool mgmtCheckIsMonitorDB(char *db, char *monitordb);
|
bool mgmtCheckIsMonitorDB(char *db, char *monitordb);
|
||||||
|
void mgmtDropAllDbs(SAcctObj *pAcct);
|
||||||
|
|
||||||
// util func
|
// util func
|
||||||
void mgmtAddSuperTableIntoDb(SDbObj *pDb);
|
void mgmtAddSuperTableIntoDb(SDbObj *pDb);
|
||||||
|
|
|
@ -25,6 +25,7 @@ int32_t mgmtInitDnodes();
|
||||||
void mgmtCleanUpDnodes();
|
void mgmtCleanUpDnodes();
|
||||||
int32_t mgmtGetDnodesNum();
|
int32_t mgmtGetDnodesNum();
|
||||||
int32_t mgmtUpdateDnode(SDnodeObj *pDnode);
|
int32_t mgmtUpdateDnode(SDnodeObj *pDnode);
|
||||||
|
void * mgmtGetNextDnode(SShowObj *pShow, SDnodeObj **pDnode);
|
||||||
SDnodeObj* mgmtGetDnode(int32_t dnodeId);
|
SDnodeObj* mgmtGetDnode(int32_t dnodeId);
|
||||||
SDnodeObj* mgmtGetDnodeByIp(uint32_t ip);
|
SDnodeObj* mgmtGetDnodeByIp(uint32_t ip);
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ int32_t sdbUpdateRow(SSdbOperDesc *pOper);
|
||||||
void *sdbGetRow(void *handle, void *key);
|
void *sdbGetRow(void *handle, void *key);
|
||||||
void *sdbFetchRow(void *handle, void *pNode, void **ppRow);
|
void *sdbFetchRow(void *handle, void *pNode, void **ppRow);
|
||||||
int64_t sdbGetNumOfRows(void *handle);
|
int64_t sdbGetNumOfRows(void *handle);
|
||||||
|
int64_t sdbGetId(void *handle);
|
||||||
uint64_t sdbGetVersion();
|
uint64_t sdbGetVersion();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -25,6 +25,8 @@ int32_t mgmtInitUsers();
|
||||||
void mgmtCleanUpUsers();
|
void mgmtCleanUpUsers();
|
||||||
SUserObj *mgmtGetUser(char *name);
|
SUserObj *mgmtGetUser(char *name);
|
||||||
SUserObj *mgmtGetUserFromConn(void *pConn, bool *usePublicIp);
|
SUserObj *mgmtGetUserFromConn(void *pConn, bool *usePublicIp);
|
||||||
|
int32_t mgmtCreateUser(SAcctObj *pAcct, char *name, char *pass);
|
||||||
|
void mgmtDropAllUsers(SAcctObj *pAcct);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -899,3 +899,20 @@ static void mgmtProcessDropDbMsg(SQueuedMsg *pMsg) {
|
||||||
newMsg->ahandle = pDb;
|
newMsg->ahandle = pDb;
|
||||||
taosTmrReset(mgmtDropDb, 10, newMsg, tsMgmtTmr, &tmpTmr);
|
taosTmrReset(mgmtDropDb, 10, newMsg, tsMgmtTmr, &tmpTmr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mgmtDropAllDbs(SAcctObj *pAcct) {
|
||||||
|
int32_t numOfDbs = 0;
|
||||||
|
SDbObj *pDb = NULL;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
void *pNode = sdbFetchRow(tsDbSdb, pNode, (void **)&pDb);
|
||||||
|
if (pDb == NULL) break;
|
||||||
|
|
||||||
|
if (pDb->pAcct == pAcct) {
|
||||||
|
mgmtSetDbDirty(pDb);
|
||||||
|
numOfDbs++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mTrace("acct:%s, all dbs is is set dirty", pAcct->acctId, numOfDbs);
|
||||||
|
}
|
|
@ -36,7 +36,6 @@ void * (*mgmtGetNextDnodeFp)(SShowObj *pShow, SDnodeObj **pDnode) = NULL;
|
||||||
void (*mgmtSetDnodeUnRemoveFp)(SDnodeObj *pDnode) = NULL;
|
void (*mgmtSetDnodeUnRemoveFp)(SDnodeObj *pDnode) = NULL;
|
||||||
|
|
||||||
static SDnodeObj tsDnodeObj = {0};
|
static SDnodeObj tsDnodeObj = {0};
|
||||||
static void * mgmtGetNextDnode(SShowObj *pShow, SDnodeObj **pDnode);
|
|
||||||
static bool mgmtCheckConfigShow(SGlobalConfig *cfg);
|
static bool mgmtCheckConfigShow(SGlobalConfig *cfg);
|
||||||
static int32_t mgmtGetModuleMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
|
static int32_t mgmtGetModuleMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
|
||||||
static int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
static int32_t mgmtRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
static void *tsUserSdb = NULL;
|
static void *tsUserSdb = NULL;
|
||||||
static int32_t tsUserUpdateSize = 0;
|
static int32_t tsUserUpdateSize = 0;
|
||||||
|
|
||||||
static int32_t mgmtCreateUser(SAcctObj *pAcct, char *name, char *pass);
|
|
||||||
static int32_t mgmtDropUser(SAcctObj *pAcct, char *name);
|
static int32_t mgmtDropUser(SAcctObj *pAcct, char *name);
|
||||||
static int32_t mgmtUpdateUser(SUserObj *pUser);
|
static int32_t mgmtUpdateUser(SUserObj *pUser);
|
||||||
static int32_t mgmtGetUserMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
|
static int32_t mgmtGetUserMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
|
||||||
|
@ -155,7 +154,7 @@ static int32_t mgmtUpdateUser(SUserObj *pUser) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mgmtCreateUser(SAcctObj *pAcct, char *name, char *pass) {
|
int32_t mgmtCreateUser(SAcctObj *pAcct, char *name, char *pass) {
|
||||||
int32_t code = mgmtCheckUserLimit(pAcct);
|
int32_t code = mgmtCheckUserLimit(pAcct);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -482,3 +481,30 @@ static void mgmtProcessDropUserMsg(SQueuedMsg *pMsg) {
|
||||||
|
|
||||||
mgmtSendSimpleResp(pMsg->thandle, code);
|
mgmtSendSimpleResp(pMsg->thandle, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mgmtDropAllUsers(SAcctObj *pAcct) {
|
||||||
|
void *pNode = NULL;
|
||||||
|
void *pLastNode = NULL;
|
||||||
|
int32_t numOfUsers = 0;
|
||||||
|
int32_t acctNameLen = strlen(pAcct->user);
|
||||||
|
SUserObj *pUser = NULL;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
pNode = sdbFetchRow(tsUserSdb, pNode, (void **)&pUser);
|
||||||
|
if (pUser == NULL) break;
|
||||||
|
|
||||||
|
if (strncmp(pUser->acct, pAcct->user, acctNameLen) == 0) {
|
||||||
|
SSdbOperDesc oper = {
|
||||||
|
.type = SDB_OPER_TYPE_LOCAL,
|
||||||
|
.table = tsUserSdb,
|
||||||
|
.pObj = pUser,
|
||||||
|
};
|
||||||
|
sdbDeleteRow(&oper);
|
||||||
|
pNode = pLastNode;
|
||||||
|
numOfUsers++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mTrace("acct:%s, all users is dropped from sdb", pAcct->acctId, numOfUsers);
|
||||||
|
}
|
Loading…
Reference in New Issue