Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
58bad4cf
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
58bad4cf
编写于
8月 18, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-1151] fix the coverity warnings
上级
39618bec
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
60 addition
and
62 deletion
+60
-62
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+4
-2
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+20
-37
src/query/inc/qTsbuf.h
src/query/inc/qTsbuf.h
+2
-2
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+23
-17
src/query/src/qResultbuf.c
src/query/src/qResultbuf.c
+9
-2
src/query/src/qTsbuf.c
src/query/src/qTsbuf.c
+1
-1
src/util/src/hash.c
src/util/src/hash.c
+1
-1
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
58bad4cf
...
...
@@ -1166,7 +1166,8 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
size_t
numOfNode
=
taosArrayGetSize
(
colList
);
for
(
int32_t
k
=
0
;
k
<
numOfNode
;
++
k
)
{
SColIndex
*
pIndex
=
taosArrayGet
(
colList
,
k
);
if
(
pIndex
->
flag
==
1
)
{
if
(
TSDB_COL_IS_TAG
(
pIndex
->
flag
))
{
tExprTreeDestroy
(
&
pNode
,
NULL
);
taosTFree
(
arithmeticExprStr
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
...
...
@@ -1366,7 +1367,8 @@ static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumn
ids
.
num
=
1
;
ids
.
ids
[
0
]
=
*
pIndex
;
if
(
pIndex
->
columnIndex
>=
tscGetNumOfColumns
(
pTableMeta
)
||
pIndex
->
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
if
(
pIndex
->
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
||
pIndex
->
columnIndex
==
TSDB_UD_COLUMN_INDEX
||
pIndex
->
columnIndex
>=
tscGetNumOfColumns
(
pTableMeta
))
{
ids
.
num
=
0
;
}
...
...
src/client/src/tscSubquery.c
浏览文件 @
58bad4cf
...
...
@@ -685,6 +685,9 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
freeJoinSubqueryObj
(
pParentSql
);
pParentSql
->
res
.
code
=
code
;
tscQueueAsyncRes
(
pParentSql
);
taosArrayDestroy
(
s1
);
taosArrayDestroy
(
s2
);
return
;
}
...
...
@@ -1284,8 +1287,14 @@ int32_t tscHandleMasterJoinQuery(SSqlObj* pSql) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
assert
((
pQueryInfo
->
type
&
TSDB_QUERY_TYPE_SUBQUERY
)
==
0
);
// todo add test
SSubqueryState
*
pState
=
calloc
(
1
,
sizeof
(
SSubqueryState
));
if
(
pState
==
NULL
)
{
pSql
->
res
.
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
pSql
->
res
.
code
;
}
pState
->
numOfTotal
=
pQueryInfo
->
numOfTables
;
pState
->
numOfRemain
=
pState
->
numOfTotal
;
...
...
@@ -1297,7 +1306,8 @@ int32_t tscHandleMasterJoinQuery(SSqlObj* pSql) {
tscError
(
"%p tableIndex:%d, failed to allocate join support object, abort further query"
,
pSql
,
i
);
pState
->
numOfRemain
=
i
;
pSql
->
res
.
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
taosTFree
(
pState
);
return
pSql
->
res
.
code
;
}
...
...
@@ -1511,7 +1521,6 @@ static int32_t tscReissueSubquery(SRetrieveSupport *trsupport, SSqlObj *pSql, in
tstrerror
(
code
),
subqueryIndex
,
trsupport
->
numOfRetry
);
SSqlObj
*
pNew
=
tscCreateSqlObjForSubquery
(
trsupport
->
pParentSql
,
trsupport
,
pSql
);
if
(
pNew
==
NULL
)
{
tscError
(
"%p sub:%p failed to create new subquery due to error:%s, abort retry, vgId:%d, orderOfSub:%d"
,
trsupport
->
pParentSql
,
pSql
,
tstrerror
(
terrno
),
pVgroup
->
vgId
,
trsupport
->
subqueryIndex
);
...
...
@@ -1522,8 +1531,14 @@ static int32_t tscReissueSubquery(SRetrieveSupport *trsupport, SSqlObj *pSql, in
return
pParentSql
->
res
.
code
;
}
taos_free_result
(
pSql
);
return
tscProcessSql
(
pNew
);
int32_t
ret
=
tscProcessSql
(
pNew
);
// if failed to process sql, let following code handle the pSql
if
(
ret
==
TSDB_CODE_SUCCESS
)
{
taos_free_result
(
pSql
);
}
return
code
;
}
void
tscHandleSubqueryError
(
SRetrieveSupport
*
trsupport
,
SSqlObj
*
pSql
,
int
numOfRows
)
{
...
...
@@ -2063,39 +2078,7 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) {
doBuildResFromSubqueries
(
pSql
);
tsem_post
(
&
pSql
->
rspSem
);
return
;
// continue retrieve data from vnode
// if (!tscHasRemainDataInSubqueryResultSet(pSql)) {
// tscDebug("%p at least one subquery exhausted, free all other %d subqueries", pSql, pSql->numOfSubs - 1);
// SSubqueryState* pState = NULL;
//
// // free all sub sqlobj
// for (int32_t i = 0; i < pSql->numOfSubs; ++i) {
// SSqlObj* pChildObj = pSql->pSubs[i];
// if (pChildObj == NULL) {
// continue;
// }
//
// SJoinSupporter* pSupporter = (SJoinSupporter*)pChildObj->param;
// pState = pSupporter->pState;
//
// tscDestroyJoinSupporter(pChildObj->param);
// taos_free_result(pChildObj);
// }
//
// free(pState);
//
// pRes->completed = true; // set query completed
// tsem_post(&pSql->rspSem);
// return;
// }
tscFetchDatablockFromSubquery
(
pSql
);
if
(
pRes
->
code
!=
TSDB_CODE_SUCCESS
)
{
return
;
}
}
if
(
pSql
->
res
.
code
==
TSDB_CODE_SUCCESS
)
{
...
...
src/query/inc/qTsbuf.h
浏览文件 @
58bad4cf
...
...
@@ -85,8 +85,8 @@ typedef struct STSBuf {
uint32_t
fileSize
;
STSVnodeBlockInfoEx
*
pData
;
int32_t
numOfAlloc
;
int32_t
numOfVnodes
;
uint32_t
numOfAlloc
;
uint32_t
numOfVnodes
;
char
*
assistBuf
;
int32_t
bufSize
;
...
...
src/query/src/qExecutor.c
浏览文件 @
58bad4cf
...
...
@@ -967,6 +967,7 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *
int32_t
index
=
pWindowResInfo
->
curIndex
;
STimeWindow
nextWin
=
win
;
assert
(
tsCols
!=
NULL
);
while
(
1
)
{
int32_t
prevEndPos
=
(
forwardStep
-
1
)
*
step
+
startPos
;
...
...
@@ -2730,7 +2731,8 @@ void copyResToQueryResultBuf(SQInfo *pQInfo, SQuery *pQuery) {
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutput
;
++
i
)
{
int32_t
bytes
=
pRuntimeEnv
->
pCtx
[
i
].
outputBytes
;
char
*
pDest
=
pQuery
->
sdata
[
i
]
->
data
;
memcpy
(
pDest
+
offset
*
bytes
,
pData
->
data
+
pRuntimeEnv
->
offset
[
i
]
*
pData
->
num
,
bytes
*
pData
->
num
);
memcpy
(
pDest
+
offset
*
bytes
,
pData
->
data
+
pRuntimeEnv
->
offset
[
i
]
*
pData
->
num
,
(
size_t
)(
bytes
*
pData
->
num
));
}
offset
+=
(
int32_t
)
pData
->
num
;
...
...
@@ -3298,7 +3300,8 @@ static void setEnvBeforeReverseScan(SQueryRuntimeEnv *pRuntimeEnv, SQueryStatusI
pStatus
->
cur
=
tsBufGetCursor
(
pRuntimeEnv
->
pTSBuf
);
// save the cursor
if
(
pRuntimeEnv
->
pTSBuf
)
{
SWITCH_ORDER
(
pRuntimeEnv
->
pTSBuf
->
cur
.
order
);
tsBufNextPos
(
pRuntimeEnv
->
pTSBuf
);
bool
ret
=
tsBufNextPos
(
pRuntimeEnv
->
pTSBuf
);
assert
(
ret
);
}
// reverse order time range
...
...
@@ -5225,7 +5228,7 @@ static int32_t getColumnIndexInSource(SQueryTableMsg *pQueryMsg, SSqlFuncMsg *pE
if
(
TSDB_COL_IS_TAG
(
pExprMsg
->
colInfo
.
flag
))
{
if
(
pExprMsg
->
colInfo
.
colId
==
TSDB_TBNAME_COLUMN_INDEX
)
{
return
-
1
;
return
TSDB_TBNAME_COLUMN_INDEX
;
}
while
(
j
<
pQueryMsg
->
numOfTags
)
{
...
...
@@ -5644,18 +5647,19 @@ static int32_t createQFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SExprInfo *
if
(
functId
==
TSDB_FUNC_TOP
||
functId
==
TSDB_FUNC_BOTTOM
)
{
int32_t
j
=
getColumnIndexInSource
(
pQueryMsg
,
&
pExprs
[
i
].
base
,
pTagCols
);
assert
(
j
<
pQueryMsg
->
numOfCols
);
SColumnInfo
*
pCol
=
&
pQueryMsg
->
colList
[
j
];
int32_t
ret
=
getResultDataInfo
(
pCol
->
type
,
pCol
->
bytes
,
functId
,
(
int32_t
)
pExprs
[
i
].
base
.
arg
[
0
].
argValue
.
i64
,
&
pExprs
[
i
].
type
,
&
pExprs
[
i
].
bytes
,
&
pExprs
[
i
].
interBytes
,
tagLen
,
isSuperTable
);
assert
(
ret
==
TSDB_CODE_SUCCESS
);
if
(
j
<
0
||
j
>=
pQueryMsg
->
numOfCols
)
{
assert
(
0
);
}
else
{
SColumnInfo
*
pCol
=
&
pQueryMsg
->
colList
[
j
];
int32_t
ret
=
getResultDataInfo
(
pCol
->
type
,
pCol
->
bytes
,
functId
,
(
int32_t
)
pExprs
[
i
].
base
.
arg
[
0
].
argValue
.
i64
,
&
pExprs
[
i
].
type
,
&
pExprs
[
i
].
bytes
,
&
pExprs
[
i
].
interBytes
,
tagLen
,
isSuperTable
);
assert
(
ret
==
TSDB_CODE_SUCCESS
);
}
}
}
*
pExprInfo
=
pExprs
;
*
pExprInfo
=
pExprs
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -6194,14 +6198,16 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
// make sure file exist
if
(
FD_VALID
(
fd
))
{
int32
_t
s
=
lseek
(
fd
,
0
,
SEEK_END
);
UNUSED
(
s
);
qDebug
(
"QInfo:%p ts comp data return, file:%s, size:%
d"
,
pQInfo
,
pQuery
->
sdata
[
0
]
->
data
,
s
);
uint64
_t
s
=
lseek
(
fd
,
0
,
SEEK_END
);
qDebug
(
"QInfo:%p ts comp data return, file:%s, size:%
"
PRId64
,
pQInfo
,
pQuery
->
sdata
[
0
]
->
data
,
s
);
if
(
lseek
(
fd
,
0
,
SEEK_SET
)
>=
0
)
{
size_t
sz
=
read
(
fd
,
data
,
s
);
UNUSED
(
sz
);
if
(
sz
<
s
)
{
// todo handle error
assert
(
0
);
}
}
else
{
// todo handle error
UNUSED
(
s
);
}
close
(
fd
);
...
...
src/query/src/qResultbuf.c
浏览文件 @
58bad4cf
...
...
@@ -137,8 +137,15 @@ static char* doFlushPageToDisk(SDiskbasedResultBuf* pResultBuf, SPageInfo* pg) {
}
//3. write to disk.
fseek
(
pResultBuf
->
file
,
pg
->
info
.
offset
,
SEEK_SET
);
fwrite
(
t
,
size
,
1
,
pResultBuf
->
file
);
int32_t
ret
=
fseek
(
pResultBuf
->
file
,
pg
->
info
.
offset
,
SEEK_SET
);
if
(
ret
!=
0
)
{
// todo handle the error case
}
ret
=
fwrite
(
t
,
size
,
1
,
pResultBuf
->
file
);
if
(
ret
!=
size
)
{
// todo handle the error case
}
if
(
pResultBuf
->
fileSize
<
pg
->
info
.
offset
+
pg
->
info
.
length
)
{
pResultBuf
->
fileSize
=
pg
->
info
.
offset
+
pg
->
info
.
length
;
...
...
src/query/src/qTsbuf.c
浏览文件 @
58bad4cf
...
...
@@ -75,7 +75,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
return
NULL
;
}
if
(
(
int32_t
)
header
.
numOfVnode
>
pTSBuf
->
numOfAlloc
)
{
if
(
header
.
numOfVnode
>
pTSBuf
->
numOfAlloc
)
{
pTSBuf
->
numOfAlloc
=
header
.
numOfVnode
;
STSVnodeBlockInfoEx
*
tmp
=
realloc
(
pTSBuf
->
pData
,
sizeof
(
STSVnodeBlockInfoEx
)
*
pTSBuf
->
numOfAlloc
);
if
(
tmp
==
NULL
)
{
...
...
src/util/src/hash.c
浏览文件 @
58bad4cf
...
...
@@ -657,7 +657,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
}
int64_t
st
=
taosGetTimestampUs
();
void
*
pNewEntryList
=
realloc
(
pHashObj
->
hashList
,
sizeof
(
void
*
)
*
newSize
);
void
*
pNewEntryList
=
realloc
(
pHashObj
->
hashList
,
sizeof
(
void
*
)
*
newSize
);
if
(
pNewEntryList
==
NULL
)
{
// todo handle error
// uDebug("cache resize failed due to out of memory, capacity remain:%d", pHashObj->capacity);
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录