Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Mz丶苗
TDengine
提交
b77b767a
T
TDengine
项目概览
Mz丶苗
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b77b767a
编写于
9月 03, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-1317]
上级
0ef20b37
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
17 deletion
+27
-17
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+14
-14
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+7
-2
tests/script/general/parser/lastrow_query.sim
tests/script/general/parser/lastrow_query.sim
+6
-1
未找到文件。
src/query/src/qExecutor.c
浏览文件 @
b77b767a
...
...
@@ -1951,36 +1951,36 @@ static void changeExecuteScanOrder(SQInfo *pQInfo, SQueryTableMsg* pQueryMsg, bo
// todo handle the case the the order irrelevant query type mixed up with order critical query type
// descending order query for last_row query
if
(
isFirstLastRowQuery
(
pQuery
))
{
if
(
isFirstLastRowQuery
(
pQuery
)
&&
!
QUERY_IS_ASC_QUERY
(
pQuery
)
)
{
qDebug
(
"QInfo:%p scan order changed for last_row query, old:%d, new:%d"
,
GET_QINFO_ADDR
(
pQuery
),
pQuery
->
order
.
order
,
TSDB_ORDER_ASC
);
SWAP
(
pQuery
->
window
.
skey
,
pQuery
->
window
.
ekey
,
TSKEY
);
pQuery
->
order
.
order
=
TSDB_ORDER_ASC
;
if
(
pQuery
->
window
.
skey
>
pQuery
->
window
.
ekey
)
{
SWAP
(
pQuery
->
window
.
skey
,
pQuery
->
window
.
ekey
,
TSKEY
);
}
assert
(
pQuery
->
window
.
skey
<=
pQuery
->
window
.
ekey
);
doExchangeTimeWindow
(
pQInfo
,
&
pQuery
->
window
);
return
;
}
if
(
isGroupbyNormalCol
(
pQuery
->
pGroupbyExpr
)
&&
pQuery
->
order
.
order
==
TSDB_ORDER_DESC
)
{
if
(
isGroupbyNormalCol
(
pQuery
->
pGroupbyExpr
)
&&
!
QUERY_IS_ASC_QUERY
(
pQuery
)
)
{
pQuery
->
order
.
order
=
TSDB_ORDER_ASC
;
if
(
pQuery
->
window
.
skey
>
pQuery
->
window
.
ekey
)
{
SWAP
(
pQuery
->
window
.
skey
,
pQuery
->
window
.
ekey
,
TSKEY
);
}
SWAP
(
pQuery
->
window
.
skey
,
pQuery
->
window
.
ekey
,
TSKEY
);
assert
(
pQuery
->
window
.
skey
<=
pQuery
->
window
.
ekey
);
doExchangeTimeWindow
(
pQInfo
,
&
pQuery
->
window
);
return
;
}
if
(
isPointInterpoQuery
(
pQuery
)
&&
pQuery
->
intervalTime
==
0
)
{
if
(
!
QUERY_IS_ASC_QUERY
(
pQuery
))
{
qDebug
(
msg
,
GET_QINFO_ADDR
(
pQuery
),
"interp"
,
pQuery
->
order
.
order
,
TSDB_ORDER_ASC
,
pQuery
->
window
.
skey
,
pQuery
->
window
.
ekey
,
pQuery
->
window
.
ekey
,
pQuery
->
window
.
skey
);
SWAP
(
pQuery
->
window
.
skey
,
pQuery
->
window
.
ekey
,
TSKEY
);
}
if
(
isPointInterpoQuery
(
pQuery
)
&&
(
pQuery
->
intervalTime
==
0
)
&&
!
QUERY_IS_ASC_QUERY
(
pQuery
))
{
qDebug
(
msg
,
GET_QINFO_ADDR
(
pQuery
),
"interp"
,
pQuery
->
order
.
order
,
TSDB_ORDER_ASC
,
pQuery
->
window
.
skey
,
pQuery
->
window
.
ekey
,
pQuery
->
window
.
ekey
,
pQuery
->
window
.
skey
);
SWAP
(
pQuery
->
window
.
skey
,
pQuery
->
window
.
ekey
,
TSKEY
);
pQuery
->
order
.
order
=
TSDB_ORDER_ASC
;
assert
(
pQuery
->
window
.
skey
<=
pQuery
->
window
.
ekey
);
doExchangeTimeWindow
(
pQInfo
,
&
pQuery
->
window
);
return
;
}
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
b77b767a
...
...
@@ -295,9 +295,10 @@ out_of_memory:
}
TsdbQueryHandleT
tsdbQueryLastRow
(
TSDB_REPO_T
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
void
*
qinfo
)
{
pCond
->
order
=
TSDB_ORDER_ASC
;
pCond
->
twindow
=
changeTableGroupByLastrow
(
groupList
);
STsdbQueryHandle
*
pQueryHandle
=
(
STsdbQueryHandle
*
)
tsdbQueryTables
(
tsdb
,
pCond
,
groupList
,
qinfo
);
assert
(
pCond
->
order
==
TSDB_ORDER_ASC
&&
pCond
->
twindow
.
skey
<=
pCond
->
twindow
.
ekey
);
return
pQueryHandle
;
}
...
...
@@ -1982,7 +1983,6 @@ STimeWindow changeTableGroupByLastrow(STableGroupInfo *groupList) {
STimeWindow
window
=
{
INT64_MAX
,
INT64_MIN
};
// NOTE: starts from the buffer in case of descending timestamp order check data blocks
// todo consider the query time window, current last_row does not apply the query time window
size_t
numOfGroups
=
taosArrayGetSize
(
groupList
->
pGroupList
);
for
(
int32_t
j
=
0
;
j
<
numOfGroups
;
++
j
)
{
SArray
*
pGroup
=
taosArrayGetP
(
groupList
->
pGroupList
,
j
);
...
...
@@ -2019,6 +2019,11 @@ STimeWindow changeTableGroupByLastrow(STableGroupInfo *groupList) {
}
}
// window does not being updated, so set the original
if
(
window
.
skey
==
INT64_MAX
&&
window
.
ekey
==
INT64_MIN
)
{
window
=
TSWINDOW_INITIALIZER
;
}
return
window
;
}
...
...
tests/script/general/parser/lastrow_query.sim
浏览文件 @
b77b767a
...
...
@@ -153,4 +153,9 @@ if $rows != 46 then
return -1
endi
print ========>td-1317, empty table last_row query crashed
sql create table t1(ts timestamp, k int)
sql select last_row(*) from t1
if $rows != 0 then
return -1
endi
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录