Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
7cdb6c3f
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看板
提交
7cdb6c3f
编写于
9月 16, 2020
作者:
B
Bomin Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
td-1245: disable natual duration in 'insert'&'where'
上级
9c219df2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
18 addition
and
59 deletion
+18
-59
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+1
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+3
-3
src/os/inc/osTime.h
src/os/inc/osTime.h
+2
-4
src/os/src/detail/osTime.c
src/os/src/detail/osTime.c
+11
-12
src/query/src/qParserImpl.c
src/query/src/qParserImpl.c
+1
-39
未找到文件。
src/client/src/tscParseInsert.c
浏览文件 @
7cdb6c3f
...
...
@@ -142,7 +142,7 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
return
tscInvalidSQLErrMsg
(
error
,
"value expected in timestamp"
,
sToken
.
z
);
}
if
(
getTimestampInUsFromStr
(
valueToken
.
z
,
valueToken
.
n
,
&
interval
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
parseAbsoluteDuration
(
valueToken
.
z
,
valueToken
.
n
,
&
interval
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
...
...
src/client/src/tscSQLParser.c
浏览文件 @
7cdb6c3f
...
...
@@ -596,7 +596,7 @@ int32_t parseIntervalClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQ
// interval is not null
SStrToken
*
t
=
&
pQuerySql
->
interval
;
if
(
parseDuration
(
t
->
z
,
t
->
n
,
&
pQueryInfo
->
interval
.
interval
,
&
pQueryInfo
->
interval
.
intervalUnit
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
parse
Natual
Duration
(
t
->
z
,
t
->
n
,
&
pQueryInfo
->
interval
.
interval
,
&
pQueryInfo
->
interval
.
intervalUnit
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
...
...
@@ -693,7 +693,7 @@ int32_t parseOffsetClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQue
return
TSDB_CODE_SUCCESS
;
}
if
(
parseDuration
(
t
->
z
,
t
->
n
,
&
pQueryInfo
->
interval
.
offset
,
&
pQueryInfo
->
interval
.
offsetUnit
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
parse
Natual
Duration
(
t
->
z
,
t
->
n
,
&
pQueryInfo
->
interval
.
offset
,
&
pQueryInfo
->
interval
.
offsetUnit
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
...
...
@@ -751,7 +751,7 @@ int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
getTimestampInUsFromStr
(
pSliding
->
z
,
pSliding
->
n
,
&
pQueryInfo
->
interval
.
sliding
);
parseAbsoluteDuration
(
pSliding
->
z
,
pSliding
->
n
,
&
pQueryInfo
->
interval
.
sliding
);
if
(
tinfo
.
precision
==
TSDB_TIME_PRECISION_MILLI
)
{
pQueryInfo
->
interval
.
sliding
/=
1000
;
}
...
...
src/os/inc/osTime.h
浏览文件 @
7cdb6c3f
...
...
@@ -30,8 +30,6 @@ extern "C" {
#define MILLISECOND_PER_HOUR (MILLISECOND_PER_MINUTE * 60)
#define MILLISECOND_PER_DAY (MILLISECOND_PER_HOUR * 24)
#define MILLISECOND_PER_WEEK (MILLISECOND_PER_DAY * 7)
#define MILLISECOND_PER_MONTH (MILLISECOND_PER_DAY * 30)
#define MILLISECOND_PER_YEAR (MILLISECOND_PER_DAY * 365)
//@return timestamp in second
int32_t
taosGetTimestampSec
();
...
...
@@ -77,8 +75,8 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision);
int64_t
taosTimeTruncate
(
int64_t
t
,
const
SInterval
*
pInterval
,
int32_t
precision
);
int32_t
taosTimeCountInterval
(
int64_t
skey
,
int64_t
ekey
,
int64_t
interval
,
char
unit
,
int32_t
precision
);
int32_t
getTimestampInUsFromStr
(
char
*
token
,
int32_t
tokenlen
,
int64_t
*
ts
);
int32_t
parseDuration
(
const
char
*
token
,
int32_t
tokenLen
,
int64_t
*
duration
,
char
*
unit
);
int32_t
parseAbsoluteDuration
(
char
*
token
,
int32_t
tokenlen
,
int64_t
*
ts
);
int32_t
parse
Natual
Duration
(
const
char
*
token
,
int32_t
tokenLen
,
int64_t
*
duration
,
char
*
unit
);
int32_t
taosParseTime
(
char
*
timestr
,
int64_t
*
time
,
int32_t
len
,
int32_t
timePrec
,
int8_t
dayligth
);
void
deltaToUtcInitOnce
();
...
...
src/os/src/detail/osTime.c
浏览文件 @
7cdb6c3f
...
...
@@ -321,7 +321,7 @@ int32_t parseLocaltimeWithDst(char* timestr, int64_t* time, int32_t timePrec) {
}
static
int32_t
get
TimestampInUsFromStrImpl
(
int64_t
val
,
char
unit
,
int64_t
*
result
)
{
static
int32_t
get
DurationInUs
(
int64_t
val
,
char
unit
,
int64_t
*
result
)
{
*
result
=
val
;
int64_t
factor
=
1000L
;
...
...
@@ -342,19 +342,12 @@ static int32_t getTimestampInUsFromStrImpl(int64_t val, char unit, int64_t* resu
case
'w'
:
(
*
result
)
*=
MILLISECOND_PER_WEEK
*
factor
;
break
;
case
'n'
:
(
*
result
)
*=
MILLISECOND_PER_MONTH
*
factor
;
break
;
case
'y'
:
(
*
result
)
*=
MILLISECOND_PER_YEAR
*
factor
;
break
;
case
'a'
:
(
*
result
)
*=
factor
;
break
;
case
'u'
:
break
;
default:
{
;
return
-
1
;
}
}
...
...
@@ -373,7 +366,7 @@ static int32_t getTimestampInUsFromStrImpl(int64_t val, char unit, int64_t* resu
* n - Months (30 days)
* y - Years (365 days)
*/
int32_t
getTimestampInUsFromStr
(
char
*
token
,
int32_t
tokenlen
,
int64_t
*
ts
)
{
int32_t
parseAbsoluteDuration
(
char
*
token
,
int32_t
tokenlen
,
int64_t
*
duration
)
{
errno
=
0
;
char
*
endPtr
=
NULL
;
...
...
@@ -383,10 +376,16 @@ int32_t getTimestampInUsFromStr(char* token, int32_t tokenlen, int64_t* ts) {
return
-
1
;
}
return
getTimestampInUsFromStrImpl
(
timestamp
,
token
[
tokenlen
-
1
],
ts
);
/* natual month/year are not allowed in absolute duration */
char
unit
=
token
[
tokenlen
-
1
];
if
(
unit
==
'n'
||
unit
==
'y'
)
{
return
-
1
;
}
return
getDurationInUs
(
timestamp
,
unit
,
duration
);
}
int32_t
parseDuration
(
const
char
*
token
,
int32_t
tokenLen
,
int64_t
*
duration
,
char
*
unit
)
{
int32_t
parse
Natual
Duration
(
const
char
*
token
,
int32_t
tokenLen
,
int64_t
*
duration
,
char
*
unit
)
{
errno
=
0
;
/* get the basic numeric value */
...
...
@@ -400,7 +399,7 @@ int32_t parseDuration(const char* token, int32_t tokenLen, int64_t* duration, ch
return
0
;
}
return
get
TimestampInUsFromStrImpl
(
*
duration
,
*
unit
,
duration
);
return
get
DurationInUs
(
*
duration
,
*
unit
,
duration
);
}
int64_t
taosTimeAdd
(
int64_t
t
,
int64_t
duration
,
char
unit
,
int32_t
precision
)
{
...
...
src/query/src/qParserImpl.c
浏览文件 @
7cdb6c3f
...
...
@@ -135,7 +135,7 @@ tSQLExpr *tSQLExprIdValueCreate(SStrToken *pToken, int32_t optrType) {
pSQLExpr
->
val
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
pSQLExpr
->
nSQLOptr
=
TK_TIMESTAMP
;
// TK_TIMESTAMP used to denote the time value is in microsecond
}
else
if
(
optrType
==
TK_VARIABLE
)
{
int32_t
ret
=
getTimestampInUsFromStr
(
pToken
->
z
,
pToken
->
n
,
&
pSQLExpr
->
val
.
i64Key
);
int32_t
ret
=
parseAbsoluteDuration
(
pToken
->
z
,
pToken
->
n
,
&
pSQLExpr
->
val
.
i64Key
);
UNUSED
(
ret
);
pSQLExpr
->
val
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
...
...
@@ -443,44 +443,6 @@ void setDBName(SStrToken *pCpxName, SStrToken *pDB) {
pCpxName
->
n
=
pDB
->
n
;
}
int32_t
getTimestampInUsFromStrImpl
(
int64_t
val
,
char
unit
,
int64_t
*
result
)
{
*
result
=
val
;
switch
(
unit
)
{
case
's'
:
(
*
result
)
*=
MILLISECOND_PER_SECOND
;
break
;
case
'm'
:
(
*
result
)
*=
MILLISECOND_PER_MINUTE
;
break
;
case
'h'
:
(
*
result
)
*=
MILLISECOND_PER_HOUR
;
break
;
case
'd'
:
(
*
result
)
*=
MILLISECOND_PER_DAY
;
break
;
case
'w'
:
(
*
result
)
*=
MILLISECOND_PER_WEEK
;
break
;
case
'n'
:
(
*
result
)
*=
MILLISECOND_PER_MONTH
;
break
;
case
'y'
:
(
*
result
)
*=
MILLISECOND_PER_YEAR
;
break
;
case
'a'
:
break
;
default:
{
;
return
-
1
;
}
}
/* get the value in microsecond */
(
*
result
)
*=
1000L
;
return
0
;
}
void
tSQLSetColumnInfo
(
TAOS_FIELD
*
pField
,
SStrToken
*
pName
,
TAOS_FIELD
*
pType
)
{
int32_t
maxLen
=
sizeof
(
pField
->
name
)
/
sizeof
(
pField
->
name
[
0
]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录