Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c07a5a7d
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看板
提交
c07a5a7d
编写于
1月 06, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-2657]<fix>: check the invalid sql while cq started.
上级
fe94d261
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
29 deletion
+36
-29
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+14
-8
src/client/src/tscStream.c
src/client/src/tscStream.c
+22
-21
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
c07a5a7d
...
...
@@ -6259,10 +6259,12 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
int32_t
doCheckForStream
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
const
char
*
msg1
=
"invalid table name"
;
const
char
*
msg2
=
"functions not allowed in CQ"
;
const
char
*
msg3
=
"fill only available for interval query"
;
const
char
*
msg4
=
"fill option not supported in stream computing"
;
const
char
*
msg5
=
"sql too long"
;
// todo ADD support
const
char
*
msg6
=
"from missing in subclause"
;
const
char
*
msg7
=
"time interval is required"
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
...
...
@@ -6272,10 +6274,10 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
// if sql specifies db, use it, otherwise use default db
SStrToken
*
p
zTable
Name
=
&
(
pCreateTable
->
name
);
SStrToken
*
pName
=
&
(
pCreateTable
->
name
);
SQuerySQL
*
pQuerySql
=
pCreateTable
->
pSelect
;
if
(
tscValidateName
(
p
zTable
Name
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscValidateName
(
pName
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
...
...
@@ -6314,15 +6316,19 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
// set interval value
if
(
parseIntervalClause
(
pSql
,
pQueryInfo
,
pQuerySql
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
else
{
if
((
pQueryInfo
->
interval
.
interval
>
0
)
&&
(
validateFunctionsInIntervalOrGroupbyQuery
(
pCmd
,
pQueryInfo
)
!=
TSDB_CODE_SUCCESS
))
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
}
if
((
pQueryInfo
->
interval
.
interval
>
0
)
&&
(
validateFunctionsInIntervalOrGroupbyQuery
(
pCmd
,
pQueryInfo
)
!=
TSDB_CODE_SUCCESS
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
if
(
!
tscIsProjectionQuery
(
pQueryInfo
)
&&
pQueryInfo
->
interval
.
interval
==
0
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg7
);
}
// set the created table[stream] name
code
=
tscSetTableFullName
(
pTableMetaInfo
,
p
zTable
Name
,
pSql
);
code
=
tscSetTableFullName
(
pTableMetaInfo
,
pName
,
pSql
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
src/client/src/tscStream.c
浏览文件 @
c07a5a7d
...
...
@@ -399,11 +399,16 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) {
tscSetRetryTimer
(
pStream
,
pSql
,
timer
);
}
static
void
tscSetSlidingWindowInfo
(
SSqlObj
*
pSql
,
SSqlStream
*
pStream
)
{
static
int32_t
tscSetSlidingWindowInfo
(
SSqlObj
*
pSql
,
SSqlStream
*
pStream
)
{
int64_t
minIntervalTime
=
(
pStream
->
precision
==
TSDB_TIME_PRECISION_MICRO
)
?
tsMinIntervalTime
*
1000L
:
tsMinIntervalTime
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
if
(
!
pStream
->
isProject
&&
pQueryInfo
->
interval
.
interval
==
0
)
{
sprintf
(
pSql
->
cmd
.
payload
,
"the interval value is 0"
);
return
-
1
;
}
if
(
pQueryInfo
->
interval
.
intervalUnit
!=
'n'
&&
pQueryInfo
->
interval
.
intervalUnit
!=
'y'
&&
pQueryInfo
->
interval
.
interval
<
minIntervalTime
)
{
tscWarn
(
"%p stream:%p, original sample interval:%"
PRId64
" too small, reset to:%"
PRId64
,
pSql
,
pStream
,
...
...
@@ -443,6 +448,8 @@ static void tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) {
pQueryInfo
->
interval
.
interval
=
0
;
// clear the interval value to avoid the force time window split by query processor
pQueryInfo
->
interval
.
sliding
=
0
;
}
return
TSDB_CODE_SUCCESS
;
}
static
int64_t
tscGetStreamStartTimestamp
(
SSqlObj
*
pSql
,
SSqlStream
*
pStream
,
int64_t
stime
)
{
...
...
@@ -492,34 +499,19 @@ static int64_t tscGetLaunchTimestamp(const SSqlStream *pStream) {
return
(
pStream
->
precision
==
TSDB_TIME_PRECISION_MICRO
)
?
timer
/
1000L
:
timer
;
}
static
void
setErrorInfo
(
SSqlObj
*
pSql
,
int32_t
code
,
char
*
info
)
{
if
(
pSql
==
NULL
)
{
return
;
}
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pSql
->
res
.
code
=
code
;
if
(
info
!=
NULL
)
{
strncpy
(
pCmd
->
payload
,
info
,
pCmd
->
payloadLen
);
}
}
static
void
tscCreateStream
(
void
*
param
,
TAOS_RES
*
res
,
int
code
)
{
SSqlStream
*
pStream
=
(
SSqlStream
*
)
param
;
SSqlObj
*
pSql
=
pStream
->
pSql
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
setErrorInfo
(
pSql
,
code
,
pCmd
->
payload
);
tscError
(
"%p open stream failed, sql:%s, reason:%s, code:0x%08x"
,
pSql
,
pSql
->
sqlstr
,
pCmd
->
payload
,
code
);
pSql
->
res
.
code
=
code
;
tscError
(
"%p open stream failed, sql:%s, reason:%s, code:%s"
,
pSql
,
pSql
->
sqlstr
,
pCmd
->
payload
,
tstrerror
(
code
));
pStream
->
fp
(
pStream
->
param
,
NULL
,
NULL
);
return
;
}
registerSqlObj
(
pSql
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
...
...
@@ -530,13 +522,22 @@ static void tscCreateStream(void *param, TAOS_RES *res, int code) {
pStream
->
ctime
=
taosGetTimestamp
(
pStream
->
precision
);
pStream
->
etime
=
pQueryInfo
->
window
.
ekey
;
tscAddIntoStreamList
(
pStream
);
if
(
tscSetSlidingWindowInfo
(
pSql
,
pStream
)
!=
TSDB_CODE_SUCCESS
)
{
pSql
->
res
.
code
=
code
;
tscError
(
"%p stream %p open failed, since the interval value is incorrect"
,
pSql
,
pStream
);
pStream
->
fp
(
pStream
->
param
,
NULL
,
NULL
);
return
;
}
tscSetSlidingWindowInfo
(
pSql
,
pStream
);
pStream
->
stime
=
tscGetStreamStartTimestamp
(
pSql
,
pStream
,
pStream
->
stime
);
int64_t
starttime
=
tscGetLaunchTimestamp
(
pStream
);
pCmd
->
command
=
TSDB_SQL_SELECT
;
registerSqlObj
(
pSql
);
tscAddIntoStreamList
(
pStream
);
taosTmrReset
(
tscProcessStreamTimer
,
(
int32_t
)
starttime
,
pStream
,
tscTmr
,
&
pStream
->
pTimer
);
tscDebug
(
"%p stream:%p is opened, query on:%s, interval:%"
PRId64
", sliding:%"
PRId64
", first launched in:%"
PRId64
", sql:%s"
,
pSql
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录