Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
89b7e242
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
89b7e242
编写于
5月 11, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
5月 11, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12329 from taosdata/feature/check
test: add privilege test cases
上级
6a94ad73
c0bcf98c
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
246 addition
and
20 deletion
+246
-20
source/common/src/tglobal.c
source/common/src/tglobal.c
+1
-1
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+32
-15
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+2
-2
source/dnode/mnode/impl/test/user/user.cpp
source/dnode/mnode/impl/test/user/user.cpp
+2
-2
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+3
-0
tests/script/tsim/stable/alter1.sim
tests/script/tsim/stable/alter1.sim
+168
-0
tests/script/tsim/user/privilege2.sim
tests/script/tsim/user/privilege2.sim
+38
-0
未找到文件。
source/common/src/tglobal.c
浏览文件 @
89b7e242
...
...
@@ -351,7 +351,7 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) {
}
static
int32_t
taosAddServerCfg
(
SConfig
*
pCfg
)
{
if
(
cfgAddInt32
(
pCfg
,
"supportVnodes"
,
256
,
0
,
6553
6
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"supportVnodes"
,
256
,
0
,
409
6
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddDir
(
pCfg
,
"dataDir"
,
tsDataDir
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddFloat
(
pCfg
,
"minimalDataDirGB"
,
2
.
0
f
,
0
.
001
f
,
10000000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxNumOfDistinctRes"
,
tsMaxNumOfDistinctResults
,
10
*
10000
,
10000
*
10000
,
0
)
!=
0
)
return
-
1
;
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
89b7e242
...
...
@@ -832,6 +832,8 @@ static int32_t mndProcessVCreateStbRsp(SNodeMsg *pRsp) {
}
static
int32_t
mndCheckAlterStbReq
(
SMAlterStbReq
*
pAlter
)
{
if
(
pAlter
->
commentLen
!=
0
)
return
0
;
if
(
pAlter
->
numOfFields
<
1
||
pAlter
->
numOfFields
!=
(
int32_t
)
taosArrayGetSize
(
pAlter
->
pFields
))
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
...
...
@@ -839,15 +841,6 @@ static int32_t mndCheckAlterStbReq(SMAlterStbReq *pAlter) {
for
(
int32_t
i
=
0
;
i
<
pAlter
->
numOfFields
;
++
i
)
{
SField
*
pField
=
taosArrayGet
(
pAlter
->
pFields
,
i
);
if
(
pField
->
type
<=
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
}
if
(
pField
->
bytes
<=
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
}
if
(
pField
->
name
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
...
...
@@ -890,6 +883,23 @@ static int32_t mndAllocStbSchemas(const SStbObj *pOld, SStbObj *pNew) {
return
0
;
}
static
int32_t
mndUpdateStbComment
(
const
SStbObj
*
pOld
,
SStbObj
*
pNew
,
char
*
pComment
,
int32_t
commentLen
)
{
if
(
commentLen
>
0
)
{
pNew
->
commentLen
=
commentLen
;
pNew
->
comment
=
taosMemoryCalloc
(
1
,
commentLen
);
if
(
pNew
->
comment
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
memcpy
(
pNew
->
comment
,
pComment
,
commentLen
);
}
if
(
mndAllocStbSchemas
(
pOld
,
pNew
)
!=
0
)
{
return
-
1
;
}
return
0
;
}
static
int32_t
mndAddSuperTableTag
(
const
SStbObj
*
pOld
,
SStbObj
*
pNew
,
SArray
*
pFields
,
int32_t
ntags
)
{
if
(
pOld
->
numOfTags
+
ntags
>
TSDB_MAX_TAGS
)
{
terrno
=
TSDB_CODE_MND_TOO_MANY_TAGS
;
...
...
@@ -908,12 +918,12 @@ static int32_t mndAddSuperTableTag(const SStbObj *pOld, SStbObj *pNew, SArray *p
for
(
int32_t
i
=
0
;
i
<
ntags
;
i
++
)
{
SField
*
pField
=
taosArrayGet
(
pFields
,
i
);
if
(
mndFindSuperTableColumnIndex
(
pOld
,
pField
->
name
)
>
0
)
{
if
(
mndFindSuperTableColumnIndex
(
pOld
,
pField
->
name
)
>
=
0
)
{
terrno
=
TSDB_CODE_MND_COLUMN_ALREADY_EXIST
;
return
-
1
;
}
if
(
mndFindSuperTableTagIndex
(
pOld
,
pField
->
name
)
>
0
)
{
if
(
mndFindSuperTableTagIndex
(
pOld
,
pField
->
name
)
>
=
0
)
{
terrno
=
TSDB_CODE_MND_TAG_ALREADY_EXIST
;
return
-
1
;
}
...
...
@@ -1034,12 +1044,12 @@ static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, SArray
for
(
int32_t
i
=
0
;
i
<
ncols
;
i
++
)
{
SField
*
pField
=
taosArrayGet
(
pFields
,
i
);
if
(
mndFindSuperTableColumnIndex
(
pOld
,
pField
->
name
)
>
0
)
{
if
(
mndFindSuperTableColumnIndex
(
pOld
,
pField
->
name
)
>
=
0
)
{
terrno
=
TSDB_CODE_MND_COLUMN_ALREADY_EXIST
;
return
-
1
;
}
if
(
mndFindSuperTableTagIndex
(
pOld
,
pField
->
name
)
>
0
)
{
if
(
mndFindSuperTableTagIndex
(
pOld
,
pField
->
name
)
>
=
0
)
{
terrno
=
TSDB_CODE_MND_TAG_ALREADY_EXIST
;
return
-
1
;
}
...
...
@@ -1193,32 +1203,39 @@ static int32_t mndAlterStb(SMnode *pMnode, SNodeMsg *pReq, const SMAlterStbReq *
int32_t
code
=
-
1
;
STrans
*
pTrans
=
NULL
;
SField
*
pField0
=
taosArrayGet
(
pAlter
->
pFields
,
0
)
;
SField
*
pField0
=
NULL
;
switch
(
pAlter
->
alterType
)
{
case
TSDB_ALTER_TABLE_ADD_TAG
:
code
=
mndAddSuperTableTag
(
pOld
,
&
stbObj
,
pAlter
->
pFields
,
pAlter
->
numOfFields
);
break
;
case
TSDB_ALTER_TABLE_DROP_TAG
:
pField0
=
taosArrayGet
(
pAlter
->
pFields
,
0
);
code
=
mndDropSuperTableTag
(
pOld
,
&
stbObj
,
pField0
->
name
);
break
;
case
TSDB_ALTER_TABLE_UPDATE_TAG_NAME
:
code
=
mndAlterStbTagName
(
pOld
,
&
stbObj
,
pAlter
->
pFields
);
break
;
case
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES
:
pField0
=
taosArrayGet
(
pAlter
->
pFields
,
0
);
code
=
mndAlterStbTagBytes
(
pOld
,
&
stbObj
,
pField0
);
break
;
case
TSDB_ALTER_TABLE_ADD_COLUMN
:
code
=
mndAddSuperTableColumn
(
pOld
,
&
stbObj
,
pAlter
->
pFields
,
pAlter
->
numOfFields
);
break
;
case
TSDB_ALTER_TABLE_DROP_COLUMN
:
pField0
=
taosArrayGet
(
pAlter
->
pFields
,
0
);
code
=
mndDropSuperTableColumn
(
pOld
,
&
stbObj
,
pField0
->
name
);
break
;
case
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
:
pField0
=
taosArrayGet
(
pAlter
->
pFields
,
0
);
code
=
mndAlterStbColumnBytes
(
pOld
,
&
stbObj
,
pField0
);
break
;
case
TSDB_ALTER_TABLE_UPDATE_OPTIONS
:
code
=
mndUpdateStbComment
(
pOld
,
&
stbObj
,
pAlter
->
comment
,
pAlter
->
commentLen
);
break
;
default:
terrno
=
TSDB_CODE_
MND_INVALID_STB_OPTION
;
terrno
=
TSDB_CODE_
OPS_NOT_SUPPORT
;
break
;
}
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
89b7e242
...
...
@@ -507,7 +507,7 @@ static int32_t mndProcessAlterUserReq(SNodeMsg *pReq) {
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_REMOVE_READ_DB
||
alterReq
.
alterType
==
TSDB_ALTER_USER_REMOVE_ALL_DB
)
{
if
(
strcmp
(
alterReq
.
dbname
,
"*"
)
!=
0
)
{
if
(
strcmp
(
alterReq
.
dbname
,
"
1.
*"
)
!=
0
)
{
int32_t
len
=
strlen
(
alterReq
.
dbname
)
+
1
;
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
alterReq
.
dbname
);
if
(
pDb
==
NULL
)
{
...
...
@@ -521,7 +521,7 @@ static int32_t mndProcessAlterUserReq(SNodeMsg *pReq) {
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_REMOVE_WRITE_DB
||
alterReq
.
alterType
==
TSDB_ALTER_USER_REMOVE_ALL_DB
)
{
if
(
strcmp
(
alterReq
.
dbname
,
"*"
)
!=
0
)
{
if
(
strcmp
(
alterReq
.
dbname
,
"
1.
*"
)
!=
0
)
{
int32_t
len
=
strlen
(
alterReq
.
dbname
)
+
1
;
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
alterReq
.
dbname
);
if
(
pDb
==
NULL
)
{
...
...
source/dnode/mnode/impl/test/user/user.cpp
浏览文件 @
89b7e242
...
...
@@ -241,7 +241,7 @@ TEST_F(MndTestUser, 03_Alter_User) {
alterReq
.
alterType
=
TSDB_ALTER_USER_REMOVE_ALL_DB
;
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
dbname
,
"*"
);
strcpy
(
alterReq
.
dbname
,
"
1.
*"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
...
...
@@ -257,7 +257,7 @@ TEST_F(MndTestUser, 03_Alter_User) {
alterReq
.
alterType
=
TSDB_ALTER_USER_REMOVE_ALL_DB
;
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
dbname
,
"*"
);
strcpy
(
alterReq
.
dbname
,
"
1.
*"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
...
...
tests/script/jenkins/basic.txt
浏览文件 @
89b7e242
...
...
@@ -6,6 +6,8 @@
./test.sh -f tsim/user/pass_alter.sim
./test.sh -f tsim/user/pass_len.sim
./test.sh -f tsim/user/user_len.sim
./test.sh -f tsim/user/privilege1.sim
./test.sh -f tsim/user/privilege2.sim
# ---- db
./test.sh -f tsim/db/create_all_options.sim
...
...
@@ -77,6 +79,7 @@
./test.sh -f tsim/tmq/basic2Of2ConsOverlap.sim
# --- stable
./test.sh -f tsim/stable/alter1.sim
./test.sh -f tsim/stable/disk.sim
./test.sh -f tsim/stable/dnode3.sim
./test.sh -f tsim/stable/metrics.sim
...
...
tests/script/tsim/stable/alter1.sim
0 → 100644
浏览文件 @
89b7e242
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print ========== create stable
sql create database db
sql use db
sql create table db.stb (ts timestamp, c1 int, c2 binary(4)) tags(t1 int, t2 float, t3 binary(16)) comment "abd"
sql show db.stables
if $rows != 1 then
return -1
endi
if $data[0][3] != 3 then
return -1
endi
if $data[0][4] != 3 then
return -1
endi
if $data[0][6] != abd then
return -1
endi
print ========== add column
sql_error alter table db.stb add column ts int
sql_error alter table db.stb add column c1 int
sql_error alter table db.stb add column c2 int
sql_error alter table db.stb add column t1 int
sql_error alter table db.stb add column t2 int
sql_error alter table db.stb add column t3 int
sql alter table db.stb add column c3 int
sql alter table db.stb add column c4 bigint
sql alter table db.stb add column c5 binary(12)
sql show db.stables
if $rows != 1 then
return -1
endi
if $data[0][3] != 6 then
return -1
endi
if $data[0][4] != 3 then
return -1
endi
print ========== drop column
sql_error alter table db.stb drop column ts
sql_error alter table db.stb drop column c6
sql_error alter table db.stb drop column c7
sql_error alter table db.stb drop column t1
sql_error alter table db.stb drop column t2
sql_error alter table db.stb drop column t3
sql alter table db.stb drop column c1
sql alter table db.stb drop column c4
sql show db.stables
if $rows != 1 then
return -1
endi
if $data[0][3] != 4 then
return -1
endi
if $data[0][4] != 3 then
return -1
endi
print ========== update column
sql_error alter table db.stb MODIFY column ts binary(20)
sql_error alter table db.stb MODIFY column c6 binary(20)
sql_error alter table db.stb MODIFY column t1 binary(20)
sql_error alter table db.stb MODIFY column t3 binary(20)
sql_error alter table db.stb MODIFY column c2 binary(3)
sql alter table db.stb MODIFY column c2 binary(32)
sql show db.stables
if $rows != 1 then
return -1
endi
if $data[0][3] != 4 then
return -1
endi
if $data[0][4] != 3 then
return -1
endi
print ========== rename column
sql_error alter table db.stb rename column ts tx
sql_error alter table db.stb rename column c2 cx
print ========== add tag
sql_error alter table db.stb add tag ts int
sql_error alter table db.stb add tag c2 int
sql_error alter table db.stb add tag t1 int
sql_error alter table db.stb add tag t2 int
sql_error alter table db.stb add tag t3 int
sql alter table db.stb add tag t4 bigint
sql alter table db.stb add tag c1 int
sql alter table db.stb add tag t5 binary(12)
sql show db.stables
if $rows != 1 then
return -1
endi
#ts c2 c3 c5
if $data[0][3] != 4 then
return -1
endi
#t1 t2 t3 t4 c1 t5
if $data[0][4] != 6 then
return -1
endi
print ========== drop tag
sql_error alter table db.stb drop tag ts
sql_error alter table db.stb drop tag c2
sql_error alter table db.stb drop tag c3
sql_error alter table db.stb drop tag tx
sql alter table db.stb drop tag c1
sql alter table db.stb drop tag t5
sql show db.stables
if $rows != 1 then
return -1
endi
#ts c2 c3 c5
if $data[0][3] != 4 then
return -1
endi
#t1 t2 t3 t4
if $data[0][4] != 4 then
return -1
endi
print ========== update tag
sql_error alter table db.stb MODIFY tag ts binary(20)
sql_error alter table db.stb MODIFY tag c2 binary(20)
sql_error alter table db.stb MODIFY tag t1 binary(20)
sql_error alter table db.stb MODIFY tag tx binary(20)
sql alter table db.stb MODIFY tag t3 binary(32)
sql show db.stables
if $rows != 1 then
return -1
endi
if $data[0][3] != 4 then
return -1
endi
if $data[0][4] != 4 then
return -1
endi
print ========== rename tag
#t1 t2 t3 t4
sql_error alter table db.stb rename tag ts tx
sql_error alter table db.stb rename tag c2 cx
sql alter table db.stb rename tag t1 tx
print ========== alter common
sql alter table db.stb comment 'abcde' ;
sql show db.stables;
if $data[0][6] != abcde then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/user/privilege2.sim
0 → 100644
浏览文件 @
89b7e242
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print =============== show users
sql create database d1 vgroups 1;
sql create database d2 vgroups 1;
sql create database d3 vgroups 1;
sql show databases
if $rows != 5 then
return -1
endi
print =============== create users
sql create user user1 PASS 'taosdata'
sql create user user2 PASS 'taosdata'
sql show users
if $rows != 3 then
return -1
endi
sql GRANT read ON d1.* to user1;
sql GRANT write ON d2.* to user1;
print =============== re connect
sql close
sleep 2500
print user user1 login
sql connect user1
sql_error drop database d1;
sql_error drop database d2;
sql_error create stable d1.st (ts timestamp, i int) tags (j int)
sql create stable d2.st (ts timestamp, i int) tags (j int)
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录