Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
c5c611ab
T
TDengine
项目概览
慢慢CG
/
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看板
未验证
提交
c5c611ab
编写于
11月 27, 2020
作者:
H
haojun Liao
提交者:
GitHub
11月 27, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4358 from taosdata/patch/td-2135
[TD-2135]<patch>: reduce memory usage
上级
5f3bb47b
f547e29a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
18 deletion
+48
-18
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-1
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+14
-6
src/client/src/tscServer.c
src/client/src/tscServer.c
+19
-9
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+14
-2
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
c5c611ab
...
...
@@ -282,7 +282,7 @@ typedef struct {
int8_t
dataSourceType
;
// load data from file or not
int8_t
submitSchema
;
// submit block is built with table schema
STagData
tagData
;
STagData
*
pTagData
;
// NOTE: pTagData->data is used as a variant length array
SHashObj
*
pTableList
;
// referred table involved in sql
SArray
*
pDataBlocks
;
// SArray<STableDataBlocks*> submit data blocks after parsing sql
}
SSqlCmd
;
...
...
src/client/src/tscParseInsert.c
浏览文件 @
c5c611ab
...
...
@@ -790,9 +790,6 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
sql
+=
index
;
tscAllocPayload
(
pCmd
,
sizeof
(
STagData
));
STagData
*
pTag
=
&
pCmd
->
tagData
;
memset
(
pTag
,
0
,
sizeof
(
STagData
));
//the source super table is moved to the secondary position of the pTableMetaInfo list
if
(
pQueryInfo
->
numOfTables
<
2
)
{
...
...
@@ -805,7 +802,14 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
return
code
;
}
STagData
*
pTag
=
realloc
(
pCmd
->
pTagData
,
offsetof
(
STagData
,
data
));
if
(
pTag
==
NULL
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
memset
(
pTag
,
0
,
offsetof
(
STagData
,
data
));
tstrncpy
(
pTag
->
name
,
pSTableMeterMetaInfo
->
name
,
sizeof
(
pTag
->
name
));
pCmd
->
pTagData
=
pTag
;
code
=
tscGetTableMeta
(
pSql
,
pSTableMeterMetaInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
@@ -934,7 +938,13 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
tdSortKVRowByColIdx
(
row
);
pTag
->
dataLen
=
kvRowLen
(
row
);
pTag
=
(
STagData
*
)
realloc
(
pCmd
->
pTagData
,
offsetof
(
STagData
,
data
)
+
kvRowLen
(
row
));
if
(
pTag
==
NULL
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
pCmd
->
pTagData
=
pTag
;
pTag
->
dataLen
=
htonl
(
kvRowLen
(
row
));
kvRowCpy
(
pTag
->
data
,
row
);
free
(
row
);
...
...
@@ -945,8 +955,6 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
") expected"
,
sToken
.
z
);
}
pTag
->
dataLen
=
htonl
(
pTag
->
dataLen
);
if
(
tscValidateName
(
&
tableToken
)
!=
TSDB_CODE_SUCCESS
)
{
return
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"invalid table name"
,
*
sqlstr
);
}
...
...
src/client/src/tscServer.c
浏览文件 @
c5c611ab
...
...
@@ -1565,11 +1565,11 @@ int tscBuildTableMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
char
*
pMsg
=
(
char
*
)
pInfoMsg
+
sizeof
(
STableInfoMsg
);
size_t
len
=
htonl
(
pCmd
->
tagData
.
dataLen
);
if
(
pSql
->
cmd
.
autoCreated
)
{
if
(
pCmd
->
autoCreated
&&
pCmd
->
pTagData
!=
NULL
)
{
int
len
=
htonl
(
pCmd
->
pTagData
->
dataLen
);
if
(
len
>
0
)
{
len
+=
sizeof
(
pCmd
->
tagData
.
name
)
+
sizeof
(
pCmd
->
tagData
.
dataLen
);
memcpy
(
pInfoMsg
->
tags
,
&
pCmd
->
t
agData
,
len
);
len
+=
sizeof
(
pCmd
->
pTagData
->
name
)
+
sizeof
(
pCmd
->
pTagData
->
dataLen
);
memcpy
(
pInfoMsg
->
tags
,
pCmd
->
pT
agData
,
len
);
pMsg
+=
len
;
}
}
...
...
@@ -2239,8 +2239,6 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf
pNew
->
signature
=
pNew
;
pNew
->
cmd
.
command
=
TSDB_SQL_META
;
registerSqlObj
(
pNew
);
tscAddSubqueryInfo
(
&
pNew
->
cmd
);
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfoDetailSafely
(
&
pNew
->
cmd
,
0
);
...
...
@@ -2248,8 +2246,7 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf
pNew
->
cmd
.
autoCreated
=
pSql
->
cmd
.
autoCreated
;
// create table if not exists
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
&
pNew
->
cmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
+
pSql
->
cmd
.
payloadLen
))
{
tscError
(
"%p malloc failed for payload to get table meta"
,
pSql
);
free
(
pNew
);
tscFreeSqlObj
(
pNew
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
...
...
@@ -2257,12 +2254,25 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf
assert
(
pNew
->
cmd
.
numOfClause
==
1
&&
pNewQueryInfo
->
numOfTables
==
1
);
tstrncpy
(
pNewMeterMetaInfo
->
name
,
pTableMetaInfo
->
name
,
sizeof
(
pNewMeterMetaInfo
->
name
));
memcpy
(
&
pNew
->
cmd
.
tagData
,
&
pSql
->
cmd
.
tagData
,
sizeof
(
pSql
->
cmd
.
tagData
));
if
(
pSql
->
cmd
.
pTagData
!=
NULL
)
{
int
size
=
offsetof
(
STagData
,
data
)
+
htonl
(
pSql
->
cmd
.
pTagData
->
dataLen
);
pNew
->
cmd
.
pTagData
=
calloc
(
1
,
size
);
if
(
pNew
->
cmd
.
pTagData
==
NULL
)
{
tscError
(
"%p malloc failed for new tag data to get table meta"
,
pSql
);
tscFreeSqlObj
(
pNew
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
memcpy
(
pNew
->
cmd
.
pTagData
,
pSql
->
cmd
.
pTagData
,
size
);
}
tscDebug
(
"%p new pSqlObj:%p to get tableMeta, auto create:%d"
,
pSql
,
pNew
,
pNew
->
cmd
.
autoCreated
);
pNew
->
fp
=
tscTableMetaCallBack
;
pNew
->
param
=
pSql
;
registerSqlObj
(
pNew
);
int32_t
code
=
tscProcessSql
(
pNew
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
TSDB_CODE_TSC_ACTION_IN_PROGRESS
;
// notify upper application that current process need to be terminated
...
...
src/client/src/tscUtil.c
浏览文件 @
c5c611ab
...
...
@@ -408,7 +408,7 @@ void tscResetSqlCmdObj(SSqlCmd* pCmd, bool removeFromCache) {
pCmd
->
pTableList
=
NULL
;
pCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
pDataBlocks
);
tscFreeQueryInfo
(
pCmd
,
removeFromCache
);
}
...
...
@@ -512,6 +512,8 @@ void tscFreeSqlObj(SSqlObj* pSql) {
tscFreeSqlResult
(
pSql
);
tscResetSqlCmdObj
(
pCmd
,
false
);
tfree
(
pCmd
->
pTagData
);
memset
(
pCmd
->
payload
,
0
,
(
size_t
)
pCmd
->
allocSize
);
tfree
(
pCmd
->
payload
);
pCmd
->
allocSize
=
0
;
...
...
@@ -1909,7 +1911,17 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm
pCmd
->
command
=
cmd
;
pCmd
->
parseFinished
=
1
;
pCmd
->
autoCreated
=
pSql
->
cmd
.
autoCreated
;
memcpy
(
&
pCmd
->
tagData
,
&
pSql
->
cmd
.
tagData
,
sizeof
(
pCmd
->
tagData
));
if
(
pSql
->
cmd
.
pTagData
!=
NULL
)
{
int
size
=
offsetof
(
STagData
,
data
)
+
htonl
(
pSql
->
cmd
.
pTagData
->
dataLen
);
pNew
->
cmd
.
pTagData
=
calloc
(
1
,
size
);
if
(
pNew
->
cmd
.
pTagData
==
NULL
)
{
tscError
(
"%p new subquery failed, unable to malloc tag data, tableIndex:%d"
,
pSql
,
0
);
free
(
pNew
);
return
NULL
;
}
memcpy
(
pNew
->
cmd
.
pTagData
,
pSql
->
cmd
.
pTagData
,
size
);
}
if
(
tscAddSubqueryInfo
(
pCmd
)
!=
TSDB_CODE_SUCCESS
)
{
tscFreeSqlObj
(
pNew
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录