Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
e1a91107
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看板
提交
e1a91107
编写于
2月 29, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bugs founded in regression test(limit offset on interval query failed).
上级
3642a950
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
141 addition
and
59 deletion
+141
-59
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+5
-3
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+10
-1
src/system/detail/src/vnodeQueryImpl.c
src/system/detail/src/vnodeQueryImpl.c
+126
-55
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
e1a91107
...
@@ -4596,9 +4596,11 @@ int32_t parseLimitClause(SQueryInfo* pQueryInfo, int32_t clauseIndex, SQuerySQL*
...
@@ -4596,9 +4596,11 @@ int32_t parseLimitClause(SQueryInfo* pQueryInfo, int32_t clauseIndex, SQuerySQL*
// handle the limit offset value, validate the limit
// handle the limit offset value, validate the limit
pQueryInfo
->
limit
=
pQuerySql
->
limit
;
pQueryInfo
->
limit
=
pQuerySql
->
limit
;
pQueryInfo
->
clauseLimit
=
pQueryInfo
->
limit
.
limit
;
pQueryInfo
->
clauseLimit
=
pQueryInfo
->
limit
.
limit
;
pQueryInfo
->
slimit
=
pQuerySql
->
slimit
;
pQueryInfo
->
slimit
=
pQuerySql
->
slimit
;
tscTrace
(
"%p limit:%d, offset:%"
PRId64
" slimit:%d, soffset:%"
PRId64
,
pSql
,
pQueryInfo
->
limit
.
limit
,
pQueryInfo
->
limit
.
offset
,
pQueryInfo
->
slimit
.
limit
,
pQueryInfo
->
slimit
.
offset
);
if
(
pQueryInfo
->
slimit
.
offset
<
0
||
pQueryInfo
->
limit
.
offset
<
0
)
{
if
(
pQueryInfo
->
slimit
.
offset
<
0
||
pQueryInfo
->
limit
.
offset
<
0
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg0
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg0
);
}
}
...
@@ -4631,7 +4633,7 @@ int32_t parseLimitClause(SQueryInfo* pQueryInfo, int32_t clauseIndex, SQuerySQL*
...
@@ -4631,7 +4633,7 @@ int32_t parseLimitClause(SQueryInfo* pQueryInfo, int32_t clauseIndex, SQuerySQL*
}
}
if
(
pQueryInfo
->
slimit
.
limit
==
0
)
{
if
(
pQueryInfo
->
slimit
.
limit
==
0
)
{
tscTrace
(
"%p limit 0, no output result"
,
pSql
);
tscTrace
(
"%p
s
limit 0, no output result"
,
pSql
);
pQueryInfo
->
command
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
pQueryInfo
->
command
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
src/client/src/tscUtil.c
浏览文件 @
e1a91107
...
@@ -215,7 +215,16 @@ bool tscIsTwoStageMergeMetricQuery(SQueryInfo* pQueryInfo, int32_t tableIndex) {
...
@@ -215,7 +215,16 @@ bool tscIsTwoStageMergeMetricQuery(SQueryInfo* pQueryInfo, int32_t tableIndex) {
}
}
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
tableIndex
);
if
(
pMeterMetaInfo
==
NULL
||
pMeterMetaInfo
->
pMetricMeta
==
NULL
)
{
if
(
pMeterMetaInfo
==
NULL
)
{
return
false
;
}
// for select query super table, the metricmeta can not be null in any cases.
if
(
pQueryInfo
->
command
==
TSDB_SQL_SELECT
&&
UTIL_METER_IS_SUPERTABLE
(
pMeterMetaInfo
))
{
assert
(
pMeterMetaInfo
->
pMetricMeta
!=
NULL
);
}
if
(
pMeterMetaInfo
->
pMetricMeta
==
NULL
)
{
return
false
;
return
false
;
}
}
...
...
src/system/detail/src/vnodeQueryImpl.c
浏览文件 @
e1a91107
...
@@ -1784,12 +1784,12 @@ static int32_t getNextQualifiedWindow(SQueryRuntimeEnv *pRuntimeEnv, STimeWindow
...
@@ -1784,12 +1784,12 @@ static int32_t getNextQualifiedWindow(SQueryRuntimeEnv *pRuntimeEnv, STimeWindow
continue
;
continue
;
}
}
if
(
pNextWin
->
ekey
>
pQuery
->
ekey
&&
QUERY_IS_ASC_QUERY
(
pQuery
))
{
//
if (pNextWin->ekey > pQuery->ekey && QUERY_IS_ASC_QUERY(pQuery)) {
pNextWin
->
ekey
=
pQuery
->
ekey
;
//
pNextWin->ekey = pQuery->ekey;
}
//
}
if
(
pNextWin
->
skey
<
pQuery
->
ekey
&&
!
QUERY_IS_ASC_QUERY
(
pQuery
))
{
//
if (pNextWin->skey < pQuery->ekey && !QUERY_IS_ASC_QUERY(pQuery)) {
pNextWin
->
skey
=
pQuery
->
ekey
;
//
pNextWin->skey = pQuery->ekey;
}
//
}
return
startPos
;
return
startPos
;
}
}
...
@@ -4113,53 +4113,37 @@ static bool forwardQueryStartPosIfNeeded(SQInfo *pQInfo, STableQuerySupportObj *
...
@@ -4113,53 +4113,37 @@ static bool forwardQueryStartPosIfNeeded(SQInfo *pQInfo, STableQuerySupportObj *
while
(
pQuery
->
limit
.
offset
>
0
)
{
while
(
pQuery
->
limit
.
offset
>
0
)
{
SBlockInfo
blockInfo
=
getBlockInfo
(
pRuntimeEnv
);
SBlockInfo
blockInfo
=
getBlockInfo
(
pRuntimeEnv
);
// time window ended in current data block
STimeWindow
tw
=
win
;
if
(
win
.
ekey
<=
blockInfo
.
keyLast
)
{
getNextTimeWindow
(
pQuery
,
&
tw
);
pQuery
->
limit
.
offset
-=
1
;
if
(
win
.
ekey
==
blockInfo
.
keyLast
)
{
// next time window starts from current data block
moveToNextBlock
(
pRuntimeEnv
,
step
,
searchFn
,
false
);
if
((
tw
.
skey
<=
blockInfo
.
keyLast
&&
QUERY_IS_ASC_QUERY
(
pQuery
))
||
if
(
Q_STATUS_EQUAL
(
pQuery
->
over
,
QUERY_NO_DATA_TO_CHECK
))
{
(
tw
.
ekey
>=
blockInfo
.
keyFirst
&&
!
QUERY_IS_ASC_QUERY
(
pQuery
)))
{
break
;
}
// next block does not included in time range, abort query
// query completed
blockInfo
=
getBlockInfo
(
pRuntimeEnv
);
if
((
tw
.
skey
>
pQuery
->
ekey
&&
QUERY_IS_ASC_QUERY
(
pQuery
))
||
if
((
blockInfo
.
keyFirst
>
pQuery
->
ekey
&&
QUERY_IS_ASC_QUERY
(
pQuery
))
||
(
tw
.
ekey
<
pQuery
->
ekey
&&
!
QUERY_IS_ASC_QUERY
(
pQuery
)))
{
(
blockInfo
.
keyLast
<
pQuery
->
ekey
&&
!
QUERY_IS_ASC_QUERY
(
pQuery
)))
{
setQueryStatus
(
pQuery
,
QUERY_COMPLETED
);
setQueryStatus
(
pQuery
,
QUERY_COMPLETED
);
break
;
break
;
}
}
// set the window that start from the next data block
// check its position in this block to make sure this time window covers data.
win
=
getActiveTimeWindow
(
pWindowResInfo
,
blockInfo
.
keyFirst
,
pQuery
);
}
else
{
// the time window is closed in current data block, load disk file block into memory to
// check the next time window
if
(
IS_DISK_DATA_BLOCK
(
pQuery
))
{
if
(
IS_DISK_DATA_BLOCK
(
pQuery
))
{
getTimestampInDiskBlock
(
pRuntimeEnv
,
0
);
getTimestampInDiskBlock
(
pRuntimeEnv
,
0
);
}
}
STimeWindow
nextWin
=
win
;
tw
=
win
;
int32_t
startPos
=
int32_t
startPos
=
getNextQualifiedWindow
(
pRuntimeEnv
,
&
tw
,
pWindowResInfo
,
&
blockInfo
,
primaryKey
,
searchFn
);
getNextQualifiedWindow
(
pRuntimeEnv
,
&
nextWin
,
pWindowResInfo
,
&
blockInfo
,
primaryKey
,
searchFn
);
assert
(
startPos
>
0
);
if
(
startPos
<
0
)
{
// failed to find the qualified time window
pQuery
->
limit
.
offset
-=
1
;
assert
((
nextWin
.
skey
>
pQuery
->
ekey
&&
QUERY_IS_ASC_QUERY
(
pQuery
))
||
(
nextWin
.
ekey
<
pQuery
->
ekey
&&
!
QUERY_IS_ASC_QUERY
(
pQuery
)));
setQueryStatus
(
pQuery
,
QUERY_COMPLETED
);
// set the abort info
break
;
}
else
{
// set the abort info
pQuery
->
pos
=
startPos
;
pQuery
->
pos
=
startPos
;
pQuery
->
lastKey
=
primaryKey
[
startPos
];
pQuery
->
lastKey
=
primaryKey
[
startPos
];
win
=
nextWin
;
win
=
tw
;
}
}
continue
;
continue
;
}
}
else
{
moveToNextBlock
(
pRuntimeEnv
,
step
,
searchFn
,
false
);
moveToNextBlock
(
pRuntimeEnv
,
step
,
searchFn
,
false
);
if
(
Q_STATUS_EQUAL
(
pQuery
->
over
,
QUERY_NO_DATA_TO_CHECK
))
{
if
(
Q_STATUS_EQUAL
(
pQuery
->
over
,
QUERY_NO_DATA_TO_CHECK
))
{
break
;
break
;
...
@@ -4171,6 +4155,92 @@ static bool forwardQueryStartPosIfNeeded(SQInfo *pQInfo, STableQuerySupportObj *
...
@@ -4171,6 +4155,92 @@ static bool forwardQueryStartPosIfNeeded(SQInfo *pQInfo, STableQuerySupportObj *
setQueryStatus
(
pQuery
,
QUERY_COMPLETED
);
setQueryStatus
(
pQuery
,
QUERY_COMPLETED
);
break
;
break
;
}
}
// set the window that start from the next data block
TSKEY
key
=
(
QUERY_IS_ASC_QUERY
(
pQuery
))
?
blockInfo
.
keyFirst
:
blockInfo
.
keyLast
;
STimeWindow
n
=
getActiveTimeWindow
(
pWindowResInfo
,
key
,
pQuery
);
// next data block are still covered by current time window
if
(
n
.
skey
==
win
.
skey
&&
n
.
ekey
==
win
.
ekey
)
{
// do nothing
}
else
{
pQuery
->
limit
.
offset
-=
1
;
// query completed
if
((
n
.
skey
>
pQuery
->
ekey
&&
QUERY_IS_ASC_QUERY
(
pQuery
))
||
(
n
.
ekey
<
pQuery
->
ekey
&&
!
QUERY_IS_ASC_QUERY
(
pQuery
)))
{
setQueryStatus
(
pQuery
,
QUERY_COMPLETED
);
break
;
}
// set the abort info
pQuery
->
pos
=
QUERY_IS_ASC_QUERY
(
pQuery
)
?
0
:
blockInfo
.
size
-
1
;
pQuery
->
lastKey
=
QUERY_IS_ASC_QUERY
(
pQuery
)
?
blockInfo
.
keyFirst
:
blockInfo
.
keyLast
;
win
=
n
;
if
(
pQuery
->
limit
.
offset
==
0
&&
IS_DISK_DATA_BLOCK
(
pQuery
))
{
getTimestampInDiskBlock
(
pRuntimeEnv
,
0
);
}
}
}
// if (win.ekey <= blockInfo.keyLast) {
// pQuery->limit.offset -= 1;
//
// if (win.ekey == blockInfo.keyLast) {
// moveToNextBlock(pRuntimeEnv, step, searchFn, false);
// if (Q_STATUS_EQUAL(pQuery->over, QUERY_NO_DATA_TO_CHECK)) {
// break;
// }
//
// // next block does not included in time range, abort query
// blockInfo = getBlockInfo(pRuntimeEnv);
// if ((blockInfo.keyFirst > pQuery->ekey && QUERY_IS_ASC_QUERY(pQuery)) ||
// (blockInfo.keyLast < pQuery->ekey && !QUERY_IS_ASC_QUERY(pQuery))) {
// setQueryStatus(pQuery, QUERY_COMPLETED);
// break;
// }
//
// // set the window that start from the next data block
// win = getActiveTimeWindow(pWindowResInfo, blockInfo.keyFirst, pQuery);
// } else {
// // the time window is closed in current data block, load disk file block into memory to
// // check the next time window
// if (IS_DISK_DATA_BLOCK(pQuery)) {
// getTimestampInDiskBlock(pRuntimeEnv, 0);
// }
//
// STimeWindow nextWin = win;
// int32_t startPos =
// getNextQualifiedWindow(pRuntimeEnv, &nextWin, pWindowResInfo, &blockInfo, primaryKey, searchFn);
//
// if (startPos < 0) { // failed to find the qualified time window
// assert((nextWin.skey > pQuery->ekey && QUERY_IS_ASC_QUERY(pQuery)) ||
// (nextWin.ekey < pQuery->ekey && !QUERY_IS_ASC_QUERY(pQuery)));
//
// setQueryStatus(pQuery, QUERY_COMPLETED);
// break;
// } else { // set the abort info
// pQuery->pos = startPos;
// pQuery->lastKey = primaryKey[startPos];
// win = nextWin;
// }
// }
//
// continue;
// }
//
// moveToNextBlock(pRuntimeEnv, step, searchFn, false);
// if (Q_STATUS_EQUAL(pQuery->over, QUERY_NO_DATA_TO_CHECK)) {
// break;
// }
//
// blockInfo = getBlockInfo(pRuntimeEnv);
// if ((blockInfo.keyFirst > pQuery->ekey && QUERY_IS_ASC_QUERY(pQuery)) ||
// (blockInfo.keyLast < pQuery->ekey && !QUERY_IS_ASC_QUERY(pQuery))) {
// setQueryStatus(pQuery, QUERY_COMPLETED);
// break;
// }
}
}
if
(
Q_STATUS_EQUAL
(
pQuery
->
over
,
QUERY_NO_DATA_TO_CHECK
|
QUERY_COMPLETED
)
||
pQuery
->
limit
.
offset
>
0
)
{
if
(
Q_STATUS_EQUAL
(
pQuery
->
over
,
QUERY_NO_DATA_TO_CHECK
|
QUERY_COMPLETED
)
||
pQuery
->
limit
.
offset
>
0
)
{
...
@@ -5291,6 +5361,7 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
...
@@ -5291,6 +5361,7 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
if
(
isIntervalQuery
(
pQuery
)
&&
IS_MASTER_SCAN
(
pRuntimeEnv
))
{
if
(
isIntervalQuery
(
pQuery
)
&&
IS_MASTER_SCAN
(
pRuntimeEnv
))
{
if
(
Q_STATUS_EQUAL
(
pQuery
->
over
,
QUERY_COMPLETED
|
QUERY_NO_DATA_TO_CHECK
))
{
if
(
Q_STATUS_EQUAL
(
pQuery
->
over
,
QUERY_COMPLETED
|
QUERY_NO_DATA_TO_CHECK
))
{
closeAllTimeWindow
(
&
pRuntimeEnv
->
windowResInfo
);
closeAllTimeWindow
(
&
pRuntimeEnv
->
windowResInfo
);
pRuntimeEnv
->
windowResInfo
.
curIndex
=
pRuntimeEnv
->
windowResInfo
.
size
-
1
;
}
else
if
(
Q_STATUS_EQUAL
(
pQuery
->
over
,
QUERY_RESBUF_FULL
))
{
// check if window needs to be closed
}
else
if
(
Q_STATUS_EQUAL
(
pQuery
->
over
,
QUERY_RESBUF_FULL
))
{
// check if window needs to be closed
SBlockInfo
blockInfo
=
getBlockInfo
(
pRuntimeEnv
);
SBlockInfo
blockInfo
=
getBlockInfo
(
pRuntimeEnv
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录