fix pdml bug after or expansion transformation
This commit is contained in:
@ -36,6 +36,7 @@ namespace sql
|
||||
#define DIRECT_MODE_INSERT_INTO_SELECT "Direct-mode is enabled in insert into select"
|
||||
#define PARALLEL_DISABLED_BY_DBLINK "Degree of Parallelisim is %ld because stmt contain dblink which force das scan"
|
||||
#define PDML_DISABLED_BY_INSERT_PK_AUTO_INC "PDML disabled because the insert statement primary key has specified auto-increment column"
|
||||
#define PDML_DISABLED_BY_TRANSFORMATIONS "PDML disabled because transformations like or-expansion"
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -424,6 +424,9 @@ int ObOptimizer::check_pdml_supported_feature(const ObDelUpdStmt &pdml_stmt,
|
||||
static_cast< const ObInsertStmt &>(pdml_stmt).is_insert_up()) {
|
||||
is_use_pdml = false;
|
||||
ctx_.add_plan_note(PDML_DISABLED_BY_INSERT_UP);
|
||||
} else if (pdml_stmt.is_pdml_disabled()) {
|
||||
is_use_pdml = false;
|
||||
ctx_.add_plan_note(PDML_DISABLED_BY_TRANSFORMATIONS);
|
||||
} else if (ctx_.has_dblink()) {
|
||||
is_use_pdml = false;
|
||||
} else if (ctx_.contain_user_nested_sql()) {
|
||||
|
@ -419,6 +419,7 @@ int ObDelUpdStmt::deep_copy_stmt_struct(ObIAllocator &allocator,
|
||||
ignore_ = other.ignore_;
|
||||
has_global_index_ = other.has_global_index_;
|
||||
has_instead_of_trigger_ = other.has_instead_of_trigger_;
|
||||
pdml_disabled_ = other.pdml_disabled_;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -443,6 +444,7 @@ int ObDelUpdStmt::assign(const ObDelUpdStmt &other)
|
||||
has_global_index_ = other.has_global_index_;
|
||||
has_instead_of_trigger_ = other.has_instead_of_trigger_;
|
||||
ab_stmt_id_expr_ = other.ab_stmt_id_expr_;
|
||||
pdml_disabled_ = other.pdml_disabled_;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -402,7 +402,8 @@ public:
|
||||
error_log_info_(),
|
||||
has_instead_of_trigger_(false),
|
||||
ab_stmt_id_expr_(nullptr),
|
||||
dml_source_from_join_(false)
|
||||
dml_source_from_join_(false),
|
||||
pdml_disabled_(false)
|
||||
{ }
|
||||
virtual ~ObDelUpdStmt() { }
|
||||
int deep_copy_stmt_struct(ObIAllocator &allocator,
|
||||
@ -469,6 +470,8 @@ public:
|
||||
void set_dml_source_from_join(bool from_join) { dml_source_from_join_ = from_join; }
|
||||
inline bool dml_source_from_join() const { return dml_source_from_join_; }
|
||||
int check_dml_source_from_join();
|
||||
bool is_pdml_disabled() const { return pdml_disabled_; }
|
||||
void set_pdml_disabled() { pdml_disabled_ = true; }
|
||||
protected:
|
||||
common::ObSEArray<ObRawExpr*, common::OB_PREALLOCATED_NUM, common::ModulePageAllocator, true> returning_exprs_;
|
||||
common::ObSEArray<ObRawExpr*, common::OB_PREALLOCATED_NUM, common::ModulePageAllocator, true> returning_into_exprs_;
|
||||
@ -482,6 +485,7 @@ protected:
|
||||
common::ObSEArray<ObRawExpr *, 16, common::ModulePageAllocator, true> sharding_conditions_;
|
||||
ObRawExpr *ab_stmt_id_expr_; //for array binding batch execution to mark the stmt id
|
||||
bool dml_source_from_join_;
|
||||
bool pdml_disabled_; // pdml is disabled after some transformation like or-expansion
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -410,6 +410,8 @@ int ObTransformOrExpansion::try_do_transform_inner_join(ObIArray<ObParentDMLStmt
|
||||
} else if (OB_FAIL(ObTransformUtils::deep_copy_stmt(*ctx_->stmt_factory_, *ctx_->expr_factory_,
|
||||
stmt, origin_trans_stmt))) {
|
||||
LOG_WARN("failed to deep copy stmt", K(ret));
|
||||
} else if (OB_FAIL(disable_pdml_for_upd_del_stmt(*origin_trans_stmt))) {
|
||||
LOG_WARN("failed to disable pdml for upd_del_stmt", K(ret));
|
||||
} else if (OB_FAIL(create_single_joined_table_stmt(origin_trans_stmt, joined_table->table_id_,
|
||||
view_table, ref_query))) {
|
||||
LOG_WARN("failed to create view with table", K(ret));
|
||||
@ -529,6 +531,8 @@ int ObTransformOrExpansion::try_do_transform_left_join(ObIArray<ObParentDMLStmt>
|
||||
} else if (OB_FAIL(ObTransformUtils::deep_copy_stmt(*ctx_->stmt_factory_, *ctx_->expr_factory_,
|
||||
stmt, origin_trans_stmt))) {
|
||||
LOG_WARN("failed to deep copy stmt", K(ret));
|
||||
} else if (OB_FAIL(disable_pdml_for_upd_del_stmt(*origin_trans_stmt))) {
|
||||
LOG_WARN("failed to disable pdml for upd_del_stmt", K(ret));
|
||||
} else if (OB_FAIL(create_single_joined_table_stmt(origin_trans_stmt, joined_table->table_id_,
|
||||
view_table, ref_query))) {
|
||||
LOG_WARN("failed to create view with table", K(ret));
|
||||
@ -1224,32 +1228,25 @@ int ObTransformOrExpansion::check_upd_del_stmt_validity(const ObDelUpdStmt &stmt
|
||||
} else if (1 != table_infos.count()) {
|
||||
is_valid = false;
|
||||
OPT_TRACE("multi dml table not support or expansion");
|
||||
} else if (OB_ISNULL(table_infos.at(0)) || OB_ISNULL(query_ctx)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null param", K(ret));
|
||||
} else {
|
||||
// TODO following code has been removed on 3.2
|
||||
// ObDmlTableInfo* table_info = table_infos.at(0);
|
||||
// for (int64_t i = 0; OB_SUCC(ret) && is_valid && i < index_infos.count(); ++i) {
|
||||
// if (NULL != stmt.get_part_expr(index_infos.at(i).loc_table_id_,
|
||||
// index_infos.at(i).index_tid_)) {
|
||||
// is_valid = false;
|
||||
// }
|
||||
// }
|
||||
if (NULL != stmt.get_part_expr(table_infos.at(0)->loc_table_id_,
|
||||
table_infos.at(0)->ref_table_id_)) {
|
||||
bool is_use_pdml = false;
|
||||
if (query_ctx->get_global_hint().get_pdml_option() == ObPDMLOption::ENABLE) {
|
||||
is_use_pdml = true;
|
||||
} else if (query_ctx->get_global_hint().get_pdml_option() == ObPDMLOption::DISABLE) {
|
||||
is_use_pdml = false;
|
||||
} else if (OB_FAIL(ctx_->session_info_->get_enable_parallel_dml(is_use_pdml))) {
|
||||
LOG_WARN("failed to get enable parallel dml", K(ret));
|
||||
}
|
||||
if (OB_SUCC(ret) && is_use_pdml) {
|
||||
is_valid = false;
|
||||
OPT_TRACE("parallel dml table not support or expansion");
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// for update/delete stmt, disable pdml after or expansion
|
||||
int ObTransformOrExpansion::disable_pdml_for_upd_del_stmt(ObDMLStmt &stmt)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (stmt.is_update_stmt() || stmt.is_delete_stmt()) {
|
||||
ObSEArray<ObDmlTableInfo*, 2> table_infos;
|
||||
if (OB_FAIL(static_cast<ObDelUpdStmt&>(stmt).get_dml_table_infos(table_infos))) {
|
||||
LOG_WARN("failed to get dml table infos", K(ret));
|
||||
} else if (OB_UNLIKELY(table_infos.empty()) || OB_ISNULL(table_infos.at(0))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null param", K(ret));
|
||||
} else if (NULL != stmt.get_part_expr(table_infos.at(0)->loc_table_id_,
|
||||
table_infos.at(0)->ref_table_id_)) {
|
||||
OPT_TRACE("disable parallel dml after or expansion");
|
||||
static_cast<ObDelUpdStmt&>(stmt).set_pdml_disabled();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@ -1284,6 +1281,8 @@ int ObTransformOrExpansion::get_trans_view(ObDMLStmt *stmt,
|
||||
} else if (OB_ISNULL(upper_stmt)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected error", K(ret), K(upper_stmt));
|
||||
} else if (OB_FAIL(disable_pdml_for_upd_del_stmt(*upper_stmt))) {
|
||||
LOG_WARN("failed to disable pdml for upd_del_stmt", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::create_simple_view(ctx_, upper_stmt, child_stmt, false))) {
|
||||
LOG_WARN("failed to create simple view", K(ret));
|
||||
} else if (OB_FAIL(upper_stmt->formalize_stmt_expr_reference(expr_factory, ctx_->session_info_))) {
|
||||
|
@ -206,6 +206,7 @@ private:
|
||||
bool reached_max_times_for_or_expansion() { return try_times_ >= MAX_TIMES_FOR_OR_EXPANSION; }
|
||||
|
||||
int check_upd_del_stmt_validity(const ObDelUpdStmt &stmt, bool &is_valid);
|
||||
int disable_pdml_for_upd_del_stmt(ObDMLStmt &stmt);
|
||||
|
||||
int has_odd_function(const ObDMLStmt &stmt, bool &has);
|
||||
|
||||
|
Reference in New Issue
Block a user