Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
b541ece4
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看板
未验证
提交
b541ece4
编写于
6月 26, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
6月 26, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2454 from taosdata/hotfix/coverity_query_issue
coverity issue
上级
103f6888
d0b20875
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
41 addition
and
24 deletion
+41
-24
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+36
-22
src/query/src/qpercentile.c
src/query/src/qpercentile.c
+5
-2
未找到文件。
src/query/src/qExecutor.c
浏览文件 @
b541ece4
...
...
@@ -767,6 +767,9 @@ static void* getDataBlockImpl(SArray* pDataBlock, int32_t colId) {
static
char
*
getDataBlock
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SArithmeticSupport
*
sas
,
int32_t
col
,
int32_t
size
,
SArray
*
pDataBlock
)
{
if
(
pDataBlock
==
NULL
)
{
return
NULL
;
}
char
*
dataBlock
=
NULL
;
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
...
...
@@ -854,6 +857,7 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *
STimeWindow
win
=
getActiveTimeWindow
(
pWindowResInfo
,
ts
,
pQuery
);
if
(
setWindowOutputBufByKey
(
pRuntimeEnv
,
pWindowResInfo
,
pDataBlockInfo
->
tid
,
&
win
)
!=
TSDB_CODE_SUCCESS
)
{
tfree
(
sasArray
);
return
;
}
...
...
@@ -1349,10 +1353,13 @@ static void setCtxTagColumnInfo(SQuery *pQuery, SQLFunctionCtx *pCtx) {
// the column may be the normal column, group by normal_column, the functionId is TSDB_FUNC_PRJ
}
}
p
->
tagInfo
.
pTagCtxList
=
pTagCtx
;
p
->
tagInfo
.
numOfTagCols
=
num
;
p
->
tagInfo
.
tagsLen
=
tagLen
;
if
(
p
!=
NULL
)
{
p
->
tagInfo
.
pTagCtxList
=
pTagCtx
;
p
->
tagInfo
.
numOfTagCols
=
num
;
p
->
tagInfo
.
tagsLen
=
tagLen
;
}
else
{
tfree
(
pTagCtx
);
}
}
}
...
...
@@ -3497,7 +3504,7 @@ static int32_t doCopyToSData(SQInfo *pQInfo, SWindowResult *result, int32_t orde
continue
;
}
assert
(
result
[
i
].
numOfRows
>=
0
&&
pQInfo
->
offset
<=
1
);
assert
(
pQInfo
->
offset
<=
1
);
int32_t
numOfRowsToCopy
=
result
[
i
].
numOfRows
-
pQInfo
->
offset
;
int32_t
oldOffset
=
pQInfo
->
offset
;
...
...
@@ -5295,9 +5302,9 @@ static int32_t createQFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SExprInfo *
bytes
=
s
.
bytes
;
}
else
{
int32_t
j
=
getColumnIndexInSource
(
pQueryMsg
,
&
pExprs
[
i
].
base
,
pTagCols
);
assert
(
j
<
pQueryMsg
->
numOfCols
||
j
<
pQueryMsg
->
numOfTags
||
j
==
TSDB_TBNAME_COLUMN_INDEX
);
assert
(
j
<
pQueryMsg
->
numOfCols
||
j
<
pQueryMsg
->
numOfTags
);
if
(
pExprs
[
i
].
base
.
colInfo
.
colId
!=
TSDB_TBNAME_COLUMN_INDEX
)
{
if
(
pExprs
[
i
].
base
.
colInfo
.
colId
!=
TSDB_TBNAME_COLUMN_INDEX
&&
j
>=
0
)
{
SColumnInfo
*
pCol
=
(
TSDB_COL_IS_TAG
(
pExprs
[
i
].
base
.
colInfo
.
flag
))
?
&
pTagCols
[
j
]
:&
pQueryMsg
->
colList
[
j
];
type
=
pCol
->
type
;
bytes
=
pCol
->
bytes
;
...
...
@@ -5339,8 +5346,6 @@ static int32_t createQFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SExprInfo *
assert
(
ret
==
TSDB_CODE_SUCCESS
);
}
}
tfree
(
pExprMsg
);
*
pExprInfo
=
pExprs
;
return
TSDB_CODE_SUCCESS
;
...
...
@@ -5591,11 +5596,14 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList,
pQInfo
->
signature
=
pQInfo
;
pQInfo
->
tableGroupInfo
=
*
pTableGroupInfo
;
size_t
numOfGroups
=
taosArrayGetSize
(
pTableGroupInfo
->
pGroupList
);
size_t
numOfGroups
=
0
;
if
(
pTableGroupInfo
->
pGroupList
!=
NULL
)
{
numOfGroups
=
taosArrayGetSize
(
pTableGroupInfo
->
pGroupList
);
pQInfo
->
tableqinfoGroupInfo
.
pGroupList
=
taosArrayInit
(
numOfGroups
,
POINTER_BYTES
);
pQInfo
->
tableqinfoGroupInfo
.
numOfTables
=
pTableGroupInfo
->
numOfTables
;
}
pQInfo
->
tableqinfoGroupInfo
.
pGroupList
=
taosArrayInit
(
numOfGroups
,
POINTER_BYTES
);
pQInfo
->
tableqinfoGroupInfo
.
numOfTables
=
pTableGroupInfo
->
numOfTables
;
int
tableIndex
=
0
;
STimeWindow
window
=
pQueryMsg
->
window
;
taosArraySort
(
pTableIdList
,
compareTableIdInfo
);
...
...
@@ -5693,7 +5701,8 @@ static int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQ
pTSBuf
=
tsBufCreateFromCompBlocks
(
tsBlock
,
pQueryMsg
->
tsNumOfBlocks
,
pQueryMsg
->
tsLen
,
pQueryMsg
->
tsOrder
);
tsBufResetPos
(
pTSBuf
);
tsBufNextPos
(
pTSBuf
);
bool
ret
=
tsBufNextPos
(
pTSBuf
);
UNUSED
(
ret
);
}
// only the successful complete requries the sem_post/over = 1 operations.
...
...
@@ -5839,18 +5848,23 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
// make sure file exist
if
(
FD_VALID
(
fd
))
{
size_t
s
=
lseek
(
fd
,
0
,
SEEK_END
);
qTrace
(
"QInfo:%p ts comp data return, file:%s, size:%zu"
,
pQInfo
,
pQuery
->
sdata
[
0
]
->
data
,
s
);
lseek
(
fd
,
0
,
SEEK_SET
);
read
(
fd
,
data
,
s
);
int32_t
s
=
lseek
(
fd
,
0
,
SEEK_END
);
UNUSED
(
s
);
qTrace
(
"QInfo:%p ts comp data return, file:%s, size:%d"
,
pQInfo
,
pQuery
->
sdata
[
0
]
->
data
,
s
);
s
=
lseek
(
fd
,
0
,
SEEK_SET
);
if
(
s
>=
0
)
{
size_t
sz
=
read
(
fd
,
data
,
s
);
UNUSED
(
sz
);
}
close
(
fd
);
unlink
(
pQuery
->
sdata
[
0
]
->
data
);
}
else
{
// todo return the error code to client
// todo return the error code to client
and handle invalid fd
qError
(
"QInfo:%p failed to open tmp file to send ts-comp data to client, path:%s, reason:%s"
,
pQInfo
,
pQuery
->
sdata
[
0
]
->
data
,
strerror
(
errno
));
if
(
fd
!=
-
1
)
{
close
(
fd
);
}
}
// all data returned, set query over
...
...
@@ -5903,7 +5917,6 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi
}
if
((
code
=
createQFunctionExprFromMsg
(
pQueryMsg
,
&
pExprs
,
pExprMsg
,
pTagColumnInfo
))
!=
TSDB_CODE_SUCCESS
)
{
free
(
pExprMsg
);
goto
_over
;
}
...
...
@@ -5975,6 +5988,7 @@ _over:
}
free
(
pTagColumnInfo
);
free
(
pExprs
);
free
(
pExprMsg
);
taosArrayDestroy
(
pTableIdList
);
//pQInfo already freed in initQInfo, but *pQInfo may not pointer to null;
...
...
src/query/src/qpercentile.c
浏览文件 @
b541ece4
...
...
@@ -880,8 +880,11 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
for
(
uint32_t
jx
=
0
;
jx
<
pFlushInfo
->
numOfPages
;
++
jx
)
{
size_t
sz
=
fread
(
pPage
,
pMemBuffer
->
pageSize
,
1
,
pMemBuffer
->
file
);
UNUSED
(
sz
);
tMemBucketPut
(
pMemBucket
,
pPage
->
data
,
pPage
->
num
);
if
(
sz
!=
pMemBuffer
->
pageSize
)
{
uError
(
"MemBucket:%p, read tmp file %s failed"
,
pMemBucket
,
pMemBuffer
->
path
);
}
else
{
tMemBucketPut
(
pMemBucket
,
pPage
->
data
,
pPage
->
num
);
}
}
fclose
(
pMemBuffer
->
file
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录