Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
96089657
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,发现更多精彩内容 >>
提交
96089657
编写于
1月 24, 2022
作者:
S
Shengliang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ut for udf manage
上级
022b5f85
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
128 deletion
+42
-128
include/common/tmsg.h
include/common/tmsg.h
+2
-2
source/dnode/mnode/impl/src/mndFunc.c
source/dnode/mnode/impl/src/mndFunc.c
+1
-1
source/dnode/mnode/impl/test/func/func.cpp
source/dnode/mnode/impl/test/func/func.cpp
+39
-125
未找到文件。
include/common/tmsg.h
浏览文件 @
96089657
...
@@ -539,8 +539,8 @@ typedef struct {
...
@@ -539,8 +539,8 @@ typedef struct {
}
SCreateFuncReq
;
}
SCreateFuncReq
;
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_FUNC_NAME_LEN
];
char
name
[
TSDB_FUNC_NAME_LEN
];
int8_t
igNotExists
;
int8_t
igNotExists
;
}
SDropFuncReq
;
}
SDropFuncReq
;
typedef
struct
{
typedef
struct
{
...
...
source/dnode/mnode/impl/src/mndFunc.c
浏览文件 @
96089657
...
@@ -405,7 +405,7 @@ static int32_t mndProcessRetrieveFuncReq(SMnodeMsg *pReq) {
...
@@ -405,7 +405,7 @@ static int32_t mndProcessRetrieveFuncReq(SMnodeMsg *pReq) {
pFuncInfo
->
codeSize
=
htonl
(
pFunc
->
codeSize
);
pFuncInfo
->
codeSize
=
htonl
(
pFunc
->
codeSize
);
memcpy
(
pFuncInfo
->
pCont
,
pFunc
->
pComment
,
pFunc
->
commentSize
);
memcpy
(
pFuncInfo
->
pCont
,
pFunc
->
pComment
,
pFunc
->
commentSize
);
memcpy
(
pFuncInfo
->
pCont
+
pFunc
->
commentSize
,
pFunc
->
pCode
,
pFunc
->
codeSize
);
memcpy
(
pFuncInfo
->
pCont
+
pFunc
->
commentSize
,
pFunc
->
pCode
,
pFunc
->
codeSize
);
pOutput
+=
sizeof
(
SFuncInfo
)
+
pFunc
->
commentSize
+
pFunc
->
codeSize
;
pOutput
+=
(
sizeof
(
SFuncInfo
)
+
pFunc
->
commentSize
+
pFunc
->
codeSize
)
;
mndReleaseFunc
(
pMnode
,
pFunc
);
mndReleaseFunc
(
pMnode
,
pFunc
);
}
}
...
...
source/dnode/mnode/impl/test/func/func.cpp
浏览文件 @
96089657
...
@@ -363,7 +363,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
...
@@ -363,7 +363,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
contLen
=
(
contLen
+
numOfFuncs
*
TSDB_FUNC_NAME_LEN
);
contLen
=
(
contLen
+
numOfFuncs
*
TSDB_FUNC_NAME_LEN
);
SRetrieveFuncReq
*
pReq
=
(
SRetrieveFuncReq
*
)
rpcMallocCont
(
contLen
);
SRetrieveFuncReq
*
pReq
=
(
SRetrieveFuncReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
numOfFuncs
=
htonl
(
1
);
pReq
->
numOfFuncs
=
htonl
(
numOfFuncs
);
strcpy
(
pReq
->
pFuncNames
,
"f2"
);
strcpy
(
pReq
->
pFuncNames
,
"f2"
);
strcpy
((
char
*
)
pReq
->
pFuncNames
+
TSDB_FUNC_NAME_LEN
,
"f1"
);
strcpy
((
char
*
)
pReq
->
pFuncNames
+
TSDB_FUNC_NAME_LEN
,
"f1"
);
...
@@ -425,41 +425,54 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
...
@@ -425,41 +425,54 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
EXPECT_EQ
(
pFuncInfo
->
commentSize
,
TSDB_FUNC_COMMENT_LEN
);
EXPECT_EQ
(
pFuncInfo
->
commentSize
,
TSDB_FUNC_COMMENT_LEN
);
EXPECT_EQ
(
pFuncInfo
->
codeSize
,
TSDB_FUNC_CODE_LEN
);
EXPECT_EQ
(
pFuncInfo
->
codeSize
,
TSDB_FUNC_CODE_LEN
);
//
char* pComment = pFuncInfo->pCont;
char
*
pComment
=
pFuncInfo
->
pCont
;
//
char* pCode = pFuncInfo->pCont + pFuncInfo->commentSize;
char
*
pCode
=
pFuncInfo
->
pCont
+
pFuncInfo
->
commentSize
;
//
char comments[TSDB_FUNC_COMMENT_LEN] = {0};
char
comments
[
TSDB_FUNC_COMMENT_LEN
]
=
{
0
};
//
for (int32_t i = 0; i < TSDB_FUNC_COMMENT_LEN - 1; ++i) {
for
(
int32_t
i
=
0
;
i
<
TSDB_FUNC_COMMENT_LEN
-
1
;
++
i
)
{
//
comments[i] = 'm';
comments
[
i
]
=
'm'
;
//
}
}
//
char codes[TSDB_FUNC_CODE_LEN] = {0};
char
codes
[
TSDB_FUNC_CODE_LEN
]
=
{
0
};
//
for (int32_t i = 0; i < TSDB_FUNC_CODE_LEN - 1; ++i) {
for
(
int32_t
i
=
0
;
i
<
TSDB_FUNC_CODE_LEN
-
1
;
++
i
)
{
//
codes[i] = 'd';
codes
[
i
]
=
'd'
;
//
}
}
//
EXPECT_STREQ(pComment, comments);
EXPECT_STREQ
(
pComment
,
comments
);
//
EXPECT_STREQ(pCode, codes);
EXPECT_STREQ
(
pCode
,
codes
);
}
}
}
}
}
#if 0
{
int32_t
contLen
=
sizeof
(
SRetrieveFuncReq
);
int32_t
numOfFuncs
=
2
;
contLen
=
(
contLen
+
numOfFuncs
*
TSDB_FUNC_NAME_LEN
);
SRetrieveFuncReq
*
pReq
=
(
SRetrieveFuncReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
numOfFuncs
=
htonl
(
numOfFuncs
);
strcpy
(
pReq
->
pFuncNames
,
"f2"
);
strcpy
((
char
*
)
pReq
->
pFuncNames
+
TSDB_FUNC_NAME_LEN
,
"f3"
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_RETRIEVE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_FUNC
);
}
}
TEST_F
(
MndTestFunc
,
04
_Drop_Func
)
{
TEST_F
(
MndTestFunc
,
04
_Drop_Func
)
{
{
{
int32_t
contLen
=
sizeof
(
SDropFuncReq
);
int32_t
contLen
=
sizeof
(
SDropFuncReq
);
SDropFuncReq
*
pReq
=
(
SDropFuncReq
*
)
rpcMallocCont
(
contLen
);
SDropFuncReq
*
pReq
=
(
SDropFuncReq
*
)
rpcMallocCont
(
contLen
);
strcpy(pReq->
user
, "");
strcpy
(
pReq
->
name
,
""
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_FUNC_
FORMAT
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_FUNC_
NAME
);
}
}
{
{
int32_t
contLen
=
sizeof
(
SDropFuncReq
);
int32_t
contLen
=
sizeof
(
SDropFuncReq
);
SDropFuncReq
*
pReq
=
(
SDropFuncReq
*
)
rpcMallocCont
(
contLen
);
SDropFuncReq
*
pReq
=
(
SDropFuncReq
*
)
rpcMallocCont
(
contLen
);
strcpy(pReq->
user, "u4
");
strcpy
(
pReq
->
name
,
"f3
"
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -470,100 +483,19 @@ TEST_F(MndTestFunc, 04_Drop_Func) {
...
@@ -470,100 +483,19 @@ TEST_F(MndTestFunc, 04_Drop_Func) {
int32_t
contLen
=
sizeof
(
SDropFuncReq
);
int32_t
contLen
=
sizeof
(
SDropFuncReq
);
SDropFuncReq
*
pReq
=
(
SDropFuncReq
*
)
rpcMallocCont
(
contLen
);
SDropFuncReq
*
pReq
=
(
SDropFuncReq
*
)
rpcMallocCont
(
contLen
);
strcpy(pReq->user, "u1");
strcpy
(
pReq
->
name
,
"f3"
);
pReq
->
igNotExists
=
1
;
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
test.SendShowMetaReq(TSDB_MGMT_TABLE_FUNC, "");
CHECK_META("show functions", 4);
test.SendShowRetrieveReq();
EXPECT_EQ(test.GetShowRows(), 1);
}
TEST_F(MndTestFunc, 05_Create_Drop_Alter_Func) {
{
int32_t contLen = sizeof(SCreateFuncReq);
SCreateFuncReq* pReq = (SCreateFuncReq*)rpcMallocCont(contLen);
strcpy(pReq->user, "u1");
strcpy(pReq->pass, "p1");
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_FUNC, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, 0);
}
{
int32_t contLen = sizeof(SCreateFuncReq);
SCreateFuncReq* pReq = (SCreateFuncReq*)rpcMallocCont(contLen);
strcpy(pReq->user, "u2");
strcpy(pReq->pass, "p2");
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_FUNC, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, 0);
}
test.SendShowMetaReq(TSDB_MGMT_TABLE_FUNC, "");
CHECK_META("show functions", 4);
test.SendShowRetrieveReq();
EXPECT_EQ(test.GetShowRows(), 3);
CheckBinary("u1", TSDB_FUNC_LEN);
CheckBinary("root", TSDB_FUNC_LEN);
CheckBinary("u2", TSDB_FUNC_LEN);
CheckBinary("normal", 10);
CheckBinary("super", 10);
CheckBinary("normal", 10);
CheckTimestamp();
CheckTimestamp();
CheckTimestamp();
CheckBinary("root", TSDB_FUNC_LEN);
CheckBinary("root", TSDB_FUNC_LEN);
CheckBinary("root", TSDB_FUNC_LEN);
{
int32_t contLen = sizeof(SAlterFuncReq);
SAlterFuncReq* pReq = (SAlterFuncReq*)rpcMallocCont(contLen);
strcpy(pReq->user, "u1");
strcpy(pReq->pass, "p2");
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_FUNC, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, 0);
}
test.SendShowMetaReq(TSDB_MGMT_TABLE_FUNC, "");
CHECK_META("show functions", 4);
test.SendShowRetrieveReq();
EXPECT_EQ(test.GetShowRows(), 3);
CheckBinary("u1", TSDB_FUNC_LEN);
CheckBinary("root", TSDB_FUNC_LEN);
CheckBinary("u2", TSDB_FUNC_LEN);
CheckBinary("normal", 10);
CheckBinary("super", 10);
CheckBinary("normal", 10);
CheckTimestamp();
CheckTimestamp();
CheckTimestamp();
CheckBinary("root", TSDB_FUNC_LEN);
CheckBinary("root", TSDB_FUNC_LEN);
CheckBinary("root", TSDB_FUNC_LEN);
{
{
int32_t
contLen
=
sizeof
(
SDropFuncReq
);
int32_t
contLen
=
sizeof
(
SDropFuncReq
);
SDropFuncReq
*
pReq
=
(
SDropFuncReq
*
)
rpcMallocCont
(
contLen
);
SDropFuncReq
*
pReq
=
(
SDropFuncReq
*
)
rpcMallocCont
(
contLen
);
strcpy(pReq->
user, "u
1");
strcpy
(
pReq
->
name
,
"f
1"
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -571,37 +503,19 @@ TEST_F(MndTestFunc, 05_Create_Drop_Alter_Func) {
...
@@ -571,37 +503,19 @@ TEST_F(MndTestFunc, 05_Create_Drop_Alter_Func) {
}
}
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_FUNC
,
""
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_FUNC
,
""
);
CHECK_META("show functions",
4
);
CHECK_META
(
"show functions"
,
7
);
test
.
SendShowRetrieveReq
();
test
.
SendShowRetrieveReq
();
EXPECT_EQ(test.GetShowRows(), 2);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary("root", TSDB_FUNC_LEN);
CheckBinary("u2", TSDB_FUNC_LEN);
CheckBinary("super", 10);
CheckBinary("normal", 10);
CheckTimestamp();
CheckTimestamp();
CheckBinary("root", TSDB_FUNC_LEN);
CheckBinary("root", TSDB_FUNC_LEN);
// restart
// restart
test
.
Restart
();
test
.
Restart
();
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_FUNC
,
""
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_FUNC
,
""
);
CHECK_META("show functions",
4
);
CHECK_META
(
"show functions"
,
7
);
test
.
SendShowRetrieveReq
();
test
.
SendShowRetrieveReq
();
EXPECT_EQ(test.GetShowRows(),
2
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary("root", TSDB_FUNC_LEN);
CheckBinary
(
"f2"
,
TSDB_FUNC_NAME_LEN
);
CheckBinary("u2", TSDB_FUNC_LEN);
CheckBinary("super", 10);
CheckBinary("normal", 10);
CheckTimestamp();
CheckTimestamp();
CheckBinary("root", TSDB_FUNC_LEN);
CheckBinary("root", TSDB_FUNC_LEN);
}
}
#endif
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录