Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7bd533bf
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,发现更多精彩内容 >>
提交
7bd533bf
编写于
11月 03, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-1876]<fix>: fix bugs in arithmetic expression during two super table join query.
上级
5e0fba93
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
22 addition
and
4 deletion
+22
-4
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+22
-4
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
7bd533bf
...
@@ -1211,7 +1211,7 @@ static void tscInsertPrimaryTSSourceColumn(SQueryInfo* pQueryInfo, SColumnIndex*
...
@@ -1211,7 +1211,7 @@ static void tscInsertPrimaryTSSourceColumn(SQueryInfo* pQueryInfo, SColumnIndex*
tscColumnListInsert
(
pQueryInfo
->
colList
,
&
tsCol
);
tscColumnListInsert
(
pQueryInfo
->
colList
,
&
tsCol
);
}
}
static
int32_t
handleArithmeticExpr
(
SSqlCmd
*
pCmd
,
int32_t
clauseIndex
,
int32_t
exprIndex
,
tSQLExprItem
*
pItem
)
{
static
int32_t
handleArithmeticExpr
(
SSqlCmd
*
pCmd
,
int32_t
clauseIndex
,
int32_t
exprIndex
,
tSQLExprItem
*
pItem
)
{
const
char
*
msg1
=
"invalid column name,
or illegal column type
"
;
const
char
*
msg1
=
"invalid column name,
illegal column type, or columns in arithmetic expression from two tables
"
;
const
char
*
msg2
=
"invalid arithmetic expression in select clause"
;
const
char
*
msg2
=
"invalid arithmetic expression in select clause"
;
const
char
*
msg3
=
"tag columns can not be used in arithmetic expression"
;
const
char
*
msg3
=
"tag columns can not be used in arithmetic expression"
;
const
char
*
msg4
=
"columns from different table mixed up in arithmetic expression"
;
const
char
*
msg4
=
"columns from different table mixed up in arithmetic expression"
;
...
@@ -3353,7 +3353,8 @@ int32_t doArithmeticExprToString(tSQLExpr* pExpr, char** exprString) {
...
@@ -3353,7 +3353,8 @@ int32_t doArithmeticExprToString(tSQLExpr* pExpr, char** exprString) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
validateSQLExpr
(
SSqlCmd
*
pCmd
,
tSQLExpr
*
pExpr
,
SQueryInfo
*
pQueryInfo
,
SColumnList
*
pList
,
int32_t
*
type
)
{
static
int32_t
validateSQLExpr
(
SSqlCmd
*
pCmd
,
tSQLExpr
*
pExpr
,
SQueryInfo
*
pQueryInfo
,
SColumnList
*
pList
,
int32_t
*
type
,
uint64_t
*
uid
)
{
if
(
pExpr
->
nSQLOptr
==
TK_ID
)
{
if
(
pExpr
->
nSQLOptr
==
TK_ID
)
{
if
(
*
type
==
NON_ARITHMEIC_EXPR
)
{
if
(
*
type
==
NON_ARITHMEIC_EXPR
)
{
*
type
=
NORMAL_ARITHMETIC
;
*
type
=
NORMAL_ARITHMETIC
;
...
@@ -3402,13 +3403,22 @@ static int32_t validateSQLExpr(SSqlCmd* pCmd, tSQLExpr* pExpr, SQueryInfo* pQuer
...
@@ -3402,13 +3403,22 @@ static int32_t validateSQLExpr(SSqlCmd* pCmd, tSQLExpr* pExpr, SQueryInfo* pQuer
}
}
// Not supported data type in arithmetic expression
// Not supported data type in arithmetic expression
uint64_t
id
=
-
1
;
for
(
int32_t
i
=
0
;
i
<
inc
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
inc
;
++
i
)
{
SSqlExpr
*
p1
=
tscSqlExprGet
(
pQueryInfo
,
i
+
outputIndex
);
SSqlExpr
*
p1
=
tscSqlExprGet
(
pQueryInfo
,
i
+
outputIndex
);
int16_t
t
=
p1
->
resType
;
int16_t
t
=
p1
->
resType
;
if
(
t
==
TSDB_DATA_TYPE_BINARY
||
t
==
TSDB_DATA_TYPE_NCHAR
||
t
==
TSDB_DATA_TYPE_BOOL
||
t
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
if
(
t
==
TSDB_DATA_TYPE_BINARY
||
t
==
TSDB_DATA_TYPE_NCHAR
||
t
==
TSDB_DATA_TYPE_BOOL
||
t
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
return
TSDB_CODE_TSC_INVALID_SQL
;
}
}
if
(
i
==
0
)
{
id
=
p1
->
uid
;
}
else
if
(
id
!=
p1
->
uid
){
return
TSDB_CODE_TSC_INVALID_SQL
;
}
}
}
*
uid
=
id
;
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -3420,13 +3430,16 @@ static int32_t validateArithmeticSQLExpr(SSqlCmd* pCmd, tSQLExpr* pExpr, SQueryI
...
@@ -3420,13 +3430,16 @@ static int32_t validateArithmeticSQLExpr(SSqlCmd* pCmd, tSQLExpr* pExpr, SQueryI
}
}
tSQLExpr
*
pLeft
=
pExpr
->
pLeft
;
tSQLExpr
*
pLeft
=
pExpr
->
pLeft
;
uint64_t
uidLeft
=
0
;
uint64_t
uidRight
=
0
;
if
(
pLeft
->
nSQLOptr
>=
TK_PLUS
&&
pLeft
->
nSQLOptr
<=
TK_REM
)
{
if
(
pLeft
->
nSQLOptr
>=
TK_PLUS
&&
pLeft
->
nSQLOptr
<=
TK_REM
)
{
int32_t
ret
=
validateArithmeticSQLExpr
(
pCmd
,
pLeft
,
pQueryInfo
,
pList
,
type
);
int32_t
ret
=
validateArithmeticSQLExpr
(
pCmd
,
pLeft
,
pQueryInfo
,
pList
,
type
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
return
ret
;
}
}
}
else
{
}
else
{
int32_t
ret
=
validateSQLExpr
(
pCmd
,
pLeft
,
pQueryInfo
,
pList
,
type
);
int32_t
ret
=
validateSQLExpr
(
pCmd
,
pLeft
,
pQueryInfo
,
pList
,
type
,
&
uidLeft
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
return
ret
;
}
}
...
@@ -3439,10 +3452,15 @@ static int32_t validateArithmeticSQLExpr(SSqlCmd* pCmd, tSQLExpr* pExpr, SQueryI
...
@@ -3439,10 +3452,15 @@ static int32_t validateArithmeticSQLExpr(SSqlCmd* pCmd, tSQLExpr* pExpr, SQueryI
return
ret
;
return
ret
;
}
}
}
else
{
}
else
{
int32_t
ret
=
validateSQLExpr
(
pCmd
,
pRight
,
pQueryInfo
,
pList
,
type
);
int32_t
ret
=
validateSQLExpr
(
pCmd
,
pRight
,
pQueryInfo
,
pList
,
type
,
&
uidRight
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
return
ret
;
}
}
// the expression not from the same table, return error
if
(
uidLeft
!=
uidRight
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录