Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
289e1082
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看板
提交
289e1082
编写于
7月 16, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-5250]<enhance>: fix memory leak and remove duplicated name in name array list.
上级
0b05f0b0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
56 addition
and
10 deletion
+56
-10
src/client/src/tscServer.c
src/client/src/tscServer.c
+7
-1
src/client/src/tscSql.c
src/client/src/tscSql.c
+12
-9
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+37
-0
未找到文件。
src/client/src/tscServer.c
浏览文件 @
289e1082
...
...
@@ -2073,6 +2073,7 @@ int tscProcessMultiTableMetaRsp(SSqlObj *pSql) {
return
code
;
}
bool
freeMeta
=
false
;
STableMeta
*
pTableMeta
=
tscCreateTableMetaFromMsg
(
pMetaMsg
);
if
(
!
tIsValidSchema
(
pTableMeta
->
schema
,
pTableMeta
->
tableInfo
.
numOfColumns
,
pTableMeta
->
tableInfo
.
numOfTags
))
{
tscError
(
"0x%"
PRIx64
" invalid table meta from mnode, name:%s"
,
pSql
->
self
,
pMetaMsg
->
tableFname
);
...
...
@@ -2092,11 +2093,13 @@ int tscProcessMultiTableMetaRsp(SSqlObj *pSql) {
const
char
*
tableName
=
tNameGetTableName
(
&
sn
);
size_t
keyLen
=
strlen
(
tableName
);
taosHashPut
(
pParentCmd
->
pTableMetaMap
,
tableName
,
keyLen
,
&
p
,
sizeof
(
STableMetaVgroupInfo
));
}
else
{
freeMeta
=
true
;
}
// for each super table, only update meta information once
bool
updateStableMeta
=
false
;
if
(
pTableMeta
->
tableType
==
TSDB_CHILD_TABLE
&&
taosHashGet
(
pSet
,
&
pMetaMsg
->
uid
,
sizeof
(
pMetaMsg
->
uid
))
==
NULL
)
{
if
(
pTableMeta
->
tableType
==
TSDB_CHILD_TABLE
&&
taosHashGet
(
pSet
,
&
pMetaMsg
->
suid
,
sizeof
(
pMetaMsg
->
s
uid
))
==
NULL
)
{
updateStableMeta
=
true
;
taosHashPut
(
pSet
,
&
pTableMeta
->
suid
,
sizeof
(
pMetaMsg
->
suid
),
""
,
0
);
}
...
...
@@ -2112,6 +2115,9 @@ int tscProcessMultiTableMetaRsp(SSqlObj *pSql) {
}
pMsg
+=
pMetaMsg
->
contLen
;
if
(
freeMeta
)
{
tfree
(
pTableMeta
);
}
}
for
(
int32_t
i
=
0
;
i
<
pMultiMeta
->
numOfVgroup
;
++
i
)
{
...
...
src/client/src/tscSql.c
浏览文件 @
289e1082
...
...
@@ -945,21 +945,19 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
return
TSDB_CODE_TSC_DISCONNECTED
;
}
SSqlObj
*
pSql
=
calloc
(
1
,
sizeof
(
SSqlObj
));
pSql
->
pTscObj
=
taos
;
pSql
->
signature
=
pSql
;
int32_t
length
=
(
int32_t
)
strlen
(
tableNameList
);
if
(
length
==
0
)
{
return
TSDB_CODE_SUCCESS
;
}
if
(
length
>
MAX_TABLE_NAME_LENGTH
)
{
tscError
(
"0x%"
PRIx64
" tableNameList too long, length:%d, maximum allowed:%d"
,
pSql
->
self
,
length
,
MAX_TABLE_NAME_LENGTH
);
tscFreeSqlObj
(
pSql
);
tscError
(
"tableNameList too long, length:%d, maximum allowed:%d"
,
length
,
MAX_TABLE_NAME_LENGTH
);
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
char
*
str
=
calloc
(
1
,
length
+
1
);
if
(
str
==
NULL
)
{
tscError
(
"0x%"
PRIx64
" failed to allocate sql string buffer"
,
pSql
->
self
);
tscFreeSqlObj
(
pSql
);
tscError
(
"failed to allocate sql string buffer, size:%d"
,
length
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
...
...
@@ -968,10 +966,15 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
SArray
*
vgroupList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
if
(
plist
==
NULL
||
vgroupList
==
NULL
)
{
tfree
(
str
);
tscFreeSqlObj
(
pSql
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
SSqlObj
*
pSql
=
calloc
(
1
,
sizeof
(
SSqlObj
));
tscAllocPayload
(
&
pSql
->
cmd
,
1024
);
pSql
->
pTscObj
=
taos
;
pSql
->
signature
=
pSql
;
int32_t
code
=
(
uint8_t
)
tscTransferTableNameList
(
pSql
,
str
,
length
,
plist
);
free
(
str
);
...
...
src/client/src/tscUtil.c
浏览文件 @
289e1082
...
...
@@ -4497,6 +4497,15 @@ static int32_t doAddTableName(char* nextStr, char** str, SArray* pNameArray, SSq
return
TSDB_CODE_SUCCESS
;
}
int32_t
nameComparFn
(
const
void
*
n1
,
const
void
*
n2
)
{
int32_t
ret
=
strcmp
(
*
(
char
**
)
n1
,
*
(
char
**
)
n2
);
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
;
...
...
@@ -4538,6 +4547,34 @@ int tscTransferTableNameList(SSqlObj *pSql, const char *pNameList, int32_t lengt
return
code
;
}
taosArraySort
(
pNameArray
,
nameComparFn
);
size_t
len
=
taosArrayGetSize
(
pNameArray
);
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
;
return
TSDB_CODE_SUCCESS
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录