Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
78f58194
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看板
提交
78f58194
编写于
7月 19, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-5404]<fix>: fix memory leak in union query.
上级
b4154d8a
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
101 addition
and
35 deletion
+101
-35
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+27
-2
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+25
-32
src/util/CMakeLists.txt
src/util/CMakeLists.txt
+1
-1
src/util/inc/tarray.h
src/util/inc/tarray.h
+7
-0
src/util/src/tarray.c
src/util/src/tarray.c
+40
-0
tests/script/sh/prepare_udf.sh
tests/script/sh/prepare_udf.sh
+1
-0
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
78f58194
...
...
@@ -8005,6 +8005,28 @@ static void freeElem(void* p) {
tfree
(
*
(
char
**
)
p
);
}
int32_t
tnameComparFn
(
const
void
*
p1
,
const
void
*
p2
)
{
SName
*
pn1
=
(
SName
*
)
p1
;
SName
*
pn2
=
(
SName
*
)
p2
;
int32_t
ret
=
strncmp
(
pn1
->
acctId
,
pn2
->
acctId
,
tListLen
(
pn1
->
acctId
));
if
(
ret
!=
0
)
{
return
ret
>
0
?
1
:-
1
;
}
else
{
ret
=
strncmp
(
pn1
->
dbname
,
pn2
->
dbname
,
tListLen
(
pn1
->
dbname
));
if
(
ret
!=
0
)
{
return
ret
>
0
?
1
:-
1
;
}
else
{
ret
=
strncmp
(
pn1
->
tname
,
pn2
->
tname
,
tListLen
(
pn1
->
tname
));
if
(
ret
!=
0
)
{
return
ret
>
0
?
1
:-
1
;
}
else
{
return
0
;
}
}
}
}
int32_t
loadAllTableMeta
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
...
...
@@ -8055,6 +8077,9 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
plist
=
taosArrayInit
(
4
,
POINTER_BYTES
);
pVgroupList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
taosArraySort
(
tableNameList
,
tnameComparFn
);
taosArrayRemoveDuplicate
(
tableNameList
,
tnameComparFn
,
NULL
);
size_t
numOfTables
=
taosArrayGetSize
(
tableNameList
);
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
SName
*
pname
=
taosArrayGet
(
tableNameList
,
i
);
...
...
@@ -8075,8 +8100,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
continue
;
}
}
else
if
(
pTableMeta
->
tableType
==
TSDB_SUPER_TABLE
)
{
// the vgroup list of a super table is not kept in local buffer, so here need retrieve it
// from the mnode each time
// the vgroup list of super table is not kept in local buffer, so here need retrieve it from the mnode each time
char
*
t
=
strdup
(
name
);
taosArrayPush
(
pVgroupList
,
&
t
);
}
...
...
@@ -8103,6 +8127,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if
(
pInfo
->
funcs
)
{
funcSize
=
taosArrayGetSize
(
pInfo
->
funcs
);
}
if
(
funcSize
>
0
)
{
for
(
size_t
i
=
0
;
i
<
funcSize
;
++
i
)
{
SStrToken
*
t
=
taosArrayGet
(
pInfo
->
funcs
,
i
);
...
...
src/client/src/tscUtil.c
浏览文件 @
78f58194
...
...
@@ -1315,8 +1315,7 @@ void tscFreeQueryInfo(SSqlCmd* pCmd, bool removeMeta) {
return
;
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
pCmd
);
SQueryInfo
*
pQueryInfo
=
pCmd
->
pQueryInfo
;
while
(
pQueryInfo
!=
NULL
)
{
SQueryInfo
*
p
=
pQueryInfo
->
sibling
;
...
...
@@ -1596,7 +1595,7 @@ void freeUdfInfo(SUdfInfo* pUdfInfo) {
taosCloseDll
(
pUdfInfo
->
handle
);
}
// todo refactor
void
*
tscDestroyUdfArrayList
(
SArray
*
pUdfList
)
{
if
(
pUdfList
==
NULL
)
{
return
NULL
;
...
...
@@ -2986,6 +2985,7 @@ void tscInitQueryInfo(SQueryInfo* pQueryInfo) {
int32_t
tscAddQueryInfo
(
SSqlCmd
*
pCmd
)
{
assert
(
pCmd
!=
NULL
);
SQueryInfo
*
pQueryInfo
=
calloc
(
1
,
sizeof
(
SQueryInfo
));
if
(
pQueryInfo
==
NULL
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
...
...
@@ -3968,17 +3968,21 @@ void tscTryQueryNextClause(SSqlObj* pSql, __async_cb_func_t fp) {
//backup the total number of result first
int64_t
num
=
pRes
->
numOfTotal
+
pRes
->
numOfClauseTotal
;
// DON't free final since it may be recoreded and used later in APP
TAOS_FIELD
*
finalBk
=
pRes
->
final
;
pRes
->
final
=
NULL
;
tscFreeSqlResult
(
pSql
);
pRes
->
final
=
finalBk
;
pRes
->
final
=
finalBk
;
pRes
->
numOfTotal
=
num
;
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
taos_free_result
(
pSql
->
pSubs
[
i
]);
}
tfree
(
pSql
->
pSubs
);
pSql
->
subState
.
numOfSub
=
0
;
pSql
->
fp
=
fp
;
tscDebug
(
"0x%"
PRIx64
" try data in the next subclause"
,
pSql
->
self
);
...
...
@@ -4618,6 +4622,20 @@ int32_t nameComparFn(const void* n1, const void* n2) {
}
}
static
void
freeContent
(
void
*
p
)
{
char
*
ptr
=
*
(
char
**
)
p
;
tfree
(
ptr
);
}
static
int32_t
contCompare
(
const
void
*
p1
,
const
void
*
p2
)
{
int32_t
ret
=
strcmp
(
p1
,
p2
);
if
(
ret
==
0
)
{
return
0
;
}
else
{
return
ret
>
0
?
1
:-
1
;
}
}
int
tscTransferTableNameList
(
SSqlObj
*
pSql
,
const
char
*
pNameList
,
int32_t
length
,
SArray
*
pNameArray
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
...
...
@@ -4665,32 +4683,7 @@ int tscTransferTableNameList(SSqlObj *pSql, const char *pNameList, int32_t lengt
}
taosArraySort
(
pNameArray
,
nameComparFn
);
int32_t
pos
=
0
;
for
(
int32_t
i
=
1
;
i
<
len
;
++
i
)
{
char
**
p1
=
taosArrayGet
(
pNameArray
,
pos
);
char
**
p2
=
taosArrayGet
(
pNameArray
,
i
);
if
(
strcmp
(
*
p1
,
*
p2
)
==
0
)
{
// do nothing
}
else
{
if
(
pos
+
1
!=
i
)
{
char
*
p
=
taosArrayGetP
(
pNameArray
,
pos
+
1
);
tfree
(
p
);
taosArraySet
(
pNameArray
,
pos
+
1
,
p2
);
pos
+=
1
;
}
else
{
pos
+=
1
;
}
}
}
for
(
int32_t
i
=
pos
+
1
;
i
<
pNameArray
->
size
;
++
i
)
{
char
*
p
=
taosArrayGetP
(
pNameArray
,
i
);
tfree
(
p
);
}
pNameArray
->
size
=
pos
+
1
;
taosArrayRemoveDuplicate
(
pNameArray
,
contCompare
,
freeContent
);
return
TSDB_CODE_SUCCESS
;
}
...
...
src/util/CMakeLists.txt
浏览文件 @
78f58194
...
...
@@ -11,7 +11,7 @@ TARGET_LINK_LIBRARIES(tutil pthread os lz4 z rmonotonic)
IF
(
TD_LINUX
)
TARGET_LINK_LIBRARIES
(
tutil m rt
)
#
ADD_SUBDIRECTORY(tests)
ADD_SUBDIRECTORY
(
tests
)
FIND_PATH
(
ICONV_INCLUDE_EXIST iconv.h /usr/include/ /usr/local/include/
)
IF
(
ICONV_INCLUDE_EXIST
)
...
...
src/util/inc/tarray.h
浏览文件 @
78f58194
...
...
@@ -60,6 +60,13 @@ void *taosArrayAddBatch(SArray *pArray, const void *pData, int nEles);
*/
void
taosArrayRemoveBatch
(
SArray
*
pArray
,
const
int32_t
*
pData
,
int32_t
numOfElems
);
/**
*
* @param pArray
* @param comparFn
* @param fp
*/
void
taosArrayRemoveDuplicate
(
SArray
*
pArray
,
__compar_fn_t
comparFn
,
void
(
*
fp
)(
void
*
));
/**
* add all element from the source array list into the destination
...
...
src/util/src/tarray.c
浏览文件 @
78f58194
...
...
@@ -124,6 +124,46 @@ void taosArrayRemoveBatch(SArray *pArray, const int32_t* pData, int32_t numOfEle
pArray
->
size
-=
numOfElems
;
}
void
taosArrayRemoveDuplicate
(
SArray
*
pArray
,
__compar_fn_t
comparFn
,
void
(
*
fp
)(
void
*
))
{
assert
(
pArray
);
size_t
size
=
pArray
->
size
;
if
(
size
<=
1
)
{
return
;
}
int32_t
pos
=
0
;
for
(
int32_t
i
=
1
;
i
<
size
;
++
i
)
{
char
*
p1
=
taosArrayGet
(
pArray
,
pos
);
char
*
p2
=
taosArrayGet
(
pArray
,
i
);
if
(
comparFn
(
p1
,
p2
)
==
0
)
{
// do nothing
}
else
{
if
(
pos
+
1
!=
i
)
{
void
*
p
=
taosArrayGet
(
pArray
,
pos
+
1
);
if
(
fp
!=
NULL
)
{
fp
(
p
);
}
taosArraySet
(
pArray
,
pos
+
1
,
p2
);
pos
+=
1
;
}
else
{
pos
+=
1
;
}
}
}
if
(
fp
!=
NULL
)
{
for
(
int32_t
i
=
pos
+
1
;
i
<
pArray
->
size
;
++
i
)
{
void
*
p
=
taosArrayGet
(
pArray
,
i
);
fp
(
p
);
}
}
pArray
->
size
=
pos
+
1
;
}
void
*
taosArrayAddAll
(
SArray
*
pArray
,
const
SArray
*
pInput
)
{
return
taosArrayAddBatch
(
pArray
,
pInput
->
pData
,
(
int32_t
)
taosArrayGetSize
(
pInput
));
}
...
...
tests/script/sh/prepare_udf.sh
浏览文件 @
78f58194
...
...
@@ -5,6 +5,7 @@ echo -n "" > /tmp/empty
dd
if
=
/dev/zero
bs
=
3584
of
=
/tmp/big
count
=
1
rm
-rf
/tmp/sum_double.so /tmp/add_one.so
touch
/tmp/normal
gcc
-g
-O0
-fPIC
-shared
sh/sum_double.c
-o
/tmp/sum_double.so
gcc
-g
-O0
-fPIC
-shared
sh/add_one.c
-o
/tmp/add_one.so
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录