Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fcba7e32
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看板
提交
fcba7e32
编写于
5月 25, 2023
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:add privilege for schemaless
上级
fb9b0a3e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
126 addition
and
5 deletion
+126
-5
source/client/src/clientSml.c
source/client/src/clientSml.c
+1
-1
utils/test/c/sml_test.c
utils/test/c/sml_test.c
+125
-4
未找到文件。
source/client/src/clientSml.c
浏览文件 @
fcba7e32
...
...
@@ -106,7 +106,7 @@ static int32_t smlCheckAuth(SSmlHandle *info, SRequestConnInfo* conn, const cha
code
=
catalogChkAuth
(
info
->
pCatalog
,
conn
,
&
pAuth
,
&
authRes
);
return
code
?
(
authRes
.
pass
?
TSDB_CODE_SUCCESS
:
TSDB_CODE_PAR_PERMISSION_DENIED
)
:
code
;
return
(
code
==
TSDB_CODE_SUCCESS
)
?
(
authRes
.
pass
?
TSDB_CODE_SUCCESS
:
TSDB_CODE_PAR_PERMISSION_DENIED
)
:
code
;
}
inline
bool
smlDoubleToInt64OverFlow
(
double
num
)
{
...
...
utils/test/c/sml_test.c
浏览文件 @
fcba7e32
...
...
@@ -1135,18 +1135,34 @@ int sml_td22900_Test() {
int
sml_td24070_Test
()
{
TAOS
*
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS_RES
*
pRes
=
taos_query
(
taos
,
"CREATE user test pass 'test'"
);
TAOS_RES
*
pRes
=
taos_query
(
taos
,
"CREATE user test_db pass 'test'"
);
ASSERT
(
taos_errno
(
pRes
)
==
0
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"CREATE DATABASE IF NOT EXISTS td24070"
);
pRes
=
taos_query
(
taos
,
"CREATE DATABASE IF NOT EXISTS td24070_read"
);
ASSERT
(
taos_errno
(
pRes
)
==
0
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"grant read on td24070_read to test_db"
);
ASSERT
(
taos_errno
(
pRes
)
==
0
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"CREATE DATABASE IF NOT EXISTS td24070_write"
);
ASSERT
(
taos_errno
(
pRes
)
==
0
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"grant write on td24070_write to test_db"
);
ASSERT
(
taos_errno
(
pRes
)
==
0
);
taos_free_result
(
pRes
);
taos_close
(
taos
);
taos
=
taos_connect
(
"localhost"
,
"test"
,
"test"
,
NULL
,
0
);
// test db privilege
taos
=
taos_connect
(
"localhost"
,
"test_db"
,
"test"
,
NULL
,
0
);
const
char
*
sql
[]
=
{
"stb2,t1=1,dataModelName=t0 f1=283i32 1632299372000"
};
pRes
=
taos_query
(
taos
,
"use td24070"
);
pRes
=
taos_query
(
taos
,
"use td24070
_read
"
);
taos_free_result
(
pRes
);
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]),
TSDB_SML_LINE_PROTOCOL
,
...
...
@@ -1154,8 +1170,113 @@ int sml_td24070_Test() {
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
int
code
=
taos_errno
(
pRes
);
ASSERT
(
code
!=
0
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"use td24070_write"
);
taos_free_result
(
pRes
);
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]),
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_MILLI_SECONDS
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
code
=
taos_errno
(
pRes
);
ASSERT
(
code
==
0
);
taos_free_result
(
pRes
);
taos_close
(
taos
);
// test db privilege end
// test stable privilege
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
pRes
=
taos_query
(
taos
,
"CREATE user test_stb_read pass 'test'"
);
ASSERT
(
taos_errno
(
pRes
)
==
0
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"CREATE user test_stb_write pass 'test'"
);
ASSERT
(
taos_errno
(
pRes
)
==
0
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"grant read on td24070_write.stb2 to test_stb_read"
);
ASSERT
(
taos_errno
(
pRes
)
==
0
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"grant write on td24070_write.stb2 to test_stb_write"
);
ASSERT
(
taos_errno
(
pRes
)
==
0
);
taos_free_result
(
pRes
);
taos_close
(
taos
);
taos
=
taos_connect
(
"localhost"
,
"test_stb_read"
,
"test"
,
"td24070_write"
,
0
);
const
char
*
sql1
[]
=
{
"stb2,t1=1,dataModelName=t0 f1=283i32 1632299373000"
};
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql1
,
sizeof
(
sql1
)
/
sizeof
(
sql1
[
0
]),
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_MILLI_SECONDS
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
code
=
taos_errno
(
pRes
);
ASSERT
(
code
!=
0
);
taos_free_result
(
pRes
);
taos_close
(
taos
);
taos
=
taos_connect
(
"localhost"
,
"test_stb_write"
,
"test"
,
"td24070_write"
,
0
);
const
char
*
sql2
[]
=
{
"stb2,t1=1,dataModelName=t0 f1=283i32 1632299373000"
};
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql2
,
sizeof
(
sql2
)
/
sizeof
(
sql2
[
0
]),
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_MILLI_SECONDS
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
code
=
taos_errno
(
pRes
);
ASSERT
(
code
==
0
);
taos_free_result
(
pRes
);
taos_close
(
taos
);
// test stable privilege
// test table privilege
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
pRes
=
taos_query
(
taos
,
"CREATE user test_tb_read pass 'test'"
);
ASSERT
(
taos_errno
(
pRes
)
==
0
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"CREATE user test_tb_write pass 'test'"
);
ASSERT
(
taos_errno
(
pRes
)
==
0
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"grant read on td24070_write.t_035c845c1a3df238c54d9b8f1a8844bd to test_tb_read"
);
ASSERT
(
taos_errno
(
pRes
)
==
0
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"grant write on td24070_write.t_035c845c1a3df238c54d9b8f1a8844bd to test_tb_write"
);
ASSERT
(
taos_errno
(
pRes
)
==
0
);
taos_free_result
(
pRes
);
taos_close
(
taos
);
taos
=
taos_connect
(
"localhost"
,
"test_tb_read"
,
"test"
,
"td24070_write"
,
0
);
const
char
*
sql3
[]
=
{
"stb2,t1=1,dataModelName=t0 f1=283i32 1632299374000"
};
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql3
,
sizeof
(
sql3
)
/
sizeof
(
sql3
[
0
]),
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_MILLI_SECONDS
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
code
=
taos_errno
(
pRes
);
ASSERT
(
code
!=
0
);
taos_free_result
(
pRes
);
taos_close
(
taos
);
taos
=
taos_connect
(
"localhost"
,
"test_tb_write"
,
"test"
,
"td24070_write"
,
0
);
const
char
*
sql4
[]
=
{
"stb2,t1=1,dataModelName=t0 f1=283i32 1632299374000"
};
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql4
,
sizeof
(
sql4
)
/
sizeof
(
sql4
[
0
]),
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_MILLI_SECONDS
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
code
=
taos_errno
(
pRes
);
ASSERT
(
code
==
0
);
taos_free_result
(
pRes
);
taos_close
(
taos
);
// test table privilege
return
code
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录