Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
野花太放肆
oceanbase
提交
09edba0f
O
oceanbase
项目概览
野花太放肆
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
1
Star
1
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,发现更多精彩内容 >>
提交
09edba0f
编写于
7月 27, 2021
作者:
L
leslieyuchen
提交者:
wangzelin.wzl
7月 27, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CP 3.1 commit to open source
上级
2b51e4f0
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
117 addition
and
107 deletion
+117
-107
src/sql/code_generator/ob_static_engine_cg.cpp
src/sql/code_generator/ob_static_engine_cg.cpp
+9
-20
src/sql/optimizer/ob_insert_log_plan.cpp
src/sql/optimizer/ob_insert_log_plan.cpp
+3
-5
src/sql/optimizer/ob_log_del_upd.cpp
src/sql/optimizer/ob_log_del_upd.cpp
+48
-18
src/sql/optimizer/ob_log_del_upd.h
src/sql/optimizer/ob_log_del_upd.h
+2
-1
src/sql/optimizer/ob_log_delete.cpp
src/sql/optimizer/ob_log_delete.cpp
+0
-17
src/sql/optimizer/ob_log_delete.h
src/sql/optimizer/ob_log_delete.h
+0
-2
src/sql/optimizer/ob_log_insert.cpp
src/sql/optimizer/ob_log_insert.cpp
+0
-7
src/sql/optimizer/ob_log_update.cpp
src/sql/optimizer/ob_log_update.cpp
+3
-16
src/sql/optimizer/ob_log_update.h
src/sql/optimizer/ob_log_update.h
+0
-1
src/sql/optimizer/ob_merge_log_plan.cpp
src/sql/optimizer/ob_merge_log_plan.cpp
+3
-5
src/sql/optimizer/ob_table_location.cpp
src/sql/optimizer/ob_table_location.cpp
+11
-6
src/sql/optimizer/ob_table_location.h
src/sql/optimizer/ob_table_location.h
+1
-1
src/sql/resolver/dml/ob_del_upd_stmt.cpp
src/sql/resolver/dml/ob_del_upd_stmt.cpp
+7
-1
src/sql/resolver/dml/ob_del_upd_stmt.h
src/sql/resolver/dml/ob_del_upd_stmt.h
+2
-1
src/sql/resolver/dml/ob_dml_resolver.cpp
src/sql/resolver/dml/ob_dml_resolver.cpp
+1
-1
src/sql/resolver/dml/ob_update_resolver.cpp
src/sql/resolver/dml/ob_update_resolver.cpp
+2
-1
src/sql/resolver/dml/ob_update_stmt.cpp
src/sql/resolver/dml/ob_update_stmt.cpp
+4
-3
src/sql/resolver/dml/ob_update_stmt.h
src/sql/resolver/dml/ob_update_stmt.h
+2
-1
src/sql/resolver/expr/ob_raw_expr_util.cpp
src/sql/resolver/expr/ob_raw_expr_util.cpp
+18
-0
src/sql/resolver/expr/ob_raw_expr_util.h
src/sql/resolver/expr/ob_raw_expr_util.h
+1
-0
未找到文件。
src/sql/code_generator/ob_static_engine_cg.cpp
浏览文件 @
09edba0f
...
...
@@ -5585,26 +5585,15 @@ int ObStaticEngineCG::generate_pdml_insert_exprs(const ObIArray<ObColumnRefRawEx
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"the count is not equal"
,
K
(
ret
),
K
(
index_exprs
.
count
()),
K
(
index_dml_conv_columns
.
count
()));
}
else
{
for
(
int
i
=
0
;
i
<
index_exprs
.
count
()
&&
OB_SUCC
(
ret
);
i
++
)
{
CK
(
OB_NOT_NULL
(
index_exprs
.
at
(
i
)));
const
ObColumnRefRawExpr
*
index_expr
=
index_exprs
.
at
(
i
);
if
(
OB_SUCC
(
ret
))
{
if
(
is_shadow_column
(
index_expr
->
get_column_id
()))
{
const
ObRawExpr
*
spk_expr
=
index_expr
->
get_dependant_expr
();
CK
(
OB_NOT_NULL
(
spk_expr
));
OZ
(
generate_rt_expr
(
*
spk_expr
,
expr
));
OZ
(
pdml_insert_exprs
.
push_back
(
expr
));
}
else
{
ObRawExpr
*
conv_expr
=
index_dml_conv_columns
.
at
(
i
);
if
(
OB_ISNULL
(
conv_expr
))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"invalid argument"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
generate_rt_expr
(
*
conv_expr
,
expr
)))
{
LOG_WARN
(
"fail to push cur op expr"
,
K
(
ret
),
K
(
index_exprs
));
}
else
if
(
OB_FAIL
(
pdml_insert_exprs
.
push_back
(
expr
)))
{
LOG_WARN
(
"fail to push expr"
,
K
(
ret
));
}
}
for
(
int
i
=
0
;
i
<
index_dml_conv_columns
.
count
()
&&
OB_SUCC
(
ret
);
i
++
)
{
ObRawExpr
*
conv_expr
=
index_dml_conv_columns
.
at
(
i
);
if
(
OB_ISNULL
(
conv_expr
))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"invalid argument"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
generate_rt_expr
(
*
conv_expr
,
expr
)))
{
LOG_WARN
(
"fail to push cur op expr"
,
K
(
ret
),
K
(
index_exprs
));
}
else
if
(
OB_FAIL
(
pdml_insert_exprs
.
push_back
(
expr
)))
{
LOG_WARN
(
"fail to push expr"
,
K
(
ret
));
}
}
}
...
...
src/sql/optimizer/ob_insert_log_plan.cpp
浏览文件 @
09edba0f
...
...
@@ -65,12 +65,10 @@ int ObInsertLogPlan::generate_plan()
ObIArray
<
IndexDMLInfo
>&
index_infos
=
table_columns
.
at
(
0
).
index_dml_infos_
;
for
(
int64_t
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
index_infos
.
count
();
++
i
)
{
LOG_DEBUG
(
"table_assign"
,
K
(
table_assign
.
at
(
0
).
assignments_
));
if
(
OB_FAIL
(
index_infos
.
at
(
i
).
init_assignment_info
(
table_assign
.
at
(
0
).
assignments_
)))
{
bool
use_static_typing_engine
=
optimizer_context_
.
get_session_info
()
->
use_static_typing_engine
();
if
(
OB_FAIL
(
index_infos
.
at
(
i
).
init_assignment_info
(
table_assign
.
at
(
0
).
assignments_
,
optimizer_context_
.
get_expr_factory
(),
use_static_typing_engine
)))
{
LOG_WARN
(
"init index assignment info failed"
,
K
(
ret
));
}
else
if
(
optimizer_context_
.
get_session_info
()
->
use_static_typing_engine
())
{
if
(
OB_FAIL
(
index_infos
.
at
(
i
).
add_spk_assignment_info
(
optimizer_context_
.
get_expr_factory
())))
{
LOG_WARN
(
"fail to add spk assignment info"
,
K
(
ret
));
}
}
}
}
...
...
src/sql/optimizer/ob_log_del_upd.cpp
浏览文件 @
09edba0f
...
...
@@ -55,12 +55,15 @@ int ObLogDelUpd::add_table_columns_to_ctx(ObAllocExprContext& ctx)
LOG_WARN
(
"invalid argument"
,
K
(
ret
));
}
else
{
for
(
int64_t
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
all_table_columns_
->
count
();
i
++
)
{
if
(
OB_UNLIKELY
(
all_table_columns_
->
at
(
i
).
index_dml_infos_
.
count
()
<=
0
))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"unexpected array count"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
add_exprs_to_ctx
(
ctx
,
all_table_columns_
->
at
(
i
).
index_dml_infos_
.
at
(
0
).
column_exprs_
)))
{
LOG_WARN
(
"failed to add exprs to ctx"
,
K
(
ret
));
}
else
{
/*do nothing*/
for
(
int64_t
j
=
0
;
OB_SUCC
(
ret
)
&&
j
<
all_table_columns_
->
at
(
i
).
index_dml_infos_
.
count
();
++
j
)
{
const
IndexDMLInfo
&
index_dml_info
=
all_table_columns_
->
at
(
i
).
index_dml_infos_
.
at
(
j
);
if
(
OB_FAIL
(
add_exprs_to_ctx
(
ctx
,
index_dml_info
.
column_exprs_
)))
{
LOG_WARN
(
"add column exprs to ctx failed"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
add_exprs_to_ctx
(
ctx
,
index_dml_info
.
column_convert_exprs_
)))
{
LOG_WARN
(
"add column convert exprs to ctx failed"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
add_exprs_to_ctx
(
ctx
,
index_dml_info
.
calc_part_id_exprs_
)))
{
LOG_WARN
(
"add calc part id exprs failed"
,
K
(
ret
));
}
}
}
}
...
...
@@ -765,15 +768,28 @@ int ObLogDelUpd::check_output_dep_specific(ObRawExprCheckDep& checker)
if
(
all_table_columns_
!=
NULL
)
{
int64_t
N
=
all_table_columns_
->
count
();
for
(
int64_t
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
N
;
i
++
)
{
const
ObIArray
<
ObColumnRefRawExpr
*>&
columns
=
all_table_columns_
->
at
(
i
).
index_dml_infos_
.
at
(
0
).
column_exprs_
;
int64_t
M
=
columns
.
count
();
for
(
int64_t
j
=
0
;
OB_SUCC
(
ret
)
&&
j
<
M
;
++
j
)
{
if
(
OB_ISNULL
(
columns
.
at
(
j
)))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"columns->at(j) contains null"
,
K
(
ret
),
K
(
j
));
}
else
if
(
OB_FAIL
(
checker
.
check
(
*
static_cast
<
ObRawExpr
*>
(
columns
.
at
(
j
)))))
{
LOG_WARN
(
"failed to check column expr"
,
K
(
ret
),
K
(
j
));
}
else
{
const
TableColumns
&
table_columns
=
all_table_columns_
->
at
(
i
);
for
(
int64_t
k
=
0
;
OB_SUCC
(
ret
)
&&
k
<
table_columns
.
index_dml_infos_
.
count
();
++
k
)
{
const
IndexDMLInfo
&
index_dml_info
=
table_columns
.
index_dml_infos_
.
at
(
k
);
if
(
0
==
k
)
{
// index dml info中的expr是主表的expr的指针拷贝,所以这里只用检查主表的expr
const
ObIArray
<
ObColumnRefRawExpr
*>&
columns
=
index_dml_info
.
column_exprs_
;
int64_t
M
=
columns
.
count
();
for
(
int64_t
j
=
0
;
OB_SUCC
(
ret
)
&&
j
<
M
;
++
j
)
{
if
(
OB_ISNULL
(
columns
.
at
(
j
)))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"columns->at(j) contains null"
,
K
(
ret
),
K
(
j
));
}
else
if
(
OB_FAIL
(
checker
.
check
(
*
static_cast
<
ObRawExpr
*>
(
columns
.
at
(
j
)))))
{
LOG_WARN
(
"failed to check column expr"
,
K
(
ret
),
K
(
j
));
}
else
{
}
}
}
for
(
int64_t
j
=
0
;
OB_SUCC
(
ret
)
&&
j
<
index_dml_info
.
calc_part_id_exprs_
.
count
();
++
j
)
{
if
(
OB_ISNULL
(
index_dml_info
.
calc_part_id_exprs_
.
at
(
j
)))
{
// ignore nullptr calc part id expr, do nothing
}
else
if
(
OB_FAIL
(
checker
.
check
(
*
index_dml_info
.
calc_part_id_exprs_
.
at
(
j
))))
{
LOG_WARN
(
"failed to check column expr"
,
K
(
ret
));
}
}
}
}
...
...
@@ -1066,7 +1082,18 @@ int ObLogDelUpd::alloc_partition_id_expr(ObAllocExprContext& ctx)
return
ret
;
}
int
ObLogDelUpd
::
alloc_shadow_pk_column_for_pdml
(
ObAllocExprContext
&
ctx
)
int
ObLogDelUpd
::
allocate_expr_post
(
ObAllocExprContext
&
ctx
)
{
int
ret
=
OB_SUCCESS
;
if
(
OB_FAIL
(
alloc_shadow_pk_column_for_gui
(
ctx
)))
{
LOG_WARN
(
"failed alloc generated column for pdml index maintain"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
ObLogicalOperator
::
allocate_expr_post
(
ctx
)))
{
LOG_WARN
(
"failed to allocate expr post"
,
K
(
ret
));
}
return
ret
;
}
int
ObLogDelUpd
::
alloc_shadow_pk_column_for_gui
(
ObAllocExprContext
&
ctx
)
{
int
ret
=
OB_SUCCESS
;
for
(
int64_t
i
=
0
;
i
<
ctx
.
expr_producers_
.
count
()
&&
OB_SUCC
(
ret
);
i
++
)
{
...
...
@@ -1075,14 +1102,17 @@ int ObLogDelUpd::alloc_shadow_pk_column_for_pdml(ObAllocExprContext& ctx)
if
(
expr_producer
.
consumer_id_
==
id_
&&
expr_producer
.
expr_
->
is_column_ref_expr
())
{
ObColumnRefRawExpr
*
column_ref_expr
=
(
ObColumnRefRawExpr
*
)(
expr_producer
.
expr_
);
if
(
column_ref_expr
->
is_virtual_generated_column
()
&&
!
OB_ISNULL
(
column_ref_expr
->
get_dependant_expr
())
&&
column_ref_expr
->
get_dependant_expr
()
->
get_expr_type
()
==
T_OP_SHADOW_UK_PROJECT
)
{
is_shadow_column
(
column_ref_expr
->
get_column_id
())
)
{
if
(
OB_FAIL
(
mark_expr_produced
(
column_ref_expr
,
branch_id_
,
id_
,
ctx
,
found
)))
{
LOG_WARN
(
"failed to mark expr produce"
,
K
(
ret
),
K
(
id_
),
K
(
get_name
()),
K
(
*
column_ref_expr
));
}
else
if
(
!
found
)
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"find error with mark expr produce for pdml"
,
K
(
ret
),
K
(
id_
),
K
(
get_name
()));
}
else
{
LOG_TRACE
(
"the generated column expr is producing, and not add to output exprs"
,
K
(
id_
),
K
(
get_name
()));
LOG_TRACE
(
"the generated column expr is producing, and not add to output exprs"
,
K
(
id_
),
K
(
get_name
()),
KPC
(
column_ref_expr
));
}
}
}
...
...
src/sql/optimizer/ob_log_del_upd.h
浏览文件 @
09edba0f
...
...
@@ -246,7 +246,8 @@ protected:
int
calculate_table_location
(
uint64_t
loc_table_id
,
uint64_t
ref_table_id
,
const
ObPartHint
*
part_hint
,
ObTablePartitionInfo
&
table_partition_info
);
int
alloc_partition_id_expr
(
ObAllocExprContext
&
ctx
);
int
alloc_shadow_pk_column_for_pdml
(
ObAllocExprContext
&
ctx
);
virtual
int
allocate_expr_post
(
ObAllocExprContext
&
ctx
);
int
alloc_shadow_pk_column_for_gui
(
ObAllocExprContext
&
ctx
);
virtual
int
need_multi_table_dml
(
AllocExchContext
&
ctx
,
ObShardingInfo
&
sharding_info
,
bool
&
is_needed
);
int
check_multi_table_dml_for_px
(
AllocExchContext
&
ctx
,
ObShardingInfo
*
source_sharding
,
ObShardingInfo
&
sharding_info
,
const
ObPhyTableLocationInfo
*
phy_table_locaion_info
,
bool
&
is_needed
);
...
...
src/sql/optimizer/ob_log_delete.cpp
浏览文件 @
09edba0f
...
...
@@ -36,23 +36,6 @@ int ObLogDelete::allocate_expr_pre(ObAllocExprContext& ctx)
return
ret
;
}
int
ObLogDelete
::
allocate_expr_post
(
ObAllocExprContext
&
ctx
)
{
int
ret
=
OB_SUCCESS
;
if
(
is_pdml
()
&&
is_index_maintenance
())
{
// handle shadow pk column
if
(
OB_FAIL
(
alloc_shadow_pk_column_for_pdml
(
ctx
)))
{
LOG_WARN
(
"failed alloc generated column for pdml index maintain"
,
K
(
ret
));
}
}
if
(
OB_SUCC
(
ret
))
{
if
(
OB_FAIL
(
ObLogicalOperator
::
allocate_expr_post
(
ctx
)))
{
LOG_WARN
(
"failed to allocate expr post for delete"
,
K
(
ret
));
}
}
return
ret
;
}
const
char
*
ObLogDelete
::
get_name
()
const
{
const
char
*
name
=
NULL
;
...
...
src/sql/optimizer/ob_log_delete.h
浏览文件 @
09edba0f
...
...
@@ -32,8 +32,6 @@ public:
*/
virtual
int
allocate_expr_pre
(
ObAllocExprContext
&
ctx
)
override
;
virtual
int
allocate_expr_post
(
ObAllocExprContext
&
ctx
)
override
;
virtual
int
est_cost
();
virtual
int
copy_without_child
(
ObLogicalOperator
*&
out
)
...
...
src/sql/optimizer/ob_log_insert.cpp
浏览文件 @
09edba0f
...
...
@@ -291,13 +291,6 @@ int ObLogInsert::allocate_expr_post(ObAllocExprContext& ctx)
}
}
if
(
OB_SUCC
(
ret
)
&&
is_pdml
()
&&
is_index_maintenance
())
{
// handle shadow pk column
if
(
OB_FAIL
(
alloc_shadow_pk_column_for_pdml
(
ctx
)))
{
LOG_WARN
(
"failed alloc generated column for pdml index maintain"
,
K
(
ret
));
}
}
if
(
OB_SUCC
(
ret
))
{
if
(
OB_FAIL
(
ObLogDelUpd
::
allocate_expr_post
(
ctx
)))
{
LOG_WARN
(
"failed to allocate expr post"
,
K
(
ret
));
...
...
src/sql/optimizer/ob_log_update.cpp
浏览文件 @
09edba0f
...
...
@@ -119,22 +119,6 @@ int ObLogUpdate::allocate_expr_pre(ObAllocExprContext& ctx)
return
ret
;
}
int
ObLogUpdate
::
allocate_expr_post
(
ObAllocExprContext
&
ctx
)
{
int
ret
=
OB_SUCCESS
;
if
(
is_pdml
()
&&
is_index_maintenance
())
{
if
(
OB_FAIL
(
alloc_shadow_pk_column_for_pdml
(
ctx
)))
{
LOG_WARN
(
"failed alloc generated column for pdml index maintain"
,
K
(
ret
));
}
}
if
(
OB_SUCC
(
ret
))
{
if
(
OB_FAIL
(
ObLogicalOperator
::
allocate_expr_post
(
ctx
)))
{
LOG_WARN
(
"failed to allocate expr post for delete"
,
K
(
ret
));
}
}
return
ret
;
}
int
ObLogUpdate
::
check_output_dep_specific
(
ObRawExprCheckDep
&
checker
)
{
int
ret
=
OB_SUCCESS
;
...
...
@@ -194,6 +178,9 @@ int ObLogUpdate::allocate_exchange_post(AllocExchContext* ctx)
for
(
int64_t
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
index_infos
.
count
();
++
i
)
{
ObRawExpr
*
expr
=
NULL
;
OZ
(
gen_calc_part_id_expr
(
index_infos
.
at
(
i
).
loc_table_id_
,
index_infos
.
at
(
i
).
index_tid_
,
expr
));
// calc part id expr's column reference expr need to be marked with explicit reference
// let TSC to produce its column expr
OZ
(
ObRawExprUtils
::
mark_column_explicited_reference
(
*
expr
));
OZ
(
index_infos
.
at
(
i
).
calc_part_id_exprs_
.
push_back
(
expr
));
CK
(
OB_NOT_NULL
(
get_plan
()));
CK
(
OB_NOT_NULL
(
get_plan
()
->
get_optimizer_context
().
get_session_info
()));
...
...
src/sql/optimizer/ob_log_update.h
浏览文件 @
09edba0f
...
...
@@ -40,7 +40,6 @@ public:
virtual
uint64_t
hash
(
uint64_t
seed
)
const
;
virtual
int
allocate_expr_pre
(
ObAllocExprContext
&
ctx
)
override
;
virtual
int
allocate_expr_post
(
ObAllocExprContext
&
ctx
)
override
;
virtual
int
check_output_dep_specific
(
ObRawExprCheckDep
&
checker
);
virtual
const
char
*
get_name
()
const
;
void
set_update_set
(
bool
update_set
)
...
...
src/sql/optimizer/ob_merge_log_plan.cpp
浏览文件 @
09edba0f
...
...
@@ -67,12 +67,10 @@ int ObMergeLogPlan::generate_plan()
if
(
OB_SUCC
(
ret
)
&&
OB_LIKELY
(
table_assign
.
count
()
==
1
))
{
ObIArray
<
IndexDMLInfo
>&
index_infos
=
table_columns
.
at
(
0
).
index_dml_infos_
;
for
(
int64_t
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
index_infos
.
count
();
i
++
)
{
if
(
OB_FAIL
(
index_infos
.
at
(
i
).
init_assignment_info
(
table_assign
.
at
(
0
).
assignments_
)))
{
bool
use_static_typing_engine
=
optimizer_context_
.
get_session_info
()
->
use_static_typing_engine
();
if
(
OB_FAIL
(
index_infos
.
at
(
i
).
init_assignment_info
(
table_assign
.
at
(
0
).
assignments_
,
optimizer_context_
.
get_expr_factory
(),
use_static_typing_engine
)))
{
LOG_WARN
(
"init index assignment info failed"
,
K
(
ret
));
}
else
if
(
optimizer_context_
.
get_session_info
()
->
use_static_typing_engine
())
{
if
(
OB_FAIL
(
index_infos
.
at
(
i
).
add_spk_assignment_info
(
optimizer_context_
.
get_expr_factory
())))
{
LOG_WARN
(
"fail to add spk assignment info"
,
K
(
ret
));
}
}
}
}
...
...
src/sql/optimizer/ob_table_location.cpp
浏览文件 @
09edba0f
...
...
@@ -1190,12 +1190,13 @@ void ObTableLocation::reset()
}
int
ObTableLocation
::
init_table_location
(
ObSqlSchemaGuard
&
schema_guard
,
uint64_t
table_id
,
uint64_t
ref_table_id
,
ObDMLStmt
&
stmt
,
RowDesc
&
row_desc
,
const
bool
is_dml_table
,
/*whether the ref_table is modified*/
ObDMLStmt
&
stmt
,
const
RowDesc
&
row_desc
,
const
bool
is_dml_table
,
/*whether the ref_table is modified*/
const
ObOrderDirection
&
direction
)
{
int
ret
=
OB_SUCCESS
;
const
ObTableSchema
*
table_schema
=
NULL
;
const
ObRawExpr
*
part_raw_expr
=
NULL
;
RowDesc
loc_row_desc
;
table_id_
=
table_id
;
ref_table_id_
=
ref_table_id
;
...
...
@@ -1239,6 +1240,10 @@ int ObTableLocation::init_table_location(ObSqlSchemaGuard& schema_guard, uint64_
}
else
if
(
0
>=
(
part_num_
=
table_schema
->
get_part_option
().
get_part_num
()))
{
ret
=
OB_SCHEMA_ERROR
;
LOG_WARN
(
"partitioned virtual table's part num should > 0"
,
K
(
ret
),
K
(
part_num_
));
}
else
if
(
OB_FAIL
(
loc_row_desc
.
init
()))
{
LOG_WARN
(
"init loc row desc failed"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
loc_row_desc
.
assign
(
row_desc
)))
{
LOG_WARN
(
"assign location row desc failed"
,
K
(
ret
));
}
else
{
if
(
OB_ISNULL
(
part_raw_expr
=
get_related_part_expr
(
stmt
,
PARTITION_LEVEL_ONE
,
table_id
,
ref_table_id_
)))
{
ret
=
OB_ERR_UNEXPECTED
;
...
...
@@ -1249,10 +1254,10 @@ int ObTableLocation::init_table_location(ObSqlSchemaGuard& schema_guard, uint64_
}
else
if
(
FALSE_IT
(
is_col_part_expr_
=
part_raw_expr
->
is_column_ref_expr
()))
{
// never reach
}
else
if
(
OB_FAIL
(
ObExprGeneratorImpl
::
gen_expression_with_row_desc
(
sql_expression_factory_
,
expr_op_factory_
,
row_desc
,
part_raw_expr
,
part_expr_
)))
{
sql_expression_factory_
,
expr_op_factory_
,
loc_
row_desc
,
part_raw_expr
,
part_expr_
)))
{
LOG_WARN
(
"gen expression with row desc failed"
,
K
(
ret
));
}
else
if
(
PARTITION_FUNC_TYPE_RANGE_COLUMNS
==
part_type_
||
PARTITION_FUNC_TYPE_LIST_COLUMNS
==
part_type_
)
{
if
(
OB_FAIL
(
part_projector_
.
init_part_projector
(
part_raw_expr
,
row_desc
)))
{
if
(
OB_FAIL
(
part_projector_
.
init_part_projector
(
part_raw_expr
,
loc_
row_desc
)))
{
LOG_WARN
(
"init part projector failed"
,
K
(
ret
));
}
}
else
{
...
...
@@ -1278,17 +1283,17 @@ int ObTableLocation::init_table_location(ObSqlSchemaGuard& schema_guard, uint64_
can_get_part_by_range_for_range_columns
(
subpart_raw_expr
,
is_valid_range_columns_subpart_range_
)))
{
LOG_WARN
(
"failed to check can get part by range for range columns"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
ObExprGeneratorImpl
::
gen_expression_with_row_desc
(
sql_expression_factory_
,
expr_op_factory_
,
row_desc
,
subpart_raw_expr
,
subpart_expr_
)))
{
sql_expression_factory_
,
expr_op_factory_
,
loc_
row_desc
,
subpart_raw_expr
,
subpart_expr_
)))
{
LOG_WARN
(
"gen expression with row desc failed"
,
K
(
ret
));
}
else
if
(
PARTITION_FUNC_TYPE_RANGE_COLUMNS
==
subpart_type_
||
PARTITION_FUNC_TYPE_LIST_COLUMNS
==
subpart_type_
)
{
if
(
OB_FAIL
(
part_projector_
.
init_subpart_projector
(
subpart_raw_expr
,
row_desc
)))
{
if
(
OB_FAIL
(
part_projector_
.
init_subpart_projector
(
subpart_raw_expr
,
loc_
row_desc
)))
{
LOG_WARN
(
"init subpart projector failed"
,
K
(
ret
));
}
}
}
if
(
OB_SUCC
(
ret
))
{
part_projector_
.
set_column_cnt
(
row_desc
.
get_column_num
());
part_projector_
.
set_column_cnt
(
loc_
row_desc
.
get_column_num
());
bool
check_dropped_schema
=
false
;
ObTablePartitionKeyIter
iter
(
*
table_schema
,
check_dropped_schema
);
int64_t
partition_id
=
-
1
;
...
...
src/sql/optimizer/ob_table_location.h
浏览文件 @
09edba0f
...
...
@@ -646,7 +646,7 @@ public:
share
::
schema
::
ObSchemaGetterGuard
&
schema_guard
,
uint64_t
table_id
,
const
common
::
ObIArray
<
ObRowkey
>&
rowkeys
,
common
::
ObIArray
<
int64_t
>&
part_ids
,
common
::
ObIArray
<
RowkeyArray
>&
rowkey_lists
);
int
init_table_location
(
ObSqlSchemaGuard
&
schema_guard
,
uint64_t
table_id
,
uint64_t
ref_table_id
,
ObDMLStmt
&
stmt
,
RowDesc
&
row_desc
,
const
bool
is_dml_table
,
const
ObOrderDirection
&
direction
=
default_asc_direction
());
const
RowDesc
&
row_desc
,
const
bool
is_dml_table
,
const
ObOrderDirection
&
direction
=
default_asc_direction
());
int
init_table_location_with_rowkey
(
ObSqlSchemaGuard
&
schema_guard
,
uint64_t
table_id
,
ObSQLSessionInfo
&
session_info
,
const
bool
is_dml_table
=
true
);
int
calculate_partition_ids_by_row
(
ObExecContext
&
exec_ctx
,
ObPartMgr
*
part_mgr
,
const
common
::
ObNewRow
&
row
,
...
...
src/sql/resolver/dml/ob_del_upd_stmt.cpp
浏览文件 @
09edba0f
...
...
@@ -575,7 +575,8 @@ int64_t IndexDMLInfo::to_explain_string(char* buf, int64_t buf_len, ExplainType
return
pos
;
}
int
IndexDMLInfo
::
init_assignment_info
(
const
ObAssignments
&
assignments
)
int
IndexDMLInfo
::
init_assignment_info
(
const
ObAssignments
&
assignments
,
ObRawExprFactory
&
expr_factory
,
bool
use_static_typing_engine
)
{
int
ret
=
OB_SUCCESS
;
assignments_
.
reset
();
...
...
@@ -586,6 +587,11 @@ int IndexDMLInfo::init_assignment_info(const ObAssignments& assignments)
}
}
}
if
(
OB_SUCC
(
ret
)
&&
use_static_typing_engine
)
{
if
(
OB_FAIL
(
add_spk_assignment_info
(
expr_factory
)))
{
LOG_WARN
(
"fail to add spk assignment info"
,
K
(
ret
));
}
}
if
(
OB_SUCC
(
ret
)
&&
OB_FAIL
(
init_column_convert_expr
(
assignments_
)))
{
LOG_WARN
(
"fail init column convert exprs"
,
K
(
ret
));
}
...
...
src/sql/resolver/dml/ob_del_upd_stmt.h
浏览文件 @
09edba0f
...
...
@@ -50,7 +50,8 @@ public:
calc_part_id_exprs_
.
reset
();
}
int64_t
to_explain_string
(
char
*
buf
,
int64_t
buf_len
,
ExplainType
type
)
const
;
int
init_assignment_info
(
const
ObAssignments
&
assignments
);
int
init_assignment_info
(
const
ObAssignments
&
assignments
,
ObRawExprFactory
&
expr_factory
,
bool
use_static_typing_engine
);
int
add_spk_assignment_info
(
ObRawExprFactory
&
expr_factory
);
int
deep_copy
(
ObRawExprFactory
&
expr_factory
,
const
IndexDMLInfo
&
other
);
...
...
src/sql/resolver/dml/ob_dml_resolver.cpp
浏览文件 @
09edba0f
...
...
@@ -9843,7 +9843,7 @@ int ObDMLResolver::fill_index_column_convert_exprs(bool use_static_engine, const
}
if
(
is_shadow_pk_column
&&
use_static_engine
)
{
ObColumnRefRawExpr
*
column_ref_expr
=
column_exprs
.
at
(
i
);
if
(
OB_FAIL
(
column_convert_exprs
.
push_back
(
column_ref_expr
)))
{
if
(
OB_FAIL
(
column_convert_exprs
.
push_back
(
column_ref_expr
->
get_dependant_expr
()
)))
{
LOG_WARN
(
"failed to push back to column convert exprs"
,
K
(
ret
));
}
}
else
if
(
is_shadow_pk_column
)
{
...
...
src/sql/resolver/dml/ob_update_resolver.cpp
浏览文件 @
09edba0f
...
...
@@ -232,7 +232,8 @@ int ObUpdateResolver::resolve(const ParseNode& parse_tree)
if
(
OB_SUCC
(
ret
))
{
// Distribute the centralized assignment information to each index, and do assignment updates for each index
if
(
OB_FAIL
(
update_stmt
->
refill_index_assignment_info
()))
{
if
(
OB_FAIL
(
update_stmt
->
refill_index_assignment_info
(
*
params_
.
expr_factory_
,
session_info_
->
use_static_typing_engine
())))
{
LOG_WARN
(
"init index assignment info failed"
,
K
(
ret
));
}
}
...
...
src/sql/resolver/dml/ob_update_stmt.cpp
浏览文件 @
09edba0f
...
...
@@ -47,7 +47,7 @@ int ObUpdateStmt::deep_copy_stmt_struct(
}
}
if
(
OB_SUCC
(
ret
))
{
if
(
OB_FAIL
(
refill_index_assignment_info
()))
{
if
(
OB_FAIL
(
refill_index_assignment_info
(
expr_factory
,
other
.
use_static_typing_engine_
)))
{
LOG_WARN
(
"fail refill index assignment info"
,
K
(
ret
));
}
}
...
...
@@ -342,7 +342,7 @@ const ObTablesAssignments* ObUpdateStmt::get_slice_from_all_table_assignments(
return
tables_assignments
;
}
int
ObUpdateStmt
::
refill_index_assignment_info
()
int
ObUpdateStmt
::
refill_index_assignment_info
(
ObRawExprFactory
&
expr_factory
,
bool
use_static_typing_engine
)
{
int
ret
=
OB_SUCCESS
;
const
ObTablesAssignments
&
table_assign
=
get_tables_assignments
();
...
...
@@ -353,11 +353,12 @@ int ObUpdateStmt::refill_index_assignment_info()
ObIArray
<
IndexDMLInfo
>&
index_infos
=
all_table_columns
.
at
(
i
).
index_dml_infos_
;
for
(
int64_t
j
=
0
;
OB_SUCC
(
ret
)
&&
j
<
index_infos
.
count
();
++
j
)
{
IndexDMLInfo
&
index_info
=
index_infos
.
at
(
j
);
if
(
OB_FAIL
(
index_info
.
init_assignment_info
(
assignments
)))
{
if
(
OB_FAIL
(
index_info
.
init_assignment_info
(
assignments
,
expr_factory
,
use_static_typing_engine
)))
{
LOG_WARN
(
"init index assignment info failed"
,
K
(
i
),
K
(
ret
));
}
}
}
use_static_typing_engine_
=
use_static_typing_engine
;
return
ret
;
}
...
...
src/sql/resolver/dml/ob_update_stmt.h
浏览文件 @
09edba0f
...
...
@@ -75,7 +75,7 @@ public:
virtual
int
has_special_expr
(
const
ObExprInfoFlag
,
bool
&
has
)
const
override
;
virtual
int
replace_inner_stmt_expr
(
const
common
::
ObIArray
<
ObRawExpr
*>&
other_exprs
,
const
common
::
ObIArray
<
ObRawExpr
*>&
new_exprs
)
override
;
int
refill_index_assignment_info
();
int
refill_index_assignment_info
(
ObRawExprFactory
&
expr_factory
,
bool
use_static_typing_engine
);
const
ObTablesAssignments
*
get_slice_from_all_table_assignments
(
common
::
ObIAllocator
&
allocator
,
int64_t
table_idx
,
int64_t
index_idx
)
const
;
...
...
@@ -102,6 +102,7 @@ private:
*/
bool
low_priority_
;
bool
update_set_
;
bool
use_static_typing_engine_
;
};
}
// namespace sql
}
// namespace oceanbase
...
...
src/sql/resolver/expr/ob_raw_expr_util.cpp
浏览文件 @
09edba0f
...
...
@@ -1536,6 +1536,24 @@ int ObRawExprUtils::extract_column_exprs(const ObIArray<ObRawExpr*>& exprs, ObIA
return
ret
;
}
int
ObRawExprUtils
::
mark_column_explicited_reference
(
ObRawExpr
&
expr
)
{
int
ret
=
OB_SUCCESS
;
ObSEArray
<
ObRawExpr
*
,
2
>
column_exprs
;
if
(
OB_FAIL
(
extract_column_exprs
(
&
expr
,
column_exprs
)))
{
LOG_WARN
(
"extract column exprs failed"
,
K
(
ret
),
K
(
expr
));
}
for
(
int64_t
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
column_exprs
.
count
();
++
i
)
{
if
(
!
column_exprs
.
at
(
i
)
->
is_column_ref_expr
())
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"column expr is unexpected"
,
K
(
ret
));
}
else
{
static_cast
<
ObColumnRefRawExpr
*>
(
column_exprs
.
at
(
i
))
->
set_explicited_reference
();
}
}
return
ret
;
}
int
ObRawExprUtils
::
extract_column_ids
(
const
ObIArray
<
ObRawExpr
*>&
exprs
,
common
::
ObIArray
<
uint64_t
>&
column_ids
)
{
int
ret
=
OB_SUCCESS
;
...
...
src/sql/resolver/expr/ob_raw_expr_util.h
浏览文件 @
09edba0f
...
...
@@ -220,6 +220,7 @@ public:
static
int
extract_column_exprs
(
const
ObRawExpr
*
raw_expr
,
common
::
ObIArray
<
ObRawExpr
*>&
column_exprs
);
static
int
extract_column_exprs
(
const
common
::
ObIArray
<
ObRawExpr
*>&
exprs
,
common
::
ObIArray
<
ObRawExpr
*>&
column_exprs
);
static
int
mark_column_explicited_reference
(
ObRawExpr
&
expr
);
static
int
extract_column_ids
(
const
ObIArray
<
ObRawExpr
*>&
exprs
,
common
::
ObIArray
<
uint64_t
>&
column_ids
);
static
int
extract_column_ids
(
const
ObRawExpr
*
raw_expr
,
common
::
ObIArray
<
uint64_t
>&
column_ids
);
static
int
extract_table_ids
(
const
ObRawExpr
*
raw_expr
,
common
::
ObIArray
<
uint64_t
>&
table_ids
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录