Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
db725c6f
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看板
提交
db725c6f
编写于
3月 30, 2023
作者:
C
cademfly
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
show priviledge format
上级
3ae49964
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
81 addition
and
26 deletion
+81
-26
include/util/tdef.h
include/util/tdef.h
+1
-0
source/common/src/systable.c
source/common/src/systable.c
+3
-1
source/dnode/mnode/impl/inc/mndStb.h
source/dnode/mnode/impl/inc/mndStb.h
+1
-0
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+7
-0
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+69
-25
未找到文件。
include/util/tdef.h
浏览文件 @
db725c6f
...
...
@@ -198,6 +198,7 @@ typedef enum ELogicConditionType {
#define TSDB_STREAM_NAME_LEN 193 // it is a null-terminated string
#define TSDB_DB_NAME_LEN 65
#define TSDB_DB_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_PRIVILEDGE_CONDITION_LEN 200
#define TSDB_FUNC_NAME_LEN 65
#define TSDB_FUNC_COMMENT_LEN 1024 * 1024
...
...
source/common/src/systable.c
浏览文件 @
db725c6f
...
...
@@ -296,7 +296,9 @@ static const SSysDbTableSchema vnodesSchema[] = {
static
const
SSysDbTableSchema
userUserPrivilegesSchema
[]
=
{
{.
name
=
"user_name"
,
.
bytes
=
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"privilege"
,
.
bytes
=
10
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"object_name"
,
.
bytes
=
TSDB_DB_NAME_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"db_name"
,
.
bytes
=
TSDB_DB_NAME_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"table_name"
,
.
bytes
=
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"condition"
,
.
bytes
=
TSDB_PRIVILEDGE_CONDITION_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
};
static
const
SSysTableMeta
infosMeta
[]
=
{
...
...
source/dnode/mnode/impl/inc/mndStb.h
浏览文件 @
db725c6f
...
...
@@ -38,6 +38,7 @@ void mndFreeStb(SStbObj *pStb);
int32_t
mndBuildSMCreateStbRsp
(
SMnode
*
pMnode
,
char
*
dbFName
,
char
*
stbFName
,
void
**
pCont
,
int32_t
*
pLen
);
void
mndExtractDbNameFromStbFullName
(
const
char
*
stbFullName
,
char
*
dst
);
void
mndExtractShortDbNameFromStbFullName
(
const
char
*
stbFullName
,
char
*
dst
);
void
mndExtractTbNameFromStbFullName
(
const
char
*
stbFullName
,
char
*
dst
,
int32_t
dstSize
);
const
char
*
mndGetStbStr
(
const
char
*
src
);
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
db725c6f
...
...
@@ -2613,6 +2613,13 @@ void mndExtractDbNameFromStbFullName(const char *stbFullName, char *dst) {
tNameGetFullDbName
(
&
name
,
dst
);
}
void
mndExtractShortDbNameFromStbFullName
(
const
char
*
stbFullName
,
char
*
dst
)
{
SName
name
=
{
0
};
tNameFromString
(
&
name
,
stbFullName
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
tNameGetDbName
(
&
name
,
dst
);
}
void
mndExtractTbNameFromStbFullName
(
const
char
*
stbFullName
,
char
*
dst
,
int32_t
dstSize
)
{
int32_t
pos
=
-
1
;
int32_t
num
=
0
;
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
db725c6f
...
...
@@ -1081,48 +1081,50 @@ static void mndLoopHash(SHashObj * hash, char *priType, SSDataBlock *pBlock, int
size_t
keyLen
=
0
;
void
*
key
=
taosHashGetKey
(
value
,
&
keyLen
);
char
dbName
[
TSDB_DB_NAME_LEN
]
=
{
0
};
mndExtractShortDbNameFromStbFullName
(
key
,
dbName
);
char
dbNameContent
[
TSDB_DB_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
dbNameContent
,
dbName
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
*
numOfRows
,
(
const
char
*
)
dbNameContent
,
false
);
char
tableName
[
TSDB_TABLE_NAME_LEN
]
=
{
0
};
mndExtractTbNameFromStbFullName
(
key
,
tableName
,
TSDB_TABLE_NAME_LEN
);
char
tableNameContent
[
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
tableNameContent
,
tableName
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
*
numOfRows
,
(
const
char
*
)
tableNameContent
,
false
);
if
(
strcmp
(
key
,
value
)
==
0
){
char
*
obj
=
taosMemoryMalloc
(
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
);
STR_WITH_MAXSIZE_TO_VARSTR
(
obj
,
tableName
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
*
numOfRows
,
(
const
char
*
)
obj
,
false
);
taosMemoryFree
(
obj
);
}
else
{
if
(
strcmp
(
key
,
value
)
!=
0
){
SNode
*
pAst
=
NULL
;
int32_t
sqlLen
=
0
;
char
*
sql
=
NULL
;
char
sql
[
TSDB_EXPLAIN_RESULT_ROW_SIZE
]
=
{
0
}
;
if
(
nodesStringToNode
(
value
,
&
pAst
)
==
0
)
{
sql
=
taosMemoryMalloc
(
TSDB_EXPLAIN_RESULT_ROW_SIZE
);
nodesNodeToSQL
(
pAst
,
sql
,
TSDB_EXPLAIN_RESULT_ROW_SIZE
,
&
sqlLen
);
nodesDestroyNode
(
pAst
);
}
else
{
sqlLen
=
5
;
sql
=
taosMemoryMalloc
(
sqlLen
+
1
);
sprintf
(
sql
,
"error"
);
}
int32_t
contentLen
=
sqlLen
+
TSDB_TABLE_NAME_LEN
+
3
;
char
*
content
=
taosMemoryMalloc
(
contentLen
);
if
(
sql
!=
NULL
){
sprintf
(
content
,
"%s(%s)"
,
tableName
,
sql
);
taosMemoryFree
(
sql
);
}
char
*
obj
=
taosMemoryMalloc
(
contentLen
+
VARSTR_HEADER_SIZE
);
STR_WITH_MAXSIZE_TO_VARSTR
(
obj
,
content
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
taosMemoryFree
(
content
);
//char *obj = taosMemoryMalloc(sqlLen + VARSTR_HEADER_SIZE + 1);
char
obj
[
TSDB_PRIVILEDGE_CONDITION_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
obj
,
sql
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
*
numOfRows
,
(
const
char
*
)
obj
,
false
);
taosMemoryFree
(
obj
);
//
taosMemoryFree(obj);
}
else
{
char
condition
[
20
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
condition
,
""
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
*
numOfRows
,
(
const
char
*
)
condition
,
false
);
}
(
*
numOfRows
)
++
;
value
=
taosHashIterate
(
hash
,
value
);
}
...
...
@@ -1143,7 +1145,9 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
int32_t
numOfReadDbs
=
taosHashGetSize
(
pUser
->
readDbs
);
int32_t
numOfWriteDbs
=
taosHashGetSize
(
pUser
->
writeDbs
);
int32_t
numOfTopics
=
taosHashGetSize
(
pUser
->
topics
);
if
(
numOfRows
+
numOfReadDbs
+
numOfWriteDbs
+
numOfTopics
>=
rows
)
break
;
int32_t
numOfReadTbs
=
taosHashGetSize
(
pUser
->
readTbs
);
int32_t
numOfWriteTbs
=
taosHashGetSize
(
pUser
->
writeTbs
);
if
(
numOfRows
+
numOfReadDbs
+
numOfWriteDbs
+
numOfTopics
+
numOfReadTbs
+
numOfWriteTbs
>=
rows
)
break
;
if
(
pUser
->
superUser
)
{
cols
=
0
;
...
...
@@ -1162,6 +1166,16 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
objName
,
false
);
char
tableName
[
20
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
tableName
,
""
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
tableName
,
false
);
char
condition
[
20
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
condition
,
""
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
condition
,
false
);
numOfRows
++
;
}
...
...
@@ -1186,6 +1200,16 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
objName
,
false
);
char
tableName
[
20
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
tableName
,
""
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
tableName
,
false
);
char
condition
[
20
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
condition
,
""
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
condition
,
false
);
numOfRows
++
;
db
=
taosHashIterate
(
pUser
->
readDbs
,
db
);
}
...
...
@@ -1211,6 +1235,16 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
objName
,
false
);
char
tableName
[
20
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
tableName
,
""
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
tableName
,
false
);
char
condition
[
20
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
condition
,
""
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
condition
,
false
);
numOfRows
++
;
db
=
taosHashIterate
(
pUser
->
writeDbs
,
db
);
}
...
...
@@ -1238,6 +1272,16 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
topicName
,
false
);
char
tableName
[
20
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
tableName
,
""
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
tableName
,
false
);
char
condition
[
20
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
condition
,
""
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
condition
,
false
);
numOfRows
++
;
topic
=
taosHashIterate
(
pUser
->
topics
,
topic
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录