Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
codyshao
TDengine
提交
392c23c7
T
TDengine
项目概览
codyshao
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
2
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,发现更多精彩内容 >>
提交
392c23c7
编写于
5月 21, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] fix bugs in limit/offset
上级
6962a823
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
23 deletion
+26
-23
src/client/src/tscSecondaryMerge.c
src/client/src/tscSecondaryMerge.c
+15
-15
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+11
-8
未找到文件。
src/client/src/tscSecondaryMerge.c
浏览文件 @
392c23c7
...
...
@@ -808,18 +808,19 @@ void adjustLoserTreeFromNewData(SLocalReducer *pLocalReducer, SLocalDataSource *
}
}
void
savePrevRecordAndSetupInterpoInfo
(
SLocalReducer
*
pLocalReducer
,
SQueryInfo
*
pQueryInfo
,
SFillInfo
*
pFillInfo
)
{
void
savePrevRecordAndSetupInterpoInfo
(
SLocalReducer
*
pLocalReducer
,
SQueryInfo
*
pQueryInfo
,
SFillInfo
*
pFillInfo
)
{
// discard following dataset in the same group and reset the interpolation information
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
int16_t
prec
=
tinfo
.
precision
;
int64_t
stime
=
(
pQueryInfo
->
window
.
skey
<
pQueryInfo
->
window
.
ekey
)
?
pQueryInfo
->
window
.
skey
:
pQueryInfo
->
window
.
ekey
;
int64_t
revisedSTime
=
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
slidingTimeUnit
,
prec
);
taosResetFillInfo
(
pFillInfo
,
revisedSTime
);
if
(
pFillInfo
!=
NULL
)
{
int64_t
stime
=
(
pQueryInfo
->
window
.
skey
<
pQueryInfo
->
window
.
ekey
)
?
pQueryInfo
->
window
.
skey
:
pQueryInfo
->
window
.
ekey
;
int64_t
revisedSTime
=
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
slidingTime
,
pQueryInfo
->
slidingTimeUnit
,
tinfo
.
precision
);
taosResetFillInfo
(
pFillInfo
,
revisedSTime
);
}
pLocalReducer
->
discard
=
true
;
pLocalReducer
->
discardData
->
num
=
0
;
...
...
@@ -915,13 +916,12 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
if
(
pQueryInfo
->
limit
.
limit
>=
0
&&
pRes
->
numOfClauseTotal
>
pQueryInfo
->
limit
.
limit
)
{
/* impose the limitation of output rows on the final result */
int32_t
prevSize
=
pFinalDataPage
->
num
;
int32_t
overFlow
=
pRes
->
numOfClauseTotal
-
pQueryInfo
->
limit
.
limit
;
assert
(
overFlow
<
pRes
->
numOfRows
);
int32_t
overflow
=
pRes
->
numOfClauseTotal
-
pQueryInfo
->
limit
.
limit
;
assert
(
overflow
<
pRes
->
numOfRows
);
pRes
->
numOfClauseTotal
=
pQueryInfo
->
limit
.
limit
;
pRes
->
numOfRows
-=
over
F
low
;
pFinalDataPage
->
num
-=
over
F
low
;
pRes
->
numOfRows
-=
over
f
low
;
pFinalDataPage
->
num
-=
over
f
low
;
tColModelCompact
(
pLocalReducer
->
resColModel
,
pFinalDataPage
,
prevSize
);
...
...
@@ -988,13 +988,13 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
if
(
pRes
->
numOfRows
>
0
)
{
if
(
pQueryInfo
->
limit
.
limit
>=
0
&&
pRes
->
numOfClauseTotal
>
pQueryInfo
->
limit
.
limit
)
{
int32_t
over
F
low
=
pRes
->
numOfClauseTotal
-
pQueryInfo
->
limit
.
limit
;
pRes
->
numOfRows
-=
over
F
low
;
int32_t
over
f
low
=
pRes
->
numOfClauseTotal
-
pQueryInfo
->
limit
.
limit
;
pRes
->
numOfRows
-=
over
f
low
;
assert
(
pRes
->
numOfRows
>=
0
);
pRes
->
numOfClauseTotal
=
pQueryInfo
->
limit
.
limit
;
pFinalDataPage
->
num
-=
over
F
low
;
pFinalDataPage
->
num
-=
over
f
low
;
/* set remain data to be discarded, and reset the interpolation information */
savePrevRecordAndSetupInterpoInfo
(
pLocalReducer
,
pQueryInfo
,
pFillInfo
);
...
...
src/query/src/qExecutor.c
浏览文件 @
392c23c7
...
...
@@ -3030,11 +3030,13 @@ static void updateTableQueryInfoForReverseScan(SQuery *pQuery, STableQueryInfo *
// order has change already!
int32_t
step
=
GET_FORWARD_DIRECTION_FACTOR
(
pQuery
->
order
.
order
);
if
(
!
QUERY_IS_ASC_QUERY
(
pQuery
))
{
assert
(
pTableQueryInfo
->
win
.
ekey
>=
pTableQueryInfo
->
lastKey
+
step
);
}
else
{
assert
(
pTableQueryInfo
->
win
.
ekey
<=
pTableQueryInfo
->
lastKey
+
step
);
}
// TODO validate the assertion
// if (!QUERY_IS_ASC_QUERY(pQuery)) {
// assert(pTableQueryInfo->win.ekey >= pTableQueryInfo->lastKey + step);
// } else {
// assert(pTableQueryInfo->win.ekey <= pTableQueryInfo->lastKey + step);
// }
pTableQueryInfo
->
win
.
ekey
=
pTableQueryInfo
->
lastKey
+
step
;
...
...
@@ -3113,7 +3115,7 @@ void disableFuncInReverseScan(SQInfo *pQInfo) {
void
switchCtxOrder
(
SQueryRuntimeEnv
*
pRuntimeEnv
)
{
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutput
;
++
i
)
{
SWITCH_ORDER
(
pRuntimeEnv
->
pCtx
[
i
]
.
order
);
SWITCH_ORDER
(
pRuntimeEnv
->
pCtx
[
i
].
order
);
}
}
...
...
@@ -4384,10 +4386,11 @@ static int64_t queryOnDataBlocks(SQInfo *pQInfo) {
SArray
*
pDataBlock
=
loadDataBlockOnDemand
(
pRuntimeEnv
,
pQueryHandle
,
&
blockInfo
,
&
pStatis
);
TSKEY
nextKey
=
blockInfo
.
window
.
skey
;
if
(
!
isIntervalQuery
(
pQuery
))
{
setExecutionContext
(
pQInfo
,
&
pTableQueryInfo
->
id
,
pTableQueryInfo
->
groupIdx
,
nextKey
);
int32_t
step
=
QUERY_IS_ASC_QUERY
(
pQuery
)
?
1
:-
1
;
setExecutionContext
(
pQInfo
,
&
pTableQueryInfo
->
id
,
pTableQueryInfo
->
groupIdx
,
blockInfo
.
window
.
ekey
+
step
);
}
else
{
// interval query
TSKEY
nextKey
=
blockInfo
.
window
.
skey
;
setIntervalQueryRange
(
pQInfo
,
nextKey
);
int32_t
ret
=
setAdditionalInfo
(
pQInfo
,
&
pTableQueryInfo
->
id
,
pTableQueryInfo
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录