Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
512f7539
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看板
提交
512f7539
编写于
5月 16, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor:fix memory leak
上级
a1afea40
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
35 addition
and
33 deletion
+35
-33
source/client/src/clientSml.c
source/client/src/clientSml.c
+6
-6
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+8
-8
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+0
-6
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+21
-13
未找到文件。
source/client/src/clientSml.c
浏览文件 @
512f7539
...
@@ -1007,8 +1007,6 @@ static int32_t smlParseTelnetTags(const char* data, SArray *cols, SHashObj *dump
...
@@ -1007,8 +1007,6 @@ static int32_t smlParseTelnetTags(const char* data, SArray *cols, SHashObj *dump
while
(
*
sql
!=
'\0'
)
{
while
(
*
sql
!=
'\0'
)
{
// parse value
// parse value
if
(
*
sql
==
SPACE
)
{
if
(
*
sql
==
SPACE
)
{
valueLen
=
sql
-
value
;
sql
++
;
break
;
break
;
}
}
if
(
*
sql
==
EQUAL
)
{
if
(
*
sql
==
EQUAL
)
{
...
@@ -1017,9 +1015,7 @@ static int32_t smlParseTelnetTags(const char* data, SArray *cols, SHashObj *dump
...
@@ -1017,9 +1015,7 @@ static int32_t smlParseTelnetTags(const char* data, SArray *cols, SHashObj *dump
}
}
sql
++
;
sql
++
;
}
}
if
(
valueLen
==
0
){
valueLen
=
sql
-
value
;
valueLen
=
sql
-
value
;
}
if
(
valueLen
==
0
){
if
(
valueLen
==
0
){
smlBuildInvalidDataMsg
(
msg
,
"invalid value"
,
value
);
smlBuildInvalidDataMsg
(
msg
,
"invalid value"
,
value
);
...
@@ -1365,7 +1361,7 @@ static void smlDestroySTableMeta(SSmlSTableMeta *meta){
...
@@ -1365,7 +1361,7 @@ static void smlDestroySTableMeta(SSmlSTableMeta *meta){
static
void
smlDestroyCols
(
SArray
*
cols
)
{
static
void
smlDestroyCols
(
SArray
*
cols
)
{
if
(
!
cols
)
return
;
if
(
!
cols
)
return
;
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
cols
);
++
i
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
cols
);
++
i
)
{
void
*
kv
=
taosArrayGet
(
cols
,
i
);
void
*
kv
=
taosArrayGet
P
(
cols
,
i
);
taosMemoryFree
(
kv
);
taosMemoryFree
(
kv
);
}
}
}
}
...
@@ -2077,12 +2073,16 @@ static int32_t smlParseTelnetLine(SSmlHandle* info, void *data) {
...
@@ -2077,12 +2073,16 @@ static int32_t smlParseTelnetLine(SSmlHandle* info, void *data) {
if
(
ret
!=
TSDB_CODE_SUCCESS
){
if
(
ret
!=
TSDB_CODE_SUCCESS
){
uError
(
"SML:0x%"
PRIx64
" smlParseTelnetLine failed"
,
info
->
id
);
uError
(
"SML:0x%"
PRIx64
" smlParseTelnetLine failed"
,
info
->
id
);
smlDestroyTableInfo
(
info
,
tinfo
);
smlDestroyTableInfo
(
info
,
tinfo
);
smlDestroyCols
(
cols
);
taosArrayDestroy
(
cols
);
taosArrayDestroy
(
cols
);
return
ret
;
return
ret
;
}
}
if
(
taosArrayGetSize
(
tinfo
->
tags
)
<=
0
||
taosArrayGetSize
(
tinfo
->
tags
)
>
TSDB_MAX_TAGS
){
if
(
taosArrayGetSize
(
tinfo
->
tags
)
<=
0
||
taosArrayGetSize
(
tinfo
->
tags
)
>
TSDB_MAX_TAGS
){
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"invalidate tags length:[1,128]"
,
NULL
);
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"invalidate tags length:[1,128]"
,
NULL
);
smlDestroyTableInfo
(
info
,
tinfo
);
smlDestroyCols
(
cols
);
taosArrayDestroy
(
cols
);
return
TSDB_CODE_SML_INVALID_DATA
;
return
TSDB_CODE_SML_INVALID_DATA
;
}
}
taosHashClear
(
info
->
dumplicateKey
);
taosHashClear
(
info
->
dumplicateKey
);
...
...
source/client/test/smlTest.cpp
浏览文件 @
512f7539
...
@@ -516,8 +516,8 @@ TEST(testCase, smlProcess_influx_Test) {
...
@@ -516,8 +516,8 @@ TEST(testCase, smlProcess_influx_Test) {
int
ret
=
smlProcess
(
info
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]));
int
ret
=
smlProcess
(
info
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]));
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
ret
,
0
);
TAOS_RES
*
res
=
taos_query
(
taos
,
"select * from t_6885c584b98481584ee13dac399e173d"
);
//
TAOS_RES *res = taos_query(taos, "select * from t_6885c584b98481584ee13dac399e173d");
ASSERT_NE
(
res
,
nullptr
);
//
ASSERT_NE(res, nullptr);
// int fieldNum = taos_field_count(res);
// int fieldNum = taos_field_count(res);
// ASSERT_EQ(fieldNum, 5);
// ASSERT_EQ(fieldNum, 5);
// int rowNum = taos_affected_rows(res);
// int rowNum = taos_affected_rows(res);
...
@@ -525,7 +525,7 @@ TEST(testCase, smlProcess_influx_Test) {
...
@@ -525,7 +525,7 @@ TEST(testCase, smlProcess_influx_Test) {
// for (int i = 0; i < rowNum; ++i) {
// for (int i = 0; i < rowNum; ++i) {
// TAOS_ROW rows = taos_fetch_row(res);
// TAOS_ROW rows = taos_fetch_row(res);
// }
// }
taos_free_result
(
res
);
//
taos_free_result(res);
destroyRequest
(
request
);
destroyRequest
(
request
);
smlDestroyInfo
(
info
);
smlDestroyInfo
(
info
);
}
}
...
@@ -670,16 +670,16 @@ TEST(testCase, smlProcess_json1_Test) {
...
@@ -670,16 +670,16 @@ TEST(testCase, smlProcess_json1_Test) {
int
ret
=
smlProcess
(
info
,
(
char
**
)(
&
sql
),
-
1
);
int
ret
=
smlProcess
(
info
,
(
char
**
)(
&
sql
),
-
1
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
ret
,
0
);
TAOS_RES
*
res
=
taos_query
(
taos
,
"select * from t_cb27a7198d637b4f1c6464bd73f756a7"
);
//
TAOS_RES *res = taos_query(taos, "select * from t_cb27a7198d637b4f1c6464bd73f756a7");
ASSERT_NE
(
res
,
nullptr
);
//
ASSERT_NE(res, nullptr);
int
fieldNum
=
taos_field_count
(
res
);
//
int fieldNum = taos_field_count(res);
ASSERT_EQ
(
fieldNum
,
2
);
//
ASSERT_EQ(fieldNum, 2);
// int rowNum = taos_affected_rows(res);
// int rowNum = taos_affected_rows(res);
// ASSERT_EQ(rowNum, 1);
// ASSERT_EQ(rowNum, 1);
// for (int i = 0; i < rowNum; ++i) {
// for (int i = 0; i < rowNum; ++i) {
// TAOS_ROW rows = taos_fetch_row(res);
// TAOS_ROW rows = taos_fetch_row(res);
// }
// }
taos_free_result
(
res
);
//
taos_free_result(res);
destroyRequest
(
request
);
destroyRequest
(
request
);
smlDestroyInfo
(
info
);
smlDestroyInfo
(
info
);
}
}
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
512f7539
...
@@ -2576,12 +2576,6 @@ int32_t catalogGetHandle(uint64_t clusterId, SCatalog** catalogHandle) {
...
@@ -2576,12 +2576,6 @@ int32_t catalogGetHandle(uint64_t clusterId, SCatalog** catalogHandle) {
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
SHashObj
*
metaCache
=
taosHashInit
(
gCtgMgmt
.
cfg
.
maxTblCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
metaCache
)
{
qError
(
"taosHashInit failed, num:%d"
,
gCtgMgmt
.
cfg
.
maxTblCacheNum
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
code
=
taosHashPut
(
gCtgMgmt
.
pCluster
,
&
clusterId
,
sizeof
(
clusterId
),
&
clusterCtg
,
POINTER_BYTES
);
code
=
taosHashPut
(
gCtgMgmt
.
pCluster
,
&
clusterId
,
sizeof
(
clusterId
),
&
clusterCtg
,
POINTER_BYTES
);
if
(
code
)
{
if
(
code
)
{
if
(
HASH_NODE_EXIST
(
code
))
{
if
(
HASH_NODE_EXIST
(
code
))
{
...
...
source/libs/parser/src/parInsert.c
浏览文件 @
512f7539
...
@@ -1289,7 +1289,7 @@ int32_t qBuildStmtOutput(SQuery* pQuery, SHashObj* pVgHash, SHashObj* pBlockHash
...
@@ -1289,7 +1289,7 @@ int32_t qBuildStmtOutput(SQuery* pQuery, SHashObj* pVgHash, SHashObj* pBlockHash
CHECK_CODE
(
buildOutput
(
&
insertCtx
));
CHECK_CODE
(
buildOutput
(
&
insertCtx
));
destroy
InsertParseContext
(
&
insertCtx
);
destroy
BlockArrayList
(
insertCtx
.
pVgDataBlocks
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1569,16 +1569,25 @@ int32_t qBuildStmtColFields(void* pBlock, int32_t* fieldNum, TAOS_FIELD** fields
...
@@ -1569,16 +1569,25 @@ int32_t qBuildStmtColFields(void* pBlock, int32_t* fieldNum, TAOS_FIELD** fields
// schemaless logic start
// schemaless logic start
typedef
struct
SmlExecHandle
{
typedef
struct
SmlExecTableHandle
{
SHashObj
*
pBlockHash
;
SParsedDataColInfo
tags
;
// each table
SParsedDataColInfo
tags
;
// each table
SKVRowBuilder
tagsBuilder
;
// each table
SKVRowBuilder
tagsBuilder
;
// each table
SVCreateTbReq
createTblReq
;
// each table
SVCreateTbReq
createTblReq
;
// each table
}
SmlExecTableHandle
;
SQuery
*
pQuery
;
typedef
struct
SmlExecHandle
{
SHashObj
*
pBlockHash
;
SmlExecTableHandle
tableExecHandle
;
SQuery
*
pQuery
;
}
SSmlExecHandle
;
}
SSmlExecHandle
;
static
void
smlDestroyTableHandle
(
void
*
pHandle
)
{
SmlExecTableHandle
*
handle
=
(
SmlExecTableHandle
*
)
pHandle
;
tdDestroyKVRowBuilder
(
&
handle
->
tagsBuilder
);
destroyBoundColumnInfo
(
&
handle
->
tags
);
destroyCreateSubTbReq
(
&
handle
->
createTblReq
);
}
static
int32_t
smlBoundColumnData
(
SArray
*
cols
,
SParsedDataColInfo
*
pColList
,
SSchema
*
pSchema
)
{
static
int32_t
smlBoundColumnData
(
SArray
*
cols
,
SParsedDataColInfo
*
pColList
,
SSchema
*
pSchema
)
{
col_id_t
nCols
=
pColList
->
numOfCols
;
col_id_t
nCols
=
pColList
->
numOfCols
;
...
@@ -1681,25 +1690,26 @@ int32_t smlBindData(void *handle, SArray *tags, SArray *colsSchema, SArray *cols
...
@@ -1681,25 +1690,26 @@ int32_t smlBindData(void *handle, SArray *tags, SArray *colsSchema, SArray *cols
SMsgBuf
pBuf
=
{.
buf
=
msgBuf
,
.
len
=
msgBufLen
};
SMsgBuf
pBuf
=
{.
buf
=
msgBuf
,
.
len
=
msgBufLen
};
SSmlExecHandle
*
smlHandle
=
(
SSmlExecHandle
*
)
handle
;
SSmlExecHandle
*
smlHandle
=
(
SSmlExecHandle
*
)
handle
;
smlDestroyTableHandle
(
&
smlHandle
->
tableExecHandle
);
// free for each table
SSchema
*
pTagsSchema
=
getTableTagSchema
(
pTableMeta
);
SSchema
*
pTagsSchema
=
getTableTagSchema
(
pTableMeta
);
setBoundColumnInfo
(
&
smlHandle
->
tags
,
pTagsSchema
,
getNumOfTags
(
pTableMeta
));
setBoundColumnInfo
(
&
smlHandle
->
ta
bleExecHandle
.
ta
gs
,
pTagsSchema
,
getNumOfTags
(
pTableMeta
));
int
ret
=
smlBoundColumnData
(
tags
,
&
smlHandle
->
tags
,
pTagsSchema
);
int
ret
=
smlBoundColumnData
(
tags
,
&
smlHandle
->
ta
bleExecHandle
.
ta
gs
,
pTagsSchema
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
buildInvalidOperationMsg
(
&
pBuf
,
"bound tags error"
);
buildInvalidOperationMsg
(
&
pBuf
,
"bound tags error"
);
return
ret
;
return
ret
;
}
}
SKVRow
row
=
NULL
;
SKVRow
row
=
NULL
;
ret
=
smlBuildTagRow
(
tags
,
&
smlHandle
->
ta
gsBuilder
,
&
smlHandle
->
tags
,
pTagsSchema
,
&
row
,
&
pBuf
);
ret
=
smlBuildTagRow
(
tags
,
&
smlHandle
->
ta
bleExecHandle
.
tagsBuilder
,
&
smlHandle
->
tableExecHandle
.
tags
,
pTagsSchema
,
&
row
,
&
pBuf
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
return
ret
;
}
}
buildCreateTbReq
(
&
smlHandle
->
createTblReq
,
tableName
,
row
,
pTableMeta
->
suid
);
buildCreateTbReq
(
&
smlHandle
->
tableExecHandle
.
createTblReq
,
tableName
,
row
,
pTableMeta
->
suid
);
STableDataBlocks
*
pDataBlock
=
NULL
;
STableDataBlocks
*
pDataBlock
=
NULL
;
ret
=
getDataBlockFromList
(
smlHandle
->
pBlockHash
,
&
pTableMeta
->
uid
,
sizeof
(
pTableMeta
->
uid
),
ret
=
getDataBlockFromList
(
smlHandle
->
pBlockHash
,
&
pTableMeta
->
uid
,
sizeof
(
pTableMeta
->
uid
),
TSDB_DEFAULT_PAYLOAD_SIZE
,
sizeof
(
SSubmitBlk
),
getTableInfo
(
pTableMeta
).
rowSize
,
TSDB_DEFAULT_PAYLOAD_SIZE
,
sizeof
(
SSubmitBlk
),
getTableInfo
(
pTableMeta
).
rowSize
,
pTableMeta
,
&
pDataBlock
,
NULL
,
&
smlHandle
->
createTblReq
);
pTableMeta
,
&
pDataBlock
,
NULL
,
&
smlHandle
->
tableExecHandle
.
createTblReq
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
buildInvalidOperationMsg
(
&
pBuf
,
"create data block error"
);
buildInvalidOperationMsg
(
&
pBuf
,
"create data block error"
);
return
ret
;
return
ret
;
...
@@ -1815,9 +1825,7 @@ void smlDestroyHandle(void* pHandle) {
...
@@ -1815,9 +1825,7 @@ void smlDestroyHandle(void* pHandle) {
if
(
!
pHandle
)
return
;
if
(
!
pHandle
)
return
;
SSmlExecHandle
*
handle
=
(
SSmlExecHandle
*
)
pHandle
;
SSmlExecHandle
*
handle
=
(
SSmlExecHandle
*
)
pHandle
;
destroyBlockHashmap
(
handle
->
pBlockHash
);
destroyBlockHashmap
(
handle
->
pBlockHash
);
tdDestroyKVRowBuilder
(
&
handle
->
tagsBuilder
);
smlDestroyTableHandle
(
&
handle
->
tableExecHandle
);
destroyBoundColumnInfo
(
&
handle
->
tags
);
destroyCreateSubTbReq
(
&
handle
->
createTblReq
);
taosMemoryFree
(
handle
);
taosMemoryFree
(
handle
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录