[scn] fix 4377 caused by miss one line code when refresh

This commit is contained in:
obdev
2022-11-28 03:03:36 +00:00
committed by ob-robot
parent 5e0066c1e7
commit 045c826c51
84 changed files with 625 additions and 330 deletions

View File

@ -116,7 +116,7 @@ int ObGetDiagnosticsResolver::resolve(const ParseNode &parse_tree)
OB_ISNULL(var = item->children_[0]) || OB_ISNULL(val = item->children_[1])) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("parser tree is wrong", K(ret));
} else if (NULL == session_info_->get_pl_context() && T_IDENT == var->type_) {
} else if (T_IDENT == var->type_) {
ret = OB_ERR_SP_UNDECLARED_VAR;
LOG_WARN("undeclared var", K(ret));
LOG_USER_ERROR(OB_ERR_SP_UNDECLARED_VAR, static_cast<int>(var->str_len_), var->str_value_);

View File

@ -116,10 +116,11 @@ int ObLoadDataResolver::resolve(const ParseNode &parse_tree)
} else {
ObString file_name(file_name_node->str_len_, file_name_node->str_value_);
if (ObLoadFileLocation::OSS != load_args.load_file_storage_) {
load_args.file_name_ = file_name;
char *full_path_buf = nullptr;
char *actual_path = nullptr;
if (OB_ISNULL(full_path_buf = static_cast<char*>(allocator_->alloc(DEFAULT_BUF_LENGTH)))) {
if (OB_FAIL(ob_write_string(*allocator_, file_name, load_args.file_name_, true))) {
LOG_WARN("fail to write string", K(ret));
} else if (OB_ISNULL(full_path_buf = static_cast<char*>(allocator_->alloc(DEFAULT_BUF_LENGTH)))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("fail to allocate memory", K(ret));
} else if (OB_ISNULL(actual_path = realpath(file_name_node->str_value_, full_path_buf))) {
@ -138,12 +139,16 @@ int ObLoadDataResolver::resolve(const ParseNode &parse_tree)
}
}
} else {
load_args.file_name_ = file_name.split_on('?');
if (load_args.file_name_.length() <= 0
|| file_name <= 0) {
ObString temp_file_name = file_name.split_on('?');
ObString storage_info;
if (OB_FAIL(ob_write_string(*allocator_, temp_file_name, load_args.file_name_, true))) {
LOG_WARN("fail to copy string", K(ret));
} else if (OB_FAIL(ob_write_string(*allocator_, file_name, storage_info, true))) {
LOG_WARN("fail to copy string", K(ret));
} else if (temp_file_name.length() <= 0 || storage_info.length() <= 0) {
ret = OB_INVALID_ARGUMENT;
LOG_USER_ERROR(OB_INVALID_ARGUMENT, "file name or access key");
} else if (OB_FAIL(load_args.access_info_.set(load_args.file_name_.ptr(), file_name.ptr()))) {
} else if (OB_FAIL(load_args.access_info_.set(load_args.file_name_.ptr(), storage_info.ptr()))) {
LOG_WARN("failed to set access info", K(ret));
}
}

View File

@ -212,6 +212,41 @@ int ObUpdateResolver::try_expand_returning_exprs()
}
}
}
if (OB_SUCC(ret) && is_oracle_mode()) {
if (OB_FAIL(check_update_assign_duplicated(update_stmt))) {
LOG_WARN("update has duplicate columns", K(ret));
}
}
return ret;
}
int ObUpdateResolver::check_update_assign_duplicated(const ObUpdateStmt *update_stmt)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(update_stmt)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("stmt is null", K(ret));
} else {
// check duplicate assignments
// update t1 set c1 = 1, c1 = 2;
const ObIArray<ObUpdateTableInfo*> &table_infos = update_stmt->get_update_table_info();
for (int64_t i = 0; OB_SUCC(ret) && i < table_infos.count(); ++i) {
ObUpdateTableInfo* table_info = table_infos.at(i);
if (OB_ISNULL(table_info)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get null table info", K(ret));
}
for (int64_t j = 0; OB_SUCC(ret) && j < table_info->assignments_.count(); ++j) {
const ObAssignment &assign_item = table_info->assignments_.at(j);
if (assign_item.is_duplicated_) {
ret = OB_ERR_FIELD_SPECIFIED_TWICE;
LOG_USER_ERROR(OB_ERR_FIELD_SPECIFIED_TWICE, to_cstring(assign_item.column_expr_->get_column_name()));
}
}
}
}
return ret;
}

View File

@ -46,6 +46,7 @@ private:
int check_multi_update_table_conflict();
int check_join_update_conflict();
int is_join_table_update(const ObDMLStmt *stmt, bool &is_multi_table);
int check_update_assign_duplicated(const ObUpdateStmt *update_stmt);
int check_view_updatable();
int try_expand_returning_exprs();
int try_add_remove_const_expr_for_assignments();