Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
42f56a1e
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
42f56a1e
编写于
5月 19, 2022
作者:
X
xywang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(query): fixed bitwise operation check error
上级
004ca0fe
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
204 addition
and
13 deletion
+204
-13
src/common/src/texpr.c
src/common/src/texpr.c
+204
-13
未找到文件。
src/common/src/texpr.c
浏览文件 @
42f56a1e
...
@@ -107,8 +107,13 @@ int32_t exprTreeValidateFunctionNode(char* msgbuf, tExprNode *pExpr) {
...
@@ -107,8 +107,13 @@ int32_t exprTreeValidateFunctionNode(char* msgbuf, tExprNode *pExpr) {
}
}
int32_t
exprTreeValidateExprNode
(
tExprNode
*
pExpr
)
{
int32_t
exprTreeValidateExprNode
(
tExprNode
*
pExpr
)
{
int16_t
leftType
=
pExpr
->
_node
.
pLeft
->
resultType
;
tExprNode
*
pLeft
=
pExpr
->
_node
.
pLeft
;
int16_t
rightType
=
pExpr
->
_node
.
pRight
->
resultType
;
tExprNode
*
pRight
=
pExpr
->
_node
.
pRight
;
int16_t
leftType
=
pLeft
->
resultType
;
int16_t
rightType
=
pRight
->
resultType
;
int32_t
brChecked
=
0
;
if
(
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_ADD
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_SUBTRACT
||
if
(
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_ADD
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_SUBTRACT
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_MULTIPLY
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_DIVIDE
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_MULTIPLY
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_DIVIDE
||
...
@@ -139,11 +144,120 @@ int32_t exprTreeValidateExprNode(tExprNode *pExpr) {
...
@@ -139,11 +144,120 @@ int32_t exprTreeValidateExprNode(tExprNode *pExpr) {
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_RSHIFT
)
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_RSHIFT
)
{
{
if
(
!
IS_NUMERIC_TYPE
(
leftType
)
||
!
IS_NUMERIC_TYPE
(
rightType
))
{
if
(
!
IS_NUMERIC_TYPE
(
leftType
)
||
!
IS_NUMERIC_TYPE
(
rightType
))
{
if
(
pLeft
->
_node
.
pLeft
)
{
if
(
!
IS_NUMERIC_TYPE
(
pLeft
->
_node
.
pLeft
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
if
(
IS_FLOAT_TYPE
(
pLeft
->
_node
.
pLeft
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
brChecked
++
;
}
if
(
pLeft
->
_node
.
pRight
)
{
if
(
!
IS_NUMERIC_TYPE
(
pLeft
->
_node
.
pRight
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
if
(
IS_FLOAT_TYPE
(
pLeft
->
_node
.
pRight
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
brChecked
++
;
}
if
(
pRight
->
_node
.
pLeft
)
{
if
(
!
IS_NUMERIC_TYPE
(
pRight
->
_node
.
pLeft
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
if
(
IS_FLOAT_TYPE
(
pRight
->
_node
.
pLeft
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
brChecked
++
;
}
if
(
pRight
->
_node
.
pRight
)
{
if
(
!
IS_NUMERIC_TYPE
(
pRight
->
_node
.
pRight
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
if
(
IS_FLOAT_TYPE
(
pRight
->
_node
.
pRight
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
}
brChecked
++
;
}
if
(
brChecked
==
0
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
brChecked
=
0
;
}
if
(
IS_FLOAT_TYPE
(
leftType
)
||
IS_FLOAT_TYPE
(
rightType
))
{
if
(
IS_FLOAT_TYPE
(
leftType
)
||
IS_FLOAT_TYPE
(
rightType
))
{
if
(
pLeft
->
_node
.
pLeft
)
{
if
(
!
IS_NUMERIC_TYPE
(
pLeft
->
_node
.
pLeft
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
if
(
IS_FLOAT_TYPE
(
pLeft
->
_node
.
pLeft
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
brChecked
++
;
}
if
(
pLeft
->
_node
.
pRight
)
{
if
(
!
IS_NUMERIC_TYPE
(
pLeft
->
_node
.
pRight
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
if
(
IS_FLOAT_TYPE
(
pLeft
->
_node
.
pRight
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
brChecked
++
;
}
if
(
pRight
->
_node
.
pLeft
)
{
if
(
!
IS_NUMERIC_TYPE
(
pRight
->
_node
.
pLeft
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
if
(
IS_FLOAT_TYPE
(
pRight
->
_node
.
pLeft
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
brChecked
++
;
}
if
(
pRight
->
_node
.
pRight
)
{
if
(
!
IS_NUMERIC_TYPE
(
pRight
->
_node
.
pRight
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
if
(
IS_FLOAT_TYPE
(
pRight
->
_node
.
pRight
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
brChecked
++
;
}
if
(
brChecked
==
0
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
}
}
// colx bitwise_op (coly logic_op n)
if
(
pRight
->
resultType
==
TSDB_DATA_TYPE_DOUBLE
)
{
pRight
->
resultType
=
TSDB_DATA_TYPE_BIGINT
;
pRight
->
resultBytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
;
}
if
(
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_LSHIFT
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_RSHIFT
)
{
if
(
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_LSHIFT
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_RSHIFT
)
{
pExpr
->
resultType
=
leftType
;
pExpr
->
resultType
=
leftType
;
pExpr
->
resultBytes
=
tDataTypes
[
leftType
].
bytes
;
pExpr
->
resultBytes
=
tDataTypes
[
leftType
].
bytes
;
...
@@ -154,10 +268,40 @@ int32_t exprTreeValidateExprNode(tExprNode *pExpr) {
...
@@ -154,10 +268,40 @@ int32_t exprTreeValidateExprNode(tExprNode *pExpr) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
else
if
(
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITNOT
)
{
}
else
if
(
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITNOT
)
{
if
(
!
IS_NUMERIC_TYPE
(
leftType
)
||
IS_FLOAT_TYPE
(
leftType
))
{
if
(
!
IS_NUMERIC_TYPE
(
leftType
)
||
IS_FLOAT_TYPE
(
leftType
))
{
if
(
pLeft
->
_node
.
pLeft
)
{
if
(
!
IS_NUMERIC_TYPE
(
pLeft
->
_node
.
pLeft
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
if
(
IS_FLOAT_TYPE
(
pLeft
->
_node
.
pLeft
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
}
brChecked
++
;
}
if
(
pLeft
->
_node
.
pRight
)
{
if
(
!
IS_NUMERIC_TYPE
(
pLeft
->
_node
.
pRight
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
if
(
IS_FLOAT_TYPE
(
pLeft
->
_node
.
pRight
->
resultType
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
brChecked
++
;
}
if
(
brChecked
==
0
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
}
if
(
leftType
==
TSDB_DATA_TYPE_DOUBLE
)
{
pExpr
->
resultType
=
TSDB_DATA_TYPE_BIGINT
;
}
else
{
pExpr
->
resultType
=
leftType
;
pExpr
->
resultType
=
leftType
;
pExpr
->
resultBytes
=
tDataTypes
[
leftType
].
bytes
;
}
pExpr
->
resultBytes
=
tDataTypes
[
pExpr
->
resultType
].
bytes
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
else
{
}
else
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -491,8 +635,8 @@ void exprTreeExprNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandI
...
@@ -491,8 +635,8 @@ void exprTreeExprNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandI
tExprNode
*
pLeft
=
pExpr
->
_node
.
pLeft
;
tExprNode
*
pLeft
=
pExpr
->
_node
.
pLeft
;
tExprNode
*
pRight
=
pExpr
->
_node
.
pRight
;
tExprNode
*
pRight
=
pExpr
->
_node
.
pRight
;
char
*
ltmp
=
NULL
,
*
rtmp
=
NULL
;
char
*
ltmp
=
NULL
,
*
rtmp
=
NULL
,
*
pl
=
NULL
,
*
pr
=
NULL
,
*
pt
=
NULL
;
char
*
leftIn
=
NULL
,
*
rightIn
=
NULL
;
char
*
leftIn
=
NULL
,
*
rightIn
=
NULL
,
*
transl
=
NULL
,
*
transr
=
NULL
;
int32_t
leftNum
=
0
,
rightNum
=
0
;
int32_t
leftNum
=
0
,
rightNum
=
0
;
int32_t
leftType
=
0
,
rightType
=
0
;
int32_t
leftType
=
0
,
rightType
=
0
;
int32_t
fnOrder
=
TSDB_ORDER_ASC
;
int32_t
fnOrder
=
TSDB_ORDER_ASC
;
...
@@ -504,7 +648,29 @@ void exprTreeExprNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandI
...
@@ -504,7 +648,29 @@ void exprTreeExprNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandI
exprTreeInternalNodeTraverse
(
pLeft
,
numOfRows
,
&
left
,
param
,
order
,
getSourceDataBlock
);
exprTreeInternalNodeTraverse
(
pLeft
,
numOfRows
,
&
left
,
param
,
order
,
getSourceDataBlock
);
leftIn
=
ltmp
;
leftIn
=
ltmp
;
if
(
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITAND
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITOR
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITXOR
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITNOT
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_LSHIFT
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_RSHIFT
)
{
if
(
left
.
type
==
TSDB_DATA_TYPE_DOUBLE
)
{
transl
=
(
char
*
)
malloc
(
sizeof
(
int64_t
)
*
left
.
numOfRows
);
if
(
transl
==
NULL
)
{
return
;
}
pl
=
ltmp
;
pt
=
transl
;
for
(
int16_t
i
=
0
;
i
<
left
.
numOfRows
;
i
++
)
{
*
((
int64_t
*
)
pt
+
i
)
=
(
int64_t
)(
*
((
double
*
)
pl
+
i
));
}
leftIn
=
transl
;
leftType
=
TSDB_DATA_TYPE_BIGINT
;
}
}
else
{
leftType
=
left
.
type
;
leftType
=
left
.
type
;
}
leftNum
=
left
.
numOfRows
;
leftNum
=
left
.
numOfRows
;
}
else
if
(
pLeft
->
nodeType
==
TSQL_NODE_COL
)
{
}
else
if
(
pLeft
->
nodeType
==
TSQL_NODE_COL
)
{
char
*
pInputData
=
getSourceDataBlock
(
param
,
pLeft
->
pSchema
->
name
,
pLeft
->
pSchema
->
colId
);
char
*
pInputData
=
getSourceDataBlock
(
param
,
pLeft
->
pSchema
->
name
,
pLeft
->
pSchema
->
colId
);
...
@@ -533,7 +699,29 @@ void exprTreeExprNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandI
...
@@ -533,7 +699,29 @@ void exprTreeExprNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandI
exprTreeInternalNodeTraverse
(
pRight
,
numOfRows
,
&
right
,
param
,
order
,
getSourceDataBlock
);
exprTreeInternalNodeTraverse
(
pRight
,
numOfRows
,
&
right
,
param
,
order
,
getSourceDataBlock
);
rightIn
=
rtmp
;
rightIn
=
rtmp
;
if
(
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITAND
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITOR
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITXOR
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_BITNOT
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_LSHIFT
||
pExpr
->
_node
.
optr
==
TSDB_BINARY_OP_RSHIFT
)
{
if
(
right
.
type
==
TSDB_DATA_TYPE_DOUBLE
)
{
transr
=
(
char
*
)
malloc
(
sizeof
(
int64_t
)
*
right
.
numOfRows
);
if
(
transr
==
NULL
)
{
return
;
}
pr
=
rtmp
;
pt
=
transr
;
for
(
int16_t
i
=
0
;
i
<
right
.
numOfRows
;
i
++
)
{
*
((
int64_t
*
)
pt
+
i
)
=
(
int64_t
)(
*
((
double
*
)
pr
+
i
));
}
rightIn
=
transr
;
rightType
=
TSDB_DATA_TYPE_BIGINT
;
}
}
else
{
rightType
=
right
.
type
;
rightType
=
right
.
type
;
}
rightNum
=
right
.
numOfRows
;
rightNum
=
right
.
numOfRows
;
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_COL
)
{
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_COL
)
{
char
*
pInputData
=
getSourceDataBlock
(
param
,
pRight
->
pSchema
->
name
,
pRight
->
pSchema
->
colId
);
char
*
pInputData
=
getSourceDataBlock
(
param
,
pRight
->
pSchema
->
name
,
pRight
->
pSchema
->
colId
);
...
@@ -576,6 +764,9 @@ void exprTreeExprNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandI
...
@@ -576,6 +764,9 @@ void exprTreeExprNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandI
}
}
output
->
bytes
=
tDataTypes
[
output
->
type
].
bytes
;
output
->
bytes
=
tDataTypes
[
output
->
type
].
bytes
;
if
(
transl
)
tfree
(
transl
);
if
(
transr
)
tfree
(
transr
);
tfree
(
ltmp
);
tfree
(
ltmp
);
tfree
(
rtmp
);
tfree
(
rtmp
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录