Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
fb19257a
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看板
提交
fb19257a
编写于
8月 27, 2020
作者:
B
Bomin Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
td-1099: parse natual month/year
上级
c476eb09
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
54 addition
and
27 deletion
+54
-27
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+2
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+32
-26
src/os/inc/osTime.h
src/os/inc/osTime.h
+1
-0
src/os/src/detail/osTime.c
src/os/src/detail/osTime.c
+19
-0
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
fb19257a
...
...
@@ -229,8 +229,9 @@ typedef struct STableDataBlocks {
typedef
struct
SQueryInfo
{
int16_t
command
;
// the command may be different for each subclause, so keep it seperately.
uint32_t
type
;
// query/insert type
char
intervalTimeUnit
;
char
slidingTimeUnit
;
uint32_t
type
;
// query/insert type
STimeWindow
window
;
// query time window
int64_t
intervalTime
;
// aggregation time interval
int64_t
slidingTime
;
// sliding window in mseconds
...
...
src/client/src/tscSQLParser.c
浏览文件 @
fb19257a
...
...
@@ -586,23 +586,22 @@ int32_t parseIntervalClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQ
}
// interval is not null
SS
tr
Token
*
t
=
&
pQuerySql
->
interval
;
if
(
getTimestampInUsFromStr
(
t
->
z
,
t
->
n
,
&
pQueryInfo
->
intervalTime
)
!=
TSDB_CODE_SUCCESS
)
{
SS
QL
Token
*
t
=
&
pQuerySql
->
interval
;
if
(
parseDuration
(
t
->
z
,
t
->
n
,
&
pQueryInfo
->
intervalTime
,
&
pQueryInfo
->
intervalTimeUnit
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
if
(
pQueryInfo
->
intervalTimeUnit
!=
'n'
&&
pQueryInfo
->
intervalTimeUnit
!=
'y'
)
{
// if the unit of time window value is millisecond, change the value from microsecond
if
(
tinfo
.
precision
==
TSDB_TIME_PRECISION_MILLI
)
{
pQueryInfo
->
intervalTime
=
pQueryInfo
->
intervalTime
/
1000
;
}
/* parser has filter the illegal type, no need to check here */
pQueryInfo
->
slidingTimeUnit
=
pQuerySql
->
interval
.
z
[
pQuerySql
->
interval
.
n
-
1
];
// interval cannot be less than 10 milliseconds
if
(
pQueryInfo
->
intervalTime
<
tsMinIntervalTime
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
}
// for top/bottom + interval query, we do not add additional timestamp column in the front
if
(
isTopBottomQuery
(
pQueryInfo
))
{
...
...
@@ -666,14 +665,24 @@ int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu
const
char
*
msg0
=
"sliding value too small"
;
const
char
*
msg1
=
"sliding value no larger than the interval value"
;
const
char
*
msg2
=
"sliding value can not less than 1% of interval value"
;
const
char
*
msg3
=
"does not support sliding when interval is natual month/year"
;
const
static
int32_t
INTERVAL_SLIDING_FACTOR
=
100
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
SStrToken
*
pSliding
=
&
pQuerySql
->
sliding
;
if
(
pSliding
->
n
!=
0
)
{
SSQLToken
*
pSliding
=
&
pQuerySql
->
sliding
;
if
(
pSliding
->
n
==
0
)
{
pQueryInfo
->
slidingTimeUnit
=
pQueryInfo
->
intervalTimeUnit
;
pQueryInfo
->
slidingTime
=
pQueryInfo
->
intervalTime
;
return
TSDB_CODE_SUCCESS
;
}
if
(
pQueryInfo
->
intervalTimeUnit
==
'n'
||
pQueryInfo
->
intervalTimeUnit
==
'y'
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
getTimestampInUsFromStr
(
pSliding
->
z
,
pSliding
->
n
,
&
pQueryInfo
->
slidingTime
);
if
(
tinfo
.
precision
==
TSDB_TIME_PRECISION_MILLI
)
{
pQueryInfo
->
slidingTime
/=
1000
;
...
...
@@ -686,9 +695,6 @@ int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu
if
(
pQueryInfo
->
slidingTime
>
pQueryInfo
->
intervalTime
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
}
else
{
pQueryInfo
->
slidingTime
=
pQueryInfo
->
intervalTime
;
}
if
((
pQueryInfo
->
intervalTime
!=
0
)
&&
(
pQueryInfo
->
intervalTime
/
pQueryInfo
->
slidingTime
>
INTERVAL_SLIDING_FACTOR
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
...
...
src/os/inc/osTime.h
浏览文件 @
fb19257a
...
...
@@ -64,6 +64,7 @@ static FORCE_INLINE int64_t taosGetTimestamp(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
taosParseTime
(
char
*
timestr
,
int64_t
*
time
,
int32_t
len
,
int32_t
timePrec
,
int8_t
dayligth
);
void
deltaToUtcInitOnce
();
...
...
src/os/src/detail/osTime.c
浏览文件 @
fb19257a
...
...
@@ -319,6 +319,8 @@ int32_t parseLocaltimeWithDst(char* timestr, int64_t* time, int32_t timePrec) {
*
time
=
factor
*
seconds
+
fraction
;
return
0
;
}
static
int32_t
getTimestampInUsFromStrImpl
(
int64_t
val
,
char
unit
,
int64_t
*
result
)
{
*
result
=
val
;
...
...
@@ -384,6 +386,23 @@ int32_t getTimestampInUsFromStr(char* token, int32_t tokenlen, int64_t* ts) {
return
getTimestampInUsFromStrImpl
(
timestamp
,
token
[
tokenlen
-
1
],
ts
);
}
int32_t
parseDuration
(
const
char
*
token
,
int32_t
tokenLen
,
int64_t
*
duration
,
char
*
unit
)
{
errno
=
0
;
/* get the basic numeric value */
*
duration
=
strtoll
(
token
,
NULL
,
10
);
if
(
errno
!=
0
)
{
return
-
1
;
}
*
unit
=
token
[
tokenLen
-
1
];
if
(
*
unit
==
'n'
||
*
unit
==
'y'
)
{
return
0
;
}
return
getTimestampInUsFromStrImpl
(
*
duration
,
*
unit
,
duration
);
}
// internal function, when program is paused in debugger,
// one can call this function from debugger to print a
// timestamp as human readable string, for example (gdb):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录