Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
25d2821d
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看板
提交
25d2821d
编写于
6月 29, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225]fix bug found by regression test.
上级
51dc9fa4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
55 addition
and
14 deletion
+55
-14
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+2
-2
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+49
-12
tests/script/general/parser/single_row_in_tb_query.sim
tests/script/general/parser/single_row_in_tb_query.sim
+4
-0
未找到文件。
src/query/src/qExecutor.c
浏览文件 @
25d2821d
...
...
@@ -4145,8 +4145,8 @@ static SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, in
return
pFillCol
;
}
int32_t
doInitQInfo
(
SQInfo
*
pQInfo
,
STSBuf
*
pTsBuf
,
void
*
tsdb
,
void
*
sourceOptr
,
int32_t
tbScanner
,
SArray
*
pOperator
,
void
*
param
)
{
int32_t
doInitQInfo
(
SQInfo
*
pQInfo
,
STSBuf
*
pTsBuf
,
void
*
tsdb
,
void
*
sourceOptr
,
int32_t
tbScanner
,
SArray
*
pOperator
,
void
*
param
)
{
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
SQueryAttr
*
pQueryAttr
=
pQInfo
->
runtimeEnv
.
pQueryAttr
;
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
25d2821d
...
...
@@ -343,6 +343,15 @@ static SArray* createCheckInfoFromCheckInfo(STableCheckInfo* pCheckInfo, TSKEY s
return
pNew
;
}
static
bool
emptyQueryTimewindow
(
STsdbQueryHandle
*
pQueryHandle
)
{
assert
(
pQueryHandle
!=
NULL
);
STimeWindow
*
w
=
&
pQueryHandle
->
window
;
bool
asc
=
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
);
return
((
asc
&&
w
->
skey
>
w
->
ekey
)
||
(
!
asc
&&
w
->
ekey
>
w
->
skey
));
}
// Update the query time window according to the data time to live(TTL) information, in order to avoid to return
// the expired data to client, even it is queried already.
static
int64_t
getEarliestValidTimestamp
(
STsdbRepo
*
pTsdb
)
{
...
...
@@ -355,23 +364,27 @@ static int64_t getEarliestValidTimestamp(STsdbRepo* pTsdb) {
static
void
setQueryTimewindow
(
STsdbQueryHandle
*
pQueryHandle
,
STsdbQueryCond
*
pCond
)
{
pQueryHandle
->
window
=
pCond
->
twindow
;
bool
updateTs
=
false
;
int64_t
startTs
=
getEarliestValidTimestamp
(
pQueryHandle
->
pTsdb
);
if
(
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
{
if
(
startTs
>
pQueryHandle
->
window
.
skey
)
{
pQueryHandle
->
window
.
skey
=
startTs
;
pCond
->
twindow
.
skey
=
startTs
;
updateTs
=
true
;
}
assert
(
pQueryHandle
->
window
.
skey
<=
pQueryHandle
->
window
.
ekey
);
}
else
{
if
(
startTs
>
pQueryHandle
->
window
.
ekey
)
{
pQueryHandle
->
window
.
ekey
=
startTs
;
pCond
->
twindow
.
ekey
=
startTs
;
updateTs
=
true
;
}
assert
(
pQueryHandle
->
window
.
skey
>=
pQueryHandle
->
window
.
ekey
);
}
tsdbDebug
(
"%p update the query time window, old:%"
PRId64
" - %"
PRId64
", new:%"
PRId64
" - %"
PRId64
", 0x%"
PRIx64
,
pQueryHandle
,
pCond
->
twindow
.
skey
,
pCond
->
twindow
.
ekey
,
pQueryHandle
->
window
.
skey
,
pQueryHandle
->
window
.
ekey
,
pQueryHandle
->
qId
);
if
(
updateTs
)
{
tsdbDebug
(
"%p update the query time window, old:%"
PRId64
" - %"
PRId64
", new:%"
PRId64
" - %"
PRId64
", 0x%"
PRIx64
,
pQueryHandle
,
pCond
->
twindow
.
skey
,
pCond
->
twindow
.
ekey
,
pQueryHandle
->
window
.
skey
,
pQueryHandle
->
window
.
ekey
,
pQueryHandle
->
qId
);
}
}
static
STsdbQueryHandle
*
tsdbQueryTablesImpl
(
STsdbRepo
*
tsdb
,
STsdbQueryCond
*
pCond
,
uint64_t
qId
,
SMemRef
*
pMemRef
)
{
...
...
@@ -456,6 +469,9 @@ static STsdbQueryHandle* tsdbQueryTablesImpl(STsdbRepo* tsdb, STsdbQueryCond* pC
TsdbQueryHandleT
*
tsdbQueryTables
(
STsdbRepo
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
SMemRef
*
pRef
)
{
STsdbQueryHandle
*
pQueryHandle
=
tsdbQueryTablesImpl
(
tsdb
,
pCond
,
qId
,
pRef
);
if
(
emptyQueryTimewindow
(
pQueryHandle
))
{
return
(
TsdbQueryHandleT
*
)
pQueryHandle
;
}
STsdbMeta
*
pMeta
=
tsdbGetMeta
(
tsdb
);
assert
(
pMeta
!=
NULL
);
...
...
@@ -479,6 +495,15 @@ TsdbQueryHandleT* tsdbQueryTables(STsdbRepo* tsdb, STsdbQueryCond* pCond, STable
void
tsdbResetQueryHandle
(
TsdbQueryHandleT
queryHandle
,
STsdbQueryCond
*
pCond
)
{
STsdbQueryHandle
*
pQueryHandle
=
queryHandle
;
if
(
emptyQueryTimewindow
(
pQueryHandle
))
{
if
(
pCond
->
order
!=
pQueryHandle
->
order
)
{
pQueryHandle
->
order
=
pCond
->
order
;
SWAP
(
pQueryHandle
->
window
.
skey
,
pQueryHandle
->
window
.
ekey
,
int64_t
);
}
return
;
}
pQueryHandle
->
order
=
pCond
->
order
;
pQueryHandle
->
window
=
pCond
->
twindow
;
pQueryHandle
->
type
=
TSDB_QUERY_TYPE_ALL
;
...
...
@@ -1204,8 +1229,9 @@ static int32_t handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SBlock* p
static
int32_t
loadFileDataBlock
(
STsdbQueryHandle
*
pQueryHandle
,
SBlock
*
pBlock
,
STableCheckInfo
*
pCheckInfo
,
bool
*
exists
)
{
SQueryFilePos
*
cur
=
&
pQueryHandle
->
cur
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
bool
asc
=
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
);
if
(
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
)
{
if
(
asc
)
{
// query ended in/started from current block
if
(
pQueryHandle
->
window
.
ekey
<
pBlock
->
keyLast
||
pCheckInfo
->
lastKey
>
pBlock
->
keyFirst
)
{
if
((
code
=
doLoadFileDataBlock
(
pQueryHandle
,
pBlock
,
pCheckInfo
,
cur
->
slot
))
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -1226,7 +1252,7 @@ static int32_t loadFileDataBlock(STsdbQueryHandle* pQueryHandle, SBlock* pBlock,
assert
(
pCheckInfo
->
lastKey
<=
pBlock
->
keyLast
);
doMergeTwoLevelData
(
pQueryHandle
,
pCheckInfo
,
pBlock
);
}
else
{
// the whole block is loaded in to buffer
cur
->
pos
=
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
?
0
:
(
pBlock
->
numOfRows
-
1
);
cur
->
pos
=
asc
?
0
:
(
pBlock
->
numOfRows
-
1
);
code
=
handleDataMergeIfNeeded
(
pQueryHandle
,
pBlock
,
pCheckInfo
);
}
}
else
{
//desc order, query ended in current block
...
...
@@ -1246,7 +1272,7 @@ static int32_t loadFileDataBlock(STsdbQueryHandle* pQueryHandle, SBlock* pBlock,
assert
(
pCheckInfo
->
lastKey
>=
pBlock
->
keyFirst
);
doMergeTwoLevelData
(
pQueryHandle
,
pCheckInfo
,
pBlock
);
}
else
{
cur
->
pos
=
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
?
0
:
(
pBlock
->
numOfRows
-
1
);
cur
->
pos
=
asc
?
0
:
(
pBlock
->
numOfRows
-
1
);
code
=
handleDataMergeIfNeeded
(
pQueryHandle
,
pBlock
,
pCheckInfo
);
}
}
...
...
@@ -2717,6 +2743,11 @@ static bool loadDataBlockFromTableSeq(STsdbQueryHandle* pQueryHandle) {
bool
tsdbNextDataBlock
(
TsdbQueryHandleT
pHandle
)
{
STsdbQueryHandle
*
pQueryHandle
=
(
STsdbQueryHandle
*
)
pHandle
;
if
(
emptyQueryTimewindow
(
pQueryHandle
))
{
tsdbDebug
(
"%p query window not overlaps with the data set, no result returned, 0x%"
PRIx64
,
pQueryHandle
,
pQueryHandle
->
qId
);
return
false
;
}
int64_t
stime
=
taosGetTimestampUs
();
int64_t
elapsedTime
=
stime
;
...
...
@@ -3669,15 +3700,21 @@ void tsdbCleanupQueryHandle(TsdbQueryHandleT queryHandle) {
return
;
}
pQueryHandle
->
pTableCheckInfo
=
destroyTableCheckInfo
(
pQueryHandle
->
pTableCheckInfo
);
pQueryHandle
->
pColumns
=
doFreeColumnInfoData
(
pQueryHandle
->
pColumns
);
taosArrayDestroy
(
pQueryHandle
->
defaultLoadColumn
);
tfree
(
pQueryHandle
->
pDataBlockInfo
);
tfree
(
pQueryHandle
->
statis
);
// todo check error
tsdbMayUnTakeMemSnapshot
(
pQueryHandle
);
if
(
!
emptyQueryTimewindow
(
pQueryHandle
))
{
tsdbMayUnTakeMemSnapshot
(
pQueryHandle
);
}
else
{
assert
(
pQueryHandle
->
pTableCheckInfo
==
NULL
);
}
if
(
pQueryHandle
->
pTableCheckInfo
!=
NULL
)
{
pQueryHandle
->
pTableCheckInfo
=
destroyTableCheckInfo
(
pQueryHandle
->
pTableCheckInfo
);
}
tsdbDestroyReadH
(
&
pQueryHandle
->
rhelper
);
...
...
tests/script/general/parser/single_row_in_tb_query.sim
浏览文件 @
25d2821d
...
...
@@ -193,3 +193,7 @@ endi
if $data04 != 1 then
return -1
endi
print ===============>safty check TD-4927
sql select first(ts, c1) from sr_stb where ts<1 group by t1;
sql select first(ts, c1) from sr_stb where ts>0 and ts<1;
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录