Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8309718a
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
8309718a
编写于
3月 29, 2023
作者:
C
cademfly
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
condition
上级
6265251a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
166 addition
and
19 deletion
+166
-19
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+166
-19
未找到文件。
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
8309718a
...
...
@@ -130,9 +130,36 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
int32_t
numOfTopics
=
taosHashGetSize
(
pUser
->
topics
);
int32_t
size
=
sizeof
(
SUserObj
)
+
USER_RESERVE_SIZE
+
(
numOfReadDbs
+
numOfWriteDbs
)
*
TSDB_DB_FNAME_LEN
+
(
numOfReadStbs
+
numOfWriteStbs
)
*
TSDB_TABLE_FNAME_LEN
+
numOfTopics
*
TSDB_TOPIC_FNAME_LEN
;
char
*
stb
=
taosHashIterate
(
pUser
->
readStbs
,
NULL
);
while
(
stb
!=
NULL
)
{
size_t
keyLen
=
0
;
void
*
key
=
taosHashGetKey
(
stb
,
&
keyLen
);
size
+=
sizeof
(
int32_t
);
size
+=
keyLen
;
size_t
valueLen
=
0
;
valueLen
=
strlen
(
stb
);
size
+=
sizeof
(
int32_t
);
size
+=
valueLen
;
stb
=
taosHashIterate
(
pUser
->
readStbs
,
stb
);
}
stb
=
taosHashIterate
(
pUser
->
writeStbs
,
NULL
);
while
(
stb
!=
NULL
)
{
size_t
keyLen
=
0
;
void
*
key
=
taosHashGetKey
(
stb
,
&
keyLen
);
size
+=
sizeof
(
int32_t
);
size
+=
keyLen
;
size_t
valueLen
=
0
;
valueLen
=
strlen
(
stb
);
size
+=
sizeof
(
int32_t
);
size
+=
keyLen
;
stb
=
taosHashIterate
(
pUser
->
writeStbs
,
stb
);
}
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_USER
,
USER_VER_NUMBER
,
size
);
if
(
pRaw
==
NULL
)
goto
_OVER
;
...
...
@@ -171,15 +198,31 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
topic
=
taosHashIterate
(
pUser
->
topics
,
topic
);
}
char
*
stb
=
taosHashIterate
(
pUser
->
readStbs
,
NULL
);
stb
=
taosHashIterate
(
pUser
->
readStbs
,
NULL
);
while
(
stb
!=
NULL
)
{
SDB_SET_BINARY
(
pRaw
,
dataPos
,
stb
,
TSDB_TABLE_FNAME_LEN
,
_OVER
);
size_t
keyLen
=
0
;
void
*
key
=
taosHashGetKey
(
stb
,
&
keyLen
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
keyLen
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
key
,
keyLen
,
_OVER
);
size_t
valueLen
=
0
;
valueLen
=
strlen
(
stb
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
valueLen
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
stb
,
valueLen
,
_OVER
);
stb
=
taosHashIterate
(
pUser
->
readStbs
,
stb
);
}
stb
=
taosHashIterate
(
pUser
->
writeStbs
,
NULL
);
while
(
stb
!=
NULL
)
{
SDB_SET_BINARY
(
pRaw
,
dataPos
,
stb
,
TSDB_TABLE_FNAME_LEN
,
_OVER
);
size_t
keyLen
=
0
;
void
*
key
=
taosHashGetKey
(
stb
,
&
keyLen
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
keyLen
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
key
,
keyLen
,
_OVER
);
size_t
valueLen
=
0
;
valueLen
=
strlen
(
stb
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
valueLen
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
stb
,
valueLen
,
_OVER
);
stb
=
taosHashIterate
(
pUser
->
writeStbs
,
stb
);
}
...
...
@@ -279,17 +322,39 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
if
(
sver
>=
3
){
for
(
int32_t
i
=
0
;
i
<
numOfReadStbs
;
++
i
)
{
char
stb
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
SDB_GET_BINARY
(
pRaw
,
dataPos
,
stb
,
TSDB_TABLE_FNAME_LEN
,
_OVER
)
int32_t
len
=
strlen
(
stb
)
+
1
;
taosHashPut
(
pUser
->
readStbs
,
stb
,
len
,
stb
,
TSDB_DB_FNAME_LEN
);
int32_t
keyLen
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
keyLen
,
_OVER
);
char
*
key
=
taosMemoryCalloc
(
keyLen
+
1
,
sizeof
(
char
));
SDB_GET_BINARY
(
pRaw
,
dataPos
,
key
,
keyLen
,
_OVER
);
int32_t
valuelen
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
valuelen
,
_OVER
);
char
*
value
=
taosMemoryCalloc
(
valuelen
+
1
,
sizeof
(
char
));
SDB_GET_BINARY
(
pRaw
,
dataPos
,
value
,
valuelen
,
_OVER
)
taosHashPut
(
pUser
->
readStbs
,
key
,
keyLen
,
value
,
valuelen
);
taosMemoryFree
(
key
);
taosMemoryFree
(
value
);
}
for
(
int32_t
i
=
0
;
i
<
numOfWriteStbs
;
++
i
)
{
char
stb
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
SDB_GET_BINARY
(
pRaw
,
dataPos
,
stb
,
TSDB_TABLE_FNAME_LEN
,
_OVER
)
int32_t
len
=
strlen
(
stb
)
+
1
;
taosHashPut
(
pUser
->
writeStbs
,
stb
,
len
,
stb
,
TSDB_TABLE_FNAME_LEN
);
int32_t
keyLen
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
keyLen
,
_OVER
);
char
*
key
=
taosMemoryCalloc
(
keyLen
+
1
,
sizeof
(
char
));
SDB_GET_BINARY
(
pRaw
,
dataPos
,
key
,
keyLen
,
_OVER
);
int32_t
valuelen
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
valuelen
,
_OVER
);
char
*
value
=
taosMemoryCalloc
(
valuelen
+
1
,
sizeof
(
char
));
SDB_GET_BINARY
(
pRaw
,
dataPos
,
value
,
valuelen
,
_OVER
)
taosHashPut
(
pUser
->
writeStbs
,
key
,
keyLen
,
value
,
valuelen
);
taosMemoryFree
(
key
);
taosMemoryFree
(
value
);
}
}
...
...
@@ -755,6 +820,48 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
taosHashPut
(
newUser
.
topics
,
pTopic
->
name
,
len
,
pTopic
->
name
,
TSDB_TOPIC_FNAME_LEN
);
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_ADD_READ_TAG
)
{
char
tbFName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
snprintf
(
tbFName
,
sizeof
(
tbFName
),
"%s.%s"
,
alterReq
.
objname
,
alterReq
.
tabName
);
int32_t
len
=
strlen
(
tbFName
)
+
1
;
SStbObj
*
pStb
=
mndAcquireStb
(
pMnode
,
tbFName
);
if
(
pStb
==
NULL
)
{
mndReleaseStb
(
pMnode
,
pStb
);
goto
_OVER
;
}
if
(
alterReq
.
tagCond
==
NULL
){
mndReleaseStb
(
pMnode
,
pStb
);
goto
_OVER
;
}
int32_t
condLen
=
strlen
(
alterReq
.
tagCond
);
if
(
taosHashPut
(
newUser
.
readStbs
,
tbFName
,
len
,
alterReq
.
tagCond
,
strlen
(
alterReq
.
tagCond
))
!=
0
)
{
mndReleaseStb
(
pMnode
,
pStb
);
goto
_OVER
;
}
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_ADD_WRITE_TAG
)
{
char
tbFName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
snprintf
(
tbFName
,
sizeof
(
tbFName
),
"%s.%s"
,
alterReq
.
objname
,
alterReq
.
tabName
);
int32_t
len
=
strlen
(
tbFName
)
+
1
;
SStbObj
*
pStb
=
mndAcquireStb
(
pMnode
,
tbFName
);
if
(
pStb
==
NULL
)
{
mndReleaseStb
(
pMnode
,
pStb
);
goto
_OVER
;
}
if
(
alterReq
.
tagCond
==
NULL
){
mndReleaseStb
(
pMnode
,
pStb
);
goto
_OVER
;
}
int32_t
condLen
=
strlen
(
alterReq
.
tagCond
);
if
(
taosHashPut
(
newUser
.
writeStbs
,
tbFName
,
len
,
alterReq
.
tagCond
,
condLen
)
!=
0
)
{
mndReleaseStb
(
pMnode
,
pStb
);
goto
_OVER
;
}
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_REMOVE_SUBSCRIBE_TOPIC
)
{
int32_t
len
=
strlen
(
alterReq
.
objname
)
+
1
;
SMqTopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
alterReq
.
objname
);
...
...
@@ -1037,12 +1144,32 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
STR_WITH_MAXSIZE_TO_VARSTR
(
privilege
,
"read"
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
privilege
,
false
);
size_t
superTableLen
=
0
;
void
*
superTable
=
taosHashGetKey
(
stb
,
&
superTableLen
);
char
objName
[
TSDB_TABLE_NAME_LEN
]
=
{
0
};
mndExtractTbNameFromStbFullName
(
superTable
,
objName
,
TSDB_TABLE_NAME_LEN
);
SNode
*
pAst
=
NULL
;
int32_t
code
=
nodesStringToNode
(
stb
,
&
pAst
);
char
*
buf
=
taosMemoryCalloc
(
TSDB_EXPLAIN_RESULT_ROW_SIZE
,
sizeof
(
char
));
int32_t
sqlLen
=
0
;
nodesNodeToSQL
(
pAst
,
buf
,
TSDB_EXPLAIN_RESULT_ROW_SIZE
*
sizeof
(
char
),
&
sqlLen
);
char
*
value
=
taosMemoryCalloc
(
sqlLen
+
TSDB_TABLE_NAME_LEN
+
1
,
sizeof
(
char
));
sprintf
(
value
,
"%s(%s)"
,
objName
,
buf
);
char
*
obj
=
taosMemoryCalloc
(
sqlLen
+
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
+
1
,
sizeof
(
char
));
STR_WITH_MAXSIZE_TO_VARSTR
(
obj
,
value
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
char
objName
[
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
mndExtractTbNameFromStbFullName
(
stb
,
&
objName
[
VARSTR_HEADER_SIZE
],
TSDB_TABLE_NAME_LEN
);
varDataSetLen
(
objName
,
strlen
(
&
objName
[
VARSTR_HEADER_SIZE
]));
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
objName
,
false
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
obj
,
false
);
taosMemoryFree
(
value
);
taosMemoryFree
(
buf
);
taosMemoryFree
(
obj
);
numOfRows
++
;
stb
=
taosHashIterate
(
pUser
->
readStbs
,
stb
);
...
...
@@ -1061,11 +1188,31 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
privilege
,
false
);
size_t
superTableLen
=
0
;
void
*
superTable
=
taosHashGetKey
(
stb
,
&
superTableLen
);
char
objName
[
TSDB_TABLE_NAME_LEN
]
=
{
0
};
mndExtractTbNameFromStbFullName
(
stb
,
&
objName
[
VARSTR_HEADER_SIZE
],
TSDB_TABLE_NAME_LEN
);
varDataSetLen
(
objName
,
strlen
(
&
objName
[
VARSTR_HEADER_SIZE
]));
mndExtractTbNameFromStbFullName
(
superTable
,
objName
,
TSDB_TABLE_NAME_LEN
);
SNode
*
pAst
=
NULL
;
int32_t
code
=
nodesStringToNode
(
stb
,
&
pAst
);
char
*
buf
=
taosMemoryCalloc
(
TSDB_EXPLAIN_RESULT_ROW_SIZE
,
sizeof
(
char
));
int32_t
sqlLen
=
0
;
nodesNodeToSQL
(
pAst
,
buf
,
TSDB_EXPLAIN_RESULT_ROW_SIZE
*
sizeof
(
char
),
&
sqlLen
);
char
*
value
=
taosMemoryCalloc
(
sqlLen
+
TSDB_TABLE_NAME_LEN
+
1
,
sizeof
(
char
));
sprintf
(
value
,
"%s(%s)"
,
objName
,
buf
);
char
*
obj
=
taosMemoryCalloc
(
sqlLen
+
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
+
1
,
sizeof
(
char
));
STR_WITH_MAXSIZE_TO_VARSTR
(
obj
,
value
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
objName
,
false
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
obj
,
false
);
taosMemoryFree
(
value
);
taosMemoryFree
(
buf
);
taosMemoryFree
(
obj
);
numOfRows
++
;
stb
=
taosHashIterate
(
pUser
->
writeStbs
,
stb
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录