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

fix extract onetime expr bug of sharing query ref expr

上级 13774e30
......@@ -460,7 +460,7 @@ int get_proc_db_name(
} else {
uint64_t tenant_id = ctx.session_info_->get_login_tenant_id();
ObSchemaGetterGuard &schema_guard = *ctx.schema_guard_;
uint64_t db_id;
uint64_t db_id = OB_INVALID_ID;
const ObDatabaseSchema *db_schema = NULL;
if (static_cast<uint64_t>(ObObjectType::FUNCTION) == need_priv.obj_type_) {
const ObRoutineInfo *routine_schema = NULL;
......@@ -494,7 +494,7 @@ int get_seq_db_name(
ObString &db_name)
{
int ret = OB_SUCCESS;
uint64_t db_id;
uint64_t db_id = OB_INVALID_ID;
const ObSequenceSchema *seq_schema = NULL;
const ObDatabaseSchema *db_schema = NULL;
OZ (schema_guard.get_sequence_schema(tenant_id, obj_id, seq_schema));
......
......@@ -1046,12 +1046,17 @@ int ObTransformPostProcess::extract_onetime_subquery(ObRawExpr *&expr,
!expr->has_flag(CNT_ALIAS);
if (is_valid) {
int64_t ref_count = 0;
if (OB_FAIL(is_non_correlated_exists_for_onetime(expr,
is_valid_non_correlated_exists))) {
is_valid_non_correlated_exists,
ref_count))) {
LOG_WARN("failed to check non correlated exist for one time", K(ret));
} else if (is_valid_non_correlated_exists &&
OB_FAIL(onetime_list.push_back(expr))) {
} else if (!is_valid_non_correlated_exists) {
// do nothing
} else if (OB_FAIL(onetime_list.push_back(expr))) {
LOG_WARN("failed to push back non-correlated exists", K(ret));
} else if (ref_count > 1) {
is_valid = false;
}
}
}
......@@ -1165,7 +1170,8 @@ int ObTransformPostProcess::create_onetime_param(ObDMLStmt *stmt,
}
int ObTransformPostProcess::is_non_correlated_exists_for_onetime(ObRawExpr *expr,
bool &is_non_correlated_exists_for_onetime)
bool &is_non_correlated_exists_for_onetime,
int64_t &ref_count)
{
int ret = OB_SUCCESS;
is_non_correlated_exists_for_onetime = false;
......@@ -1181,6 +1187,7 @@ int ObTransformPostProcess::is_non_correlated_exists_for_onetime(ObRawExpr *expr
LOG_WARN("failed to check subquery has ref assign user var", K(ret));
} else if (!has_ref_assign_user_var && query_ref_expr->get_param_count() == 0) {
is_non_correlated_exists_for_onetime = true;
ref_count = query_ref_expr->get_ref_count();
}
}
return ret;
......
......@@ -142,7 +142,8 @@ private:
const int64_t stmt_level);
int is_non_correlated_exists_for_onetime(ObRawExpr *expr,
bool &is_non_correlated_exists_for_onetime);
bool &is_non_correlated_exists_for_onetime,
int64_t &ref_count);
DISALLOW_COPY_AND_ASSIGN(ObTransformPostProcess);
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册