Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Messij2001
oceanbase
提交
0a794fca
O
oceanbase
项目概览
Messij2001
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
0a794fca
编写于
9月 24, 2021
作者:
Z
zs0
提交者:
wangzelin.wzl
9月 24, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix transform expr bug, convert single value row c1 in (1) to c1 = 1
上级
ae8c941e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
75 addition
and
68 deletion
+75
-68
src/sql/rewrite/ob_transform_pre_process.cpp
src/sql/rewrite/ob_transform_pre_process.cpp
+72
-68
src/sql/rewrite/ob_transform_pre_process.h
src/sql/rewrite/ob_transform_pre_process.h
+3
-0
未找到文件。
src/sql/rewrite/ob_transform_pre_process.cpp
浏览文件 @
0a794fca
...
...
@@ -3133,49 +3133,27 @@ int ObTransformPreProcess::transform_in_or_notin_expr_without_row(ObRawExprFacto
}
}
else
{
LOG_DEBUG
(
"distinct types"
,
K
(
distinct_types
));
ObSEArray
<
ObRawExpr
*
,
4
>
transed_in_exprs
;
ObOpRawExpr
*
tmp_in_expr
=
NULL
;
ObOpRawExpr
*
tmp_row_expr
=
NULL
;
ObRawExpr
*
tmp_left_expr
=
NULL
;
ObItemType
op_type
=
is_in_expr
?
T_OP_IN
:
T_OP_NOT_IN
;
ObSEArray
<
ObRawExpr
*
,
4
>
transed_in_exprs
;
ObSEArray
<
ObRawExpr
*
,
4
>
same_type_exprs
;
for
(
int
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
distinct_types
.
count
();
i
++
)
{
same_type_exprs
.
reuse
();
DistinctObjMeta
obj_meta
=
distinct_types
.
at
(
i
);
if
(
OB_FAIL
(
expr_factory
.
create_raw_expr
(
op_type
,
tmp_in_expr
))
||
OB_FAIL
(
expr_factory
.
create_raw_expr
(
T_OP_ROW
,
tmp_row_expr
))
||
OB_FAIL
(
ObRawExprUtils
::
copy_expr
(
expr_factory
,
left_expr
,
tmp_left_expr
,
COPY_REF_DEFAULT
)))
{
LOG_WARN
(
"failed to create or create raw expr"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
tmp_in_expr
)
||
OB_ISNULL
(
tmp_row_expr
)
||
OB_ISNULL
(
tmp_left_expr
))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"invalid null expr"
,
K
(
ret
),
K
(
tmp_in_expr
),
K
(
tmp_row_expr
),
K
(
tmp_left_expr
));
}
else
{
for
(
int
j
=
0
;
OB_SUCC
(
ret
)
&&
j
<
right_expr
->
get_param_count
();
j
++
)
{
ObObjType
obj_type
=
right_expr
->
get_param_expr
(
j
)
->
get_result_type
().
get_type
();
ObCollationType
coll_type
=
right_expr
->
get_param_expr
(
j
)
->
get_result_type
().
get_collation_type
();
ObCollationLevel
coll_level
=
right_expr
->
get_param_expr
(
j
)
->
get_result_type
().
get_collation_level
();
DistinctObjMeta
tmp_meta
(
obj_type
,
coll_type
,
coll_level
);
if
(
obj_meta
==
tmp_meta
&&
OB_FAIL
(
tmp_row_expr
->
add_param_expr
(
right_expr
->
get_param_expr
(
j
))))
{
LOG_WARN
(
"failed to add param expr"
,
K
(
ret
));
}
else
{
/* do nothing */
}
}
// for end
if
(
OB_FAIL
(
ret
))
{
// do nothing
}
else
if
(
OB_FAIL
(
tmp_in_expr
->
add_param_expr
(
tmp_left_expr
))
||
OB_FAIL
(
tmp_in_expr
->
add_param_expr
(
tmp_row_expr
)))
{
LOG_WARN
(
"failed to add param exprs"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
transed_in_exprs
.
push_back
(
tmp_in_expr
)))
{
LOG_WARN
(
"failed to push back element"
,
K
(
ret
));
}
else
{
tmp_in_expr
->
set_deduce_type_adding_implicit_cast
(
true
);
LOG_DEBUG
(
"partial in expr"
,
K
(
*
tmp_in_expr
),
K
(
*
tmp_row_expr
),
K
(
*
left_expr
));
tmp_left_expr
=
NULL
;
tmp_row_expr
=
NULL
;
tmp_in_expr
=
NULL
;
for
(
int
j
=
0
;
OB_SUCC
(
ret
)
&&
j
<
right_expr
->
get_param_count
();
j
++
)
{
ObObjType
obj_type
=
right_expr
->
get_param_expr
(
j
)
->
get_result_type
().
get_type
();
ObCollationType
coll_type
=
right_expr
->
get_param_expr
(
j
)
->
get_result_type
().
get_collation_type
();
ObCollationLevel
coll_level
=
right_expr
->
get_param_expr
(
j
)
->
get_result_type
().
get_collation_level
();
DistinctObjMeta
tmp_meta
(
obj_type
,
coll_type
,
coll_level
);
if
(
obj_meta
==
tmp_meta
&&
OB_FAIL
(
same_type_exprs
.
push_back
(
right_expr
->
get_param_expr
(
j
))))
{
LOG_WARN
(
"failed to add param expr"
,
K
(
ret
));
}
else
{
/* do nothing */
}
}
// for end
if
(
OB_SUCC
(
ret
)
&&
OB_FAIL
(
create_partial_expr
(
expr_factory
,
left_expr
,
same_type_exprs
,
is_in_expr
,
transed_in_exprs
)))
{
LOG_WARN
(
"failed to create partial expr"
,
K
(
ret
));
}
}
// for end
if
(
OB_FAIL
(
ret
))
{
// do nothing
}
else
if
(
OB_FAIL
(
get_final_transed_or_and_expr
(
expr_factory
,
session
,
is_in_expr
,
transed_in_exprs
,
in_expr
)))
{
LOG_WARN
(
"failed to get final transed or expr"
,
K
(
ret
));
}
else
{
...
...
@@ -3229,10 +3207,6 @@ int ObTransformPreProcess::transform_in_or_notin_expr_with_row(ObRawExprFactory&
}
}
}
// for end
ObSEArray
<
ObRawExpr
*
,
4
>
transed_in_exprs
;
ObOpRawExpr
*
tmp_in_expr
=
NULL
;
ObOpRawExpr
*
tmp_row_expr
=
NULL
;
ObRawExpr
*
tmp_left_expr
=
NULL
;
if
(
OB_FAIL
(
ret
))
{
// do nothing
}
else
if
(
1
==
distinct_row_types
.
count
())
{
...
...
@@ -3245,38 +3219,22 @@ int ObTransformPreProcess::transform_in_or_notin_expr_with_row(ObRawExprFactory&
op_raw_expr
->
set_deduce_type_adding_implicit_cast
(
true
);
}
}
else
{
ObItemType
op_type
=
is_in_expr
?
T_OP_IN
:
T_OP_NOT_IN
;
ObSEArray
<
ObRawExpr
*
,
4
>
transed_in_exprs
;
ObSEArray
<
ObRawExpr
*
,
4
>
same_type_exprs
;
for
(
int
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
distinct_row_types
.
count
();
i
++
)
{
if
(
OB_FAIL
(
expr_factory
.
create_raw_expr
(
op_type
,
tmp_in_expr
))
||
OB_FAIL
(
expr_factory
.
create_raw_expr
(
T_OP_ROW
,
tmp_row_expr
))
||
OB_FAIL
(
ObRawExprUtils
::
copy_expr
(
expr_factory
,
left_expr
,
tmp_left_expr
,
COPY_REF_DEFAULT
)))
{
LOG_WARN
(
"failed to create or copy raw expr"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
tmp_in_expr
)
||
OB_ISNULL
(
tmp_row_expr
)
||
OB_ISNULL
(
tmp_left_expr
))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"invalid null raw expr"
,
K
(
ret
),
K
(
tmp_in_expr
),
K
(
tmp_left_expr
),
K
(
tmp_row_expr
));
}
else
{
for
(
int
j
=
0
;
OB_SUCC
(
ret
)
&&
j
<
all_row_types
.
count
();
j
++
)
{
if
(
is_same_row_type
(
distinct_row_types
.
at
(
i
),
all_row_types
.
at
(
j
))
&&
OB_FAIL
(
tmp_row_expr
->
add_param_expr
(
right_expr
->
get_param_expr
(
j
))))
{
LOG_WARN
(
"failed to add param expr"
,
K
(
ret
));
}
}
// for end
if
(
OB_FAIL
(
ret
))
{
// do nothing
}
else
if
(
OB_FAIL
(
tmp_in_expr
->
add_param_expr
(
tmp_left_expr
))
||
OB_FAIL
(
tmp_in_expr
->
add_param_expr
(
tmp_row_expr
)))
{
LOG_WARN
(
"failed to add param exprs"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
transed_in_exprs
.
push_back
(
tmp_in_expr
)))
{
LOG_WARN
(
"failed to push back element"
,
K
(
ret
));
}
else
{
tmp_in_expr
->
set_deduce_type_adding_implicit_cast
(
true
);
tmp_row_expr
=
NULL
;
tmp_in_expr
=
NULL
;
same_type_exprs
.
reuse
();
for
(
int
j
=
0
;
OB_SUCC
(
ret
)
&&
j
<
all_row_types
.
count
();
j
++
)
{
if
(
is_same_row_type
(
distinct_row_types
.
at
(
i
),
all_row_types
.
at
(
j
))
&&
OB_FAIL
(
same_type_exprs
.
push_back
(
right_expr
->
get_param_expr
(
j
))))
{
LOG_WARN
(
"failed to add param expr"
,
K
(
ret
));
}
}
// for end
if
(
OB_SUCC
(
ret
)
&&
OB_FAIL
(
create_partial_expr
(
expr_factory
,
left_expr
,
same_type_exprs
,
is_in_expr
,
transed_in_exprs
)))
{
LOG_WARN
(
"failed to create partial expr"
,
K
(
ret
));
}
}
// for end
if
(
OB_FAIL
(
ret
))
{
// do nothing
}
else
if
(
OB_FAIL
(
get_final_transed_or_and_expr
(
expr_factory
,
session
,
is_in_expr
,
transed_in_exprs
,
in_expr
)))
{
LOG_WARN
(
"failed to get final transed in expr"
,
K
(
ret
));
}
else
{
...
...
@@ -3286,6 +3244,52 @@ int ObTransformPreProcess::transform_in_or_notin_expr_with_row(ObRawExprFactory&
return
ret
;
}
int
ObTransformPreProcess
::
create_partial_expr
(
ObRawExprFactory
&
expr_factory
,
ObRawExpr
*
left_expr
,
ObIArray
<
ObRawExpr
*>
&
same_type_exprs
,
const
bool
is_in_expr
,
ObIArray
<
ObRawExpr
*>
&
transed_in_exprs
)
{
int
ret
=
OB_SUCCESS
;
ObOpRawExpr
*
tmp_expr
=
NULL
;
ObOpRawExpr
*
tmp_row_expr
=
NULL
;
ObRawExpr
*
tmp_left_expr
=
NULL
;
ObRawExpr
*
tmp_right_expr
=
NULL
;
if
(
OB_UNLIKELY
(
same_type_exprs
.
empty
()))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"unexpected empty same_type_exprs"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
ObRawExprUtils
::
copy_expr
(
expr_factory
,
left_expr
,
tmp_left_expr
,
COPY_REF_DEFAULT
)))
{
LOG_WARN
(
"failed to copy raw expr"
,
K
(
ret
));
}
else
if
(
1
==
same_type_exprs
.
count
())
{
// = / <>
if
(
OB_FAIL
(
expr_factory
.
create_raw_expr
(
is_in_expr
?
T_OP_EQ
:
T_OP_NE
,
tmp_expr
)))
{
LOG_WARN
(
"failed to create or create raw expr"
,
K
(
ret
));
}
else
{
tmp_right_expr
=
same_type_exprs
.
at
(
0
);
}
}
else
if
(
OB_FAIL
(
expr_factory
.
create_raw_expr
(
is_in_expr
?
T_OP_IN
:
T_OP_NOT_IN
,
tmp_expr
))
// in / not in
||
OB_FAIL
(
expr_factory
.
create_raw_expr
(
T_OP_ROW
,
tmp_row_expr
)))
{
LOG_WARN
(
"failed to create or create raw expr"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
tmp_row_expr
))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"unexpected null expr"
,
K
(
ret
),
K
(
tmp_row_expr
));
}
else
if
(
OB_FAIL
(
append
(
tmp_row_expr
->
get_param_exprs
(),
same_type_exprs
)))
{
LOG_WARN
(
"failed to append exprs"
,
K
(
ret
));
}
else
{
tmp_right_expr
=
tmp_row_expr
;
}
if
(
OB_FAIL
(
ret
))
{
}
else
if
(
OB_ISNULL
(
tmp_expr
)
||
OB_ISNULL
(
tmp_left_expr
)
||
OB_ISNULL
(
tmp_right_expr
))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"unexpected null expr"
,
K
(
ret
),
K
(
tmp_expr
),
K
(
tmp_left_expr
),
K
(
tmp_right_expr
));
}
else
if
(
OB_FAIL
(
tmp_expr
->
add_param_expr
(
tmp_left_expr
))
||
OB_FAIL
(
tmp_expr
->
add_param_expr
(
tmp_right_expr
)))
{
LOG_WARN
(
"failed to add param exprs"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
transed_in_exprs
.
push_back
(
tmp_expr
)))
{
LOG_WARN
(
"failed to push back element"
,
K
(
ret
));
}
else
{
tmp_expr
->
set_deduce_type_adding_implicit_cast
(
true
);
LOG_DEBUG
(
"partial in expr"
,
K
(
*
tmp_expr
),
K
(
*
tmp_right_expr
),
K
(
*
left_expr
));
}
return
ret
;
}
int
ObTransformPreProcess
::
transform_arg_case_recursively
(
ObRawExprFactory
&
expr_factory
,
const
ObSQLSessionInfo
&
session
,
ObRawExpr
*&
expr
,
bool
&
trans_happened
)
{
...
...
src/sql/rewrite/ob_transform_pre_process.h
浏览文件 @
0a794fca
...
...
@@ -188,6 +188,9 @@ private:
static
int
transform_in_or_notin_expr_without_row
(
ObRawExprFactory
&
expr_factory
,
const
ObSQLSessionInfo
&
session
,
const
bool
is_in_expr
,
ObRawExpr
*&
in_epxr
,
bool
&
trans_happened
);
static
int
create_partial_expr
(
ObRawExprFactory
&
expr_factory
,
ObRawExpr
*
left_expr
,
ObIArray
<
ObRawExpr
*>
&
same_type_exprs
,
const
bool
is_in_expr
,
ObIArray
<
ObRawExpr
*>
&
transed_in_exprs
);
/*
* following functions are used to transform arg_case_expr to case_expr
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录