Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
765c09d5
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看板
提交
765c09d5
编写于
4月 10, 2023
作者:
“
“happyguoxy”
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update function
上级
b2de711a
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
72 addition
and
18 deletion
+72
-18
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+1
-0
source/dnode/mnode/impl/src/mndFunc.c
source/dnode/mnode/impl/src/mndFunc.c
+71
-18
未找到文件。
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
765c09d5
...
...
@@ -448,6 +448,7 @@ typedef struct {
char
*
pComment
;
char
*
pCode
;
int32_t
funcVersion
;
SRWLatch
lock
;
}
SFuncObj
;
typedef
struct
{
...
...
source/dnode/mnode/impl/src/mndFunc.c
浏览文件 @
765c09d5
...
...
@@ -152,6 +152,8 @@ static SSdbRow *mndFuncActionDecode(SSdbRaw *pRaw) {
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
SDB_FUNC_RESERVE_SIZE
,
_OVER
)
taosInitRWLatch
(
&
pFunc
->
lock
);
terrno
=
0
;
_OVER:
...
...
@@ -179,6 +181,44 @@ static int32_t mndFuncActionDelete(SSdb *pSdb, SFuncObj *pFunc) {
static
int32_t
mndFuncActionUpdate
(
SSdb
*
pSdb
,
SFuncObj
*
pOld
,
SFuncObj
*
pNew
)
{
mTrace
(
"func:%s, perform update action, old row:%p new row:%p"
,
pOld
->
name
,
pOld
,
pNew
);
taosWLockLatch
(
&
pOld
->
lock
);
pOld
->
align
=
pNew
->
align
;
pOld
->
bufSize
=
pNew
->
bufSize
;
pOld
->
codeSize
=
pNew
->
codeSize
;
pOld
->
commentSize
=
pNew
->
commentSize
;
pOld
->
createdTime
=
pNew
->
createdTime
;
pOld
->
funcType
=
pNew
->
funcType
;
pOld
->
funcVersion
=
pNew
->
funcVersion
;
pOld
->
outputLen
=
pNew
->
outputLen
;
pOld
->
outputType
=
pNew
->
outputType
;
if
(
pOld
->
pComment
!=
NULL
){
taosMemoryFree
(
pOld
->
pComment
);
pOld
->
pComment
=
NULL
;
}
if
(
pNew
->
commentSize
>
0
&&
pNew
->
pComment
!=
NULL
){
pOld
->
commentSize
=
pNew
->
commentSize
;
pOld
->
pComment
=
taosMemoryMalloc
(
pOld
->
commentSize
);
memcpy
(
pOld
->
pComment
,
pNew
->
pComment
,
pOld
->
commentSize
);
}
if
(
pOld
->
pCode
!=
NULL
){
taosMemoryFree
(
pOld
->
pCode
);
pOld
->
pCode
=
NULL
;
}
if
(
pNew
->
codeSize
>
0
&&
pNew
->
pCode
!=
NULL
){
pOld
->
codeSize
=
pNew
->
codeSize
;
pOld
->
pCode
=
taosMemoryMalloc
(
pOld
->
codeSize
);
memcpy
(
pOld
->
pCode
,
pNew
->
pCode
,
pOld
->
codeSize
);
}
pOld
->
scriptType
=
pNew
->
scriptType
;
pOld
->
signature
=
pNew
->
signature
;
taosWUnLockLatch
(
&
pOld
->
lock
);
return
0
;
}
...
...
@@ -229,19 +269,27 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre
}
memcpy
(
func
.
pCode
,
pCreate
->
pCode
,
func
.
codeSize
);
if
(
pCreate
->
orReplace
==
1
){
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_CONFLICT_NOTHING
,
pReq
,
"create-func"
);
if
(
pTrans
==
NULL
)
goto
_OVER
;
mInfo
(
"trans:%d, used to create func:%s"
,
pTrans
->
id
,
pCreate
->
name
);
SFuncObj
*
oldFunc
=
mndAcquireFunc
(
pMnode
,
pCreate
->
name
);
if
(
oldFunc
!=
NULL
){
if
(
pCreate
->
orReplace
==
1
&&
oldFunc
!=
NULL
){
func
.
funcVersion
=
oldFunc
->
funcVersion
+
1
;
mndReleaseFunc
(
pMnode
,
oldFunc
);
}
}
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_CONFLICT_NOTHING
,
pReq
,
"create-func"
);
if
(
pTrans
==
NULL
)
goto
_OVER
;
SSdbRaw
*
pRedoRaw
=
mndFuncActionEncode
(
oldFunc
);
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
goto
_OVER
;
if
(
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_READY
)
!=
0
)
goto
_OVER
;
mInfo
(
"trans:%d, used to create func:%s"
,
pTrans
->
id
,
pCreate
->
name
);
SSdbRaw
*
pUndoRaw
=
mndFuncActionEncode
(
oldFunc
);
if
(
pUndoRaw
==
NULL
||
mndTransAppendUndolog
(
pTrans
,
pUndoRaw
)
!=
0
)
goto
_OVER
;
if
(
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_READY
)
!=
0
)
goto
_OVER
;
SSdbRaw
*
pCommitRaw
=
mndFuncActionEncode
(
&
func
);
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
goto
_OVER
;
if
(
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_READY
)
!=
0
)
goto
_OVER
;
}
else
{
SSdbRaw
*
pRedoRaw
=
mndFuncActionEncode
(
&
func
);
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
goto
_OVER
;
if
(
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_CREATING
)
!=
0
)
goto
_OVER
;
...
...
@@ -253,12 +301,17 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre
SSdbRaw
*
pCommitRaw
=
mndFuncActionEncode
(
&
func
);
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
goto
_OVER
;
if
(
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_READY
)
!=
0
)
goto
_OVER
;
}
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
code
=
0
;
_OVER:
if
(
oldFunc
!=
NULL
){
mndReleaseFunc
(
pMnode
,
oldFunc
);
}
taosMemoryFree
(
func
.
pCode
);
taosMemoryFree
(
func
.
pComment
);
mndTransDrop
(
pTrans
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录