Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Mz丶苗
TDengine
提交
4f6d3b56
T
TDengine
项目概览
Mz丶苗
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4f6d3b56
编写于
4月 23, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] fix memory leaks.
上级
d18ff90c
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
72 addition
and
78 deletion
+72
-78
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+0
-1
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+6
-0
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+10
-10
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+38
-22
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+0
-3
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+16
-39
src/query/src/qSqlParser.c
src/query/src/qSqlParser.c
+1
-1
tests/tsim/src/simSystem.c
tests/tsim/src/simSystem.c
+1
-2
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
4f6d3b56
...
...
@@ -119,7 +119,6 @@ typedef struct SInternalField {
TAOS_FIELD
field
;
bool
visible
;
SExprInfo
*
pExpr
;
// SExprFilter *pFieldFilters;
}
SInternalField
;
typedef
struct
SFieldInfo
{
...
...
src/client/src/tscParseInsert.c
浏览文件 @
4f6d3b56
...
...
@@ -829,6 +829,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
index
=
0
;
sToken
=
tStrGetToken
(
sql
,
&
index
,
false
);
if
(
sToken
.
type
!=
TK_TAGS
&&
sToken
.
type
!=
TK_LP
)
{
tscDestroyBoundColumnInfo
(
&
spd
);
return
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"keyword TAGS expected"
,
sToken
.
z
);
}
...
...
@@ -841,6 +842,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
char
*
end
=
NULL
;
code
=
parseBoundColumns
(
pCmd
,
&
spd
,
pTagSchema
,
sql
,
&
end
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscDestroyBoundColumnInfo
(
&
spd
);
return
code
;
}
...
...
@@ -858,11 +860,13 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
sql
+=
index
;
if
(
sToken
.
type
!=
TK_LP
)
{
tscDestroyBoundColumnInfo
(
&
spd
);
return
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"( is expected"
,
sToken
.
z
);
}
SKVRowBuilder
kvRowBuilder
=
{
0
};
if
(
tdInitKVRowBuilder
(
&
kvRowBuilder
)
<
0
)
{
tscDestroyBoundColumnInfo
(
&
spd
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
...
...
@@ -875,6 +879,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
if
(
TK_ILLEGAL
==
sToken
.
type
)
{
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
tscDestroyBoundColumnInfo
(
&
spd
);
return
TSDB_CODE_TSC_INVALID_SQL
;
}
...
...
@@ -892,6 +897,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
code
=
tsParseOneColumn
(
pSchema
,
&
sToken
,
tagVal
,
pCmd
->
payload
,
&
sql
,
false
,
tinfo
.
precision
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
tscDestroyBoundColumnInfo
(
&
spd
);
return
code
;
}
...
...
src/client/src/tscSQLParser.c
浏览文件 @
4f6d3b56
...
...
@@ -1504,24 +1504,24 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32
SInternalField
*
pInfo
=
tscFieldInfoGetInternalField
(
&
pQueryInfo
->
fieldsInfo
,
slot
);
if
(
pInfo
->
pExpr
==
NULL
)
{
SExprInfo
*
p
Arith
ExprInfo
=
calloc
(
1
,
sizeof
(
SExprInfo
));
SExprInfo
*
pExprInfo
=
calloc
(
1
,
sizeof
(
SExprInfo
));
// arithmetic expression always return result in the format of double float
p
ArithExprInfo
->
base
.
resBytes
=
sizeof
(
double
);
p
ArithExprInfo
->
base
.
interBytes
=
sizeof
(
double
);
p
ArithExprInfo
->
base
.
resType
=
TSDB_DATA_TYPE_DOUBLE
;
p
ExprInfo
->
base
.
resBytes
=
sizeof
(
double
);
p
ExprInfo
->
base
.
interBytes
=
sizeof
(
double
);
p
ExprInfo
->
base
.
resType
=
TSDB_DATA_TYPE_DOUBLE
;
p
Arith
ExprInfo
->
base
.
functionId
=
TSDB_FUNC_ARITHM
;
p
Arith
ExprInfo
->
base
.
numOfParams
=
1
;
p
Arith
ExprInfo
->
base
.
resColId
=
getNewResColId
(
pQueryInfo
);
pExprInfo
->
base
.
functionId
=
TSDB_FUNC_ARITHM
;
pExprInfo
->
base
.
numOfParams
=
1
;
pExprInfo
->
base
.
resColId
=
getNewResColId
(
pQueryInfo
);
int32_t
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
p
ArithExprInfo
->
pExpr
,
pItem
->
pNode
,
pQueryInfo
,
NULL
,
&
(
pArith
ExprInfo
->
base
.
uid
));
int32_t
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
p
ExprInfo
->
pExpr
,
pItem
->
pNode
,
pQueryInfo
,
NULL
,
&
(
p
ExprInfo
->
base
.
uid
));
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
tExprTreeDestroy
(
p
Arith
ExprInfo
->
pExpr
,
NULL
);
tExprTreeDestroy
(
pExprInfo
->
pExpr
,
NULL
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"invalid expression in select clause"
);
}
pInfo
->
pExpr
=
p
Arith
ExprInfo
;
pInfo
->
pExpr
=
pExprInfo
;
}
SBufferWriter
bw
=
tbufInitWriter
(
NULL
,
false
);
...
...
src/client/src/tscUtil.c
浏览文件 @
4f6d3b56
...
...
@@ -1484,11 +1484,43 @@ static void destroyFilterInfo(SColumnFilterList* pFilterList) {
pFilterList
->
numOfFilters
=
0
;
}
void
*
sqlExprDestroy
(
SExprInfo
*
pExpr
)
{
if
(
pExpr
==
NULL
)
{
return
NULL
;
}
SSqlExpr
*
p
=
&
pExpr
->
base
;
for
(
int32_t
i
=
0
;
i
<
tListLen
(
p
->
param
);
++
i
)
{
tVariantDestroy
(
&
p
->
param
[
i
]);
}
if
(
p
->
flist
.
numOfFilters
>
0
)
{
tfree
(
p
->
flist
.
filterInfo
);
}
if
(
pExpr
->
pExpr
!=
NULL
)
{
tExprTreeDestroy
(
pExpr
->
pExpr
,
NULL
);
}
tfree
(
pExpr
);
return
NULL
;
}
void
tscFieldInfoClear
(
SFieldInfo
*
pFieldInfo
)
{
if
(
pFieldInfo
==
NULL
)
{
return
;
}
if
(
pFieldInfo
->
internalField
!=
NULL
)
{
size_t
num
=
taosArrayGetSize
(
pFieldInfo
->
internalField
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SInternalField
*
pfield
=
taosArrayGet
(
pFieldInfo
->
internalField
,
i
);
if
(
pfield
->
pExpr
!=
NULL
&&
pfield
->
pExpr
->
pExpr
!=
NULL
)
{
sqlExprDestroy
(
pfield
->
pExpr
);
}
}
}
taosArrayDestroy
(
pFieldInfo
->
internalField
);
tfree
(
pFieldInfo
->
final
);
...
...
@@ -1629,25 +1661,6 @@ SExprInfo* tscSqlExprGet(SQueryInfo* pQueryInfo, int32_t index) {
return
taosArrayGetP
(
pQueryInfo
->
exprList
,
index
);
}
void
*
sqlExprDestroy
(
SExprInfo
*
pExpr
)
{
if
(
pExpr
==
NULL
)
{
return
NULL
;
}
SSqlExpr
*
p
=
&
pExpr
->
base
;
for
(
int32_t
i
=
0
;
i
<
tListLen
(
p
->
param
);
++
i
)
{
tVariantDestroy
(
&
p
->
param
[
i
]);
}
if
(
pExpr
->
pExpr
!=
NULL
)
{
tExprTreeDestroy
(
pExpr
->
pExpr
,
NULL
);
}
tfree
(
pExpr
);
return
NULL
;
}
/*
* NOTE: Does not release SExprInfo here.
*/
...
...
@@ -1715,8 +1728,11 @@ void tscSqlExprAssign(SExprInfo* dst, const SExprInfo* src) {
assert
(
dst
!=
NULL
&&
src
!=
NULL
);
*
dst
=
*
src
;
dst
->
base
.
flist
.
filterInfo
=
calloc
(
src
->
base
.
flist
.
numOfFilters
,
sizeof
(
SColumnFilterInfo
));
memcpy
(
dst
->
base
.
flist
.
filterInfo
,
src
->
base
.
flist
.
filterInfo
,
sizeof
(
SColumnFilterInfo
)
*
src
->
base
.
flist
.
numOfFilters
);
if
(
src
->
base
.
flist
.
numOfFilters
>
0
)
{
dst
->
base
.
flist
.
filterInfo
=
calloc
(
src
->
base
.
flist
.
numOfFilters
,
sizeof
(
SColumnFilterInfo
));
memcpy
(
dst
->
base
.
flist
.
filterInfo
,
src
->
base
.
flist
.
filterInfo
,
sizeof
(
SColumnFilterInfo
)
*
src
->
base
.
flist
.
numOfFilters
);
}
dst
->
pExpr
=
exprdup
(
src
->
pExpr
);
...
...
src/query/inc/qExecutor.h
浏览文件 @
4f6d3b56
...
...
@@ -430,13 +430,10 @@ typedef struct SSLimitOperatorInfo {
int64_t
rowsTotal
;
int64_t
currentOffset
;
SLimitVal
limit
;
SLimitVal
slimit
;
struct
SLocalMerger
*
pMerger
;
char
**
prevRow
;
bool
hasPrev
;
SArray
*
orderColumnList
;
}
SSLimitOperatorInfo
;
...
...
src/query/src/qExecutor.c
浏览文件 @
4f6d3b56
...
...
@@ -1879,7 +1879,6 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
pRuntimeEnv
->
pool
=
destroyResultRowPool
(
pRuntimeEnv
->
pool
);
taosArrayDestroyEx
(
pRuntimeEnv
->
prevResult
,
freeInterResult
);
pRuntimeEnv
->
prevResult
=
NULL
;
}
static
bool
needBuildResAfterQueryComplete
(
SQInfo
*
pQInfo
)
{
...
...
@@ -4516,6 +4515,12 @@ static void destroyGlobalAggOperatorInfo(void* param, int32_t numOfOutput) {
tfree
(
pInfo
->
currentGroupColData
);
}
static
void
destroySlimitOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
SSLimitOperatorInfo
*
pInfo
=
(
SSLimitOperatorInfo
*
)
param
;
taosArrayDestroy
(
pInfo
->
orderColumnList
);
tfree
(
pInfo
->
prevRow
);
}
SOperatorInfo
*
createGlobalAggregateOperatorInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
void
*
param
)
{
SMultiwayMergeInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SMultiwayMergeInfo
));
...
...
@@ -5598,9 +5603,8 @@ SOperatorInfo* createSLimitOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperator
SQueryAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
pInfo
->
orderColumnList
=
getResultGroupCheckColumns
(
pQueryAttr
);
pInfo
->
pMerger
=
pMerger
;
pInfo
->
slimit
=
pQueryAttr
->
slimit
;
pInfo
->
limit
=
pQueryAttr
->
limit
;
pInfo
->
slimit
=
pQueryAttr
->
slimit
;
pInfo
->
limit
=
pQueryAttr
->
limit
;
pInfo
->
currentGroupOffset
=
pQueryAttr
->
slimit
.
offset
;
pInfo
->
currentOffset
=
pQueryAttr
->
limit
.
offset
;
...
...
@@ -5632,7 +5636,7 @@ SOperatorInfo* createSLimitOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperator
pOperator
->
exec
=
doSLimit
;
pOperator
->
info
=
pInfo
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
cleanup
=
destroySlimitOperatorInfo
;
return
pOperator
;
}
...
...
@@ -6974,6 +6978,10 @@ static void* destroyQueryFuncExpr(SExprInfo* pExprInfo, int32_t numOfExpr) {
if
(
pExprInfo
[
i
].
base
.
flist
.
filterInfo
)
{
freeColumnFilterInfo
(
pExprInfo
[
i
].
base
.
flist
.
filterInfo
,
pExprInfo
[
i
].
base
.
flist
.
numOfFilters
);
}
for
(
int32_t
j
=
0
;
j
<
pExprInfo
[
i
].
base
.
numOfParams
;
++
j
)
{
tVariantDestroy
(
&
pExprInfo
[
i
].
base
.
param
[
j
]);
}
}
tfree
(
pExprInfo
);
...
...
@@ -6991,40 +6999,13 @@ void freeQInfo(SQInfo *pQInfo) {
releaseQueryBuf
(
pRuntimeEnv
->
tableqinfoGroupInfo
.
numOfTables
);
doDestroyTableQueryInfo
(
&
pRuntimeEnv
->
tableqinfoGroupInfo
);
teardownQueryRuntimeEnv
(
&
pQInfo
->
runtimeEnv
);
SQueryAttr
*
pQueryAttr
=
pQInfo
->
runtimeEnv
.
pQueryAttr
;
if
(
pQueryAttr
!=
NULL
)
{
if
(
pQueryAttr
->
fillVal
!=
NULL
)
{
tfree
(
pQueryAttr
->
fillVal
);
}
pQueryAttr
->
pFilterInfo
=
doDestroyFilterInfo
(
pQueryAttr
->
pFilterInfo
,
pQueryAttr
->
numOfFilterCols
);
pQueryAttr
->
pExpr1
=
destroyQueryFuncExpr
(
pQueryAttr
->
pExpr1
,
pQueryAttr
->
numOfOutput
);
pQueryAttr
->
pExpr2
=
destroyQueryFuncExpr
(
pQueryAttr
->
pExpr2
,
pQueryAttr
->
numOfExpr2
);
pQueryAttr
->
pExpr3
=
destroyQueryFuncExpr
(
pQueryAttr
->
pExpr3
,
pQueryAttr
->
numOfExpr3
);
tfree
(
pQueryAttr
->
tagColList
);
if
(
pQueryAttr
->
tableCols
!=
NULL
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryAttr
->
numOfCols
;
i
++
)
{
SColumnInfo
*
column
=
pQueryAttr
->
tableCols
+
i
;
freeColumnFilterInfo
(
column
->
flist
.
filterInfo
,
column
->
flist
.
numOfFilters
);
}
tfree
(
pQueryAttr
->
tableCols
);
}
if
(
pQueryAttr
->
pGroupbyExpr
!=
NULL
)
{
taosArrayDestroy
(
pQueryAttr
->
pGroupbyExpr
->
columnInfo
);
tfree
(
pQueryAttr
->
pGroupbyExpr
);
}
}
freeQueryAttr
(
pQueryAttr
);
tsdbDestroyTableGroup
(
&
pQueryAttr
->
tableGroupInfo
);
tfree
(
pQInfo
->
pBuf
);
tfree
(
pQInfo
->
sql
);
...
...
@@ -7182,15 +7163,11 @@ void freeQueryAttr(SQueryAttr* pQueryAttr) {
tfree
(
pQueryAttr
->
fillVal
);
}
for
(
int32_t
i
=
0
;
i
<
pQueryAttr
->
numOfFilterCols
;
++
i
)
{
SSingleColumnFilterInfo
*
pColFilter
=
&
pQueryAttr
->
pFilterInfo
[
i
];
if
(
pColFilter
->
numOfFilters
>
0
)
{
tfree
(
pColFilter
->
pFilters
);
}
}
pQueryAttr
->
pFilterInfo
=
doDestroyFilterInfo
(
pQueryAttr
->
pFilterInfo
,
pQueryAttr
->
numOfFilterCols
);
pQueryAttr
->
pExpr1
=
destroyQueryFuncExpr
(
pQueryAttr
->
pExpr1
,
pQueryAttr
->
numOfOutput
);
pQueryAttr
->
pExpr2
=
destroyQueryFuncExpr
(
pQueryAttr
->
pExpr2
,
pQueryAttr
->
numOfExpr2
);
pQueryAttr
->
pExpr3
=
destroyQueryFuncExpr
(
pQueryAttr
->
pExpr3
,
pQueryAttr
->
numOfExpr3
);
tfree
(
pQueryAttr
->
tagColList
);
tfree
(
pQueryAttr
->
pFilterInfo
);
...
...
src/query/src/qSqlParser.c
浏览文件 @
4f6d3b56
...
...
@@ -788,7 +788,6 @@ void destroySqlNode(SSqlNode *pSqlNode) {
}
tSqlExprListDestroy
(
pSqlNode
->
pSelNodeList
);
pSqlNode
->
pSelNodeList
=
NULL
;
tSqlExprDestroy
(
pSqlNode
->
pWhere
);
...
...
@@ -805,6 +804,7 @@ void destroySqlNode(SSqlNode *pSqlNode) {
taosArrayDestroyEx
(
pSqlNode
->
fillType
,
freeVariant
);
pSqlNode
->
fillType
=
NULL
;
tSqlExprDestroy
(
pSqlNode
->
pHaving
);
free
(
pSqlNode
);
}
...
...
tests/tsim/src/simSystem.c
浏览文件 @
4f6d3b56
...
...
@@ -164,10 +164,9 @@ void *simExecuteScript(void *inputScript) {
}
if
(
script
->
killed
||
script
->
linePos
>=
script
->
numOfLines
)
{
printf
(
"killed ---------------------->
\n
"
);
script
=
simProcessCallOver
(
script
);
if
(
script
==
NULL
)
{
printf
(
"abort now!
\n
"
);
simDebug
(
"sim test abort now!
"
);
break
;
}
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录