Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7cc95a6e
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
7cc95a6e
编写于
1月 05, 2021
作者:
H
haojun Liao
提交者:
GitHub
1月 05, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4799 from taosdata/hotfix/TD-2631
[TD-2631]last_row/interval can't be mixed up
上级
90db65b5
d05e1428
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
14 addition
and
8 deletion
+14
-8
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+14
-8
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
7cc95a6e
...
...
@@ -75,11 +75,11 @@ static int32_t insertResultField(SQueryInfo* pQueryInfo, int32_t outputIndex, SC
static
int32_t
convertFunctionId
(
int32_t
optr
,
int16_t
*
functionId
);
static
uint8_t
convertOptr
(
SStrToken
*
pToken
);
static
int32_t
parseSelectClause
(
SSqlCmd
*
pCmd
,
int32_t
clauseIndex
,
tSQLExprList
*
pSelection
,
bool
isSTable
,
bool
joinQuery
);
static
int32_t
parseSelectClause
(
SSqlCmd
*
pCmd
,
int32_t
clauseIndex
,
tSQLExprList
*
pSelection
,
bool
isSTable
,
bool
joinQuery
,
bool
intervalQuery
);
static
bool
validateIpAddress
(
const
char
*
ip
,
size_t
size
);
static
bool
hasUnsupportFunctionsForSTableQuery
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
);
static
bool
functionCompatibleCheck
(
SQueryInfo
*
pQueryInfo
,
bool
joinQuery
);
static
bool
functionCompatibleCheck
(
SQueryInfo
*
pQueryInfo
,
bool
joinQuery
,
bool
intervalQuery
);
static
int32_t
parseGroupbyClause
(
SQueryInfo
*
pQueryInfo
,
SArray
*
pList
,
SSqlCmd
*
pCmd
);
...
...
@@ -1475,7 +1475,7 @@ static void addPrimaryTsColIntoResult(SQueryInfo* pQueryInfo) {
pQueryInfo
->
type
|=
TSDB_QUERY_TYPE_PROJECTION_QUERY
;
}
int32_t
parseSelectClause
(
SSqlCmd
*
pCmd
,
int32_t
clauseIndex
,
tSQLExprList
*
pSelection
,
bool
isSTable
,
bool
joinQuery
)
{
int32_t
parseSelectClause
(
SSqlCmd
*
pCmd
,
int32_t
clauseIndex
,
tSQLExprList
*
pSelection
,
bool
isSTable
,
bool
joinQuery
,
bool
intervalQuery
)
{
assert
(
pSelection
!=
NULL
&&
pCmd
!=
NULL
);
const
char
*
msg2
=
"functions can not be mixed up"
;
...
...
@@ -1531,7 +1531,7 @@ int32_t parseSelectClause(SSqlCmd* pCmd, int32_t clauseIndex, tSQLExprList* pSel
addPrimaryTsColIntoResult
(
pQueryInfo
);
}
if
(
!
functionCompatibleCheck
(
pQueryInfo
,
joinQuery
))
{
if
(
!
functionCompatibleCheck
(
pQueryInfo
,
joinQuery
,
intervalQuery
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
...
...
@@ -2810,7 +2810,7 @@ bool hasUnsupportFunctionsForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo)
return
false
;
}
static
bool
functionCompatibleCheck
(
SQueryInfo
*
pQueryInfo
,
bool
joinQuery
)
{
static
bool
functionCompatibleCheck
(
SQueryInfo
*
pQueryInfo
,
bool
joinQuery
,
bool
intervalQuery
)
{
int32_t
startIdx
=
0
;
size_t
numOfExpr
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
...
...
@@ -2826,6 +2826,10 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo, bool joinQuery) {
int32_t
factor
=
functionCompatList
[
tscSqlExprGet
(
pQueryInfo
,
startIdx
)
->
functionId
];
if
(
tscSqlExprGet
(
pQueryInfo
,
0
)
->
functionId
==
TSDB_FUNC_LAST_ROW
&&
(
joinQuery
||
intervalQuery
))
{
return
false
;
}
// diff function cannot be executed with other function
// arithmetic function can be executed with other arithmetic functions
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
...
...
@@ -2850,7 +2854,7 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo, bool joinQuery) {
}
}
if
(
functionId
==
TSDB_FUNC_LAST_ROW
&&
joinQuery
)
{
if
(
functionId
==
TSDB_FUNC_LAST_ROW
&&
(
joinQuery
||
intervalQuery
)
)
{
return
false
;
}
}
...
...
@@ -6320,7 +6324,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
}
bool
isSTable
=
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
);
if
(
parseSelectClause
(
&
pSql
->
cmd
,
0
,
pQuerySql
->
pSelection
,
isSTable
,
false
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
parseSelectClause
(
&
pSql
->
cmd
,
0
,
pQuerySql
->
pSelection
,
isSTable
,
false
,
false
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
...
...
@@ -6565,7 +6569,9 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
int32_t
joinQuery
=
(
pQuerySql
->
from
!=
NULL
&&
taosArrayGetSize
(
pQuerySql
->
from
)
>
2
);
if
(
parseSelectClause
(
pCmd
,
index
,
pQuerySql
->
pSelection
,
isSTable
,
joinQuery
)
!=
TSDB_CODE_SUCCESS
)
{
int32_t
intervalQuery
=
!
(
pQuerySql
->
interval
.
type
==
0
||
pQuerySql
->
interval
.
n
==
0
);
if
(
parseSelectClause
(
pCmd
,
index
,
pQuerySql
->
pSelection
,
isSTable
,
joinQuery
,
intervalQuery
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录