Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
afbc468d
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看板
未验证
提交
afbc468d
编写于
4月 11, 2023
作者:
X
Xiaoyu Wang
提交者:
GitHub
4月 11, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20852 from taosdata/feat/table_level_privilege_wxy
feat: table level privilege
上级
b4f0fcc7
416af9a5
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
347 addition
and
233 deletion
+347
-233
include/common/tmsg.h
include/common/tmsg.h
+3
-6
source/common/src/tmsg.c
source/common/src/tmsg.c
+68
-34
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+1
-0
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+85
-67
source/libs/catalog/src/ctgCache.c
source/libs/catalog/src/ctgCache.c
+29
-23
source/libs/catalog/src/ctgUtil.c
source/libs/catalog/src/ctgUtil.c
+112
-103
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+19
-0
source/libs/parser/src/parAuthenticator.c
source/libs/parser/src/parAuthenticator.c
+30
-0
未找到文件。
include/common/tmsg.h
浏览文件 @
afbc468d
...
...
@@ -181,12 +181,8 @@ typedef enum _mgmt_table {
#define TSDB_ALTER_USER_REMOVE_READ_TABLE 0xE
#define TSDB_ALTER_USER_ADD_WRITE_TABLE 0xF
#define TSDB_ALTER_USER_REMOVE_WRITE_TABLE 0x10
#define TSDB_ALTER_USER_ADD_READ_TAG 0x11
#define TSDB_ALTER_USER_REMOVE_READ_TAG 0x12
#define TSDB_ALTER_USER_ADD_WRITE_TAG 0x13
#define TSDB_ALTER_USER_REMOVE_WRITE_TAG 0x14
#define TSDB_ALTER_USER_ADD_ALL_TABLE 0x15
#define TSDB_ALTER_USER_REMOVE_ALL_TABLE 0x16
#define TSDB_ALTER_USER_ADD_ALL_TABLE 0x11
#define TSDB_ALTER_USER_REMOVE_ALL_TABLE 0x12
#define TSDB_ALTER_USER_PRIVILEGES 0x2
...
...
@@ -713,6 +709,7 @@ typedef struct {
SHashObj
*
writeDbs
;
SHashObj
*
readTbs
;
SHashObj
*
writeTbs
;
SHashObj
*
useDbs
;
}
SGetUserAuthRsp
;
int32_t
tSerializeSGetUserAuthRsp
(
void
*
buf
,
int32_t
bufLen
,
SGetUserAuthRsp
*
pRsp
);
...
...
source/common/src/tmsg.c
浏览文件 @
afbc468d
...
...
@@ -1445,14 +1445,10 @@ int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp)
int32_t
numOfCreatedDbs
=
taosHashGetSize
(
pRsp
->
createdDbs
);
int32_t
numOfReadDbs
=
taosHashGetSize
(
pRsp
->
readDbs
);
int32_t
numOfWriteDbs
=
taosHashGetSize
(
pRsp
->
writeDbs
);
int32_t
numOfReadTbs
=
taosHashGetSize
(
pRsp
->
readTbs
);
int32_t
numOfWriteTbs
=
taosHashGetSize
(
pRsp
->
writeTbs
);
if
(
tEncodeI32
(
pEncoder
,
numOfCreatedDbs
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
numOfReadDbs
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
numOfWriteDbs
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
numOfReadTbs
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
numOfWriteTbs
)
<
0
)
return
-
1
;
char
*
db
=
taosHashIterate
(
pRsp
->
createdDbs
,
NULL
);
while
(
db
!=
NULL
)
{
...
...
@@ -1472,6 +1468,13 @@ int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp)
db
=
taosHashIterate
(
pRsp
->
writeDbs
,
db
);
}
int32_t
numOfReadTbs
=
taosHashGetSize
(
pRsp
->
readTbs
);
int32_t
numOfWriteTbs
=
taosHashGetSize
(
pRsp
->
writeTbs
);
int32_t
numOfUseTbs
=
taosHashGetSize
(
pRsp
->
useDbs
);
if
(
tEncodeI32
(
pEncoder
,
numOfReadTbs
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
numOfWriteTbs
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
numOfUseTbs
)
<
0
)
return
-
1
;
char
*
tb
=
taosHashIterate
(
pRsp
->
readTbs
,
NULL
);
while
(
tb
!=
NULL
)
{
size_t
keyLen
=
0
;
...
...
@@ -1502,6 +1505,17 @@ int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp)
tb
=
taosHashIterate
(
pRsp
->
writeTbs
,
tb
);
}
int32_t
*
useDb
=
taosHashIterate
(
pRsp
->
useDbs
,
NULL
);
while
(
useDb
!=
NULL
)
{
size_t
keyLen
=
0
;
void
*
key
=
taosHashGetKey
(
useDb
,
&
keyLen
);
if
(
tEncodeI32
(
pEncoder
,
keyLen
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
key
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
*
useDb
)
<
0
)
return
-
1
;
useDb
=
taosHashIterate
(
pRsp
->
useDbs
,
useDb
);
}
return
0
;
}
...
...
@@ -1526,7 +1540,9 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs
pRsp
->
writeDbs
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
pRsp
->
readTbs
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
pRsp
->
writeTbs
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
pRsp
->
readDbs
==
NULL
||
pRsp
->
writeDbs
==
NULL
)
{
pRsp
->
useDbs
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
pRsp
->
createdDbs
==
NULL
||
pRsp
->
readDbs
==
NULL
||
pRsp
->
writeDbs
==
NULL
||
pRsp
->
readTbs
==
NULL
||
pRsp
->
writeTbs
==
NULL
||
pRsp
->
useDbs
==
NULL
)
{
return
-
1
;
}
...
...
@@ -1540,13 +1556,9 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs
int32_t
numOfCreatedDbs
=
0
;
int32_t
numOfReadDbs
=
0
;
int32_t
numOfWriteDbs
=
0
;
int32_t
numOfReadTbs
=
0
;
int32_t
numOfWriteTbs
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
numOfCreatedDbs
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
numOfReadDbs
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
numOfWriteDbs
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
numOfReadTbs
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
numOfWriteTbs
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
numOfCreatedDbs
;
++
i
)
{
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
...
...
@@ -1569,40 +1581,61 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs
taosHashPut
(
pRsp
->
writeDbs
,
db
,
len
,
db
,
len
);
}
for
(
int32_t
i
=
0
;
i
<
numOfReadTbs
;
++
i
)
{
int32_t
keyLen
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
keyLen
)
<
0
)
return
-
1
;
if
(
!
tDecodeIsEnd
(
pDecoder
))
{
int32_t
numOfReadTbs
=
0
;
int32_t
numOfWriteTbs
=
0
;
int32_t
numOfUseDbs
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
numOfReadTbs
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
numOfWriteTbs
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
numOfUseDbs
)
<
0
)
return
-
1
;
char
*
key
=
taosMemoryCalloc
(
keyLen
+
1
,
sizeof
(
char
));
if
(
tDecodeCStrTo
(
pDecoder
,
key
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
numOfReadTbs
;
++
i
)
{
int32_t
keyLen
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
keyLen
)
<
0
)
return
-
1
;
int32_t
valuelen
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
valuelen
)
<
0
)
return
-
1
;
char
*
value
=
taosMemoryCalloc
(
valuelen
+
1
,
sizeof
(
char
));
if
(
tDecodeCStrTo
(
pDecoder
,
value
)
<
0
)
return
-
1
;
char
*
key
=
taosMemoryCalloc
(
keyLen
+
1
,
sizeof
(
char
));
if
(
tDecodeCStrTo
(
pDecoder
,
key
)
<
0
)
return
-
1
;
taosHashPut
(
pRsp
->
readTbs
,
key
,
strlen
(
key
),
value
,
valuelen
);
int32_t
valuelen
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
valuelen
)
<
0
)
return
-
1
;
char
*
value
=
taosMemoryCalloc
(
valuelen
+
1
,
sizeof
(
char
));
if
(
tDecodeCStrTo
(
pDecoder
,
value
)
<
0
)
return
-
1
;
taosMemoryFree
(
key
);
taosMemoryFree
(
value
);
}
taosHashPut
(
pRsp
->
readTbs
,
key
,
strlen
(
key
),
value
,
valuelen
+
1
);
taosMemoryFree
(
key
);
taosMemoryFree
(
value
);
}
for
(
int32_t
i
=
0
;
i
<
numOfWriteTbs
;
++
i
)
{
int32_t
keyLen
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
keyLen
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
numOfWriteTbs
;
++
i
)
{
int32_t
keyLen
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
keyLen
)
<
0
)
return
-
1
;
char
*
key
=
taosMemoryCalloc
(
keyLen
+
1
,
sizeof
(
char
));
if
(
tDecodeCStrTo
(
pDecoder
,
key
)
<
0
)
return
-
1
;
char
*
key
=
taosMemoryCalloc
(
keyLen
+
1
,
sizeof
(
char
));
if
(
tDecodeCStrTo
(
pDecoder
,
key
)
<
0
)
return
-
1
;
int32_t
valuelen
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
valuelen
)
<
0
)
return
-
1
;
char
*
value
=
taosMemoryCalloc
(
valuelen
+
1
,
sizeof
(
char
));
if
(
tDecodeCStrTo
(
pDecoder
,
value
)
<
0
)
return
-
1
;
int32_t
valuelen
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
valuelen
)
<
0
)
return
-
1
;
char
*
value
=
taosMemoryCalloc
(
valuelen
+
1
,
sizeof
(
char
));
if
(
tDecodeCStrTo
(
pDecoder
,
value
)
<
0
)
return
-
1
;
taosHashPut
(
pRsp
->
writeTbs
,
key
,
strlen
(
key
),
value
,
valuelen
);
taosHashPut
(
pRsp
->
writeTbs
,
key
,
strlen
(
key
),
value
,
valuelen
+
1
);
taosMemoryFree
(
key
);
taosMemoryFree
(
value
);
taosMemoryFree
(
key
);
taosMemoryFree
(
value
);
}
for
(
int32_t
i
=
0
;
i
<
numOfUseDbs
;
++
i
)
{
int32_t
keyLen
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
keyLen
)
<
0
)
return
-
1
;
char
*
key
=
taosMemoryCalloc
(
keyLen
+
1
,
sizeof
(
char
));
if
(
tDecodeCStrTo
(
pDecoder
,
key
)
<
0
)
return
-
1
;
int32_t
ref
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
ref
)
<
0
)
return
-
1
;
taosHashPut
(
pRsp
->
useDbs
,
key
,
strlen
(
key
),
&
ref
,
sizeof
(
ref
));
}
}
return
0
;
...
...
@@ -1628,6 +1661,7 @@ void tFreeSGetUserAuthRsp(SGetUserAuthRsp *pRsp) {
taosHashCleanup
(
pRsp
->
writeDbs
);
taosHashCleanup
(
pRsp
->
writeTbs
);
taosHashCleanup
(
pRsp
->
readTbs
);
taosHashCleanup
(
pRsp
->
useDbs
);
}
int32_t
tSerializeSCreateDropMQSNodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateQnodeReq
*
pReq
)
{
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
afbc468d
...
...
@@ -282,6 +282,7 @@ typedef struct {
SHashObj
*
topics
;
SHashObj
*
readTbs
;
SHashObj
*
writeTbs
;
SHashObj
*
useDbs
;
SRWLatch
lock
;
}
SUserObj
;
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
afbc468d
...
...
@@ -128,8 +128,9 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
int32_t
numOfReadStbs
=
taosHashGetSize
(
pUser
->
readTbs
);
int32_t
numOfWriteStbs
=
taosHashGetSize
(
pUser
->
writeTbs
);
int32_t
numOfTopics
=
taosHashGetSize
(
pUser
->
topics
);
int32_t
size
=
sizeof
(
SUserObj
)
+
USER_RESERVE_SIZE
+
(
numOfReadDbs
+
numOfWriteDbs
)
*
TSDB_DB_FNAME_LEN
+
numOfTopics
*
TSDB_TOPIC_FNAME_LEN
;
int32_t
numOfUseDbs
=
taosHashGetSize
(
pUser
->
useDbs
);
int32_t
size
=
sizeof
(
SUserObj
)
+
USER_RESERVE_SIZE
+
(
numOfReadDbs
+
numOfWriteDbs
+
numOfUseDbs
)
*
TSDB_DB_FNAME_LEN
+
numOfTopics
*
TSDB_TOPIC_FNAME_LEN
;
char
*
stb
=
taosHashIterate
(
pUser
->
readTbs
,
NULL
);
while
(
stb
!=
NULL
)
{
...
...
@@ -176,8 +177,6 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
SDB_SET_INT32
(
pRaw
,
dataPos
,
numOfReadDbs
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
numOfWriteDbs
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
numOfTopics
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
numOfReadStbs
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
numOfWriteStbs
,
_OVER
)
char
*
db
=
taosHashIterate
(
pUser
->
readDbs
,
NULL
);
while
(
db
!=
NULL
)
{
...
...
@@ -197,6 +196,10 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
topic
=
taosHashIterate
(
pUser
->
topics
,
topic
);
}
SDB_SET_INT32
(
pRaw
,
dataPos
,
numOfReadStbs
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
numOfWriteStbs
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
numOfUseDbs
,
_OVER
)
stb
=
taosHashIterate
(
pUser
->
readTbs
,
NULL
);
while
(
stb
!=
NULL
)
{
size_t
keyLen
=
0
;
...
...
@@ -225,6 +228,17 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
stb
=
taosHashIterate
(
pUser
->
writeTbs
,
stb
);
}
int32_t
*
useDb
=
taosHashIterate
(
pUser
->
useDbs
,
NULL
);
while
(
useDb
!=
NULL
)
{
size_t
keyLen
=
0
;
void
*
key
=
taosHashGetKey
(
useDb
,
&
keyLen
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
keyLen
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
key
,
keyLen
,
_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
*
useDb
,
_OVER
)
useDb
=
taosHashIterate
(
pUser
->
writeTbs
,
useDb
);
}
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
USER_RESERVE_SIZE
,
_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
_OVER
)
...
...
@@ -275,26 +289,16 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
int32_t
numOfReadDbs
=
0
;
int32_t
numOfWriteDbs
=
0
;
int32_t
numOfTopics
=
0
;
int32_t
numOfReadStbs
=
0
;
int32_t
numOfWriteStbs
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
numOfReadDbs
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
numOfWriteDbs
,
_OVER
)
if
(
sver
>=
2
)
{
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
numOfTopics
,
_OVER
)
}
if
(
sver
>=
3
)
{
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
numOfReadStbs
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
numOfWriteStbs
,
_OVER
)
}
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
);
pUser
->
topics
=
taosHashInit
(
numOfTopics
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
pUser
->
readTbs
=
taosHashInit
(
numOfReadStbs
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
pUser
->
writeTbs
=
taosHashInit
(
numOfWriteStbs
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
pUser
->
readDbs
==
NULL
||
pUser
->
writeDbs
==
NULL
||
pUser
->
topics
==
NULL
)
goto
_OVER
;
for
(
int32_t
i
=
0
;
i
<
numOfReadDbs
;
++
i
)
{
...
...
@@ -321,6 +325,19 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
}
if
(
sver
>=
3
)
{
int32_t
numOfReadStbs
=
0
;
int32_t
numOfWriteStbs
=
0
;
int32_t
numOfUseDbs
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
numOfReadStbs
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
numOfWriteStbs
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
numOfUseDbs
,
_OVER
)
pUser
->
readTbs
=
taosHashInit
(
numOfReadStbs
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
pUser
->
writeTbs
=
taosHashInit
(
numOfWriteStbs
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
pUser
->
useDbs
=
taosHashInit
(
numOfUseDbs
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
for
(
int32_t
i
=
0
;
i
<
numOfReadStbs
;
++
i
)
{
int32_t
keyLen
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
keyLen
,
_OVER
);
...
...
@@ -332,7 +349,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
int32_t
valuelen
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
valuelen
,
_OVER
);
char
*
value
=
taosMemoryCalloc
(
valuelen
,
sizeof
(
char
));
memset
(
value
,
0
,
keyL
en
);
memset
(
value
,
0
,
valuel
en
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
value
,
valuelen
,
_OVER
)
taosHashPut
(
pUser
->
readTbs
,
key
,
keyLen
,
value
,
valuelen
);
...
...
@@ -360,6 +377,20 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
taosMemoryFree
(
key
);
taosMemoryFree
(
value
);
}
for
(
int32_t
i
=
0
;
i
<
numOfUseDbs
;
++
i
)
{
int32_t
keyLen
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
keyLen
,
_OVER
);
char
*
key
=
taosMemoryCalloc
(
keyLen
,
sizeof
(
char
));
memset
(
key
,
0
,
keyLen
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
key
,
keyLen
,
_OVER
);
int32_t
ref
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
ref
,
_OVER
);
taosHashPut
(
pUser
->
useDbs
,
key
,
keyLen
,
&
ref
,
sizeof
(
ref
));
}
}
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
USER_RESERVE_SIZE
,
_OVER
)
...
...
@@ -376,6 +407,7 @@ _OVER:
taosHashCleanup
(
pUser
->
topics
);
taosHashCleanup
(
pUser
->
readTbs
);
taosHashCleanup
(
pUser
->
writeTbs
);
taosHashCleanup
(
pUser
->
useDbs
);
}
taosMemoryFreeClear
(
pRow
);
return
NULL
;
...
...
@@ -437,6 +469,7 @@ static int32_t mndUserDupObj(SUserObj *pUser, SUserObj *pNew) {
pNew
->
readTbs
=
mndDupTableHash
(
pUser
->
readTbs
);
pNew
->
writeTbs
=
mndDupTableHash
(
pUser
->
writeTbs
);
pNew
->
topics
=
mndDupTopicHash
(
pUser
->
topics
);
pNew
->
useDbs
=
mndDupDbHash
(
pUser
->
useDbs
);
taosRUnLockLatch
(
&
pUser
->
lock
);
if
(
pNew
->
readDbs
==
NULL
||
pNew
->
writeDbs
==
NULL
||
pNew
->
topics
==
NULL
)
{
...
...
@@ -451,11 +484,13 @@ static void mndUserFreeObj(SUserObj *pUser) {
taosHashCleanup
(
pUser
->
topics
);
taosHashCleanup
(
pUser
->
readTbs
);
taosHashCleanup
(
pUser
->
writeTbs
);
taosHashCleanup
(
pUser
->
useDbs
);
pUser
->
readDbs
=
NULL
;
pUser
->
writeDbs
=
NULL
;
pUser
->
topics
=
NULL
;
pUser
->
readTbs
=
NULL
;
pUser
->
writeTbs
=
NULL
;
pUser
->
useDbs
=
NULL
;
}
static
int32_t
mndUserActionDelete
(
SSdb
*
pSdb
,
SUserObj
*
pUser
)
{
...
...
@@ -477,6 +512,7 @@ static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pOld, SUserObj *pNew) {
TSWAP
(
pOld
->
topics
,
pNew
->
topics
);
TSWAP
(
pOld
->
readTbs
,
pNew
->
readTbs
);
TSWAP
(
pOld
->
writeTbs
,
pNew
->
writeTbs
);
TSWAP
(
pOld
->
useDbs
,
pNew
->
useDbs
);
taosWUnLockLatch
(
&
pOld
->
lock
);
return
0
;
...
...
@@ -647,38 +683,8 @@ SHashObj *mndDupDbHash(SHashObj *pOld) { return mndDupObjHash(pOld, TSDB_DB_FNAM
SHashObj
*
mndDupTopicHash
(
SHashObj
*
pOld
)
{
return
mndDupObjHash
(
pOld
,
TSDB_TOPIC_FNAME_LEN
);
}
static
int32_t
mndTagPriviledge
(
SMnode
*
pMnode
,
SHashObj
*
hash
,
SAlterUserReq
*
alterReq
)
{
char
tbFName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
snprintf
(
tbFName
,
TSDB_TABLE_FNAME_LEN
,
"%s.%s"
,
alterReq
->
objname
,
alterReq
->
tabName
);
int32_t
len
=
strlen
(
tbFName
)
+
1
;
SStbObj
*
pStb
=
mndAcquireStb
(
pMnode
,
tbFName
);
if
(
pStb
==
NULL
)
{
mndReleaseStb
(
pMnode
,
pStb
);
return
-
1
;
}
if
(
alterReq
->
tagCond
==
NULL
)
{
mndReleaseStb
(
pMnode
,
pStb
);
return
-
1
;
}
char
*
value
=
taosHashGet
(
hash
,
tbFName
,
len
);
if
(
value
!=
NULL
)
{
mndReleaseStb
(
pMnode
,
pStb
);
terrno
=
TSDB_CODE_MND_PRIVILEDGE_EXIST
;
return
-
1
;
}
int32_t
condLen
=
alterReq
->
tagCondLen
+
1
;
if
(
taosHashPut
(
hash
,
tbFName
,
len
,
alterReq
->
tagCond
,
condLen
)
!=
0
)
{
mndReleaseStb
(
pMnode
,
pStb
);
return
-
1
;
}
mndReleaseStb
(
pMnode
,
pStb
);
return
0
;
}
static
int32_t
mndTablePriviledge
(
SMnode
*
pMnode
,
SHashObj
*
hash
,
SAlterUserReq
*
alterReq
,
SSdb
*
pSdb
)
{
static
int32_t
mndTablePriviledge
(
SMnode
*
pMnode
,
SHashObj
*
hash
,
SHashObj
*
useDbHash
,
SAlterUserReq
*
alterReq
,
SSdb
*
pSdb
)
{
void
*
pIter
=
NULL
;
char
tbFName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
...
...
@@ -692,7 +698,7 @@ static int32_t mndTablePriviledge(SMnode *pMnode, SHashObj *hash, SAlterUserReq
return
-
1
;
}
int32_t
condLen
=
alterReq
->
tagCondLen
+
1
;
int32_t
condLen
=
alterReq
->
tagCondLen
;
if
(
taosHashPut
(
hash
,
tbFName
,
len
,
alterReq
->
tagCond
,
condLen
)
!=
0
)
{
return
-
1
;
}
...
...
@@ -702,10 +708,21 @@ static int32_t mndTablePriviledge(SMnode *pMnode, SHashObj *hash, SAlterUserReq
}
}
int32_t
dbKeyLen
=
strlen
(
alterReq
->
objname
)
+
1
;
int32_t
ref
=
1
;
int32_t
*
currRef
=
taosHashGet
(
useDbHash
,
alterReq
->
objname
,
dbKeyLen
);
if
(
NULL
!=
currRef
)
{
ref
=
(
*
currRef
)
+
1
;
}
if
(
taosHashPut
(
useDbHash
,
alterReq
->
objname
,
dbKeyLen
,
&
ref
,
sizeof
(
ref
))
!=
0
)
{
return
-
1
;
}
return
0
;
}
static
int32_t
mndRemoveTablePriviledge
(
SMnode
*
pMnode
,
SHashObj
*
hash
,
SAlterUserReq
*
alterReq
,
SSdb
*
pSdb
)
{
static
int32_t
mndRemoveTablePriviledge
(
SMnode
*
pMnode
,
SHashObj
*
hash
,
SHashObj
*
useDbHash
,
SAlterUserReq
*
alterReq
,
SSdb
*
pSdb
)
{
void
*
pIter
=
NULL
;
char
tbFName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
snprintf
(
tbFName
,
sizeof
(
tbFName
),
"%s.%s"
,
alterReq
->
objname
,
alterReq
->
tabName
);
...
...
@@ -715,6 +732,19 @@ static int32_t mndRemoveTablePriviledge(SMnode *pMnode, SHashObj *hash, SAlterUs
return
-
1
;
}
int32_t
dbKeyLen
=
strlen
(
alterReq
->
objname
)
+
1
;
int32_t
*
currRef
=
taosHashGet
(
useDbHash
,
alterReq
->
objname
,
dbKeyLen
);
if
(
NULL
==
currRef
||
1
==
*
currRef
)
{
if
(
taosHashRemove
(
useDbHash
,
alterReq
->
objname
,
dbKeyLen
)
!=
0
)
{
return
-
1
;
}
return
0
;
}
int32_t
ref
=
(
*
currRef
)
-
1
;
if
(
taosHashPut
(
useDbHash
,
alterReq
->
objname
,
dbKeyLen
,
&
ref
,
sizeof
(
ref
))
!=
0
)
{
return
-
1
;
}
return
0
;
}
...
...
@@ -858,21 +888,19 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_ADD_READ_TABLE
)
{
if
(
mndTablePriviledge
(
pMnode
,
newUser
.
readTbs
,
&
alterReq
,
pSdb
)
!=
0
)
goto
_OVER
;
if
(
mndTablePriviledge
(
pMnode
,
newUser
.
readTbs
,
newUser
.
useDbs
,
&
alterReq
,
pSdb
)
!=
0
)
goto
_OVER
;
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_ADD_WRITE_TABLE
)
{
if
(
mndTablePriviledge
(
pMnode
,
newUser
.
writeTbs
,
&
alterReq
,
pSdb
)
!=
0
)
goto
_OVER
;
if
(
mndTablePriviledge
(
pMnode
,
newUser
.
writeTbs
,
newUser
.
useDbs
,
&
alterReq
,
pSdb
)
!=
0
)
goto
_OVER
;
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_REMOVE_READ_TABLE
||
alterReq
.
alterType
==
TSDB_ALTER_USER_REMOVE_READ_TAG
)
{
if
(
mndRemoveTablePriviledge
(
pMnode
,
newUser
.
readTbs
,
&
alterReq
,
pSdb
)
!=
0
)
goto
_OVER
;
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_REMOVE_READ_TABLE
)
{
if
(
mndRemoveTablePriviledge
(
pMnode
,
newUser
.
readTbs
,
newUser
.
useDbs
,
&
alterReq
,
pSdb
)
!=
0
)
goto
_OVER
;
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_REMOVE_WRITE_TABLE
||
alterReq
.
alterType
==
TSDB_ALTER_USER_REMOVE_WRITE_TAG
)
{
if
(
mndRemoveTablePriviledge
(
pMnode
,
newUser
.
writeTbs
,
&
alterReq
,
pSdb
)
!=
0
)
goto
_OVER
;
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_REMOVE_WRITE_TABLE
)
{
if
(
mndRemoveTablePriviledge
(
pMnode
,
newUser
.
writeTbs
,
newUser
.
useDbs
,
&
alterReq
,
pSdb
)
!=
0
)
goto
_OVER
;
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_ADD_SUBSCRIBE_TOPIC
)
{
...
...
@@ -885,14 +913,6 @@ 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
)
{
if
(
mndTagPriviledge
(
pMnode
,
newUser
.
readTbs
,
&
alterReq
)
!=
0
)
goto
_OVER
;
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_ADD_WRITE_TAG
)
{
if
(
mndTagPriviledge
(
pMnode
,
newUser
.
writeTbs
,
&
alterReq
)
!=
0
)
goto
_OVER
;
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_REMOVE_SUBSCRIBE_TOPIC
)
{
int32_t
len
=
strlen
(
alterReq
.
objname
)
+
1
;
SMqTopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
alterReq
.
objname
);
...
...
@@ -1397,8 +1417,6 @@ int32_t mndUserRemoveDb(SMnode *pMnode, STrans *pTrans, char *db) {
if
(
inRead
||
inWrite
)
{
(
void
)
taosHashRemove
(
newUser
.
readDbs
,
db
,
len
);
(
void
)
taosHashRemove
(
newUser
.
writeDbs
,
db
,
len
);
(
void
)
taosHashRemove
(
newUser
.
readTbs
,
db
,
len
);
(
void
)
taosHashRemove
(
newUser
.
writeTbs
,
db
,
len
);
SSdbRaw
*
pCommitRaw
=
mndUserActionEncode
(
&
newUser
);
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
break
;
...
...
source/libs/catalog/src/ctgCache.c
浏览文件 @
afbc468d
...
...
@@ -238,10 +238,11 @@ _return:
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgAcquireVgMetaFromCache
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
const
char
*
tbName
,
SCtgDBCache
**
pDb
,
SCtgTbCache
**
pTb
)
{
int32_t
ctgAcquireVgMetaFromCache
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
const
char
*
tbName
,
SCtgDBCache
**
pDb
,
SCtgTbCache
**
pTb
)
{
SCtgDBCache
*
dbCache
=
NULL
;
SCtgTbCache
*
tbCache
=
NULL
;
bool
vgInCache
=
false
;
bool
vgInCache
=
false
;
ctgAcquireDBCache
(
pCtg
,
dbFName
,
&
dbCache
);
if
(
NULL
==
dbCache
)
{
...
...
@@ -306,7 +307,6 @@ _return:
return
TSDB_CODE_SUCCESS
;
}
/*
int32_t ctgAcquireStbMetaFromCache(SCatalog *pCtg, char *dbFName, uint64_t suid, SCtgDBCache **pDb, SCtgTbCache **pTb) {
SCtgDBCache *dbCache = NULL;
...
...
@@ -360,9 +360,10 @@ _return:
}
*/
int32_t
ctgAcquireStbMetaFromCache
(
SCtgDBCache
*
dbCache
,
SCatalog
*
pCtg
,
char
*
dbFName
,
uint64_t
suid
,
SCtgTbCache
**
pTb
)
{
int32_t
ctgAcquireStbMetaFromCache
(
SCtgDBCache
*
dbCache
,
SCatalog
*
pCtg
,
char
*
dbFName
,
uint64_t
suid
,
SCtgTbCache
**
pTb
)
{
SCtgTbCache
*
pCache
=
NULL
;
char
*
stName
=
taosHashAcquire
(
dbCache
->
stbCache
,
&
suid
,
sizeof
(
suid
));
char
*
stName
=
taosHashAcquire
(
dbCache
->
stbCache
,
&
suid
,
sizeof
(
suid
));
if
(
NULL
==
stName
)
{
ctgDebug
(
"stb 0x%"
PRIx64
" not in cache, dbFName:%s"
,
suid
,
dbFName
);
goto
_return
;
...
...
@@ -459,10 +460,11 @@ int32_t ctgTbMetaExistInCache(SCatalog *pCtg, char *dbFName, char *tbName, int32
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgCopyTbMeta
(
SCatalog
*
pCtg
,
SCtgTbMetaCtx
*
ctx
,
SCtgDBCache
**
pDb
,
SCtgTbCache
**
pTb
,
STableMeta
**
pTableMeta
,
char
*
dbFName
)
{
int32_t
ctgCopyTbMeta
(
SCatalog
*
pCtg
,
SCtgTbMetaCtx
*
ctx
,
SCtgDBCache
**
pDb
,
SCtgTbCache
**
pTb
,
STableMeta
**
pTableMeta
,
char
*
dbFName
)
{
SCtgDBCache
*
dbCache
=
*
pDb
;
SCtgTbCache
*
tbCache
=
*
pTb
;
STableMeta
*
tbMeta
=
tbCache
->
pMeta
;
STableMeta
*
tbMeta
=
tbCache
->
pMeta
;
ctx
->
tbInfo
.
inCache
=
true
;
ctx
->
tbInfo
.
dbId
=
dbCache
->
dbId
;
ctx
->
tbInfo
.
suid
=
tbMeta
->
suid
;
...
...
@@ -491,12 +493,12 @@ int32_t ctgCopyTbMeta(SCatalog *pCtg, SCtgTbMetaCtx *ctx, SCtgDBCache **pDb, SCt
memcpy
(
*
pTableMeta
,
tbMeta
,
metaSize
);
//ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
//
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
CTG_UNLOCK
(
CTG_READ
,
&
tbCache
->
metaLock
);
taosHashRelease
(
dbCache
->
tbCache
,
tbCache
);
*
pTb
=
NULL
;
ctgDebug
(
"Got ctb %s meta from cache, will continue to get its stb meta, type:%d, dbFName:%s"
,
ctx
->
pName
->
tname
,
ctx
->
tbInfo
.
tbType
,
dbFName
);
...
...
@@ -528,7 +530,6 @@ int32_t ctgCopyTbMeta(SCatalog *pCtg, SCtgTbMetaCtx *ctx, SCtgDBCache **pDb, SCt
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgReadTbMetaFromCache
(
SCatalog
*
pCtg
,
SCtgTbMetaCtx
*
ctx
,
STableMeta
**
pTableMeta
)
{
int32_t
code
=
0
;
SCtgDBCache
*
dbCache
=
NULL
;
...
...
@@ -598,17 +599,17 @@ int32_t ctgReadTbVerFromCache(SCatalog *pCtg, SName *pTableName, int32_t *sver,
// PROCESS FOR CHILD TABLE
//ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
//
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
if
(
tbCache
)
{
CTG_UNLOCK
(
CTG_READ
,
&
tbCache
->
metaLock
);
taosHashRelease
(
dbCache
->
tbCache
,
tbCache
);
}
ctgDebug
(
"Got ctb %s ver from cache, will continue to get its stb ver, dbFName:%s"
,
pTableName
->
tname
,
dbFName
);
ctgAcquireStbMetaFromCache
(
dbCache
,
pCtg
,
dbFName
,
*
suid
,
&
tbCache
);
if
(
NULL
==
tbCache
)
{
//ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
//
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
ctgDebug
(
"stb 0x%"
PRIx64
" meta not in cache"
,
*
suid
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -678,7 +679,7 @@ _return:
CTG_RET
(
code
);
}
int32_t
ctgChkAuthFromCache
(
SCatalog
*
pCtg
,
SUserAuthInfo
*
pReq
,
bool
*
inCache
,
SCtgAuthRsp
*
pRes
)
{
int32_t
ctgChkAuthFromCache
(
SCatalog
*
pCtg
,
SUserAuthInfo
*
pReq
,
bool
*
inCache
,
SCtgAuthRsp
*
pRes
)
{
if
(
IS_SYS_DBNAME
(
pReq
->
tbName
.
dbname
))
{
*
inCache
=
true
;
pRes
->
pRawRes
->
pass
=
true
;
...
...
@@ -706,7 +707,7 @@ int32_t ctgChkAuthFromCache(SCatalog *pCtg, SUserAuthInfo *pReq, bool *inCache,
int32_t
code
=
ctgChkSetAuthRes
(
pCtg
,
&
req
,
pRes
);
CTG_UNLOCK
(
CTG_READ
,
&
pUser
->
lock
);
CTG_ERR_JRET
(
code
);
if
(
pRes
->
metaNotExists
)
{
goto
_return
;
}
...
...
@@ -1685,9 +1686,9 @@ void ctgFreeAllInstance(void) {
taosHashClear
(
gCtgMgmt
.
pCluster
);
}
int32_t
ctgVgInfoIdComp
(
void
const
*
lp
,
void
const
*
rp
)
{
int32_t
*
key
=
(
int32_t
*
)
lp
;
SVgroupInfo
*
pVg
=
(
SVgroupInfo
*
)
rp
;
int32_t
ctgVgInfoIdComp
(
void
const
*
lp
,
void
const
*
rp
)
{
int32_t
*
key
=
(
int32_t
*
)
lp
;
SVgroupInfo
*
pVg
=
(
SVgroupInfo
*
)
rp
;
if
(
*
key
<
pVg
->
vgId
)
{
return
-
1
;
...
...
@@ -1698,7 +1699,6 @@ int32_t ctgVgInfoIdComp(void const* lp, void const* rp) {
return
0
;
}
int32_t
ctgOpUpdateVgroup
(
SCtgCacheOperation
*
operation
)
{
int32_t
code
=
0
;
SCtgUpdateVgMsg
*
msg
=
operation
->
data
;
...
...
@@ -1763,10 +1763,10 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
dbCache
=
NULL
;
//if (!IS_SYS_DBNAME(dbFName)) {
tstrncpy
(
vgVersion
.
dbFName
,
dbFName
,
sizeof
(
vgVersion
.
dbFName
));
CTG_ERR_JRET
(
ctgMetaRentUpdate
(
&
msg
->
pCtg
->
dbRent
,
&
vgVersion
,
vgVersion
.
dbId
,
sizeof
(
SDbVgVersion
),
ctgDbVgVersionSortCompare
,
ctgDbVgVersionSearchCompare
));
//
if (!IS_SYS_DBNAME(dbFName)) {
tstrncpy
(
vgVersion
.
dbFName
,
dbFName
,
sizeof
(
vgVersion
.
dbFName
));
CTG_ERR_JRET
(
ctgMetaRentUpdate
(
&
msg
->
pCtg
->
dbRent
,
&
vgVersion
,
vgVersion
.
dbId
,
sizeof
(
SDbVgVersion
),
ctgDbVgVersionSortCompare
,
ctgDbVgVersionSearchCompare
));
//}
_return:
...
...
@@ -2043,6 +2043,10 @@ int32_t ctgOpUpdateUser(SCtgCacheOperation *operation) {
pUser
->
userAuth
.
writeTbs
=
msg
->
userAuth
.
writeTbs
;
msg
->
userAuth
.
writeTbs
=
NULL
;
taosHashCleanup
(
pUser
->
userAuth
.
useDbs
);
pUser
->
userAuth
.
useDbs
=
msg
->
userAuth
.
useDbs
;
msg
->
userAuth
.
useDbs
=
NULL
;
CTG_UNLOCK
(
CTG_WRITE
,
&
pUser
->
lock
);
_return:
...
...
@@ -2052,6 +2056,7 @@ _return:
taosHashCleanup
(
msg
->
userAuth
.
writeDbs
);
taosHashCleanup
(
msg
->
userAuth
.
readTbs
);
taosHashCleanup
(
msg
->
userAuth
.
writeTbs
);
taosHashCleanup
(
msg
->
userAuth
.
useDbs
);
taosMemoryFreeClear
(
msg
);
...
...
@@ -2246,6 +2251,7 @@ void ctgFreeCacheOperationData(SCtgCacheOperation *op) {
taosHashCleanup
(
msg
->
userAuth
.
writeDbs
);
taosHashCleanup
(
msg
->
userAuth
.
readTbs
);
taosHashCleanup
(
msg
->
userAuth
.
writeTbs
);
taosHashCleanup
(
msg
->
userAuth
.
useDbs
);
taosMemoryFreeClear
(
op
->
data
);
break
;
}
...
...
source/libs/catalog/src/ctgUtil.c
浏览文件 @
afbc468d
...
...
@@ -179,6 +179,7 @@ void ctgFreeSCtgUserAuth(SCtgUserAuth* userCache) {
taosHashCleanup
(
userCache
->
userAuth
.
writeDbs
);
taosHashCleanup
(
userCache
->
userAuth
.
readTbs
);
taosHashCleanup
(
userCache
->
userAuth
.
writeTbs
);
taosHashCleanup
(
userCache
->
userAuth
.
useDbs
);
}
void
ctgFreeMetaRent
(
SCtgRentMgmt
*
mgmt
)
{
...
...
@@ -427,6 +428,7 @@ void ctgFreeMsgCtx(SCtgMsgCtx* pCtx) {
taosHashCleanup
(
pOut
->
writeDbs
);
taosHashCleanup
(
pOut
->
readTbs
);
taosHashCleanup
(
pOut
->
writeTbs
);
taosHashCleanup
(
pOut
->
useDbs
);
taosMemoryFreeClear
(
pCtx
->
out
);
break
;
}
...
...
@@ -873,19 +875,19 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, const SName
vgInfo
=
taosArraySearch
(
dbInfo
->
vgArray
,
&
hashValue
,
ctgHashValueComp
,
TD_EQ
);
/*
void* pIter = taosHashIterate(dbInfo->vgHash, NULL);
while (pIter) {
vgInfo = pIter;
if (hashValue >= vgInfo->hashBegin && hashValue <= vgInfo->hashEnd) {
taosHashCancelIterate(dbInfo->vgHash, pIter);
break;
}
/*
void* pIter = taosHashIterate(dbInfo->vgHash, NULL);
while (pIter) {
vgInfo = pIter;
if (hashValue >= vgInfo->hashBegin && hashValue <= vgInfo->hashEnd) {
taosHashCancelIterate(dbInfo->vgHash, pIter);
break;
}
pIter = taosHashIterate(dbInfo->vgHash, pIter);
vgInfo = NULL;
}
*/
pIter = taosHashIterate(dbInfo->vgHash, pIter);
vgInfo = NULL;
}
*/
if
(
NULL
==
vgInfo
)
{
ctgError
(
"no hash range found for hash value [%u], db:%s, numOfVgId:%d"
,
hashValue
,
db
,
...
...
@@ -910,7 +912,7 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo*
CTG_ERR_RET
(
ctgMakeVgArray
(
dbInfo
));
int32_t
vgNum
=
taosArrayGetSize
(
dbInfo
->
vgArray
);
int32_t
vgNum
=
taosArrayGetSize
(
dbInfo
->
vgArray
);
if
(
vgNum
<=
0
)
{
ctgError
(
"db vgroup cache invalid, db:%s, vgroup number:%d"
,
dbFName
,
vgNum
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
...
...
@@ -990,43 +992,43 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo*
CTG_RET
(
code
);
}
int32_t
ctgGetVgIdsFromHashValue
(
SCatalog
*
pCtg
,
SDBVgInfo
*
dbInfo
,
char
*
dbFName
,
const
char
*
pTbs
[],
int32_t
tbNum
,
int32_t
*
vgId
)
{
int32_t
code
=
0
;
CTG_ERR_RET
(
ctgMakeVgArray
(
dbInfo
));
int32_t
ctgGetVgIdsFromHashValue
(
SCatalog
*
pCtg
,
SDBVgInfo
*
dbInfo
,
char
*
dbFName
,
const
char
*
pTbs
[],
int32_t
tbNum
,
int32_t
*
vgId
)
{
int32_t
code
=
0
;
CTG_ERR_RET
(
ctgMakeVgArray
(
dbInfo
));
int32_t
vgNum
=
taosArrayGetSize
(
dbInfo
->
vgArray
);
int32_t
vgNum
=
taosArrayGetSize
(
dbInfo
->
vgArray
);
if
(
vgNum
<=
0
)
{
ctgError
(
"db vgroup cache invalid, db:%s, vgroup number:%d"
,
dbFName
,
vgNum
);
CTG_ERR_RET
(
TSDB_CODE_TSC_DB_NOT_SELECTED
);
}
if
(
vgNum
<=
0
)
{
ctgError
(
"db vgroup cache invalid, db:%s, vgroup number:%d"
,
dbFName
,
vgNum
)
;
CTG_ERR_RET
(
TSDB_CODE_TSC_DB_NOT_SELECTED
);
}
SVgroupInfo
*
vgInfo
=
NULL
;
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
]
;
snprintf
(
tbFullName
,
sizeof
(
tbFullName
),
"%s."
,
dbFName
);
int32_t
offset
=
strlen
(
tbFullName
);
SVgroupInfo
*
vgInfo
=
NULL
;
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
];
snprintf
(
tbFullName
,
sizeof
(
tbFullName
),
"%s."
,
dbFName
);
int32_t
offset
=
strlen
(
tbFullName
);
for
(
int32_t
i
=
0
;
i
<
tbNum
;
++
i
)
{
snprintf
(
tbFullName
+
offset
,
sizeof
(
tbFullName
)
-
offset
,
"%s"
,
pTbs
[
i
]);
uint32_t
hashValue
=
taosGetTbHashVal
(
tbFullName
,
(
uint32_t
)
strlen
(
tbFullName
),
dbInfo
->
hashMethod
,
dbInfo
->
hashPrefix
,
dbInfo
->
hashSuffix
);
for
(
int32_t
i
=
0
;
i
<
tbNum
;
++
i
)
{
snprintf
(
tbFullName
+
offset
,
sizeof
(
tbFullName
)
-
offset
,
"%s"
,
pTbs
[
i
]);
uint32_t
hashValue
=
taosGetTbHashVal
(
tbFullName
,
(
uint32_t
)
strlen
(
tbFullName
),
dbInfo
->
hashMethod
,
dbInfo
->
hashPrefix
,
dbInfo
->
hashSuffix
);
vgInfo
=
taosArraySearch
(
dbInfo
->
vgArray
,
&
hashValue
,
ctgHashValueComp
,
TD_EQ
);
if
(
NULL
==
vgInfo
)
{
ctgError
(
"no hash range found for hash value [%u], db:%s, numOfVgId:%d"
,
hashValue
,
dbFName
,
(
int32_t
)
taosArrayGetSize
(
dbInfo
->
vgArray
));
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
vgInfo
=
taosArraySearch
(
dbInfo
->
vgArray
,
&
hashValue
,
ctgHashValueComp
,
TD_EQ
);
if
(
NULL
==
vgInfo
)
{
ctgError
(
"no hash range found for hash value [%u], db:%s, numOfVgId:%d"
,
hashValue
,
dbFName
,
(
int32_t
)
taosArrayGetSize
(
dbInfo
->
vgArray
));
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
vgId
[
i
]
=
vgInfo
->
vgId
;
vgId
[
i
]
=
vgInfo
->
vgId
;
ctgDebug
(
"Got tb %s vgId:%d"
,
tbFullName
,
vgInfo
->
vgId
);
}
ctgDebug
(
"Got tb %s vgId:%d"
,
tbFullName
,
vgInfo
->
vgId
);
}
CTG_RET
(
code
);
CTG_RET
(
code
);
}
int32_t
ctgStbVersionSearchCompare
(
const
void
*
key1
,
const
void
*
key2
)
{
if
(
*
(
uint64_t
*
)
key1
<
((
SSTableVersion
*
)
key2
)
->
suid
)
{
return
-
1
;
...
...
@@ -1071,26 +1073,25 @@ int32_t ctgMakeVgArray(SDBVgInfo* dbInfo) {
if
(
NULL
==
dbInfo
)
{
return
TSDB_CODE_SUCCESS
;
}
if
(
dbInfo
->
vgHash
&&
NULL
==
dbInfo
->
vgArray
)
{
dbInfo
->
vgArray
=
taosArrayInit
(
100
,
sizeof
(
SVgroupInfo
));
if
(
NULL
==
dbInfo
->
vgArray
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
void
*
pIter
=
taosHashIterate
(
dbInfo
->
vgHash
,
NULL
);
void
*
pIter
=
taosHashIterate
(
dbInfo
->
vgHash
,
NULL
);
while
(
pIter
)
{
taosArrayPush
(
dbInfo
->
vgArray
,
pIter
);
pIter
=
taosHashIterate
(
dbInfo
->
vgHash
,
pIter
);
}
taosArraySort
(
dbInfo
->
vgArray
,
ctgVgInfoComp
);
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgCloneVgInfo
(
SDBVgInfo
*
src
,
SDBVgInfo
**
dst
)
{
CTG_ERR_RET
(
ctgMakeVgArray
(
src
));
...
...
@@ -1334,72 +1335,74 @@ static void* ctgCloneDnodeList(void* pSrc) { return taosArrayDup((const SArray*)
static
void
ctgFreeDnodeList
(
void
*
p
)
{
taosArrayDestroy
((
SArray
*
)((
SMetaRes
*
)
p
)
->
pRes
);
}
int32_t
ctgChkSetTbAuthRes
(
SCatalog
*
pCtg
,
SCtgAuthReq
*
req
,
SCtgAuthRsp
*
res
)
{
int32_t
code
=
0
;
STableMeta
*
pMeta
=
NULL
;
SGetUserAuthRsp
*
pInfo
=
&
req
->
authInfo
;
SHashObj
*
pTbs
=
(
AUTH_TYPE_READ
==
req
->
singleType
)
?
pInfo
->
readTbs
:
pInfo
->
writeTbs
;
int32_t
ctgChkSetTbAuthRes
(
SCatalog
*
pCtg
,
SCtgAuthReq
*
req
,
SCtgAuthRsp
*
res
)
{
int32_t
code
=
0
;
STableMeta
*
pMeta
=
NULL
;
SGetUserAuthRsp
*
pInfo
=
&
req
->
authInfo
;
SHashObj
*
pTbs
=
(
AUTH_TYPE_READ
==
req
->
singleType
)
?
pInfo
->
readTbs
:
pInfo
->
writeTbs
;
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
];
tNameExtractFullName
(
&
req
->
pRawReq
->
tbName
,
tbFullName
);
char
*
pCond
=
taosHashGet
(
pTbs
,
tbFullName
,
strlen
(
tbFullName
));
char
*
pCond
=
taosHashGet
(
pTbs
,
tbFullName
,
strlen
(
tbFullName
));
if
(
pCond
)
{
if
(
strlen
(
pCond
)
>
1
)
{
CTG_ERR_RET
(
nodesStringToNode
(
pCond
,
&
res
->
pRawRes
->
pCond
));
}
res
->
pRawRes
->
pass
=
true
;
return
TSDB_CODE_SUCCESS
;
}
CTG_ERR_RET
(
catalogGetCachedTableMeta
(
pCtg
,
&
req
->
pRawReq
->
tbName
,
&
pMeta
));
if
(
NULL
==
pMeta
)
{
if
(
req
->
onlyCache
)
{
res
->
metaNotExists
=
true
;
ctgDebug
(
"db %s tb %s meta not in cache for auth"
,
req
->
pRawReq
->
tbName
.
dbname
,
req
->
pRawReq
->
tbName
.
tname
);
return
TSDB_CODE_SUCCESS
;
}
res
->
pRawRes
->
pass
=
false
;
CTG_ERR_RET
(
catalogGetTableMeta
(
pCtg
,
req
->
pConn
,
&
req
->
pRawReq
->
tbName
,
&
pMeta
));
}
// CTG_ERR_RET(catalogGetCachedTableMeta(pCtg, &req->pRawReq->tbName, &pMeta));
// if (NULL == pMeta) {
// if (req->onlyCache) {
// res->metaNotExists = true;
// ctgDebug("db %s tb %s meta not in cache for auth", req->pRawReq->tbName.dbname, req->pRawReq->tbName.tname);
// return TSDB_CODE_SUCCESS;
// }
if
(
TSDB_SUPER_TABLE
==
pMeta
->
tableType
||
TSDB_NORMAL_TABLE
==
pMeta
->
tableType
)
{
res
->
pRawRes
->
pass
=
false
;
goto
_return
;
}
// CTG_ERR_RET(catalogGetTableMeta(pCtg, req->pConn, &req->pRawReq->tbName, &pMeta));
// }
if
(
TSDB_CHILD_TABLE
==
pMeta
->
tableType
)
{
res
->
pRawRes
->
pass
=
true
;
// if (TSDB_SUPER_TABLE == pMeta->tableType || TSDB_NORMAL_TABLE == pMeta->tableType) {
// res->pRawRes->pass = false;
// goto _return;
// }
/*
char stbName[TSDB_TABLE_NAME_LEN] = {0};
CTG_ERR_JRET(ctgGetCachedStbNameFromSuid(pCtg, pMeta->suid, stbName));
if (0 == stbName[0]) {
if (req->onlyCache) {
res->notExists = true;
return TSDB_CODE_SUCCESS;
}
CTG_ERR_RET(catalogRefreshTableMeta(pCtg, req->pConn, &req->pRawReq->tbName, 0));
}
*/
}
// if (TSDB_CHILD_TABLE == pMeta->tableType) {
// res->pRawRes->pass = true;
// /*
// char stbName[TSDB_TABLE_NAME_LEN] = {0};
// CTG_ERR_JRET(ctgGetCachedStbNameFromSuid(pCtg, pMeta->suid, stbName));
// if (0 == stbName[0]) {
// if (req->onlyCache) {
// res->notExists = true;
// return TSDB_CODE_SUCCESS;
// }
// CTG_ERR_RET(catalogRefreshTableMeta(pCtg, req->pConn, &req->pRawReq->tbName, 0));
// }
// */
// }
_return:
taosMemoryFree
(
pMeta
);
CTG_RET
(
code
);
}
int32_t
ctgChkSetAuthRes
(
SCatalog
*
pCtg
,
SCtgAuthReq
*
req
,
SCtgAuthRsp
*
res
)
{
int32_t
code
=
0
;
SUserAuthInfo
*
pReq
=
req
->
pRawReq
;
SUserAuthRes
*
pRes
=
res
->
pRawRes
;
SGetUserAuthRsp
*
pInfo
=
&
req
->
authInfo
;
int32_t
ctgChkSetAuthRes
(
SCatalog
*
pCtg
,
SCtgAuthReq
*
req
,
SCtgAuthRsp
*
res
)
{
int32_t
code
=
0
;
SUserAuthInfo
*
pReq
=
req
->
pRawReq
;
SUserAuthRes
*
pRes
=
res
->
pRawRes
;
SGetUserAuthRsp
*
pInfo
=
&
req
->
authInfo
;
pRes
->
pass
=
false
;
pRes
->
pCond
=
NULL
;
pRes
->
pCond
=
NULL
;
if
(
!
pInfo
->
enable
)
{
pRes
->
pass
=
false
;
...
...
@@ -1421,36 +1424,44 @@ int32_t ctgChkSetAuthRes(SCatalog *pCtg, SCtgAuthReq *req, SCtgAuthRsp* res) {
switch
(
pReq
->
type
)
{
case
AUTH_TYPE_READ
:
{
if
(
pInfo
->
readTbs
&&
taosHashGetSize
(
pInfo
->
readTbs
)
>
0
)
{
req
->
singleType
=
AUTH_TYPE_READ
;
CTG_ERR_RET
(
ctgChkSetTbAuthRes
(
pCtg
,
req
,
res
));
if
(
pRes
->
pass
)
{
return
TSDB_CODE_SUCCESS
;
}
}
if
(
pInfo
->
readDbs
&&
taosHashGet
(
pInfo
->
readDbs
,
dbFName
,
strlen
(
dbFName
)))
{
pRes
->
pass
=
true
;
return
TSDB_CODE_SUCCESS
;
}
if
(
pInfo
->
readTbs
&&
taosHashGetSize
(
pInfo
->
readTbs
)
>
0
)
{
req
->
singleType
=
AUTH_TYPE_READ
;
CTG_RET
(
ctgChkSetTbAuthRes
(
pCtg
,
req
,
res
));
}
break
;
}
case
AUTH_TYPE_WRITE
:
{
if
(
pInfo
->
writeTbs
&&
taosHashGetSize
(
pInfo
->
writeTbs
)
>
0
)
{
req
->
singleType
=
AUTH_TYPE_WRITE
;
CTG_ERR_RET
(
ctgChkSetTbAuthRes
(
pCtg
,
req
,
res
));
if
(
pRes
->
pass
)
{
return
TSDB_CODE_SUCCESS
;
}
}
if
(
pInfo
->
writeDbs
&&
taosHashGet
(
pInfo
->
writeDbs
,
dbFName
,
strlen
(
dbFName
)))
{
pRes
->
pass
=
true
;
return
TSDB_CODE_SUCCESS
;
}
if
(
pInfo
->
writeTbs
&&
taosHashGetSize
(
pInfo
->
writeTbs
)
>
0
)
{
req
->
singleType
=
AUTH_TYPE_WRITE
;
CTG_RET
(
ctgChkSetTbAuthRes
(
pCtg
,
req
,
res
));
}
break
;
}
case
AUTH_TYPE_READ_OR_WRITE
:
{
if
((
pInfo
->
readDbs
&&
taosHashGet
(
pInfo
->
readDbs
,
dbFName
,
strlen
(
dbFName
)))
||
(
pInfo
->
writeDbs
&&
taosHashGet
(
pInfo
->
writeDbs
,
dbFName
,
strlen
(
dbFName
))))
{
(
pInfo
->
writeDbs
&&
taosHashGet
(
pInfo
->
writeDbs
,
dbFName
,
strlen
(
dbFName
))))
{
pRes
->
pass
=
true
;
return
TSDB_CODE_SUCCESS
;
}
break
;
}
default:
...
...
@@ -1460,7 +1471,6 @@ int32_t ctgChkSetAuthRes(SCatalog *pCtg, SCtgAuthReq *req, SCtgAuthRsp* res) {
return
TSDB_CODE_SUCCESS
;
}
#if 0
static int32_t ctgCloneMetaDataArray(SArray* pSrc, __array_item_dup_fn_t copyFunc, SArray** pDst) {
if (NULL == pSrc) {
...
...
@@ -1554,4 +1564,3 @@ void catalogFreeMetaData(SMetaData* pData) {
taosMemoryFree(pData);
}
#endif
source/libs/parser/src/parAstParser.c
浏览文件 @
afbc468d
...
...
@@ -287,6 +287,10 @@ static int32_t collectMetaKeyFromDropTable(SCollectMetaKeyCxt* pCxt, SDropTableS
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveTableVgroupInCache
(
pCxt
->
pParseCxt
->
acctId
,
pClause
->
dbName
,
pClause
->
tableName
,
pCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveUserAuthInCache
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
pUser
,
pClause
->
dbName
,
pClause
->
tableName
,
AUTH_TYPE_WRITE
,
pCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
...
...
@@ -294,6 +298,11 @@ static int32_t collectMetaKeyFromDropTable(SCollectMetaKeyCxt* pCxt, SDropTableS
return
code
;
}
static
int32_t
collectMetaKeyFromDropStable
(
SCollectMetaKeyCxt
*
pCxt
,
SDropSuperTableStmt
*
pStmt
)
{
return
reserveUserAuthInCache
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
pUser
,
pStmt
->
dbName
,
pStmt
->
tableName
,
AUTH_TYPE_WRITE
,
pCxt
->
pMetaCache
);
}
static
int32_t
collectMetaKeyFromAlterTable
(
SCollectMetaKeyCxt
*
pCxt
,
SAlterTableStmt
*
pStmt
)
{
int32_t
code
=
reserveDbCfgInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pCxt
->
pMetaCache
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
@@ -302,6 +311,10 @@ static int32_t collectMetaKeyFromAlterTable(SCollectMetaKeyCxt* pCxt, SAlterTabl
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveTableVgroupInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveUserAuthInCache
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
pUser
,
pStmt
->
dbName
,
pStmt
->
tableName
,
AUTH_TYPE_WRITE
,
pCxt
->
pMetaCache
);
}
return
code
;
}
...
...
@@ -310,6 +323,10 @@ static int32_t collectMetaKeyFromAlterStable(SCollectMetaKeyCxt* pCxt, SAlterTab
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveUserAuthInCache
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
pUser
,
pStmt
->
dbName
,
pStmt
->
tableName
,
AUTH_TYPE_WRITE
,
pCxt
->
pMetaCache
);
}
return
code
;
}
...
...
@@ -638,6 +655,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
return
collectMetaKeyFromCreateMultiTable
(
pCxt
,
(
SCreateMultiTablesStmt
*
)
pStmt
);
case
QUERY_NODE_DROP_TABLE_STMT
:
return
collectMetaKeyFromDropTable
(
pCxt
,
(
SDropTableStmt
*
)
pStmt
);
case
QUERY_NODE_DROP_SUPER_TABLE_STMT
:
return
collectMetaKeyFromDropStable
(
pCxt
,
(
SDropSuperTableStmt
*
)
pStmt
);
case
QUERY_NODE_ALTER_TABLE_STMT
:
return
collectMetaKeyFromAlterTable
(
pCxt
,
(
SAlterTableStmt
*
)
pStmt
);
case
QUERY_NODE_ALTER_SUPER_TABLE_STMT
:
...
...
source/libs/parser/src/parAuthenticator.c
浏览文件 @
afbc468d
...
...
@@ -197,6 +197,29 @@ static int32_t authCreateMultiTable(SAuthCxt* pCxt, SCreateMultiTablesStmt* pStm
return
code
;
}
static
int32_t
authDropTable
(
SAuthCxt
*
pCxt
,
SDropTableStmt
*
pStmt
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
pStmt
->
pTables
)
{
SDropTableClause
*
pClause
=
(
SDropTableClause
*
)
pNode
;
code
=
checkAuth
(
pCxt
,
pClause
->
dbName
,
pClause
->
tableName
,
AUTH_TYPE_WRITE
,
NULL
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
}
return
code
;
}
static
int32_t
authDropStable
(
SAuthCxt
*
pCxt
,
SDropSuperTableStmt
*
pStmt
)
{
return
checkAuth
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
AUTH_TYPE_WRITE
,
NULL
);
}
static
int32_t
authAlterTable
(
SAuthCxt
*
pCxt
,
SAlterTableStmt
*
pStmt
)
{
SNode
*
pTagCond
=
NULL
;
// todo check tag condition for subtable
return
checkAuth
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
AUTH_TYPE_WRITE
,
NULL
);
}
static
int32_t
authQuery
(
SAuthCxt
*
pCxt
,
SNode
*
pStmt
)
{
switch
(
nodeType
(
pStmt
))
{
case
QUERY_NODE_SET_OPERATOR
:
...
...
@@ -213,6 +236,13 @@ static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) {
return
authCreateTable
(
pCxt
,
(
SCreateTableStmt
*
)
pStmt
);
case
QUERY_NODE_CREATE_MULTI_TABLES_STMT
:
return
authCreateMultiTable
(
pCxt
,
(
SCreateMultiTablesStmt
*
)
pStmt
);
case
QUERY_NODE_DROP_TABLE_STMT
:
return
authDropTable
(
pCxt
,
(
SDropTableStmt
*
)
pStmt
);
case
QUERY_NODE_DROP_SUPER_TABLE_STMT
:
return
authDropStable
(
pCxt
,
(
SDropSuperTableStmt
*
)
pStmt
);
case
QUERY_NODE_ALTER_TABLE_STMT
:
case
QUERY_NODE_ALTER_SUPER_TABLE_STMT
:
return
authAlterTable
(
pCxt
,
(
SAlterTableStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_DNODES_STMT
:
case
QUERY_NODE_SHOW_MNODES_STMT
:
case
QUERY_NODE_SHOW_MODULES_STMT
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录