提交 bf65b0f0 编写于 作者: O obdev 提交者: wangzelin.wzl

fix parent namespace stmt bug

上级 766c19f8
......@@ -1231,6 +1231,8 @@ int ObLogPlan::pre_process_quals(const ObIArray<TableItem*> &table_items,
} else {
ret = add_subquery_filter(qual);
}
} else if (qual->is_const_expr()) {
ret = add_startup_filter(qual);
} else if (qual->has_flag(CNT_RAND_FUNC) ||
qual->has_flag(CNT_USER_VARIABLE) ||
qual->has_flag(CNT_PL_UDF) ||
......@@ -1238,8 +1240,6 @@ int ObLogPlan::pre_process_quals(const ObIArray<TableItem*> &table_items,
ret = add_special_expr(qual);
} else if (ObOptimizerUtil::has_hierarchical_expr(*qual)) {
ret = normal_quals.push_back(qual);
} else if (0 == qual->get_relation_ids().num_members()) {
ret = add_startup_filter(qual);
} else {
ret = normal_quals.push_back(qual);
}
......
......@@ -2253,6 +2253,22 @@ int ObDMLStmt::get_from_subquery_stmts(ObIArray<ObSelectStmt*> &child_stmts) con
return ret;
}
int ObDMLStmt::get_subquery_stmts(common::ObIArray<ObSelectStmt*> &child_stmts) const
{
int ret = OB_SUCCESS;
for (int64_t j = 0; OB_SUCC(ret) && j < get_subquery_expr_size(); ++j) {
ObQueryRefRawExpr *subquery_ref = subquery_exprs_.at(j);
if (OB_ISNULL(subquery_ref) ||
OB_ISNULL(subquery_ref->get_ref_stmt())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("subquery reference is null", K(subquery_ref));
} else if (OB_FAIL(child_stmts.push_back(subquery_ref->get_ref_stmt()))) {
LOG_WARN("stored subquery reference stmt failed", K(ret));
}
}
return ret;
}
int ObDMLStmt::get_table_item(const ObSQLSessionInfo *session_info,
const ObString &database_name,
const ObString &object_name,
......
......@@ -739,6 +739,7 @@ public:
virtual int remove_useless_sharable_expr();
virtual int clear_sharable_expr_reference();
virtual int get_from_subquery_stmts(common::ObIArray<ObSelectStmt*> &child_stmts) const;
virtual int get_subquery_stmts(common::ObIArray<ObSelectStmt*> &child_stmts) const;
int is_referred_by_partitioning_expr(const ObRawExpr *expr,
bool &is_referred);
int64_t get_table_size() const { return table_items_.count(); }
......
......@@ -869,10 +869,13 @@ int ObSelectStmt::adjust_view_parent_namespace_stmt(ObDMLStmt *new_parent)
int ret = OB_SUCCESS;
int32_t subquery_level = (new_parent != NULL ? new_parent->get_current_level() + 1 : 0);
ObArray<ObSelectStmt *> view_stmts;
ObArray<ObSelectStmt *> subquery_stmts;
set_parent_namespace_stmt(new_parent);
set_current_level(subquery_level);
if (OB_FAIL(get_from_subquery_stmts(view_stmts))) {
LOG_WARN("get from subquery stmts failed", K(ret));
} else if (OB_FAIL(get_subquery_stmts(subquery_stmts))) {
LOG_WARN("get subquery stmts failed", K(ret));
}
for (int64_t i = 0; OB_SUCC(ret) && i < view_stmts.count(); ++i) {
ObSelectStmt *view_stmt = view_stmts.at(i);
......@@ -883,6 +886,15 @@ int ObSelectStmt::adjust_view_parent_namespace_stmt(ObDMLStmt *new_parent)
LOG_WARN("adjust view parent namespace stmt failed", K(ret));
}
}
for (int64_t i = 0; OB_SUCC(ret) && i < subquery_stmts.count(); ++i) {
ObSelectStmt *subquery = subquery_stmts.at(i);
if (OB_ISNULL(subquery)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("table_item is null", K(i));
} else if (OB_FAIL(subquery->adjust_view_parent_namespace_stmt(this))) {
LOG_WARN("adjust subquery parent namespace stmt failed", K(ret));
}
}
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册