Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a3f57b9d
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看板
未验证
提交
a3f57b9d
编写于
12月 02, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
12月 02, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18636 from taosdata/fix/3.0_bugfix_wxy
feat: sql command 'show user privileges'
上级
55e54479
71140f56
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
5 deletion
+32
-5
source/dnode/mnode/impl/inc/mndUser.h
source/dnode/mnode/impl/inc/mndUser.h
+1
-0
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+2
-0
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+29
-5
未找到文件。
source/dnode/mnode/impl/inc/mndUser.h
浏览文件 @
a3f57b9d
...
...
@@ -31,6 +31,7 @@ void mndReleaseUser(SMnode *pMnode, SUserObj *pUser);
// for trans test
SSdbRaw
*
mndUserActionEncode
(
SUserObj
*
pUser
);
SHashObj
*
mndDupDbHash
(
SHashObj
*
pOld
);
SHashObj
*
mndDupTopicHash
(
SHashObj
*
pOld
);
int32_t
mndValidateUserAuthInfo
(
SMnode
*
pMnode
,
SUserAuthVersion
*
pUsers
,
int32_t
numOfUses
,
void
**
ppRsp
,
int32_t
*
pRspLen
);
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
a3f57b9d
...
...
@@ -108,6 +108,8 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
type
=
TSDB_MGMT_TABLE_APPS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_STREAM_TASKS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_STREAM_TASKS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_USER_PRIVILEGES
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_PRIVILEGES
;
}
else
{
// ASSERT(0);
}
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
a3f57b9d
...
...
@@ -161,7 +161,7 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
char
*
topic
=
taosHashIterate
(
pUser
->
topics
,
NULL
);
while
(
topic
!=
NULL
)
{
SDB_SET_BINARY
(
pRaw
,
dataPos
,
topic
,
TSDB_TOPIC_FNAME_LEN
,
_OVER
);
db
=
taosHashIterate
(
pUser
->
topics
,
topic
);
topic
=
taosHashIterate
(
pUser
->
topics
,
topic
);
}
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
USER_RESERVE_SIZE
,
_OVER
)
...
...
@@ -446,7 +446,7 @@ static int32_t mndAlterUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SRpc
return
0
;
}
SHashObj
*
mndDup
DbHash
(
SHashObj
*
pOld
)
{
SHashObj
*
mndDup
ObjHash
(
SHashObj
*
pOld
,
int32_t
dataLen
)
{
SHashObj
*
pNew
=
taosHashInit
(
taosHashGetSize
(
pOld
),
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
pNew
==
NULL
)
{
...
...
@@ -457,7 +457,7 @@ SHashObj *mndDupDbHash(SHashObj *pOld) {
char
*
db
=
taosHashIterate
(
pOld
,
NULL
);
while
(
db
!=
NULL
)
{
int32_t
len
=
strlen
(
db
)
+
1
;
if
(
taosHashPut
(
pNew
,
db
,
len
,
db
,
TSDB_DB_FNAME_LEN
)
!=
0
)
{
if
(
taosHashPut
(
pNew
,
db
,
len
,
db
,
dataLen
)
!=
0
)
{
taosHashCancelIterate
(
pOld
,
db
);
taosHashCleanup
(
pNew
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -469,6 +469,10 @@ SHashObj *mndDupDbHash(SHashObj *pOld) {
return
pNew
;
}
SHashObj
*
mndDupDbHash
(
SHashObj
*
pOld
)
{
return
mndDupObjHash
(
pOld
,
TSDB_DB_FNAME_LEN
);
}
SHashObj
*
mndDupTopicHash
(
SHashObj
*
pOld
)
{
return
mndDupObjHash
(
pOld
,
TSDB_TOPIC_FNAME_LEN
);
}
static
int32_t
mndProcessAlterUserReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
...
...
@@ -519,7 +523,7 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
taosRLockLatch
(
&
pUser
->
lock
);
newUser
.
readDbs
=
mndDupDbHash
(
pUser
->
readDbs
);
newUser
.
writeDbs
=
mndDupDbHash
(
pUser
->
writeDbs
);
newUser
.
topics
=
mndDup
Db
Hash
(
pUser
->
topics
);
newUser
.
topics
=
mndDup
Topic
Hash
(
pUser
->
topics
);
taosRUnLockLatch
(
&
pUser
->
lock
);
if
(
newUser
.
readDbs
==
NULL
||
newUser
.
writeDbs
==
NULL
||
newUser
.
topics
==
NULL
)
{
...
...
@@ -832,6 +836,26 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
int32_t
numOfTopics
=
taosHashGetSize
(
pUser
->
topics
);
if
(
numOfRows
+
numOfReadDbs
+
numOfWriteDbs
+
numOfTopics
>=
rows
)
break
;
if
(
pUser
->
superUser
)
{
cols
=
0
;
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
char
userName
[
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
userName
,
pUser
->
user
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
userName
,
false
);
char
privilege
[
20
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
privilege
,
"all"
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
privilege
,
false
);
char
objName
[
20
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
objName
,
"all"
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
objName
,
false
);
numOfRows
++
;
}
char
*
db
=
taosHashIterate
(
pUser
->
readDbs
,
NULL
);
while
(
db
!=
NULL
)
{
cols
=
0
;
...
...
@@ -902,7 +926,7 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
topicName
,
false
);
numOfRows
++
;
db
=
taosHashIterate
(
pUser
->
topics
,
topic
);
topic
=
taosHashIterate
(
pUser
->
topics
,
topic
);
}
sdbRelease
(
pSdb
,
pUser
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录