Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
07266ba9
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
未验证
提交
07266ba9
编写于
2月 05, 2021
作者:
H
haojun Liao
提交者:
GitHub
2月 05, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5141 from taosdata/hotfix/TD-2518
[TD-2518]support query data before 1970
上级
5e060605
fbfe4a3b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
12 deletion
+37
-12
src/common/inc/tdataformat.h
src/common/inc/tdataformat.h
+16
-0
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+18
-9
tests/pytest/insert/before_1970.py
tests/pytest/insert/before_1970.py
+3
-3
未找到文件。
src/common/inc/tdataformat.h
浏览文件 @
07266ba9
...
...
@@ -134,6 +134,22 @@ typedef uint64_t TKEY;
#define tdGetTKEY(key) (((TKEY)ABS(key)) | (TKEY_NEGATIVE_FLAG & (TKEY)(key)))
#define tdGetKey(tkey) (((TSKEY)((tkey)&TKEY_VALUE_FILTER)) * (TKEY_IS_NEGATIVE(tkey) ? -1 : 1))
#define MIN_TS_KEY ((TSKEY)0x8000000000000001)
#define MAX_TS_KEY ((TSKEY)0x3fffffffffffffff)
#define TD_TO_TKEY(key) tdGetTKEY(((key) < MIN_TS_KEY) ? MIN_TS_KEY : (((key) > MAX_TS_KEY) ? MAX_TS_KEY : key))
static
FORCE_INLINE
TKEY
keyToTkey
(
TSKEY
key
)
{
TSKEY
lkey
=
key
;
if
(
key
>
MAX_TS_KEY
)
{
lkey
=
MAX_TS_KEY
;
}
else
if
(
key
<
MIN_TS_KEY
)
{
lkey
=
MIN_TS_KEY
;
}
return
tdGetTKEY
(
lkey
);
}
static
FORCE_INLINE
int
tkeyComparFn
(
const
void
*
tkey1
,
const
void
*
tkey2
)
{
TSKEY
key1
=
tdGetKey
(
*
(
TKEY
*
)
tkey1
);
TSKEY
key2
=
tdGetKey
(
*
(
TKEY
*
)
tkey2
);
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
07266ba9
...
...
@@ -317,7 +317,7 @@ static STsdbQueryHandle* tsdbQueryTablesImpl(STsdbRepo* tsdb, STsdbQueryCond* pC
pQueryHandle
->
window
=
pCond
->
twindow
;
pQueryHandle
->
pTsdb
=
tsdb
;
pQueryHandle
->
type
=
TSDB_QUERY_TYPE_ALL
;
pQueryHandle
->
cur
.
fid
=
-
1
;
pQueryHandle
->
cur
.
fid
=
INT32_MIN
;
pQueryHandle
->
cur
.
win
=
TSWINDOW_INITIALIZER
;
pQueryHandle
->
checkFiles
=
true
;
pQueryHandle
->
activeIndex
=
0
;
// current active table index
...
...
@@ -478,16 +478,18 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh
if
(
pMemT
&&
pCheckInfo
->
tableId
.
tid
<
pMemT
->
maxTables
)
{
pMem
=
pMemT
->
tData
[
pCheckInfo
->
tableId
.
tid
];
if
(
pMem
!=
NULL
&&
pMem
->
uid
==
pCheckInfo
->
tableId
.
uid
)
{
// check uid
TKEY
tLastKey
=
keyToTkey
(
pCheckInfo
->
lastKey
);
pCheckInfo
->
iter
=
tSkipListCreateIterFromVal
(
pMem
->
pData
,
(
const
char
*
)
&
pCheckInfo
->
l
astKey
,
TSDB_DATA_TYPE_TIMESTAMP
,
order
);
tSkipListCreateIterFromVal
(
pMem
->
pData
,
(
const
char
*
)
&
tL
astKey
,
TSDB_DATA_TYPE_TIMESTAMP
,
order
);
}
}
if
(
pIMemT
&&
pCheckInfo
->
tableId
.
tid
<
pIMemT
->
maxTables
)
{
pIMem
=
pIMemT
->
tData
[
pCheckInfo
->
tableId
.
tid
];
if
(
pIMem
!=
NULL
&&
pIMem
->
uid
==
pCheckInfo
->
tableId
.
uid
)
{
// check uid
TKEY
tLastKey
=
keyToTkey
(
pCheckInfo
->
lastKey
);
pCheckInfo
->
iiter
=
tSkipListCreateIterFromVal
(
pIMem
->
pData
,
(
const
char
*
)
&
pCheckInfo
->
l
astKey
,
TSDB_DATA_TYPE_TIMESTAMP
,
order
);
tSkipListCreateIterFromVal
(
pIMem
->
pData
,
(
const
char
*
)
&
tL
astKey
,
TSDB_DATA_TYPE_TIMESTAMP
,
order
);
}
}
...
...
@@ -652,7 +654,7 @@ static bool hasMoreDataInCache(STsdbQueryHandle* pHandle) {
STsdbCfg
*
pCfg
=
&
pHandle
->
pTsdb
->
config
;
size_t
size
=
taosArrayGetSize
(
pHandle
->
pTableCheckInfo
);
assert
(
pHandle
->
activeIndex
<
size
&&
pHandle
->
activeIndex
>=
0
&&
size
>=
1
);
pHandle
->
cur
.
fid
=
-
1
;
pHandle
->
cur
.
fid
=
INT32_MIN
;
STableCheckInfo
*
pCheckInfo
=
taosArrayGet
(
pHandle
->
pTableCheckInfo
,
pHandle
->
activeIndex
);
...
...
@@ -1117,7 +1119,12 @@ int32_t doCopyRowsFromFileBlock(STsdbQueryHandle* pQueryHandle, int32_t capacity
if
(
pColInfo
->
info
.
colId
==
src
->
colId
)
{
if
(
pColInfo
->
info
.
type
!=
TSDB_DATA_TYPE_BINARY
&&
pColInfo
->
info
.
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
if
(
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
for
(
int32_t
n
=
0
;
n
<
num
;
n
++
)
{
TKEY
tkey
=
*
(
TKEY
*
)((
char
*
)
src
->
pData
+
bytes
*
start
+
n
*
sizeof
(
TKEY
));
*
(
TSKEY
*
)(
pData
+
n
*
sizeof
(
TSKEY
))
=
tdGetKey
(
tkey
);
}
}
else
if
(
pColInfo
->
info
.
type
!=
TSDB_DATA_TYPE_BINARY
&&
pColInfo
->
info
.
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
memmove
(
pData
,
(
char
*
)
src
->
pData
+
bytes
*
start
,
bytes
*
num
);
}
else
{
// handle the var-string
char
*
dst
=
pData
;
...
...
@@ -1225,7 +1232,6 @@ static void copyOneRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
break
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
*
(
uint64_t
*
)
pData
=
*
(
uint64_t
*
)
value
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
...
...
@@ -1234,6 +1240,9 @@ static void copyOneRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
case
TSDB_DATA_TYPE_DOUBLE
:
SET_DOUBLE_PTR
(
pData
,
value
);
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
*
(
TSKEY
*
)
pData
=
tdGetKey
(
*
(
TKEY
*
)
value
);
break
;
default:
memcpy
(
pData
,
value
,
pColInfo
->
info
.
bytes
);
}
...
...
@@ -1893,7 +1902,7 @@ static int32_t getFirstFileDataBlock(STsdbQueryHandle* pQueryHandle, bool* exist
assert
(
pQueryHandle
->
pFileGroup
==
NULL
);
}
cur
->
fid
=
-
1
;
// denote that there are no data in file anymore
cur
->
fid
=
INT32_MIN
;
// denote that there are no data in file anymore
*
exists
=
false
;
return
code
;
}
...
...
@@ -2496,7 +2505,7 @@ void tsdbRetrieveDataBlockInfo(TsdbQueryHandleT* pQueryHandle, SDataBlockInfo* p
STable
*
pTable
=
NULL
;
// there are data in file
if
(
pHandle
->
cur
.
fid
>=
0
)
{
if
(
pHandle
->
cur
.
fid
!=
INT32_MIN
)
{
STableBlockInfo
*
pBlockInfo
=
&
pHandle
->
pDataBlockInfo
[
cur
->
slot
];
pTable
=
pBlockInfo
->
pTableCheckInfo
->
pTableObj
;
}
else
{
...
...
@@ -2580,7 +2589,7 @@ SArray* tsdbRetrieveDataBlock(TsdbQueryHandleT* pQueryHandle, SArray* pIdList) {
*/
STsdbQueryHandle
*
pHandle
=
(
STsdbQueryHandle
*
)
pQueryHandle
;
if
(
pHandle
->
cur
.
fid
<
0
)
{
if
(
pHandle
->
cur
.
fid
==
INT32_MIN
)
{
return
pHandle
->
pColumns
;
}
else
{
STableBlockInfo
*
pBlockInfo
=
&
pHandle
->
pDataBlockInfo
[
pHandle
->
cur
.
slot
];
...
...
tests/pytest/insert/before_1970.py
浏览文件 @
07266ba9
...
...
@@ -41,7 +41,7 @@ class TDTestCase:
#TODO : should add more testcases
tdSql
.
execute
(
"insert into test values('1930-12-12 01:19:20.345', 1);"
)
tdSql
.
execute
(
"insert into test values('1969-12-30 23:59:59.999', 2);"
)
tdSql
.
execute
(
"insert into test values(-3600, 3);"
)
tdSql
.
execute
(
"insert into test values(-3600
001
, 3);"
)
tdSql
.
execute
(
"insert into test values('2020-10-20 14:02:53.770', 4);"
)
print
(
"==============insert data"
)
...
...
@@ -61,11 +61,11 @@ class TDTestCase:
print
(
"==============step4"
)
tdSql
.
execute
(
"use demo;"
)
tdSql
.
query
(
"select * from test;"
)
#
print(tdSql.queryResult)
print
(
tdSql
.
queryResult
)
tdSql
.
checkRows
(
4
)
tdSql
.
checkData
(
0
,
0
,
'1930-12-12 01:19:20.345000'
)
tdSql
.
checkData
(
1
,
0
,
'1969-12-30 23:59:59.999000'
)
tdSql
.
checkData
(
2
,
0
,
'1970-01-01 0
7:00:00.000
000'
)
tdSql
.
checkData
(
2
,
0
,
'1970-01-01 0
6:59:59.999
000'
)
tdSql
.
checkData
(
3
,
0
,
'2020-10-20 14:02:53.770000'
)
print
(
"==============check data"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录