Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0474e56a
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
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看板
提交
0474e56a
编写于
12月 13, 2021
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-11970]<fix>: support timestamp arithmetic operation on timestamp tags
上级
82bdd5a1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
7 deletion
+28
-7
src/common/inc/tvariant.h
src/common/inc/tvariant.h
+2
-0
src/common/src/tvariant.c
src/common/src/tvariant.c
+26
-7
未找到文件。
src/common/inc/tvariant.h
浏览文件 @
0474e56a
...
@@ -41,6 +41,8 @@ bool tVariantIsValid(tVariant *pVar);
...
@@ -41,6 +41,8 @@ bool tVariantIsValid(tVariant *pVar);
void
tVariantCreate
(
tVariant
*
pVar
,
SStrToken
*
token
);
void
tVariantCreate
(
tVariant
*
pVar
,
SStrToken
*
token
);
void
tVariantCreateExt
(
tVariant
*
pVar
,
SStrToken
*
token
,
int32_t
optrType
);
void
tVariantCreateFromBinary
(
tVariant
*
pVar
,
const
char
*
pz
,
size_t
len
,
uint32_t
type
);
void
tVariantCreateFromBinary
(
tVariant
*
pVar
,
const
char
*
pz
,
size_t
len
,
uint32_t
type
);
void
tVariantDestroy
(
tVariant
*
pV
);
void
tVariantDestroy
(
tVariant
*
pV
);
...
...
src/common/src/tvariant.c
浏览文件 @
0474e56a
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include "hash.h"
#include "hash.h"
#include "taos.h"
#include "taos.h"
#include "taoserror.h"
#include "taosdef.h"
#include "taosdef.h"
#include "ttoken.h"
#include "ttoken.h"
#include "ttokendef.h"
#include "ttokendef.h"
...
@@ -24,6 +25,10 @@
...
@@ -24,6 +25,10 @@
#include "tvariant.h"
#include "tvariant.h"
void
tVariantCreate
(
tVariant
*
pVar
,
SStrToken
*
token
)
{
void
tVariantCreate
(
tVariant
*
pVar
,
SStrToken
*
token
)
{
tVariantCreateExt
(
pVar
,
token
,
TK_ID
);
}
void
tVariantCreateExt
(
tVariant
*
pVar
,
SStrToken
*
token
,
int32_t
optrType
)
{
int32_t
ret
=
0
;
int32_t
ret
=
0
;
int32_t
type
=
token
->
type
;
int32_t
type
=
token
->
type
;
...
@@ -47,7 +52,7 @@ void tVariantCreate(tVariant *pVar, SStrToken *token) {
...
@@ -47,7 +52,7 @@ void tVariantCreate(tVariant *pVar, SStrToken *token) {
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_INT
:{
case
TSDB_DATA_TYPE_INT
:{
ret
=
tStrToInteger
(
token
->
z
,
token
->
type
,
token
->
n
,
&
pVar
->
i64
,
true
);
ret
=
tStrToInteger
(
token
->
z
,
token
->
type
,
token
->
n
,
&
pVar
->
i64
,
true
);
if
(
ret
!=
0
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
SStrToken
t
=
{
0
};
SStrToken
t
=
{
0
};
tGetToken
(
token
->
z
,
&
t
.
type
);
tGetToken
(
token
->
z
,
&
t
.
type
);
if
(
t
.
type
==
TK_MINUS
)
{
// it is a signed number which is greater than INT64_MAX or less than INT64_MIN
if
(
t
.
type
==
TK_MINUS
)
{
// it is a signed number which is greater than INT64_MAX or less than INT64_MIN
...
@@ -57,7 +62,7 @@ void tVariantCreate(tVariant *pVar, SStrToken *token) {
...
@@ -57,7 +62,7 @@ void tVariantCreate(tVariant *pVar, SStrToken *token) {
// data overflow, try unsigned parse the input number
// data overflow, try unsigned parse the input number
ret
=
tStrToInteger
(
token
->
z
,
token
->
type
,
token
->
n
,
&
pVar
->
i64
,
false
);
ret
=
tStrToInteger
(
token
->
z
,
token
->
type
,
token
->
n
,
&
pVar
->
i64
,
false
);
if
(
ret
!=
0
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
pVar
->
nType
=
-
1
;
// -1 means error type
pVar
->
nType
=
-
1
;
// -1 means error type
return
;
return
;
}
}
...
@@ -78,15 +83,29 @@ void tVariantCreate(tVariant *pVar, SStrToken *token) {
...
@@ -78,15 +83,29 @@ void tVariantCreate(tVariant *pVar, SStrToken *token) {
break
;
break
;
}
}
case
TSDB_DATA_TYPE_TIMESTAMP
:
{
case
TSDB_DATA_TYPE_TIMESTAMP
:
{
pVar
->
i64
=
taosGetTimestamp
(
TSDB_TIME_PRECISION_NANO
);
if
(
optrType
==
TK_NOW
)
{
break
;
pVar
->
i64
=
taosGetTimestamp
(
TSDB_TIME_PRECISION_NANO
);
}
}
else
if
(
optrType
==
TK_PLUS
||
optrType
==
TK_MINUS
)
{
char
unit
=
0
;
ret
=
parseAbsoluteDuration
(
token
->
z
,
token
->
n
,
&
pVar
->
i64
,
&
unit
,
TSDB_TIME_PRECISION_NANO
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
pVar
->
nType
=
-
1
;
// -1 means error type
return
;
}
if
(
optrType
==
TK_PLUS
)
{
pVar
->
i64
+=
taosGetTimestamp
(
TSDB_TIME_PRECISION_NANO
);
}
else
{
pVar
->
i64
=
taosGetTimestamp
(
TSDB_TIME_PRECISION_NANO
)
-
pVar
->
i64
;
}
}
break
;
}
default:
{
// nType == 0 means the null value
default:
{
// nType == 0 means the null value
type
=
TSDB_DATA_TYPE_NULL
;
type
=
TSDB_DATA_TYPE_NULL
;
}
}
}
}
pVar
->
nType
=
type
;
pVar
->
nType
=
type
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录