Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ba82f05d
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
ba82f05d
编写于
3月 17, 2023
作者:
S
slzhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: keep original udf file name when rename file error
上级
c4d05af0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
57 deletion
+43
-57
source/libs/function/src/udfd.c
source/libs/function/src/udfd.c
+7
-7
tests/script/sh/bit_and.c
tests/script/sh/bit_and.c
+36
-50
未找到文件。
source/libs/function/src/udfd.c
浏览文件 @
ba82f05d
...
@@ -241,7 +241,7 @@ typedef struct SUvUdfWork {
...
@@ -241,7 +241,7 @@ typedef struct SUvUdfWork {
struct
SUvUdfWork
*
pWorkNext
;
struct
SUvUdfWork
*
pWorkNext
;
}
SUvUdfWork
;
}
SUvUdfWork
;
typedef
enum
{
UDF_STATE_INIT
=
0
,
UDF_STATE_LOADING
,
UDF_STATE_READY
}
EUdfState
;
typedef
enum
{
UDF_STATE_INIT
=
0
,
UDF_STATE_LOADING
,
UDF_STATE_READY
}
EUdfState
;
typedef
struct
SUdf
{
typedef
struct
SUdf
{
char
name
[
TSDB_FUNC_NAME_LEN
+
1
];
char
name
[
TSDB_FUNC_NAME_LEN
+
1
];
...
@@ -439,7 +439,7 @@ int32_t udfdInitScriptPlugin(int8_t scriptType) {
...
@@ -439,7 +439,7 @@ int32_t udfdInitScriptPlugin(int8_t scriptType) {
return
err
;
return
err
;
}
}
break
;
break
;
}
}
default:
default:
fnError
(
"udf script type %d not supported"
,
scriptType
);
fnError
(
"udf script type %d not supported"
,
scriptType
);
taosMemoryFree
(
plugin
);
taosMemoryFree
(
plugin
);
...
@@ -509,15 +509,15 @@ int32_t udfdRenameUdfFile(SUdf *udf) {
...
@@ -509,15 +509,15 @@ int32_t udfdRenameUdfFile(SUdf *udf) {
char
newPath
[
PATH_MAX
];
char
newPath
[
PATH_MAX
];
if
(
udf
->
scriptType
==
TSDB_FUNC_SCRIPT_BIN_LIB
)
{
if
(
udf
->
scriptType
==
TSDB_FUNC_SCRIPT_BIN_LIB
)
{
snprintf
(
newPath
,
PATH_MAX
,
"%s/lib%s.so"
,
tsTempDir
,
udf
->
name
);
snprintf
(
newPath
,
PATH_MAX
,
"%s/lib%s.so"
,
tsTempDir
,
udf
->
name
);
taosRenameFile
(
udf
->
path
,
newPath
);
sprintf
(
udf
->
path
,
"%s"
,
newPath
);
}
else
if
(
udf
->
scriptType
==
TSDB_FUNC_SCRIPT_PYTHON
)
{
}
else
if
(
udf
->
scriptType
==
TSDB_FUNC_SCRIPT_PYTHON
)
{
snprintf
(
newPath
,
PATH_MAX
,
"%s/%s.py"
,
tsTempDir
,
udf
->
name
);
snprintf
(
newPath
,
PATH_MAX
,
"%s/%s.py"
,
tsTempDir
,
udf
->
name
);
taosRenameFile
(
udf
->
path
,
newPath
);
sprintf
(
udf
->
path
,
"%s"
,
newPath
);
}
else
{
}
else
{
return
TSDB_CODE_UDF_SCRIPT_NOT_SUPPORTED
;
return
TSDB_CODE_UDF_SCRIPT_NOT_SUPPORTED
;
}
}
int32_t
code
=
taosRenameFile
(
udf
->
path
,
newPath
);
if
(
code
==
0
)
{
sprintf
(
udf
->
path
,
"%s"
,
newPath
);
}
return
0
;
return
0
;
}
}
...
@@ -1358,7 +1358,7 @@ int32_t udfdDeinitResidentFuncs() {
...
@@ -1358,7 +1358,7 @@ int32_t udfdDeinitResidentFuncs() {
char
*
funcName
=
taosArrayGet
(
global
.
residentFuncs
,
i
);
char
*
funcName
=
taosArrayGet
(
global
.
residentFuncs
,
i
);
SUdf
**
udfInHash
=
taosHashGet
(
global
.
udfsHash
,
funcName
,
strlen
(
funcName
));
SUdf
**
udfInHash
=
taosHashGet
(
global
.
udfsHash
,
funcName
,
strlen
(
funcName
));
if
(
udfInHash
)
{
if
(
udfInHash
)
{
SUdf
*
udf
=
*
udfInHash
;
SUdf
*
udf
=
*
udfInHash
;
int32_t
code
=
udf
->
scriptPlugin
->
udfDestroyFunc
(
udf
->
scriptUdfCtx
);
int32_t
code
=
udf
->
scriptPlugin
->
udfDestroyFunc
(
udf
->
scriptUdfCtx
);
fnDebug
(
"udfd destroy function returns %d"
,
code
);
fnDebug
(
"udfd destroy function returns %d"
,
code
);
taosHashRemove
(
global
.
udfsHash
,
funcName
,
strlen
(
funcName
));
taosHashRemove
(
global
.
udfsHash
,
funcName
,
strlen
(
funcName
));
...
...
tests/script/sh/bit_and.c
浏览文件 @
ba82f05d
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "taosudf.h"
#include "taosudf.h"
DLL_EXPORT
int32_t
bit_and_init
()
{
return
0
;
}
DLL_EXPORT
int32_t
bit_and_init
()
{
DLL_EXPORT
int32_t
bit_and_destroy
()
{
return
0
;
}
return
0
;
}
DLL_EXPORT
int32_t
bit_and_destroy
()
{
return
0
;
}
DLL_EXPORT
int32_t
bit_and
(
SUdfDataBlock
*
block
,
SUdfColumn
*
resultCol
)
{
if
(
block
->
numOfCols
<
2
)
{
DLL_EXPORT
int32_t
bit_and
(
SUdfDataBlock
*
block
,
SUdfColumn
*
resultCol
)
{
return
TSDB_CODE_UDF_INVALID_INPUT
;
if
(
block
->
numOfCols
<
2
)
{
}
return
TSDB_CODE_UDF_INVALID_INPUT
;
}
for
(
int32_t
i
=
0
;
i
<
block
->
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
block
->
numOfCols
;
++
i
)
{
SUdfColumn
*
col
=
block
->
udfCols
[
i
];
SUdfColumn
*
col
=
block
->
udfCols
[
i
];
if
(
!
(
col
->
colMeta
.
type
==
TSDB_DATA_TYPE_INT
))
{
if
(
!
(
col
->
colMeta
.
type
==
TSDB_DATA_TYPE_INT
))
{
return
TSDB_CODE_UDF_INVALID_INPUT
;
return
TSDB_CODE_UDF_INVALID_INPUT
;
}
}
}
}
SUdfColumnMeta
*
meta
=
&
resultCol
->
colMeta
;
SUdfColumnData
*
resultData
=
&
resultCol
->
colData
;
meta
->
bytes
=
4
;
meta
->
type
=
TSDB_DATA_TYPE_INT
;
meta
->
scale
=
0
;
meta
->
precision
=
0
;
SUdfColumnData
*
resultData
=
&
resultCol
->
colData
;
resultData
->
numOfRows
=
block
->
numOfRows
;
for
(
int32_t
i
=
0
;
i
<
resultData
->
numOfRows
;
++
i
)
{
if
(
udfColDataIsNull
(
block
->
udfCols
[
0
],
i
))
{
udfColDataSetNull
(
resultCol
,
i
);
continue
;
}
int32_t
result
=
*
(
int32_t
*
)
udfColDataGetData
(
block
->
udfCols
[
0
],
i
);
int
j
=
1
;
for
(;
j
<
block
->
numOfCols
;
++
j
)
{
if
(
udfColDataIsNull
(
block
->
udfCols
[
j
],
i
))
{
udfColDataSetNull
(
resultCol
,
i
);
break
;
}
char
*
colData
=
udfColDataGetData
(
block
->
udfCols
[
j
],
i
);
result
&=
*
(
int32_t
*
)
colData
;
}
if
(
j
==
block
->
numOfCols
)
{
udfColDataSet
(
resultCol
,
i
,
(
char
*
)
&
result
,
false
);
}
for
(
int32_t
i
=
0
;
i
<
block
->
numOfRows
;
++
i
)
{
if
(
udfColDataIsNull
(
block
->
udfCols
[
0
],
i
))
{
udfColDataSetNull
(
resultCol
,
i
);
continue
;
}
}
return
TSDB_CODE_SUCCESS
;
int32_t
result
=
*
(
int32_t
*
)
udfColDataGetData
(
block
->
udfCols
[
0
],
i
);
int
j
=
1
;
for
(;
j
<
block
->
numOfCols
;
++
j
)
{
if
(
udfColDataIsNull
(
block
->
udfCols
[
j
],
i
))
{
udfColDataSetNull
(
resultCol
,
i
);
break
;
}
char
*
colData
=
udfColDataGetData
(
block
->
udfCols
[
j
],
i
);
result
&=
*
(
int32_t
*
)
colData
;
}
if
(
j
==
block
->
numOfCols
)
{
udfColDataSet
(
resultCol
,
i
,
(
char
*
)
&
result
,
false
);
}
}
resultData
->
numOfRows
=
block
->
numOfRows
;
return
TSDB_CODE_SUCCESS
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录