Fix view merge for join on condition containing subq
This commit is contained in:
@ -505,6 +505,7 @@ int ObTransformViewMerge::transform_joined_table(
|
||||
TableItem* left_table = NULL;
|
||||
TableItem* right_table = NULL;
|
||||
trans_happened = false;
|
||||
bool cond_contain_subq = false;
|
||||
if (OB_ISNULL(stmt) || OB_ISNULL(joined_table) || OB_ISNULL(left_table = joined_table->left_table_) ||
|
||||
OB_ISNULL(right_table = joined_table->right_table_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
@ -516,6 +517,10 @@ int ObTransformViewMerge::transform_joined_table(
|
||||
LOG_WARN("too deep recursive", K(ret));
|
||||
} else if (joined_table->joined_type_ == CONNECT_BY_JOIN) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(check_outerjoin_condition_contain_subq(joined_table, cond_contain_subq))) {
|
||||
LOG_WARN("failed to check outer join condition contain subq", K(ret));
|
||||
} else if (cond_contain_subq) {
|
||||
// do nothing
|
||||
} else {
|
||||
bool can_push_where = true;
|
||||
bool need_check_where_condi = false;
|
||||
@ -912,5 +917,26 @@ int ObTransformViewMerge::adjust_stmt_semi_infos(ObDMLStmt* parent_stmt, ObSelec
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTransformViewMerge::check_outerjoin_condition_contain_subq(JoinedTable* joined_table,
|
||||
bool &contains_subq)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
contains_subq = false;
|
||||
if (joined_table->joined_type_ == FULL_OUTER_JOIN ||
|
||||
joined_table->joined_type_ == LEFT_OUTER_JOIN ||
|
||||
joined_table->joined_type_ == RIGHT_OUTER_JOIN) {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && !contains_subq && i < joined_table->get_join_conditions().count(); ++i) {
|
||||
ObRawExpr* expr = joined_table->get_join_conditions().at(i);
|
||||
if (OB_ISNULL(expr)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid condition expr", K(ret));
|
||||
} else if (expr->has_flag(CNT_SUB_QUERY)) {
|
||||
contains_subq = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
|
@ -100,6 +100,8 @@ private:
|
||||
int transform_generated_table(ObDMLStmt* parent_stmt, TableItem* table_item, bool& trans_happened);
|
||||
int transform_in_from_item(ObDMLStmt* stmt, bool& trans_happened);
|
||||
int transform_in_semi_info(ObDMLStmt* stmt, bool& trans_happened);
|
||||
|
||||
int check_outerjoin_condition_contain_subq(JoinedTable* joined_table, bool &contains_subq);
|
||||
bool for_post_process_;
|
||||
DISALLOW_COPY_AND_ASSIGN(ObTransformViewMerge);
|
||||
};
|
||||
|
Reference in New Issue
Block a user