Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b20e2ed5
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b20e2ed5
编写于
10月 19, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): set correct last value.
上级
138fc0e0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
20 deletion
+29
-20
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
+18
-12
source/libs/executor/src/cachescanoperator.c
source/libs/executor/src/cachescanoperator.c
+10
-7
tests/system-test/2-query/last_row.py
tests/system-test/2-query/last_row.py
+1
-1
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
浏览文件 @
b20e2ed5
...
...
@@ -162,7 +162,7 @@ static int32_t doExtractCacheRow(SCacheRowsReader* pr, SLRUCache* lruCache, uint
int32_t
code
=
TSDB_CODE_SUCCESS
;
*
pRow
=
NULL
;
if
(
(
pr
->
type
&
CACHESCAN_RETRIEVE_LAST_ROW
)
==
CACHESCAN_RETRIEVE_LAST_ROW
)
{
if
(
HASTYPE
(
pr
->
type
,
CACHESCAN_RETRIEVE_LAST_ROW
)
)
{
code
=
tsdbCacheGetLastrowH
(
lruCache
,
uid
,
pr
->
pVnode
->
pTsdb
,
h
);
}
else
{
code
=
tsdbCacheGetLastH
(
lruCache
,
uid
,
pr
->
pVnode
->
pTsdb
,
h
);
...
...
@@ -231,7 +231,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
}
// retrieve the only one last row of all tables in the uid list.
if
(
(
pr
->
type
&
CACHESCAN_RETRIEVE_TYPE_SINGLE
)
==
CACHESCAN_RETRIEVE_TYPE_SINGLE
)
{
if
(
HASTYPE
(
pr
->
type
,
CACHESCAN_RETRIEVE_TYPE_SINGLE
)
)
{
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
STableKeyInfo
*
pKeyInfo
=
taosArrayGet
(
pr
->
pTableList
,
i
);
...
...
@@ -255,6 +255,15 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
hasRes
=
true
;
p
->
ts
=
pCol
->
ts
;
p
->
colVal
=
pCol
->
colVal
;
// only set value for last row query
if
(
HASTYPE
(
pr
->
type
,
CACHESCAN_RETRIEVE_LAST_ROW
))
{
if
(
taosArrayGetSize
(
pTableUidList
)
==
0
)
{
taosArrayPush
(
pTableUidList
,
&
pKeyInfo
->
uid
);
}
else
{
taosArraySet
(
pTableUidList
,
0
,
&
pKeyInfo
->
uid
);
}
}
}
}
else
{
SLastCol
*
p
=
taosArrayGet
(
pLastCols
,
slotId
);
...
...
@@ -268,15 +277,12 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
hasRes
=
true
;
p
->
ts
=
pColVal
->
ts
;
if
(
COL_VAL_IS_VALUE
(
&
pColVal
->
colVal
))
{
if
(
IS_VAR_DATA_TYPE
(
pColVal
->
colVal
.
type
))
{
uint8_t
*
px
=
p
->
colVal
.
value
.
pData
;
p
->
colVal
=
pColVal
->
colVal
;
p
->
colVal
.
value
.
pData
=
px
;
memcpy
(
px
,
pColVal
->
colVal
.
value
.
pData
,
pColVal
->
colVal
.
value
.
nData
);
}
else
{
p
->
colVal
=
pColVal
->
colVal
;
}
uint8_t
*
px
=
p
->
colVal
.
value
.
pData
;
p
->
colVal
=
pColVal
->
colVal
;
if
(
COL_VAL_IS_VALUE
(
&
pColVal
->
colVal
)
&&
IS_VAR_DATA_TYPE
(
pColVal
->
colVal
.
type
))
{
p
->
colVal
.
value
.
pData
=
px
;
memcpy
(
px
,
pColVal
->
colVal
.
value
.
pData
,
pColVal
->
colVal
.
value
.
nData
);
}
}
}
...
...
@@ -290,7 +296,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
saveOneRow
(
pLastCols
,
pResBlock
,
pr
,
slotIds
,
pRes
);
}
}
else
if
(
(
pr
->
type
&
CACHESCAN_RETRIEVE_TYPE_ALL
)
==
CACHESCAN_RETRIEVE_TYPE_ALL
)
{
}
else
if
(
HASTYPE
(
pr
->
type
,
CACHESCAN_RETRIEVE_TYPE_ALL
)
)
{
for
(
int32_t
i
=
pr
->
tableIndex
;
i
<
numOfTables
;
++
i
)
{
STableKeyInfo
*
pKeyInfo
=
taosArrayGet
(
pr
->
pTableList
,
i
);
code
=
doExtractCacheRow
(
pr
,
lruCache
,
pKeyInfo
->
uid
,
&
pRow
,
&
h
);
...
...
source/libs/executor/src/cachescanoperator.c
浏览文件 @
b20e2ed5
...
...
@@ -193,20 +193,23 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
pInfo
->
currentGroupIndex
+=
1
;
// check for tag values
// TODO NOTE: The uid of pInfo->pRes is required.
if
(
pInfo
->
pRes
->
info
.
rows
>
0
)
{
if
(
pInfo
->
pseudoExprSup
.
numOfExprs
>
0
)
{
SExprSupp
*
pSup
=
&
pInfo
->
pseudoExprSup
;
pInfo
->
pRes
->
info
.
uid
=
*
(
tb_uid_t
*
)
taosArrayGet
(
pInfo
->
pUidList
,
0
);
STableKeyInfo
*
pKeyInfo
=
taosArrayGet
(
pGroupTableList
,
0
);
pInfo
->
pRes
->
info
.
groupId
=
pKeyInfo
->
groupId
;
code
=
addTagPseudoColumnData
(
&
pInfo
->
readHandle
,
pSup
->
pExprInfo
,
pSup
->
numOfExprs
,
pInfo
->
pRes
,
GET_TASKID
(
pTaskInfo
));
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pTaskInfo
->
code
=
code
;
return
NULL
;
if
(
taosArrayGetSize
(
pInfo
->
pUidList
)
>
0
)
{
ASSERT
((
pInfo
->
retrieveType
&
CACHESCAN_RETRIEVE_LAST_ROW
)
==
CACHESCAN_RETRIEVE_LAST_ROW
);
pInfo
->
pRes
->
info
.
uid
=
*
(
tb_uid_t
*
)
taosArrayGet
(
pInfo
->
pUidList
,
0
);
code
=
addTagPseudoColumnData
(
&
pInfo
->
readHandle
,
pSup
->
pExprInfo
,
pSup
->
numOfExprs
,
pInfo
->
pRes
,
GET_TASKID
(
pTaskInfo
));
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pTaskInfo
->
code
=
code
;
return
NULL
;
}
}
}
...
...
tests/system-test/2-query/last_row.py
浏览文件 @
b20e2ed5
...
...
@@ -13,7 +13,7 @@ class TDTestCase:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
(),
Fals
e
)
tdSql
.
init
(
conn
.
cursor
(),
Tru
e
)
self
.
tb_nums
=
10
self
.
row_nums
=
20
self
.
ts
=
1434938400000
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录