Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
89ec5a88
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
89ec5a88
编写于
4月 27, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: refact user mgmt
上级
15a0befa
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
16 deletion
+17
-16
include/common/tmsg.h
include/common/tmsg.h
+1
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+5
-0
source/dnode/mnode/impl/src/mndInfoSchema.c
source/dnode/mnode/impl/src/mndInfoSchema.c
+0
-1
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+11
-15
未找到文件。
include/common/tmsg.h
浏览文件 @
89ec5a88
...
...
@@ -438,6 +438,7 @@ typedef struct {
int32_t
tSerializeSGetUserAuthRsp
(
void
*
buf
,
int32_t
bufLen
,
SGetUserAuthRsp
*
pRsp
);
int32_t
tDeserializeSGetUserAuthRsp
(
void
*
buf
,
int32_t
bufLen
,
SGetUserAuthRsp
*
pRsp
);
void
tFreeSGetUserAuthRsp
(
SGetUserAuthRsp
*
pRsp
);
typedef
struct
{
int16_t
colId
;
// column id
...
...
source/common/src/tmsg.c
浏览文件 @
89ec5a88
...
...
@@ -1302,6 +1302,11 @@ int32_t tDeserializeSGetUserAuthRsp(void *buf, int32_t bufLen, SGetUserAuthRsp *
return
0
;
}
void
tFreeSGetUserAuthRsp
(
SGetUserAuthRsp
*
pRsp
)
{
taosHashCleanup
(
pRsp
->
readDbs
);
taosHashCleanup
(
pRsp
->
writeDbs
);
}
int32_t
tSerializeSCreateDropMQSBNodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateQnodeReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
...
...
source/dnode/mnode/impl/src/mndInfoSchema.c
浏览文件 @
89ec5a88
...
...
@@ -164,7 +164,6 @@ static const SInfosTableSchema userUsersSchema[] = {
{.
name
=
"name"
,
.
bytes
=
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"privilege"
,
.
bytes
=
10
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"account"
,
.
bytes
=
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
};
static
const
SInfosTableSchema
grantsSchema
[]
=
{
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
89ec5a88
...
...
@@ -165,8 +165,9 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
int32_t
numOfWriteDbs
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
numOfReadDbs
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
numOfWriteDbs
,
_OVER
)
pUser
->
readDbs
=
taosHashInit
(
numOfReadDbs
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
true
);
pUser
->
writeDbs
=
taosHashInit
(
numOfWriteDbs
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
true
);
pUser
->
readDbs
=
taosHashInit
(
numOfReadDbs
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
pUser
->
writeDbs
=
taosHashInit
(
numOfWriteDbs
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
pUser
->
readDbs
==
NULL
||
pUser
->
writeDbs
==
NULL
)
goto
_OVER
;
for
(
int32_t
i
=
0
;
i
<
numOfReadDbs
;
++
i
)
{
...
...
@@ -340,13 +341,13 @@ _OVER:
return
code
;
}
static
int32_t
mnd
Update
User
(
SMnode
*
pMnode
,
SUserObj
*
pOld
,
SUserObj
*
pNew
,
SNodeMsg
*
pReq
)
{
static
int32_t
mnd
Alter
User
(
SMnode
*
pMnode
,
SUserObj
*
pOld
,
SUserObj
*
pNew
,
SNodeMsg
*
pReq
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_ALTER_USER
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
mError
(
"user:%s, failed to
update
since %s"
,
pOld
->
user
,
terrstr
());
mError
(
"user:%s, failed to
alter
since %s"
,
pOld
->
user
,
terrstr
());
return
-
1
;
}
mDebug
(
"trans:%d, used to
update
user:%s"
,
pTrans
->
id
,
pOld
->
user
);
mDebug
(
"trans:%d, used to
alter
user:%s"
,
pTrans
->
id
,
pOld
->
user
);
SSdbRaw
*
pRedoRaw
=
mndUserActionEncode
(
pNew
);
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
{
...
...
@@ -367,7 +368,8 @@ static int32_t mndUpdateUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SNo
}
static
SHashObj
*
mndDupDbHash
(
SHashObj
*
pOld
)
{
SHashObj
*
pNew
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
true
);
SHashObj
*
pNew
=
taosHashInit
(
taosHashGetSize
(
pOld
),
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
pNew
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
...
...
@@ -378,8 +380,8 @@ static SHashObj *mndDupDbHash(SHashObj *pOld) {
int32_t
len
=
strlen
(
db
)
+
1
;
if
(
taosHashPut
(
pNew
,
db
,
len
,
db
,
TSDB_DB_FNAME_LEN
)
!=
0
)
{
taosHashCancelIterate
(
pOld
,
db
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
taosHashCleanup
(
pNew
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
db
=
taosHashIterate
(
pOld
,
db
);
...
...
@@ -485,7 +487,7 @@ static int32_t mndProcessAlterUserReq(SNodeMsg *pReq) {
goto
_OVER
;
}
code
=
mnd
Update
User
(
pMnode
,
pUser
,
&
newUser
,
pReq
);
code
=
mnd
Alter
User
(
pMnode
,
pUser
,
&
newUser
,
pReq
);
if
(
code
==
0
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
_OVER:
...
...
@@ -632,8 +634,7 @@ static int32_t mndProcessGetUserAuthReq(SNodeMsg *pReq) {
_OVER:
mndReleaseUser
(
pMnode
,
pUser
);
taosHashCleanup
(
authRsp
.
readDbs
);
taosHashCleanup
(
authRsp
.
writeDbs
);
tFreeSGetUserAuthRsp
(
&
authRsp
);
return
code
;
}
...
...
@@ -670,11 +671,6 @@ static int32_t mndRetrieveUsers(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pUser
->
createdTime
,
false
);
cols
++
;
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
);
STR_WITH_MAXSIZE_TO_VARSTR
(
name
,
pUser
->
acct
,
pShow
->
bytes
[
cols
]);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
name
,
false
);
numOfRows
++
;
sdbRelease
(
pSdb
,
pUser
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录