fix insert all not support subquery

This commit is contained in:
wangt1xiuyi
2022-12-16 15:11:27 +00:00
committed by ob-robot
parent cdc893ba9b
commit 9daa7428e9
4 changed files with 54 additions and 4 deletions

View File

@ -4226,6 +4226,9 @@ int ObDMLResolver::resolve_subquery_info(const ObIArray<ObSubQueryInfo> &subquer
ret = OB_NOT_SUPPORTED;
LOG_USER_ERROR(OB_NOT_SUPPORTED, "Too many levels of subquery");
}
//resolve subquery in insert all need reset the flag.
bool is_multi_table_insert = params_.is_multi_table_insert_;
params_.is_multi_table_insert_ = false;
for (int64_t i = 0; OB_SUCC(ret) && i < subquery_info.count(); i++) {
const ObSubQueryInfo &info = subquery_info.at(i);
ObSelectResolver subquery_resolver(params_);
@ -4247,6 +4250,7 @@ int ObDMLResolver::resolve_subquery_info(const ObIArray<ObSubQueryInfo> &subquer
}
set_query_ref_expr(NULL);
}
params_.is_multi_table_insert_ = is_multi_table_insert;
return ret;
}

View File

@ -158,6 +158,36 @@ int ObInsertAllStmt::get_view_check_exprs(ObIArray<ObRawExpr*>& view_check_exprs
return ret;
}
int ObInsertAllStmt::get_all_values_vector(ObIArray<ObRawExpr*> &all_values_vector) const
{
int ret = OB_SUCCESS;
for (int64_t i = 0; OB_SUCC(ret) && i < table_info_.count(); ++i) {
ObInsertAllTableInfo* table_info = table_info_.at(i);
if (OB_ISNULL(table_info)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get null table info", K(ret));
} else if (OB_FAIL(append(all_values_vector, table_info->values_vector_))) {
LOG_WARN("failed to append values vector", K(ret));
}
}
return ret;
}
int ObInsertAllStmt::get_all_when_cond_exprs(ObIArray<ObRawExpr*> &all_when_cond_exprs) const
{
int ret = OB_SUCCESS;
for (int64_t i = 0; OB_SUCC(ret) && i < table_info_.count(); ++i) {
ObInsertAllTableInfo* table_info = table_info_.at(i);
if (OB_ISNULL(table_info)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get null table info", K(ret));
} else if (OB_FAIL(append(all_when_cond_exprs, table_info->when_cond_exprs_))) {
LOG_WARN("failed to append when cond exprs", K(ret));
}
}
return ret;
}
int64_t ObInsertAllStmt::to_string(char *buf, const int64_t buf_len) const
{
int64_t pos = 0;

View File

@ -62,6 +62,9 @@ public:
virtual int get_dml_table_infos(ObIArray<const ObDmlTableInfo*>& dml_table_info) const override;
virtual int get_view_check_exprs(ObIArray<ObRawExpr*>& view_check_exprs) const override;
bool value_from_select() const { return !from_items_.empty(); }
int get_all_values_vector(ObIArray<ObRawExpr*> &all_values_vector) const;
int get_all_when_cond_exprs(ObIArray<ObRawExpr*> &all_when_cond_exprs) const;
DECLARE_VIRTUAL_TO_STRING;
// TO_STRING_KV(N_STMT_TYPE, stmt_type_,
// N_TABLE, table_items_,