Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Tonvia
TDengine
提交
4a7d25c8
T
TDengine
项目概览
Tonvia
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4a7d25c8
编写于
7月 11, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] refactor codes.
上级
3662e7c3
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
63 addition
and
83 deletion
+63
-83
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+1
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+0
-1
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+3
-3
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+1
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+44
-64
src/query/src/qtokenizer.c
src/query/src/qtokenizer.c
+5
-4
src/query/src/qtsbuf.c
src/query/src/qtsbuf.c
+9
-9
未找到文件。
src/client/src/tscFunctionImpl.c
浏览文件 @
4a7d25c8
...
@@ -3945,7 +3945,7 @@ static void ts_comp_finalize(SQLFunctionCtx *pCtx) {
...
@@ -3945,7 +3945,7 @@ static void ts_comp_finalize(SQLFunctionCtx *pCtx) {
tsBufFlush
(
pTSbuf
);
tsBufFlush
(
pTSbuf
);
strcpy
(
pCtx
->
aOutputBuf
,
pTSbuf
->
path
);
strcpy
(
pCtx
->
aOutputBuf
,
pTSbuf
->
path
);
tsBufDest
or
y
(
pTSbuf
);
tsBufDest
ro
y
(
pTSbuf
);
doFinalizer
(
pCtx
);
doFinalizer
(
pCtx
);
}
}
...
...
src/client/src/tscSQLParser.c
浏览文件 @
4a7d25c8
...
@@ -175,7 +175,6 @@ static int32_t handlePassword(SSqlCmd* pCmd, SSQLToken* pPwd) {
...
@@ -175,7 +175,6 @@ static int32_t handlePassword(SSqlCmd* pCmd, SSQLToken* pPwd) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
// todo handle memory leak in error handle function
int32_t
tscToSQLCmd
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
)
{
int32_t
tscToSQLCmd
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
)
{
if
(
pInfo
==
NULL
||
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
if
(
pInfo
==
NULL
||
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
return
TSDB_CODE_TSC_APP_ERROR
;
return
TSDB_CODE_TSC_APP_ERROR
;
...
...
src/client/src/tscSubquery.c
浏览文件 @
4a7d25c8
...
@@ -152,8 +152,8 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ
...
@@ -152,8 +152,8 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ
tsBufFlush
(
output1
);
tsBufFlush
(
output1
);
tsBufFlush
(
output2
);
tsBufFlush
(
output2
);
tsBufDest
or
y
(
pSupporter1
->
pTSBuf
);
tsBufDest
ro
y
(
pSupporter1
->
pTSBuf
);
tsBufDest
or
y
(
pSupporter2
->
pTSBuf
);
tsBufDest
ro
y
(
pSupporter2
->
pTSBuf
);
tscDebug
(
"%p input1:%"
PRId64
", input2:%"
PRId64
", final:%"
PRId64
" for secondary query after ts blocks "
tscDebug
(
"%p input1:%"
PRId64
", input2:%"
PRId64
", final:%"
PRId64
" for secondary query after ts blocks "
"intersecting, skey:%"
PRId64
", ekey:%"
PRId64
,
pSql
,
numOfInput1
,
numOfInput2
,
output1
->
numOfTotal
,
"intersecting, skey:%"
PRId64
", ekey:%"
PRId64
,
pSql
,
numOfInput1
,
numOfInput2
,
output1
->
numOfTotal
,
...
@@ -762,7 +762,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
...
@@ -762,7 +762,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
tsBufMerge
(
pSupporter
->
pTSBuf
,
pBuf
,
pTableMetaInfo
->
vgroupIndex
);
tsBufMerge
(
pSupporter
->
pTSBuf
,
pBuf
,
pTableMetaInfo
->
vgroupIndex
);
tsBufDest
or
y
(
pBuf
);
tsBufDest
ro
y
(
pBuf
);
}
}
// continue to retrieve ts-comp data from vnode
// continue to retrieve ts-comp data from vnode
...
...
src/client/src/tscUtil.c
浏览文件 @
4a7d25c8
...
@@ -1544,7 +1544,7 @@ static void freeQueryInfoImpl(SQueryInfo* pQueryInfo) {
...
@@ -1544,7 +1544,7 @@ static void freeQueryInfoImpl(SQueryInfo* pQueryInfo) {
pQueryInfo
->
groupbyExpr
.
columnInfo
=
NULL
;
pQueryInfo
->
groupbyExpr
.
columnInfo
=
NULL
;
}
}
pQueryInfo
->
tsBuf
=
tsBufDest
or
y
(
pQueryInfo
->
tsBuf
);
pQueryInfo
->
tsBuf
=
tsBufDest
ro
y
(
pQueryInfo
->
tsBuf
);
tfree
(
pQueryInfo
->
fillVal
);
tfree
(
pQueryInfo
->
fillVal
);
}
}
...
...
src/query/src/qExecutor.c
浏览文件 @
4a7d25c8
...
@@ -120,6 +120,7 @@ static UNUSED_FUNC void* u_calloc(size_t num, size_t __size) {
...
@@ -120,6 +120,7 @@ static UNUSED_FUNC void* u_calloc(size_t num, size_t __size) {
#define GET_TABLEGROUP(q, _index) ((SArray*) taosArrayGetP((q)->tableqinfoGroupInfo.pGroupList, (_index)))
#define GET_TABLEGROUP(q, _index) ((SArray*) taosArrayGetP((q)->tableqinfoGroupInfo.pGroupList, (_index)))
static
void
setQueryStatus
(
SQuery
*
pQuery
,
int8_t
status
);
static
void
setQueryStatus
(
SQuery
*
pQuery
,
int8_t
status
);
static
void
finalizeQueryResult
(
SQueryRuntimeEnv
*
pRuntimeEnv
);
#define QUERY_IS_INTERVAL_QUERY(_q) ((_q)->intervalTime > 0)
#define QUERY_IS_INTERVAL_QUERY(_q) ((_q)->intervalTime > 0)
...
@@ -838,6 +839,7 @@ static char *getDataBlock(SQueryRuntimeEnv *pRuntimeEnv, SArithmeticSupport *sas
...
@@ -838,6 +839,7 @@ static char *getDataBlock(SQueryRuntimeEnv *pRuntimeEnv, SArithmeticSupport *sas
sas
->
data
=
calloc
(
pQuery
->
numOfCols
,
POINTER_BYTES
);
sas
->
data
=
calloc
(
pQuery
->
numOfCols
,
POINTER_BYTES
);
if
(
sas
->
data
==
NULL
)
{
if
(
sas
->
data
==
NULL
)
{
finalizeQueryResult
(
pRuntimeEnv
);
// clean up allocated resource during query
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
}
...
@@ -900,6 +902,7 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *
...
@@ -900,6 +902,7 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *
SArithmeticSupport
*
sasArray
=
calloc
((
size_t
)
pQuery
->
numOfOutput
,
sizeof
(
SArithmeticSupport
));
SArithmeticSupport
*
sasArray
=
calloc
((
size_t
)
pQuery
->
numOfOutput
,
sizeof
(
SArithmeticSupport
));
if
(
sasArray
==
NULL
)
{
if
(
sasArray
==
NULL
)
{
finalizeQueryResult
(
pRuntimeEnv
);
// clean up allocated resource during query
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
}
...
@@ -1146,6 +1149,7 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
...
@@ -1146,6 +1149,7 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
SArithmeticSupport
*
sasArray
=
calloc
((
size_t
)
pQuery
->
numOfOutput
,
sizeof
(
SArithmeticSupport
));
SArithmeticSupport
*
sasArray
=
calloc
((
size_t
)
pQuery
->
numOfOutput
,
sizeof
(
SArithmeticSupport
));
if
(
sasArray
==
NULL
)
{
if
(
sasArray
==
NULL
)
{
finalizeQueryResult
(
pRuntimeEnv
);
// clean up allocated resource during query
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
}
...
@@ -1597,7 +1601,7 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
...
@@ -1597,7 +1601,7 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
tsdbCleanupQueryHandle
(
pRuntimeEnv
->
pQueryHandle
);
tsdbCleanupQueryHandle
(
pRuntimeEnv
->
pQueryHandle
);
tsdbCleanupQueryHandle
(
pRuntimeEnv
->
pSecQueryHandle
);
tsdbCleanupQueryHandle
(
pRuntimeEnv
->
pSecQueryHandle
);
pRuntimeEnv
->
pTSBuf
=
tsBufDest
or
y
(
pRuntimeEnv
->
pTSBuf
);
pRuntimeEnv
->
pTSBuf
=
tsBufDest
ro
y
(
pRuntimeEnv
->
pTSBuf
);
}
}
#define IS_QUERY_KILLED(_q) ((_q)->code == TSDB_CODE_TSC_QUERY_CANCELLED)
#define IS_QUERY_KILLED(_q) ((_q)->code == TSDB_CODE_TSC_QUERY_CANCELLED)
...
@@ -2225,8 +2229,10 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
...
@@ -2225,8 +2229,10 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
SDataBlockInfo
blockInfo
=
SDATA_BLOCK_INITIALIZER
;
SDataBlockInfo
blockInfo
=
SDATA_BLOCK_INITIALIZER
;
while
(
tsdbNextDataBlock
(
pQueryHandle
))
{
while
(
tsdbNextDataBlock
(
pQueryHandle
))
{
summary
->
totalBlocks
+=
1
;
summary
->
totalBlocks
+=
1
;
if
(
IS_QUERY_KILLED
(
GET_QINFO_ADDR
(
pRuntimeEnv
)))
{
if
(
IS_QUERY_KILLED
(
GET_QINFO_ADDR
(
pRuntimeEnv
)))
{
return
0
;
finalizeQueryResult
(
pRuntimeEnv
);
// clean up allocated resource during query
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_TSC_QUERY_CANCELLED
);
}
}
tsdbRetrieveDataBlockInfo
(
pQueryHandle
,
&
blockInfo
);
tsdbRetrieveDataBlockInfo
(
pQueryHandle
,
&
blockInfo
);
...
@@ -3281,7 +3287,8 @@ void scanOneTableDataBlocks(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start) {
...
@@ -3281,7 +3287,8 @@ void scanOneTableDataBlocks(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start) {
// check if query is killed or not
// check if query is killed or not
if
(
IS_QUERY_KILLED
(
pQInfo
))
{
if
(
IS_QUERY_KILLED
(
pQInfo
))
{
return
;
finalizeQueryResult
(
pRuntimeEnv
);
// clean up allocated resource during query
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_TSC_QUERY_CANCELLED
);
}
}
}
}
...
@@ -3926,7 +3933,8 @@ void skipBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
...
@@ -3926,7 +3933,8 @@ void skipBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
SDataBlockInfo
blockInfo
=
SDATA_BLOCK_INITIALIZER
;
SDataBlockInfo
blockInfo
=
SDATA_BLOCK_INITIALIZER
;
while
(
tsdbNextDataBlock
(
pQueryHandle
))
{
while
(
tsdbNextDataBlock
(
pQueryHandle
))
{
if
(
IS_QUERY_KILLED
(
GET_QINFO_ADDR
(
pRuntimeEnv
)))
{
if
(
IS_QUERY_KILLED
(
GET_QINFO_ADDR
(
pRuntimeEnv
)))
{
return
;
finalizeQueryResult
(
pRuntimeEnv
);
// clean up allocated resource during query
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_TSC_QUERY_CANCELLED
);
}
}
tsdbRetrieveDataBlockInfo
(
pQueryHandle
,
&
blockInfo
);
tsdbRetrieveDataBlockInfo
(
pQueryHandle
,
&
blockInfo
);
...
@@ -4133,7 +4141,10 @@ int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, void *tsdb, int32_t vgId, bo
...
@@ -4133,7 +4141,10 @@ int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, void *tsdb, int32_t vgId, bo
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
SQuery
*
pQuery
=
pQInfo
->
runtimeEnv
.
pQuery
;
SQuery
*
pQuery
=
pQInfo
->
runtimeEnv
.
pQuery
;
pQuery
->
precision
=
tsdbGetCfg
(
tsdb
)
->
precision
;
pQuery
->
precision
=
tsdbGetCfg
(
tsdb
)
->
precision
;
pRuntimeEnv
->
topBotQuery
=
isTopBottomQuery
(
pQuery
);
pRuntimeEnv
->
hasTagResults
=
hasTagValOutput
(
pQuery
);
setScanLimitationByResultBuffer
(
pQuery
);
setScanLimitationByResultBuffer
(
pQuery
);
changeExecuteScanOrder
(
pQInfo
,
false
);
changeExecuteScanOrder
(
pQInfo
,
false
);
...
@@ -4211,10 +4222,6 @@ int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, void *tsdb, int32_t vgId, bo
...
@@ -4211,10 +4222,6 @@ int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, void *tsdb, int32_t vgId, bo
pQuery
->
fillType
,
pColInfo
);
pQuery
->
fillType
,
pColInfo
);
}
}
// todo refactor
pRuntimeEnv
->
topBotQuery
=
isTopBottomQuery
(
pQuery
);
pRuntimeEnv
->
hasTagResults
=
hasTagValOutput
(
pQuery
);
setQueryStatus
(
pQuery
,
QUERY_NOT_COMPLETED
);
setQueryStatus
(
pQuery
,
QUERY_NOT_COMPLETED
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -4243,7 +4250,8 @@ static int64_t scanMultiTableDataBlocks(SQInfo *pQInfo) {
...
@@ -4243,7 +4250,8 @@ static int64_t scanMultiTableDataBlocks(SQInfo *pQInfo) {
while
(
tsdbNextDataBlock
(
pQueryHandle
))
{
while
(
tsdbNextDataBlock
(
pQueryHandle
))
{
summary
->
totalBlocks
+=
1
;
summary
->
totalBlocks
+=
1
;
if
(
IS_QUERY_KILLED
(
pQInfo
))
{
if
(
IS_QUERY_KILLED
(
pQInfo
))
{
break
;
finalizeQueryResult
(
pRuntimeEnv
);
// clean up allocated resource during query
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_TSC_QUERY_CANCELLED
);
}
}
tsdbRetrieveDataBlockInfo
(
pQueryHandle
,
&
blockInfo
);
tsdbRetrieveDataBlockInfo
(
pQueryHandle
,
&
blockInfo
);
...
@@ -4527,7 +4535,8 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
...
@@ -4527,7 +4535,8 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
while
(
pQInfo
->
tableIndex
<
pQInfo
->
tableqinfoGroupInfo
.
numOfTables
)
{
while
(
pQInfo
->
tableIndex
<
pQInfo
->
tableqinfoGroupInfo
.
numOfTables
)
{
if
(
IS_QUERY_KILLED
(
pQInfo
))
{
if
(
IS_QUERY_KILLED
(
pQInfo
))
{
return
;
finalizeQueryResult
(
pRuntimeEnv
);
// clean up allocated resource during query
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_TSC_QUERY_CANCELLED
);
}
}
pQuery
->
current
=
taosArrayGetP
(
group
,
pQInfo
->
tableIndex
);
pQuery
->
current
=
taosArrayGetP
(
group
,
pQInfo
->
tableIndex
);
...
@@ -4723,7 +4732,8 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
...
@@ -4723,7 +4732,8 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
// query error occurred or query is killed, abort current execution
// query error occurred or query is killed, abort current execution
if
(
pQInfo
->
code
!=
TSDB_CODE_SUCCESS
||
IS_QUERY_KILLED
(
pQInfo
))
{
if
(
pQInfo
->
code
!=
TSDB_CODE_SUCCESS
||
IS_QUERY_KILLED
(
pQInfo
))
{
qDebug
(
"QInfo:%p query killed or error occurred, code:%s, abort"
,
pQInfo
,
tstrerror
(
pQInfo
->
code
));
qDebug
(
"QInfo:%p query killed or error occurred, code:%s, abort"
,
pQInfo
,
tstrerror
(
pQInfo
->
code
));
return
;
finalizeQueryResult
(
pRuntimeEnv
);
// clean up allocated resource during query
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_TSC_QUERY_CANCELLED
);
}
}
// close all time window results
// close all time window results
...
@@ -4745,7 +4755,8 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
...
@@ -4745,7 +4755,8 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
if
(
pQInfo
->
code
!=
TSDB_CODE_SUCCESS
||
IS_QUERY_KILLED
(
pQInfo
))
{
if
(
pQInfo
->
code
!=
TSDB_CODE_SUCCESS
||
IS_QUERY_KILLED
(
pQInfo
))
{
qDebug
(
"QInfo:%p query killed or error occurred, code:%s, abort"
,
pQInfo
,
tstrerror
(
pQInfo
->
code
));
qDebug
(
"QInfo:%p query killed or error occurred, code:%s, abort"
,
pQInfo
,
tstrerror
(
pQInfo
->
code
));
return
;
finalizeQueryResult
(
pRuntimeEnv
);
// clean up allocated resource during query
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_TSC_QUERY_CANCELLED
);
}
}
if
(
QUERY_IS_INTERVAL_QUERY
(
pQuery
)
||
isSumAvgRateQuery
(
pQuery
))
{
if
(
QUERY_IS_INTERVAL_QUERY
(
pQuery
)
||
isSumAvgRateQuery
(
pQuery
))
{
...
@@ -4784,7 +4795,8 @@ static void tableFixedOutputProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo)
...
@@ -4784,7 +4795,8 @@ static void tableFixedOutputProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo)
finalizeQueryResult
(
pRuntimeEnv
);
finalizeQueryResult
(
pRuntimeEnv
);
if
(
IS_QUERY_KILLED
(
pQInfo
))
{
if
(
IS_QUERY_KILLED
(
pQInfo
))
{
return
;
finalizeQueryResult
(
pRuntimeEnv
);
// clean up allocated resource during query
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_TSC_QUERY_CANCELLED
);
}
}
// since the numOfRows must be identical for all sql functions that are allowed to be executed simutaneously.
// since the numOfRows must be identical for all sql functions that are allowed to be executed simutaneously.
...
@@ -4816,10 +4828,6 @@ static void tableMultiOutputProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo)
...
@@ -4816,10 +4828,6 @@ static void tableMultiOutputProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo)
scanOneTableDataBlocks
(
pRuntimeEnv
,
pQuery
->
current
->
lastKey
);
scanOneTableDataBlocks
(
pRuntimeEnv
,
pQuery
->
current
->
lastKey
);
finalizeQueryResult
(
pRuntimeEnv
);
finalizeQueryResult
(
pRuntimeEnv
);
if
(
IS_QUERY_KILLED
(
pQInfo
))
{
return
;
}
pQuery
->
rec
.
rows
=
getNumOfResult
(
pRuntimeEnv
);
pQuery
->
rec
.
rows
=
getNumOfResult
(
pRuntimeEnv
);
if
(
pQuery
->
limit
.
offset
>
0
&&
pQuery
->
numOfFilterCols
>
0
&&
pQuery
->
rec
.
rows
>
0
)
{
if
(
pQuery
->
limit
.
offset
>
0
&&
pQuery
->
numOfFilterCols
>
0
&&
pQuery
->
rec
.
rows
>
0
)
{
skipResults
(
pRuntimeEnv
);
skipResults
(
pRuntimeEnv
);
...
@@ -4864,10 +4872,6 @@ static void tableIntervalProcessImpl(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start)
...
@@ -4864,10 +4872,6 @@ static void tableIntervalProcessImpl(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start)
while
(
1
)
{
while
(
1
)
{
scanOneTableDataBlocks
(
pRuntimeEnv
,
start
);
scanOneTableDataBlocks
(
pRuntimeEnv
,
start
);
if
(
IS_QUERY_KILLED
(
GET_QINFO_ADDR
(
pRuntimeEnv
)))
{
return
;
}
assert
(
!
Q_STATUS_EQUAL
(
pQuery
->
status
,
QUERY_NOT_COMPLETED
));
assert
(
!
Q_STATUS_EQUAL
(
pQuery
->
status
,
QUERY_NOT_COMPLETED
));
finalizeQueryResult
(
pRuntimeEnv
);
finalizeQueryResult
(
pRuntimeEnv
);
...
@@ -5788,7 +5792,7 @@ static bool isValidQInfo(void *param) {
...
@@ -5788,7 +5792,7 @@ static bool isValidQInfo(void *param) {
return
(
sig
==
(
uint64_t
)
pQInfo
);
return
(
sig
==
(
uint64_t
)
pQInfo
);
}
}
static
int32_t
initQInfo
(
SQueryTableMsg
*
pQueryMsg
,
void
*
tsdb
,
int32_t
vgId
,
SQInfo
*
pQInfo
,
bool
isSTable
,
void
*
param
,
_qinfo_free_fn_t
fn
)
{
static
int32_t
initQInfo
(
SQueryTableMsg
*
pQueryMsg
,
void
*
tsdb
,
int32_t
vgId
,
SQInfo
*
pQInfo
,
bool
isSTable
,
void
*
param
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SQuery
*
pQuery
=
pQInfo
->
runtimeEnv
.
pQuery
;
SQuery
*
pQuery
=
pQInfo
->
runtimeEnv
.
pQuery
;
...
@@ -5813,7 +5817,6 @@ static int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQ
...
@@ -5813,7 +5817,6 @@ static int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQ
}
}
pQInfo
->
param
=
param
;
pQInfo
->
param
=
param
;
pQInfo
->
freeFn
=
fn
;
if
(
pQInfo
->
tableqinfoGroupInfo
.
numOfTables
==
0
)
{
if
(
pQInfo
->
tableqinfoGroupInfo
.
numOfTables
==
0
)
{
qDebug
(
"QInfo:%p no table qualified for tag filter, abort query"
,
pQInfo
);
qDebug
(
"QInfo:%p no table qualified for tag filter, abort query"
,
pQInfo
);
...
@@ -5995,8 +5998,7 @@ typedef struct SQueryMgmt {
...
@@ -5995,8 +5998,7 @@ typedef struct SQueryMgmt {
pthread_mutex_t
lock
;
pthread_mutex_t
lock
;
}
SQueryMgmt
;
}
SQueryMgmt
;
int32_t
qCreateQueryInfo
(
void
*
tsdb
,
int32_t
vgId
,
SQueryTableMsg
*
pQueryMsg
,
void
*
param
,
_qinfo_free_fn_t
fn
,
int32_t
qCreateQueryInfo
(
void
*
tsdb
,
int32_t
vgId
,
SQueryTableMsg
*
pQueryMsg
,
void
*
param
,
qinfo_t
*
pQInfo
)
{
qinfo_t
*
pQInfo
)
{
assert
(
pQueryMsg
!=
NULL
&&
tsdb
!=
NULL
);
assert
(
pQueryMsg
!=
NULL
&&
tsdb
!=
NULL
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
@@ -6086,7 +6088,7 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, vo
...
@@ -6086,7 +6088,7 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, vo
goto
_over
;
goto
_over
;
}
}
code
=
initQInfo
(
pQueryMsg
,
tsdb
,
vgId
,
*
pQInfo
,
isSTableQuery
,
param
,
fn
);
code
=
initQInfo
(
pQueryMsg
,
tsdb
,
vgId
,
*
pQInfo
,
isSTableQuery
,
param
);
_over:
_over:
free
(
tagCond
);
free
(
tagCond
);
...
@@ -6105,43 +6107,25 @@ _over:
...
@@ -6105,43 +6107,25 @@ _over:
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
*
pQInfo
=
NULL
;
*
pQInfo
=
NULL
;
}
else
{
}
else
{
SQInfo
*
pq
=
(
SQInfo
*
)
(
*
pQInfo
);
//
SQInfo* pq = (SQInfo*) (*pQInfo);
T_REF_INC
(
pq
);
//
T_REF_INC(pq);
T_REF_INC
(
pq
);
//
T_REF_INC(pq);
}
}
// if failed to add ref for all meters in this query, abort current query
// if failed to add ref for all meters in this query, abort current query
return
code
;
return
code
;
}
}
static
void
doDestoryQueryInfo
(
SQInfo
*
pQInfo
)
{
assert
(
pQInfo
!=
NULL
);
qDebug
(
"QInfo:%p query completed"
,
pQInfo
);
queryCostStatis
(
pQInfo
);
// print the query cost summary
freeQInfo
(
pQInfo
);
}
void
qDestroyQueryInfo
(
qinfo_t
qHandle
)
{
void
qDestroyQueryInfo
(
qinfo_t
qHandle
)
{
SQInfo
*
pQInfo
=
(
SQInfo
*
)
qHandle
;
SQInfo
*
pQInfo
=
(
SQInfo
*
)
qHandle
;
if
(
!
isValidQInfo
(
pQInfo
))
{
if
(
!
isValidQInfo
(
pQInfo
))
{
return
;
return
;
}
}
int32_t
ref
=
T_REF_DEC
(
pQInfo
);
qDebug
(
"QInfo:%p query completed"
,
pQInfo
);
qDebug
(
"QInfo:%p dec refCount, value:%d"
,
pQInfo
,
ref
);
queryCostStatis
(
pQInfo
);
// print the query cost summary
freeQInfo
(
pQInfo
);
if
(
ref
==
0
)
{
_qinfo_free_fn_t
freeFp
=
pQInfo
->
freeFn
;
void
*
param
=
pQInfo
->
param
;
doDestoryQueryInfo
(
pQInfo
);
if
(
freeFp
!=
NULL
)
{
assert
(
param
!=
NULL
);
freeFp
(
param
);
}
}
}
}
void
qTableQuery
(
qinfo_t
qinfo
)
{
void
qTableQuery
(
qinfo_t
qinfo
)
{
...
@@ -6154,29 +6138,22 @@ void qTableQuery(qinfo_t qinfo) {
...
@@ -6154,29 +6138,22 @@ void qTableQuery(qinfo_t qinfo) {
if
(
IS_QUERY_KILLED
(
pQInfo
))
{
if
(
IS_QUERY_KILLED
(
pQInfo
))
{
qDebug
(
"QInfo:%p it is already killed, abort"
,
pQInfo
);
qDebug
(
"QInfo:%p it is already killed, abort"
,
pQInfo
);
sem_post
(
&
pQInfo
->
dataReady
);
sem_post
(
&
pQInfo
->
dataReady
);
qDestroyQueryInfo
(
pQInfo
);
return
;
return
;
}
}
if
(
pQInfo
->
tableqinfoGroupInfo
.
numOfTables
==
0
)
{
if
(
pQInfo
->
tableqinfoGroupInfo
.
numOfTables
==
0
)
{
qDebug
(
"QInfo:%p no table exists for query, abort"
,
pQInfo
);
qDebug
(
"QInfo:%p no table exists for query, abort"
,
pQInfo
);
sem_post
(
&
pQInfo
->
dataReady
);
sem_post
(
&
pQInfo
->
dataReady
);
qDestroyQueryInfo
(
pQInfo
);
return
;
return
;
}
}
int32_t
ret
=
setjmp
(
pQInfo
->
runtimeEnv
.
env
);
// error occurs, record the error code and return to client
// error occurs, record the error code and return to client
int32_t
ret
=
setjmp
(
pQInfo
->
runtimeEnv
.
env
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
pQInfo
->
code
=
ret
;
pQInfo
->
code
=
ret
;
qDebug
(
"QInfo:%p query abort due to error occurs, code:%s"
,
pQInfo
,
tstrerror
(
pQInfo
->
code
));
qDebug
(
"QInfo:%p query abort due to error
/cancel
occurs, code:%s"
,
pQInfo
,
tstrerror
(
pQInfo
->
code
));
sem_post
(
&
pQInfo
->
dataReady
);
sem_post
(
&
pQInfo
->
dataReady
);
qDestroyQueryInfo
(
pQInfo
);
return
;
return
;
}
}
...
@@ -6203,7 +6180,6 @@ void qTableQuery(qinfo_t qinfo) {
...
@@ -6203,7 +6180,6 @@ void qTableQuery(qinfo_t qinfo) {
}
}
sem_post
(
&
pQInfo
->
dataReady
);
sem_post
(
&
pQInfo
->
dataReady
);
qDestroyQueryInfo
(
pQInfo
);
}
}
int32_t
qRetrieveQueryResultInfo
(
qinfo_t
qinfo
)
{
int32_t
qRetrieveQueryResultInfo
(
qinfo_t
qinfo
)
{
...
@@ -6247,7 +6223,7 @@ bool qHasMoreResultsToRetrieve(qinfo_t qinfo) {
...
@@ -6247,7 +6223,7 @@ bool qHasMoreResultsToRetrieve(qinfo_t qinfo) {
}
}
if
(
ret
)
{
if
(
ret
)
{
T_REF_INC
(
pQInfo
);
//
T_REF_INC(pQInfo);
qDebug
(
"QInfo:%p has more results waits for client retrieve"
,
pQInfo
);
qDebug
(
"QInfo:%p has more results waits for client retrieve"
,
pQInfo
);
}
}
...
@@ -6304,7 +6280,6 @@ int32_t qKillQuery(qinfo_t qinfo) {
...
@@ -6304,7 +6280,6 @@ int32_t qKillQuery(qinfo_t qinfo) {
}
}
setQueryKilled
(
pQInfo
);
setQueryKilled
(
pQInfo
);
qDestroyQueryInfo
(
pQInfo
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -6449,6 +6424,7 @@ void freeqinfoFn(void *qhandle) {
...
@@ -6449,6 +6424,7 @@ void freeqinfoFn(void *qhandle) {
}
}
qKillQuery
(
*
handle
);
qKillQuery
(
*
handle
);
qDestroyQueryInfo
(
*
handle
);
}
}
void
*
qOpenQueryMgmt
(
int32_t
vgId
)
{
void
*
qOpenQueryMgmt
(
int32_t
vgId
)
{
...
@@ -6467,7 +6443,11 @@ void* qOpenQueryMgmt(int32_t vgId) {
...
@@ -6467,7 +6443,11 @@ void* qOpenQueryMgmt(int32_t vgId) {
return
pQueryHandle
;
return
pQueryHandle
;
}
}
void
qSetQueryMgmtClosed
(
void
*
pQMgmt
)
{
static
void
queryMgmtKillQueryFn
(
void
*
handle
)
{
qKillQuery
(
handle
);
}
void
qQueryMgmtNotifyClosed
(
void
*
pQMgmt
)
{
if
(
pQMgmt
==
NULL
)
{
if
(
pQMgmt
==
NULL
)
{
return
;
return
;
}
}
...
@@ -6479,7 +6459,7 @@ void qSetQueryMgmtClosed(void* pQMgmt) {
...
@@ -6479,7 +6459,7 @@ void qSetQueryMgmtClosed(void* pQMgmt) {
pQueryMgmt
->
closed
=
true
;
pQueryMgmt
->
closed
=
true
;
pthread_mutex_unlock
(
&
pQueryMgmt
->
lock
);
pthread_mutex_unlock
(
&
pQueryMgmt
->
lock
);
taosCacheRefresh
(
pQueryMgmt
->
qinfoPool
,
freeqinfo
Fn
);
taosCacheRefresh
(
pQueryMgmt
->
qinfoPool
,
queryMgmtKillQuery
Fn
);
}
}
void
qCleanupQueryMgmt
(
void
*
pQMgmt
)
{
void
qCleanupQueryMgmt
(
void
*
pQMgmt
)
{
...
...
src/query/src/qtokenizer.c
浏览文件 @
4a7d25c8
...
@@ -509,10 +509,11 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
...
@@ -509,10 +509,11 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
for
(
i
=
1
;
isdigit
(
z
[
i
]);
i
++
)
{
for
(
i
=
1
;
isdigit
(
z
[
i
]);
i
++
)
{
}
}
/* here is the 1a/2s/3m/9y */
/* here is the 1u/1a/2s/3m/9y */
if
((
z
[
i
]
==
'a'
||
z
[
i
]
==
's'
||
z
[
i
]
==
'm'
||
z
[
i
]
==
'h'
||
z
[
i
]
==
'd'
||
z
[
i
]
==
'n'
||
z
[
i
]
==
'y'
||
if
((
z
[
i
]
==
'u'
||
z
[
i
]
==
'a'
||
z
[
i
]
==
's'
||
z
[
i
]
==
'm'
||
z
[
i
]
==
'h'
||
z
[
i
]
==
'd'
||
z
[
i
]
==
'n'
||
z
[
i
]
==
'w'
||
z
[
i
]
==
'A'
||
z
[
i
]
==
'S'
||
z
[
i
]
==
'M'
||
z
[
i
]
==
'H'
||
z
[
i
]
==
'D'
||
z
[
i
]
==
'N'
||
z
[
i
]
==
'y'
||
z
[
i
]
==
'w'
||
z
[
i
]
==
'Y'
||
z
[
i
]
==
'W'
)
&&
z
[
i
]
==
'U'
||
z
[
i
]
==
'A'
||
z
[
i
]
==
'S'
||
z
[
i
]
==
'M'
||
z
[
i
]
==
'H'
||
z
[
i
]
==
'D'
||
z
[
i
]
==
'N'
||
z
[
i
]
==
'Y'
||
z
[
i
]
==
'W'
)
&&
(
isIdChar
[(
uint8_t
)
z
[
i
+
1
]]
==
0
))
{
(
isIdChar
[(
uint8_t
)
z
[
i
+
1
]]
==
0
))
{
*
tokenType
=
TK_VARIABLE
;
*
tokenType
=
TK_VARIABLE
;
i
+=
1
;
i
+=
1
;
...
...
src/query/src/qtsbuf.c
浏览文件 @
4a7d25c8
...
@@ -79,7 +79,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
...
@@ -79,7 +79,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
pTSBuf
->
numOfAlloc
=
header
.
numOfVnode
;
pTSBuf
->
numOfAlloc
=
header
.
numOfVnode
;
STSVnodeBlockInfoEx
*
tmp
=
realloc
(
pTSBuf
->
pData
,
sizeof
(
STSVnodeBlockInfoEx
)
*
pTSBuf
->
numOfAlloc
);
STSVnodeBlockInfoEx
*
tmp
=
realloc
(
pTSBuf
->
pData
,
sizeof
(
STSVnodeBlockInfoEx
)
*
pTSBuf
->
numOfAlloc
);
if
(
tmp
==
NULL
)
{
if
(
tmp
==
NULL
)
{
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
return
NULL
;
return
NULL
;
}
}
...
@@ -92,7 +92,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
...
@@ -92,7 +92,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
pTSBuf
->
tsOrder
=
header
.
tsOrder
;
pTSBuf
->
tsOrder
=
header
.
tsOrder
;
if
(
pTSBuf
->
tsOrder
!=
TSDB_ORDER_ASC
&&
pTSBuf
->
tsOrder
!=
TSDB_ORDER_DESC
)
{
if
(
pTSBuf
->
tsOrder
!=
TSDB_ORDER_ASC
&&
pTSBuf
->
tsOrder
!=
TSDB_ORDER_DESC
)
{
// tscError("invalid order info in buf:%d", pTSBuf->tsOrder);
// tscError("invalid order info in buf:%d", pTSBuf->tsOrder);
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
return
NULL
;
return
NULL
;
}
}
...
@@ -100,7 +100,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
...
@@ -100,7 +100,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
STSVnodeBlockInfo
*
buf
=
(
STSVnodeBlockInfo
*
)
calloc
(
1
,
infoSize
);
STSVnodeBlockInfo
*
buf
=
(
STSVnodeBlockInfo
*
)
calloc
(
1
,
infoSize
);
if
(
buf
==
NULL
)
{
if
(
buf
==
NULL
)
{
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
return
NULL
;
return
NULL
;
}
}
...
@@ -120,7 +120,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
...
@@ -120,7 +120,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
struct
stat
fileStat
;
struct
stat
fileStat
;
if
(
fstat
(
fileno
(
pTSBuf
->
f
),
&
fileStat
)
!=
0
)
{
if
(
fstat
(
fileno
(
pTSBuf
->
f
),
&
fileStat
)
!=
0
)
{
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
return
NULL
;
return
NULL
;
}
}
...
@@ -137,7 +137,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
...
@@ -137,7 +137,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
return
pTSBuf
;
return
pTSBuf
;
}
}
void
*
tsBufDest
or
y
(
STSBuf
*
pTSBuf
)
{
void
*
tsBufDest
ro
y
(
STSBuf
*
pTSBuf
)
{
if
(
pTSBuf
==
NULL
)
{
if
(
pTSBuf
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -920,13 +920,13 @@ static STSBuf* allocResForTSBuf(STSBuf* pTSBuf) {
...
@@ -920,13 +920,13 @@ static STSBuf* allocResForTSBuf(STSBuf* pTSBuf) {
pTSBuf
->
numOfAlloc
=
INITIAL_VNODEINFO_SIZE
;
pTSBuf
->
numOfAlloc
=
INITIAL_VNODEINFO_SIZE
;
pTSBuf
->
pData
=
calloc
(
pTSBuf
->
numOfAlloc
,
sizeof
(
STSVnodeBlockInfoEx
));
pTSBuf
->
pData
=
calloc
(
pTSBuf
->
numOfAlloc
,
sizeof
(
STSVnodeBlockInfoEx
));
if
(
pTSBuf
->
pData
==
NULL
)
{
if
(
pTSBuf
->
pData
==
NULL
)
{
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
return
NULL
;
return
NULL
;
}
}
pTSBuf
->
tsData
.
rawBuf
=
malloc
(
MEM_BUF_SIZE
);
pTSBuf
->
tsData
.
rawBuf
=
malloc
(
MEM_BUF_SIZE
);
if
(
pTSBuf
->
tsData
.
rawBuf
==
NULL
)
{
if
(
pTSBuf
->
tsData
.
rawBuf
==
NULL
)
{
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
return
NULL
;
return
NULL
;
}
}
...
@@ -936,13 +936,13 @@ static STSBuf* allocResForTSBuf(STSBuf* pTSBuf) {
...
@@ -936,13 +936,13 @@ static STSBuf* allocResForTSBuf(STSBuf* pTSBuf) {
pTSBuf
->
assistBuf
=
malloc
(
MEM_BUF_SIZE
);
pTSBuf
->
assistBuf
=
malloc
(
MEM_BUF_SIZE
);
if
(
pTSBuf
->
assistBuf
==
NULL
)
{
if
(
pTSBuf
->
assistBuf
==
NULL
)
{
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
return
NULL
;
return
NULL
;
}
}
pTSBuf
->
block
.
payload
=
malloc
(
MEM_BUF_SIZE
);
pTSBuf
->
block
.
payload
=
malloc
(
MEM_BUF_SIZE
);
if
(
pTSBuf
->
block
.
payload
==
NULL
)
{
if
(
pTSBuf
->
block
.
payload
==
NULL
)
{
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
return
NULL
;
return
NULL
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录