Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
f6265074
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f6265074
编写于
2月 20, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
reorganize the file mgmtAcct.c and mgmtUser.c
上级
dfafa1be
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
146 addition
and
196 deletion
+146
-196
src/inc/mnode.h
src/inc/mnode.h
+0
-1
src/mnode/inc/mgmtAcct.h
src/mnode/inc/mgmtAcct.h
+0
-12
src/mnode/inc/mgmtUser.h
src/mnode/inc/mgmtUser.h
+6
-6
src/mnode/src/mgmtAcct.c
src/mnode/src/mgmtAcct.c
+54
-81
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+16
-16
src/mnode/src/mgmtSystem.c
src/mnode/src/mgmtSystem.c
+0
-1
src/mnode/src/mgmtUser.c
src/mnode/src/mgmtUser.c
+68
-77
src/mnode/src/mgmtVgroup.c
src/mnode/src/mgmtVgroup.c
+2
-2
未找到文件。
src/inc/mnode.h
浏览文件 @
f6265074
...
@@ -51,7 +51,6 @@ extern int tsAcctUpdateSize;
...
@@ -51,7 +51,6 @@ extern int tsAcctUpdateSize;
extern
int
tsDbUpdateSize
;
extern
int
tsDbUpdateSize
;
extern
int
tsDnodeUpdateSize
;
extern
int
tsDnodeUpdateSize
;
extern
int
tsMnodeUpdateSize
;
extern
int
tsMnodeUpdateSize
;
extern
int
tsUserUpdateSize
;
extern
int
tsVgUpdateSize
;
extern
int
tsVgUpdateSize
;
typedef
struct
{
typedef
struct
{
...
...
src/mnode/inc/mgmtAcct.h
浏览文件 @
f6265074
...
@@ -22,21 +22,13 @@ extern "C" {
...
@@ -22,21 +22,13 @@ extern "C" {
#include "mnode.h"
#include "mnode.h"
int32_t
mgmtCreateAcct
(
char
*
name
,
char
*
pass
,
SAcctCfg
*
pCfg
);
int32_t
mgmtUpdateAcct
(
SAcctObj
*
pAcct
);
int32_t
mgmtDropAcct
(
char
*
name
);
int32_t
mgmtAddDbIntoAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
);
int32_t
mgmtAddDbIntoAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
);
int32_t
mgmtRemoveDbFromAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
);
int32_t
mgmtRemoveDbFromAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
);
int32_t
mgmtAddUserIntoAcct
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
);
int32_t
mgmtAddUserIntoAcct
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
);
int32_t
mgmtRemoveUserFromAcct
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
);
int32_t
mgmtRemoveUserFromAcct
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
);
int32_t
mgmtAddConnIntoAcct
(
SConnObj
*
pConn
);
int32_t
mgmtRemoveConnFromAcct
(
SConnObj
*
pConn
);
int32_t
mgmtAlterAcct
(
char
*
name
,
char
*
pass
,
SAcctCfg
*
pCfg
);
int64_t
mgmtGetAcctStatistic
(
SAcctObj
*
pAcct
);
extern
int32_t
(
*
mgmtInitAccts
)();
extern
int32_t
(
*
mgmtInitAccts
)();
extern
SAcctObj
*
(
*
mgmtGetAcct
)(
char
*
acctName
);
extern
SAcctObj
*
(
*
mgmtGetAcct
)(
char
*
acctName
);
extern
void
(
*
mgmtCreateRootAcct
)();
extern
int32_t
(
*
mgmtCheckUserLimit
)(
SAcctObj
*
pAcct
);
extern
int32_t
(
*
mgmtCheckUserLimit
)(
SAcctObj
*
pAcct
);
extern
int32_t
(
*
mgmtCheckDbLimit
)(
SAcctObj
*
pAcct
);
extern
int32_t
(
*
mgmtCheckDbLimit
)(
SAcctObj
*
pAcct
);
extern
int32_t
(
*
mgmtCheckTableLimit
)(
SAcctObj
*
pAcct
,
SCreateTableMsg
*
pCreate
);
extern
int32_t
(
*
mgmtCheckTableLimit
)(
SAcctObj
*
pAcct
,
SCreateTableMsg
*
pCreate
);
...
@@ -45,10 +37,6 @@ extern void (*mgmtCleanUpAccts)();
...
@@ -45,10 +37,6 @@ extern void (*mgmtCleanUpAccts)();
extern
int32_t
(
*
mgmtGetAcctMeta
)(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
extern
int32_t
(
*
mgmtGetAcctMeta
)(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
extern
int32_t
(
*
mgmtRetrieveAccts
)(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
SConnObj
*
pConn
);
extern
int32_t
(
*
mgmtRetrieveAccts
)(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
SConnObj
*
pConn
);
void
mgmtAddMeterStatisticToAcct
(
SAcctObj
*
pAcct
,
int
numOfColumns
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
src/mnode/inc/mgmtUser.h
浏览文件 @
f6265074
...
@@ -24,13 +24,13 @@ extern "C" {
...
@@ -24,13 +24,13 @@ extern "C" {
#include <stdbool.h>
#include <stdbool.h>
#include "mnode.h"
#include "mnode.h"
int
mgmtInitUsers
();
int
32_t
mgmtInitUsers
();
SUserObj
*
mgmtGetUser
(
char
*
name
);
SUserObj
*
mgmtGetUser
(
char
*
name
);
int
mgmtCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
);
int
32_t
mgmtCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
);
int
mgmtDropUser
(
SAcctObj
*
pAcct
,
char
*
name
);
int
32_t
mgmtDropUser
(
SAcctObj
*
pAcct
,
char
*
name
);
int
mgmtUpdateUser
(
SUserObj
*
pUser
);
int
32_t
mgmtUpdateUser
(
SUserObj
*
pUser
);
int
mgmtGetUserMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
32_t
mgmtGetUserMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
);
int
mgmtRetrieveUsers
(
SShowObj
*
pShow
,
char
*
data
,
in
t
rows
,
SConnObj
*
pConn
);
int
32_t
mgmtRetrieveUsers
(
SShowObj
*
pShow
,
char
*
data
,
int32_
t
rows
,
SConnObj
*
pConn
);
void
mgmtCleanUpUsers
();
void
mgmtCleanUpUsers
();
#ifdef __cplusplus
#ifdef __cplusplus
...
...
src/mnode/src/mgmtAcct.c
浏览文件 @
f6265074
...
@@ -15,26 +15,25 @@
...
@@ -15,26 +15,25 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#include "tschemautil.h"
#include "taoserror.h"
#include "mnode.h"
#include "mnode.h"
#include "mgmtAcct.h"
#include "mgmtAcct.h"
#include "mgmtTable.h"
#include "mgmtTable.h"
#include "mgmtUser.h"
#include "mgmtUser.h"
#include "tschemautil.h"
#include "taoserror.h"
extern
void
*
u
serSdb
;
extern
void
*
tsU
serSdb
;
extern
void
*
d
bSdb
;
extern
void
*
tsD
bSdb
;
SAcctObj
acctObj
;
SAcctObj
acctObj
;
int
mgmtGetAcctsNum
();
int32_t
mgmtAddDbIntoAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
SShowObj
*
mgmtGetNextAcct
(
SShowObj
*
pShow
,
SAcctObj
**
pAcct
);
int
mgmtAddDbIntoAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pDb
->
next
=
pAcct
->
pHead
;
pDb
->
next
=
pAcct
->
pHead
;
pDb
->
prev
=
NULL
;
pDb
->
prev
=
NULL
;
if
(
pAcct
->
pHead
)
pAcct
->
pHead
->
prev
=
pDb
;
if
(
pAcct
->
pHead
)
{
pAcct
->
pHead
->
prev
=
pDb
;
}
pAcct
->
pHead
=
pDb
;
pAcct
->
pHead
=
pDb
;
pAcct
->
acctInfo
.
numOfDbs
++
;
pAcct
->
acctInfo
.
numOfDbs
++
;
...
@@ -43,13 +42,19 @@ int mgmtAddDbIntoAcct(SAcctObj *pAcct, SDbObj *pDb) {
...
@@ -43,13 +42,19 @@ int mgmtAddDbIntoAcct(SAcctObj *pAcct, SDbObj *pDb) {
return
0
;
return
0
;
}
}
int
mgmtRemoveDbFromAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
int
32_t
mgmtRemoveDbFromAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pthread_mutex_lock
(
&
pAcct
->
mutex
);
if
(
pDb
->
prev
)
pDb
->
prev
->
next
=
pDb
->
next
;
if
(
pDb
->
prev
)
{
pDb
->
prev
->
next
=
pDb
->
next
;
}
if
(
pDb
->
next
)
pDb
->
next
->
prev
=
pDb
->
prev
;
if
(
pDb
->
next
)
{
pDb
->
next
->
prev
=
pDb
->
prev
;
}
if
(
pDb
->
prev
==
NULL
)
pAcct
->
pHead
=
pDb
->
next
;
if
(
pDb
->
prev
==
NULL
)
{
pAcct
->
pHead
=
pDb
->
next
;
}
pAcct
->
acctInfo
.
numOfDbs
--
;
pAcct
->
acctInfo
.
numOfDbs
--
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
...
@@ -57,12 +62,14 @@ int mgmtRemoveDbFromAcct(SAcctObj *pAcct, SDbObj *pDb) {
...
@@ -57,12 +62,14 @@ int mgmtRemoveDbFromAcct(SAcctObj *pAcct, SDbObj *pDb) {
return
0
;
return
0
;
}
}
int
mgmtAddUserIntoAcct
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
int
32_t
mgmtAddUserIntoAcct
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pUser
->
next
=
pAcct
->
pUser
;
pUser
->
next
=
pAcct
->
pUser
;
pUser
->
prev
=
NULL
;
pUser
->
prev
=
NULL
;
if
(
pAcct
->
pUser
)
pAcct
->
pUser
->
prev
=
pUser
;
if
(
pAcct
->
pUser
)
{
pAcct
->
pUser
->
prev
=
pUser
;
}
pAcct
->
pUser
=
pUser
;
pAcct
->
pUser
=
pUser
;
pAcct
->
acctInfo
.
numOfUsers
++
;
pAcct
->
acctInfo
.
numOfUsers
++
;
...
@@ -71,13 +78,17 @@ int mgmtAddUserIntoAcct(SAcctObj *pAcct, SUserObj *pUser) {
...
@@ -71,13 +78,17 @@ int mgmtAddUserIntoAcct(SAcctObj *pAcct, SUserObj *pUser) {
return
0
;
return
0
;
}
}
int
mgmtRemoveUserFromAcct
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
int
32_t
mgmtRemoveUserFromAcct
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
pthread_mutex_lock
(
&
pAcct
->
mutex
);
pthread_mutex_lock
(
&
pAcct
->
mutex
);
if
(
pUser
->
prev
)
pUser
->
prev
->
next
=
pUser
->
next
;
if
(
pUser
->
prev
)
{
pUser
->
prev
->
next
=
pUser
->
next
;
}
if
(
pUser
->
next
)
pUser
->
next
->
prev
=
pUser
->
prev
;
if
(
pUser
->
next
)
pUser
->
next
->
prev
=
pUser
->
prev
;
if
(
pUser
->
prev
==
NULL
)
pAcct
->
pUser
=
pUser
->
next
;
if
(
pUser
->
prev
==
NULL
)
{
pAcct
->
pUser
=
pUser
->
next
;
}
pAcct
->
acctInfo
.
numOfUsers
--
;
pAcct
->
acctInfo
.
numOfUsers
--
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
...
@@ -85,85 +96,44 @@ int mgmtRemoveUserFromAcct(SAcctObj *pAcct, SUserObj *pUser) {
...
@@ -85,85 +96,44 @@ int mgmtRemoveUserFromAcct(SAcctObj *pAcct, SUserObj *pUser) {
return
0
;
return
0
;
}
}
int
mgmtAddConnIntoAcct
(
SConnObj
*
pConn
)
{
int32_t
mgmtInitAcctsImp
()
{
SAcctObj
*
pAcct
=
pConn
->
pAcct
;
if
(
pAcct
==
NULL
)
return
0
;
pthread_mutex_lock
(
&
pAcct
->
mutex
);
assert
(
pConn
!=
pAcct
->
pConn
);
pConn
->
next
=
pAcct
->
pConn
;
pConn
->
prev
=
NULL
;
if
(
pAcct
->
pConn
)
pAcct
->
pConn
->
prev
=
pConn
;
pAcct
->
pConn
=
pConn
;
pAcct
->
acctInfo
.
numOfConns
++
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
return
0
;
}
int
mgmtRemoveConnFromAcct
(
SConnObj
*
pConn
)
{
SAcctObj
*
pAcct
=
pConn
->
pAcct
;
if
(
pAcct
==
NULL
)
return
0
;
pthread_mutex_lock
(
&
pAcct
->
mutex
);
if
(
pConn
->
prev
)
pConn
->
prev
->
next
=
pConn
->
next
;
if
(
pConn
->
next
)
pConn
->
next
->
prev
=
pConn
->
prev
;
if
(
pConn
->
prev
==
NULL
)
pAcct
->
pConn
=
pConn
->
next
;
pAcct
->
acctInfo
.
numOfConns
--
;
// pAcct->numOfUsers--;
if
(
pConn
->
pQList
)
{
pAcct
->
acctInfo
.
numOfQueries
-=
pConn
->
pQList
->
numOfQueries
;
pAcct
->
acctInfo
.
numOfStreams
-=
pConn
->
pSList
->
numOfStreams
;
}
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
pConn
->
next
=
NULL
;
pConn
->
prev
=
NULL
;
return
0
;
return
0
;
}
}
int32_t
mgmtInitAcctsImp
()
{
return
0
;
}
int32_t
(
*
mgmtInitAccts
)()
=
mgmtInitAcctsImp
;
int32_t
(
*
mgmtInitAccts
)()
=
mgmtInitAcctsImp
;
void
mgmtCreateRootAcctImp
()
{}
SAcctObj
*
mgmtGetAcctImp
(
char
*
acctName
)
{
void
(
*
mgmtCreateRootAcct
)()
=
mgmtCreateRootAcctImp
;
return
&
acctObj
;
}
SAcctObj
*
mgmtGetAcctImp
(
char
*
acctName
)
{
return
&
acctObj
;
}
SAcctObj
*
(
*
mgmtGetAcct
)(
char
*
acctName
)
=
mgmtGetAcctImp
;
SAcctObj
*
(
*
mgmtGetAcct
)(
char
*
acctName
)
=
mgmtGetAcctImp
;
int32_t
mgmtCheckUserLimitImp
(
SAcctObj
*
pAcct
)
{
int32_t
mgmtCheckUserLimitImp
(
SAcctObj
*
pAcct
)
{
int
numOfUsers
=
sdbGetNumOfRows
(
u
serSdb
);
int
32_t
numOfUsers
=
sdbGetNumOfRows
(
tsU
serSdb
);
if
(
numOfUsers
>=
tsMaxUsers
)
{
if
(
numOfUsers
>=
tsMaxUsers
)
{
mWarn
(
"numOfUsers:%d, exceed tsMaxUsers:%d"
,
numOfUsers
,
tsMaxUsers
);
mWarn
(
"numOfUsers:%d, exceed tsMaxUsers:%d"
,
numOfUsers
,
tsMaxUsers
);
return
TSDB_CODE_TOO_MANY_USERS
;
return
TSDB_CODE_TOO_MANY_USERS
;
}
}
return
0
;
return
0
;
}
}
int32_t
(
*
mgmtCheckUserLimit
)(
SAcctObj
*
pAcct
)
=
mgmtCheckUserLimitImp
;
int32_t
(
*
mgmtCheckUserLimit
)(
SAcctObj
*
pAcct
)
=
mgmtCheckUserLimitImp
;
int32_t
mgmtCheckDbLimitImp
(
SAcctObj
*
pAcct
)
{
int32_t
mgmtCheckDbLimitImp
(
SAcctObj
*
pAcct
)
{
int
numOfDbs
=
sdbGetNumOfRows
(
d
bSdb
);
int
32_t
numOfDbs
=
sdbGetNumOfRows
(
tsD
bSdb
);
if
(
numOfDbs
>=
tsMaxDbs
)
{
if
(
numOfDbs
>=
tsMaxDbs
)
{
mWarn
(
"numOfDbs:%d, exceed tsMaxDbs:%d"
,
numOfDbs
,
tsMaxDbs
);
mWarn
(
"numOfDbs:%d, exceed tsMaxDbs:%d"
,
numOfDbs
,
tsMaxDbs
);
return
TSDB_CODE_TOO_MANY_DATABASES
;
return
TSDB_CODE_TOO_MANY_DATABASES
;
}
}
return
0
;
return
0
;
}
}
int32_t
(
*
mgmtCheckDbLimit
)(
SAcctObj
*
pAcct
)
=
mgmtCheckDbLimitImp
;
int32_t
(
*
mgmtCheckDbLimit
)(
SAcctObj
*
pAcct
)
=
mgmtCheckDbLimitImp
;
int32_t
mgmtCheckTableLimitImp
(
SAcctObj
*
pAcct
,
SCreateTableMsg
*
pCreate
)
{
return
0
;
}
int32_t
mgmtCheckTableLimitImp
(
SAcctObj
*
pAcct
,
SCreateTableMsg
*
pCreate
)
{
return
0
;
}
int32_t
(
*
mgmtCheckTableLimit
)(
SAcctObj
*
pAcct
,
SCreateTableMsg
*
pCreate
)
=
mgmtCheckTableLimitImp
;
int32_t
(
*
mgmtCheckTableLimit
)(
SAcctObj
*
pAcct
,
SCreateTableMsg
*
pCreate
)
=
mgmtCheckTableLimitImp
;
void
mgmtCheckAcctImp
()
{
void
mgmtCheckAcctImp
()
{
...
@@ -175,19 +145,22 @@ void mgmtCheckAcctImp() {
...
@@ -175,19 +145,22 @@ void mgmtCheckAcctImp() {
mgmtCreateUser
(
pAcct
,
"monitor"
,
tsInternalPass
);
mgmtCreateUser
(
pAcct
,
"monitor"
,
tsInternalPass
);
mgmtCreateUser
(
pAcct
,
"_root"
,
tsInternalPass
);
mgmtCreateUser
(
pAcct
,
"_root"
,
tsInternalPass
);
}
}
void
(
*
mgmtCheckAcct
)()
=
mgmtCheckAcctImp
;
void
mgmtCleanUpAcctsImp
()
{}
void
(
*
mgmtCheckAcct
)()
=
mgmtCheckAcctImp
;
void
(
*
mgmtCleanUpAccts
)()
=
mgmtCleanUpAcctsImp
;
int32_t
mgmtGetAcctMetaImp
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
return
TSDB_CODE_OPS_NOT_SUPPORT
;
}
void
mgmtCleanUpAcctsImp
()
{
int32_t
(
*
mgmtGetAcctMeta
)(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
=
mgmtGetAcctMetaImp
;
}
int32_t
mgmtRetrieveAcctsImp
(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
)
{
return
0
;
}
void
(
*
mgmtCleanUpAccts
)()
=
mgmtCleanUpAcctsImp
;
int32_t
(
*
mgmtRetrieveAccts
)(
SShowObj
*
pShow
,
char
*
data
,
int
rows
,
SConnObj
*
pConn
)
=
mgmtRetrieveAcctsImp
;
int32_t
mgmtGetAcctMetaImp
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
return
TSDB_CODE_OPS_NOT_SUPPORT
;
}
int32_t
(
*
mgmtGetAcctMeta
)(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
=
mgmtGetAcctMetaImp
;
void
mgmtAddMeterStatisticToAcct
(
SAcctObj
*
pAcct
,
int
numOfColumns
)
{
int32_t
mgmtRetrieveAcctsImp
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
SConnObj
*
pConn
)
{
pAcct
->
acctInfo
.
numOfTimeSeries
+=
(
numOfColumns
-
1
)
;
return
0
;
}
}
int32_t
(
*
mgmtRetrieveAccts
)(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
SConnObj
*
pConn
)
=
mgmtRetrieveAcctsImp
;
src/mnode/src/mgmtDb.c
浏览文件 @
f6265074
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
#include "mnode.h"
#include "mnode.h"
#include "taoserror.h"
#include "taoserror.h"
void
*
d
bSdb
=
NULL
;
void
*
tsD
bSdb
=
NULL
;
extern
void
*
vgSdb
;
extern
void
*
vgSdb
;
int
tsDbUpdateSize
;
int
tsDbUpdateSize
;
...
@@ -83,14 +83,14 @@ int32_t mgmtInitDbs() {
...
@@ -83,14 +83,14 @@ int32_t mgmtInitDbs() {
mgmtDbActionInit
();
mgmtDbActionInit
();
d
bSdb
=
sdbOpenTable
(
tsMaxDbs
,
sizeof
(
SDbObj
),
"db"
,
SDB_KEYTYPE_STRING
,
tsMgmtDirectory
,
mgmtDbAction
);
tsD
bSdb
=
sdbOpenTable
(
tsMaxDbs
,
sizeof
(
SDbObj
),
"db"
,
SDB_KEYTYPE_STRING
,
tsMgmtDirectory
,
mgmtDbAction
);
if
(
d
bSdb
==
NULL
)
{
if
(
tsD
bSdb
==
NULL
)
{
mError
(
"failed to init db data"
);
mError
(
"failed to init db data"
);
return
-
1
;
return
-
1
;
}
}
while
(
1
)
{
while
(
1
)
{
pNode
=
sdbFetchRow
(
d
bSdb
,
pNode
,
(
void
**
)
&
pDb
);
pNode
=
sdbFetchRow
(
tsD
bSdb
,
pNode
,
(
void
**
)
&
pDb
);
if
(
pDb
==
NULL
)
break
;
if
(
pDb
==
NULL
)
break
;
pDb
->
pHead
=
NULL
;
pDb
->
pHead
=
NULL
;
...
@@ -118,7 +118,7 @@ int32_t mgmtInitDbs() {
...
@@ -118,7 +118,7 @@ int32_t mgmtInitDbs() {
return
0
;
return
0
;
}
}
SDbObj
*
mgmtGetDb
(
char
*
db
)
{
return
(
SDbObj
*
)
sdbGetRow
(
d
bSdb
,
db
);
}
SDbObj
*
mgmtGetDb
(
char
*
db
)
{
return
(
SDbObj
*
)
sdbGetRow
(
tsD
bSdb
,
db
);
}
SDbObj
*
mgmtGetDbByMeterId
(
char
*
meterId
)
{
SDbObj
*
mgmtGetDbByMeterId
(
char
*
meterId
)
{
char
db
[
TSDB_TABLE_ID_LEN
],
*
pos
;
char
db
[
TSDB_TABLE_ID_LEN
],
*
pos
;
...
@@ -128,7 +128,7 @@ SDbObj *mgmtGetDbByMeterId(char *meterId) {
...
@@ -128,7 +128,7 @@ SDbObj *mgmtGetDbByMeterId(char *meterId) {
memset
(
db
,
0
,
sizeof
(
db
));
memset
(
db
,
0
,
sizeof
(
db
));
strncpy
(
db
,
meterId
,
pos
-
meterId
);
strncpy
(
db
,
meterId
,
pos
-
meterId
);
return
(
SDbObj
*
)
sdbGetRow
(
d
bSdb
,
db
);
return
(
SDbObj
*
)
sdbGetRow
(
tsD
bSdb
,
db
);
}
}
int
mgmtCheckDbParams
(
SCreateDbMsg
*
pCreate
)
{
int
mgmtCheckDbParams
(
SCreateDbMsg
*
pCreate
)
{
...
@@ -185,7 +185,7 @@ int mgmtCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate) {
...
@@ -185,7 +185,7 @@ int mgmtCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate) {
return
code
;
return
code
;
}
}
pDb
=
(
SDbObj
*
)
sdbGetRow
(
d
bSdb
,
pCreate
->
db
);
pDb
=
(
SDbObj
*
)
sdbGetRow
(
tsD
bSdb
,
pCreate
->
db
);
if
(
pDb
!=
NULL
)
{
if
(
pDb
!=
NULL
)
{
return
TSDB_CODE_DB_ALREADY_EXIST
;
return
TSDB_CODE_DB_ALREADY_EXIST
;
}
}
...
@@ -207,7 +207,7 @@ int mgmtCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate) {
...
@@ -207,7 +207,7 @@ int mgmtCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate) {
pDb
->
createdTime
=
taosGetTimestampMs
();
pDb
->
createdTime
=
taosGetTimestampMs
();
pDb
->
cfg
=
*
pCreate
;
pDb
->
cfg
=
*
pCreate
;
if
(
sdbInsertRow
(
d
bSdb
,
pDb
,
0
)
<
0
)
{
if
(
sdbInsertRow
(
tsD
bSdb
,
pDb
,
0
)
<
0
)
{
code
=
TSDB_CODE_SDB_ERROR
;
code
=
TSDB_CODE_SDB_ERROR
;
tfree
(
pDb
);
tfree
(
pDb
);
}
}
...
@@ -215,7 +215,7 @@ int mgmtCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate) {
...
@@ -215,7 +215,7 @@ int mgmtCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate) {
return
code
;
return
code
;
}
}
int
mgmtUpdateDb
(
SDbObj
*
pDb
)
{
return
sdbUpdateRow
(
d
bSdb
,
pDb
,
tsDbUpdateSize
,
1
);
}
int
mgmtUpdateDb
(
SDbObj
*
pDb
)
{
return
sdbUpdateRow
(
tsD
bSdb
,
pDb
,
tsDbUpdateSize
,
1
);
}
int
mgmtSetDbDropping
(
SDbObj
*
pDb
)
{
int
mgmtSetDbDropping
(
SDbObj
*
pDb
)
{
if
(
pDb
->
dropStatus
==
TSDB_DB_STATUS_DROP_FROM_SDB
)
return
0
;
if
(
pDb
->
dropStatus
==
TSDB_DB_STATUS_DROP_FROM_SDB
)
return
0
;
...
@@ -288,7 +288,7 @@ void mgmtDropDbFromSdb(SDbObj *pDb) {
...
@@ -288,7 +288,7 @@ void mgmtDropDbFromSdb(SDbObj *pDb) {
}
}
mPrint
(
"db:%s all meters drop finished"
,
pDb
->
name
);
mPrint
(
"db:%s all meters drop finished"
,
pDb
->
name
);
sdbDeleteRow
(
d
bSdb
,
pDb
);
sdbDeleteRow
(
tsD
bSdb
,
pDb
);
mPrint
(
"db:%s database drop finished"
,
pDb
->
name
);
mPrint
(
"db:%s database drop finished"
,
pDb
->
name
);
}
}
...
@@ -317,7 +317,7 @@ int mgmtDropDb(SDbObj *pDb) {
...
@@ -317,7 +317,7 @@ int mgmtDropDb(SDbObj *pDb) {
int
mgmtDropDbByName
(
SAcctObj
*
pAcct
,
char
*
name
,
short
ignoreNotExists
)
{
int
mgmtDropDbByName
(
SAcctObj
*
pAcct
,
char
*
name
,
short
ignoreNotExists
)
{
SDbObj
*
pDb
;
SDbObj
*
pDb
;
pDb
=
(
SDbObj
*
)
sdbGetRow
(
d
bSdb
,
name
);
pDb
=
(
SDbObj
*
)
sdbGetRow
(
tsD
bSdb
,
name
);
if
(
pDb
==
NULL
)
{
if
(
pDb
==
NULL
)
{
if
(
ignoreNotExists
)
return
TSDB_CODE_SUCCESS
;
if
(
ignoreNotExists
)
return
TSDB_CODE_SUCCESS
;
mWarn
(
"db:%s is not there"
,
name
);
mWarn
(
"db:%s is not there"
,
name
);
...
@@ -336,7 +336,7 @@ void mgmtMonitorDbDrop(void *unused, void *unusedt) {
...
@@ -336,7 +336,7 @@ void mgmtMonitorDbDrop(void *unused, void *unusedt) {
SDbObj
*
pDb
=
NULL
;
SDbObj
*
pDb
=
NULL
;
while
(
1
)
{
while
(
1
)
{
pNode
=
sdbFetchRow
(
d
bSdb
,
pNode
,
(
void
**
)
&
pDb
);
pNode
=
sdbFetchRow
(
tsD
bSdb
,
pNode
,
(
void
**
)
&
pDb
);
if
(
pDb
==
NULL
)
break
;
if
(
pDb
==
NULL
)
break
;
if
(
pDb
->
dropStatus
!=
TSDB_DB_STATUS_DROPPING
)
continue
;
if
(
pDb
->
dropStatus
!=
TSDB_DB_STATUS_DROPPING
)
continue
;
mgmtDropDb
(
pDb
);
mgmtDropDb
(
pDb
);
...
@@ -348,7 +348,7 @@ int mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter) {
...
@@ -348,7 +348,7 @@ int mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter) {
SDbObj
*
pDb
;
SDbObj
*
pDb
;
int
code
=
TSDB_CODE_SUCCESS
;
int
code
=
TSDB_CODE_SUCCESS
;
pDb
=
(
SDbObj
*
)
sdbGetRow
(
d
bSdb
,
pAlter
->
db
);
pDb
=
(
SDbObj
*
)
sdbGetRow
(
tsD
bSdb
,
pAlter
->
db
);
if
(
pDb
==
NULL
)
{
if
(
pDb
==
NULL
)
{
mTrace
(
"db:%s is not exist"
,
pAlter
->
db
);
mTrace
(
"db:%s is not exist"
,
pAlter
->
db
);
return
TSDB_CODE_INVALID_DB
;
return
TSDB_CODE_INVALID_DB
;
...
@@ -385,7 +385,7 @@ int mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter) {
...
@@ -385,7 +385,7 @@ int mgmtAlterDb(SAcctObj *pAcct, SAlterDbMsg *pAlter) {
return
TSDB_CODE_INVALID_OPTION
;
return
TSDB_CODE_INVALID_OPTION
;
}
}
if
(
sdbUpdateRow
(
d
bSdb
,
pDb
,
tsDbUpdateSize
,
1
)
<
0
)
{
if
(
sdbUpdateRow
(
tsD
bSdb
,
pDb
,
tsDbUpdateSize
,
1
)
<
0
)
{
return
TSDB_CODE_SDB_ERROR
;
return
TSDB_CODE_SDB_ERROR
;
}
}
...
@@ -488,7 +488,7 @@ int mgmtShowTables(SAcctObj *pAcct, char *db) {
...
@@ -488,7 +488,7 @@ int mgmtShowTables(SAcctObj *pAcct, char *db) {
return
code
;
return
code
;
}
}
void
mgmtCleanUpDbs
()
{
sdbCloseTable
(
d
bSdb
);
}
void
mgmtCleanUpDbs
()
{
sdbCloseTable
(
tsD
bSdb
);
}
int
mgmtGetDbMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
mgmtGetDbMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
cols
=
0
;
int
cols
=
0
;
...
@@ -623,7 +623,7 @@ int mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
...
@@ -623,7 +623,7 @@ int mgmtGetDbMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
// pShow->numOfRows = sdbGetNumOfRows (
d
bSdb);
// pShow->numOfRows = sdbGetNumOfRows (
tsD
bSdb);
pShow
->
numOfRows
=
pConn
->
pAcct
->
acctInfo
.
numOfDbs
;
pShow
->
numOfRows
=
pConn
->
pAcct
->
acctInfo
.
numOfDbs
;
pShow
->
pNode
=
pConn
->
pAcct
->
pHead
;
pShow
->
pNode
=
pConn
->
pAcct
->
pHead
;
...
...
src/mnode/src/mgmtSystem.c
浏览文件 @
f6265074
...
@@ -28,7 +28,6 @@
...
@@ -28,7 +28,6 @@
#include "mgmtSystem.h"
#include "mgmtSystem.h"
#include "mgmtTable.h"
#include "mgmtTable.h"
#include "mgmtShell.h"
#include "mgmtShell.h"
#include "dnodeModule.h"
char
tsMgmtDirectory
[
128
]
=
{
0
};
char
tsMgmtDirectory
[
128
]
=
{
0
};
void
*
tsMgmtTmr
=
NULL
;
void
*
tsMgmtTmr
=
NULL
;
...
...
src/mnode/src/mgmtUser.c
浏览文件 @
f6265074
...
@@ -15,69 +15,58 @@
...
@@ -15,69 +15,58 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#include "tschemautil.h"
#include "ttime.h"
#include "mnode.h"
#include "mnode.h"
#include "mgmtAcct.h"
#include "mgmtAcct.h"
#include "mgmtUser.h"
#include "mgmtUser.h"
#include "mgmtGrant.h"
#include "mgmtGrant.h"
#include "mgmtTable.h"
#include "mgmtTable.h"
#include "tschemautil.h"
#include "ttime.h"
void
*
userSdb
=
NULL
;
void
*
tsUserSdb
=
NULL
;
int
tsUserUpdateSize
;
void
*
(
*
mgmtUserActionFp
[
SDB_MAX_ACTION_TYPES
])(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionInsert
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionDelete
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionUpdate
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionEncode
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionDecode
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionBeforeBatchUpdate
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionBatchUpdate
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionAfterBatchUpdate
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionReset
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
mgmtUserActionDestroy
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
(
*
mgmtUserActionFp
[
SDB_MAX_ACTION_TYPES
])(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
void
*
mgmtUserActionInsert
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
void
*
mgmtUserActionDelete
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
void
*
mgmtUserActionUpdate
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
void
*
mgmtUserActionEncode
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
void
*
mgmtUserActionDecode
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
void
*
mgmtUserActionReset
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
void
*
mgmtUserActionDestroy
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
);
void
mgmtUserActionInit
()
{
void
mgmtUserActionInit
()
{
mgmtUserActionFp
[
SDB_TYPE_INSERT
]
=
mgmtUserActionInsert
;
mgmtUserActionFp
[
SDB_TYPE_INSERT
]
=
mgmtUserActionInsert
;
mgmtUserActionFp
[
SDB_TYPE_DELETE
]
=
mgmtUserActionDelete
;
mgmtUserActionFp
[
SDB_TYPE_DELETE
]
=
mgmtUserActionDelete
;
mgmtUserActionFp
[
SDB_TYPE_UPDATE
]
=
mgmtUserActionUpdate
;
mgmtUserActionFp
[
SDB_TYPE_UPDATE
]
=
mgmtUserActionUpdate
;
mgmtUserActionFp
[
SDB_TYPE_ENCODE
]
=
mgmtUserActionEncode
;
mgmtUserActionFp
[
SDB_TYPE_ENCODE
]
=
mgmtUserActionEncode
;
mgmtUserActionFp
[
SDB_TYPE_DECODE
]
=
mgmtUserActionDecode
;
mgmtUserActionFp
[
SDB_TYPE_DECODE
]
=
mgmtUserActionDecode
;
mgmtUserActionFp
[
SDB_TYPE_BEFORE_BATCH_UPDATE
]
=
mgmtUserActionBeforeBatchUpdate
;
mgmtUserActionFp
[
SDB_TYPE_RESET
]
=
mgmtUserActionReset
;
mgmtUserActionFp
[
SDB_TYPE_BATCH_UPDATE
]
=
mgmtUserActionBatchUpdate
;
mgmtUserActionFp
[
SDB_TYPE_AFTER_BATCH_UPDATE
]
=
mgmtUserActionAfterBatchUpdate
;
mgmtUserActionFp
[
SDB_TYPE_RESET
]
=
mgmtUserActionReset
;
mgmtUserActionFp
[
SDB_TYPE_DESTROY
]
=
mgmtUserActionDestroy
;
mgmtUserActionFp
[
SDB_TYPE_DESTROY
]
=
mgmtUserActionDestroy
;
}
}
void
*
mgmtUserAction
(
char
action
,
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
)
{
void
*
mgmtUserAction
(
char
action
,
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
)
{
if
(
mgmtUserActionFp
[(
uint8_t
)
action
]
!=
NULL
)
{
if
(
mgmtUserActionFp
[(
uint8_t
)
action
]
!=
NULL
)
{
return
(
*
(
mgmtUserActionFp
[(
uint8_t
)
action
]))(
row
,
str
,
size
,
ssize
);
return
(
*
(
mgmtUserActionFp
[(
uint8_t
)
action
]))(
row
,
str
,
size
,
ssize
);
}
}
return
NULL
;
return
NULL
;
}
}
int
mgmtInitUsers
()
{
int
32_t
mgmtInitUsers
()
{
void
*
pNode
=
NULL
;
void
*
pNode
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SAcctObj
*
pAcct
=
NULL
;
SAcctObj
*
pAcct
=
NULL
;
int
numOfUsers
=
0
;
int
32_t
numOfUsers
=
0
;
mgmtUserActionInit
();
mgmtUserActionInit
();
u
serSdb
=
sdbOpenTable
(
tsMaxUsers
,
sizeof
(
SUserObj
),
"user"
,
SDB_KEYTYPE_STRING
,
tsMgmtDirectory
,
mgmtUserAction
);
tsU
serSdb
=
sdbOpenTable
(
tsMaxUsers
,
sizeof
(
SUserObj
),
"user"
,
SDB_KEYTYPE_STRING
,
tsMgmtDirectory
,
mgmtUserAction
);
if
(
u
serSdb
==
NULL
)
{
if
(
tsU
serSdb
==
NULL
)
{
mError
(
"failed to init user data"
);
mError
(
"failed to init user data"
);
return
-
1
;
return
-
1
;
}
}
mgmtCreateRootAcct
();
while
(
1
)
{
while
(
1
)
{
pNode
=
sdbFetchRow
(
u
serSdb
,
pNode
,
(
void
**
)
&
pUser
);
pNode
=
sdbFetchRow
(
tsU
serSdb
,
pNode
,
(
void
**
)
&
pUser
);
if
(
pUser
==
NULL
)
break
;
if
(
pUser
==
NULL
)
break
;
pUser
->
prev
=
NULL
;
pUser
->
prev
=
NULL
;
...
@@ -89,27 +78,28 @@ int mgmtInitUsers() {
...
@@ -89,27 +78,28 @@ int mgmtInitUsers() {
numOfUsers
++
;
numOfUsers
++
;
}
}
SUserObj
tObj
;
tsUserUpdateSize
=
tObj
.
updateEnd
-
(
char
*
)
&
tObj
;
mTrace
(
"user data is initialized"
);
mTrace
(
"user data is initialized"
);
return
0
;
return
0
;
}
}
SUserObj
*
mgmtGetUser
(
char
*
name
)
{
return
(
SUserObj
*
)
sdbGetRow
(
userSdb
,
name
);
}
SUserObj
*
mgmtGetUser
(
char
*
name
)
{
return
(
SUserObj
*
)
sdbGetRow
(
tsUserSdb
,
name
);
}
int
mgmtUpdateUser
(
SUserObj
*
pUser
)
{
return
sdbUpdateRow
(
userSdb
,
pUser
,
0
,
1
);
}
int32_t
mgmtUpdateUser
(
SUserObj
*
pUser
)
{
return
sdbUpdateRow
(
tsUserSdb
,
pUser
,
0
,
1
);
}
int
mgmtCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
)
{
int
32_t
mgmtCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
)
{
SUserObj
*
pUser
;
SUserObj
*
pUser
;
int
code
;
int
32_t
code
;
code
=
mgmtCheckUserLimit
(
pAcct
);
code
=
mgmtCheckUserLimit
(
pAcct
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
return
code
;
return
code
;
}
}
pUser
=
(
SUserObj
*
)
sdbGetRow
(
u
serSdb
,
name
);
pUser
=
(
SUserObj
*
)
sdbGetRow
(
tsU
serSdb
,
name
);
if
(
pUser
!=
NULL
)
{
if
(
pUser
!=
NULL
)
{
mWarn
(
"user:%s is already there"
,
name
);
mWarn
(
"user:%s is already there"
,
name
);
return
TSDB_CODE_USER_ALREADY_EXIST
;
return
TSDB_CODE_USER_ALREADY_EXIST
;
...
@@ -133,37 +123,38 @@ int mgmtCreateUser(SAcctObj *pAcct, char *name, char *pass) {
...
@@ -133,37 +123,38 @@ int mgmtCreateUser(SAcctObj *pAcct, char *name, char *pass) {
}
}
code
=
TSDB_CODE_SUCCESS
;
code
=
TSDB_CODE_SUCCESS
;
if
(
sdbInsertRow
(
u
serSdb
,
pUser
,
0
)
<
0
)
{
if
(
sdbInsertRow
(
tsU
serSdb
,
pUser
,
0
)
<
0
)
{
tfree
(
pUser
);
tfree
(
pUser
);
code
=
TSDB_CODE_SDB_ERROR
;
code
=
TSDB_CODE_SDB_ERROR
;
}
}
// mgmtAddUserIntoAcct(pAcct, pUser);
return
code
;
return
code
;
}
}
int
mgmtDropUser
(
SAcctObj
*
pAcct
,
char
*
name
)
{
int
32_t
mgmtDropUser
(
SAcctObj
*
pAcct
,
char
*
name
)
{
SUserObj
*
pUser
;
SUserObj
*
pUser
;
pUser
=
(
SUserObj
*
)
sdbGetRow
(
u
serSdb
,
name
);
pUser
=
(
SUserObj
*
)
sdbGetRow
(
tsU
serSdb
,
name
);
if
(
pUser
==
NULL
)
{
if
(
pUser
==
NULL
)
{
mWarn
(
"user:%s is not there"
,
name
);
mWarn
(
"user:%s is not there"
,
name
);
return
TSDB_CODE_INVALID_USER
;
return
TSDB_CODE_INVALID_USER
;
}
}
if
(
strcmp
(
pAcct
->
user
,
pUser
->
acct
)
!=
0
)
return
TSDB_CODE_NO_RIGHTS
;
if
(
strcmp
(
pAcct
->
user
,
pUser
->
acct
)
!=
0
)
{
return
TSDB_CODE_NO_RIGHTS
;
}
// mgmtRemoveUserFromAcct(pAcct, pUser);
sdbDeleteRow
(
tsUserSdb
,
pUser
);
sdbDeleteRow
(
userSdb
,
pUser
);
return
0
;
return
0
;
}
}
void
mgmtCleanUpUsers
()
{
sdbCloseTable
(
userSdb
);
}
void
mgmtCleanUpUsers
()
{
sdbCloseTable
(
tsUserSdb
);
}
int
mgmtGetUserMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
32_t
mgmtGetUserMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
cols
=
0
;
int
32_t
cols
=
0
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
;
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
;
...
@@ -188,9 +179,8 @@ int mgmtGetUserMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
...
@@ -188,9 +179,8 @@ int mgmtGetUserMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
pShow
->
numOfColumns
=
cols
;
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
pShow
->
offset
[
0
]
=
0
;
for
(
int
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
for
(
int
32_t
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
// pShow->numOfRows = sdbGetNumOfRows (userSdb);
pShow
->
numOfRows
=
pConn
->
pAcct
->
acctInfo
.
numOfUsers
;
pShow
->
numOfRows
=
pConn
->
pAcct
->
acctInfo
.
numOfUsers
;
pShow
->
pNode
=
pConn
->
pAcct
->
pUser
;
pShow
->
pNode
=
pConn
->
pAcct
->
pUser
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
...
@@ -198,14 +188,13 @@ int mgmtGetUserMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
...
@@ -198,14 +188,13 @@ int mgmtGetUserMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
return
0
;
return
0
;
}
}
int
mgmtRetrieveUsers
(
SShowObj
*
pShow
,
char
*
data
,
in
t
rows
,
SConnObj
*
pConn
)
{
int
32_t
mgmtRetrieveUsers
(
SShowObj
*
pShow
,
char
*
data
,
int32_
t
rows
,
SConnObj
*
pConn
)
{
int
numOfRows
=
0
;
int
32_t
numOfRows
=
0
;
SUserObj
*
pUser
=
NULL
;
SUserObj
*
pUser
=
NULL
;
char
*
pWrite
;
char
*
pWrite
;
int
cols
=
0
;
int
32_t
cols
=
0
;
while
(
numOfRows
<
rows
)
{
while
(
numOfRows
<
rows
)
{
// pShow->pNode = sdbFetchRow(userSdb, pShow->pNode, (void **)&pUser);
pUser
=
(
SUserObj
*
)
pShow
->
pNode
;
pUser
=
(
SUserObj
*
)
pShow
->
pNode
;
if
(
pUser
==
NULL
)
break
;
if
(
pUser
==
NULL
)
break
;
pShow
->
pNode
=
(
void
*
)
pUser
->
next
;
pShow
->
pNode
=
(
void
*
)
pUser
->
next
;
...
@@ -236,26 +225,29 @@ int mgmtRetrieveUsers(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
...
@@ -236,26 +225,29 @@ int mgmtRetrieveUsers(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
return
numOfRows
;
return
numOfRows
;
}
}
void
*
mgmtUserActionInsert
(
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
)
{
void
*
mgmtUserActionInsert
(
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
)
{
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pUser
->
acct
);
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pUser
->
acct
);
mgmtAddUserIntoAcct
(
pAcct
,
pUser
);
mgmtAddUserIntoAcct
(
pAcct
,
pUser
);
return
NULL
;
return
NULL
;
}
}
void
*
mgmtUserActionDelete
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
)
{
void
*
mgmtUserActionDelete
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pUser
->
acct
);
SAcctObj
*
pAcct
=
mgmtGetAcct
(
pUser
->
acct
);
mgmtRemoveUserFromAcct
(
pAcct
,
pUser
);
mgmtRemoveUserFromAcct
(
pAcct
,
pUser
);
return
NULL
;
return
NULL
;
}
}
void
*
mgmtUserActionUpdate
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
)
{
void
*
mgmtUserActionUpdate
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
return
mgmtUserActionReset
(
row
,
str
,
size
,
ssize
);
return
mgmtUserActionReset
(
row
,
str
,
size
,
ssize
);
}
}
void
*
mgmtUserActionEncode
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
)
{
void
*
mgmtUserActionEncode
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
int
tsize
=
pUser
->
updateEnd
-
(
char
*
)
pUser
;
int
32_t
tsize
=
pUser
->
updateEnd
-
(
char
*
)
pUser
;
if
(
size
<
tsize
)
{
if
(
size
<
tsize
)
{
*
ssize
=
-
1
;
*
ssize
=
-
1
;
}
else
{
}
else
{
...
@@ -264,27 +256,26 @@ void *mgmtUserActionEncode(void *row, char *str, int size, int *ssize) {
...
@@ -264,27 +256,26 @@ void *mgmtUserActionEncode(void *row, char *str, int size, int *ssize) {
}
}
return
NULL
;
return
NULL
;
}
}
void
*
mgmtUserActionDecode
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
)
{
void
*
mgmtUserActionDecode
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
SUserObj
*
pUser
=
(
SUserObj
*
)
malloc
(
sizeof
(
SUserObj
));
SUserObj
*
pUser
=
(
SUserObj
*
)
malloc
(
sizeof
(
SUserObj
));
if
(
pUser
==
NULL
)
return
NULL
;
if
(
pUser
==
NULL
)
return
NULL
;
memset
(
pUser
,
0
,
sizeof
(
SUserObj
));
memset
(
pUser
,
0
,
sizeof
(
SUserObj
));
int
tsize
=
pUser
->
updateEnd
-
(
char
*
)
pUser
;
int
32_t
tsize
=
pUser
->
updateEnd
-
(
char
*
)
pUser
;
memcpy
(
pUser
,
str
,
tsize
);
memcpy
(
pUser
,
str
,
tsize
);
return
(
void
*
)
pUser
;
return
(
void
*
)
pUser
;
}
}
void
*
mgmtUserActionBeforeBatchUpdate
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
)
{
return
NULL
;
}
void
*
mgmtUserActionBatchUpdate
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
)
{
return
NULL
;
}
void
*
mgmtUserActionReset
(
void
*
row
,
char
*
str
,
int32_t
size
,
int32_t
*
ssize
)
{
void
*
mgmtUserActionAfterBatchUpdate
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
)
{
return
NULL
;
}
void
*
mgmtUserActionReset
(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
)
{
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
SUserObj
*
pUser
=
(
SUserObj
*
)
row
;
int
tsize
=
pUser
->
updateEnd
-
(
char
*
)
pUser
;
int
32_t
tsize
=
pUser
->
updateEnd
-
(
char
*
)
pUser
;
memcpy
(
pUser
,
str
,
tsize
);
memcpy
(
pUser
,
str
,
tsize
);
return
NULL
;
return
NULL
;
}
}
void
*
mgmtUserActionDestroy
(
void
*
row
,
char
*
str
,
int
size
,
in
t
*
ssize
)
{
void
*
mgmtUserActionDestroy
(
void
*
row
,
char
*
str
,
int
32_t
size
,
int32_
t
*
ssize
)
{
tfree
(
row
);
tfree
(
row
);
return
NULL
;
return
NULL
;
}
}
src/mnode/src/mgmtVgroup.c
浏览文件 @
f6265074
...
@@ -30,9 +30,9 @@
...
@@ -30,9 +30,9 @@
void
*
vgSdb
=
NULL
;
void
*
vgSdb
=
NULL
;
int
tsVgUpdateSize
;
int
tsVgUpdateSize
;
extern
void
*
d
bSdb
;
extern
void
*
tsD
bSdb
;
extern
void
*
acctSdb
;
extern
void
*
acctSdb
;
extern
void
*
u
serSdb
;
extern
void
*
tsU
serSdb
;
extern
void
*
dnodeSdb
;
extern
void
*
dnodeSdb
;
void
*
(
*
mgmtVgroupActionFp
[
SDB_MAX_ACTION_TYPES
])(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
void
*
(
*
mgmtVgroupActionFp
[
SDB_MAX_ACTION_TYPES
])(
void
*
row
,
char
*
str
,
int
size
,
int
*
ssize
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录