[CP] [to #44090387] fix package body create
This commit is contained in:
@ -7977,20 +7977,23 @@ int ObDDLOperator::update_routine_info(ObRoutineInfo &routine_info,
|
||||
int64_t tenant_id,
|
||||
int64_t parent_id,
|
||||
int64_t owner_id,
|
||||
int64_t database_id)
|
||||
int64_t database_id,
|
||||
int64_t routine_id = OB_INVALID_ID)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
uint64_t new_routine_id = OB_INVALID_ID;
|
||||
uint64_t new_routine_id = routine_id;
|
||||
int64_t new_schema_version = OB_INVALID_VERSION;
|
||||
ObSchemaService *schema_service = schema_service_.get_schema_service();
|
||||
lib::Worker::CompatMode compat_mode = lib::Worker::CompatMode::INVALID;
|
||||
if (OB_ISNULL(schema_service)) {
|
||||
ret = OB_ERR_SYS;
|
||||
LOG_ERROR("schema_service must not null", K(ret));
|
||||
} else if (OB_SYS_TENANT_ID == tenant_id
|
||||
} else if (OB_INVALID_ID == new_routine_id
|
||||
&& OB_SYS_TENANT_ID == tenant_id
|
||||
&& OB_FAIL(schema_service->fetch_new_sys_pl_object_id(tenant_id, new_routine_id))) {
|
||||
LOG_WARN("failed to fetch new_routine_id", K(tenant_id), K(ret));
|
||||
} else if (OB_SYS_TENANT_ID != tenant_id
|
||||
} else if (OB_INVALID_ID == new_routine_id
|
||||
&& OB_SYS_TENANT_ID != tenant_id
|
||||
&& OB_FAIL(schema_service->fetch_new_routine_id(tenant_id, new_routine_id))) {
|
||||
LOG_WARN("failed to fetch new_routine_id", K(tenant_id), K(ret));
|
||||
} else if (OB_FAIL(schema_service_.gen_new_schema_version(tenant_id, new_schema_version))) {
|
||||
@ -8055,22 +8058,29 @@ int ObDDLOperator::create_package(const ObPackageInfo *old_package_info,
|
||||
LOG_WARN("insert package info failed", K(new_package_info), K(ret));
|
||||
} else {
|
||||
ARRAY_FOREACH(public_routine_infos, routine_idx) {
|
||||
if (new_package_info.is_package()) {
|
||||
ObRoutineInfo &routine_info = public_routine_infos.at(routine_idx);
|
||||
if (new_package_info.is_package()) {
|
||||
if (OB_FAIL(update_routine_info(routine_info,
|
||||
tenant_id,
|
||||
new_package_info.get_package_id(),
|
||||
new_package_info.get_owner_id(),
|
||||
new_package_info.get_database_id()))) {
|
||||
new_package_info.get_database_id(),
|
||||
routine_info.get_routine_id()))) {
|
||||
LOG_WARN("failed to update routine info", K(ret));
|
||||
} else if (OB_FAIL(schema_service->get_routine_sql_service().create_routine(routine_info,
|
||||
&trans, NULL))) {
|
||||
LOG_WARN("insert routine info failed", K(routine_info), K(ret));
|
||||
}
|
||||
} else if (OB_INVALID_ID == routine_info.get_routine_id()) {
|
||||
OZ (update_routine_info(routine_info,
|
||||
tenant_id,
|
||||
routine_info.get_package_id(),
|
||||
routine_info.get_owner_id(),
|
||||
routine_info.get_database_id()));
|
||||
OZ (schema_service->get_routine_sql_service().create_routine(routine_info, &trans, NULL));
|
||||
} else {
|
||||
// update routine route sql
|
||||
int64_t new_schema_version = OB_INVALID_VERSION;
|
||||
ObRoutineInfo &routine_info = public_routine_infos.at(routine_idx);
|
||||
OZ (schema_service_.gen_new_schema_version(tenant_id, new_schema_version));
|
||||
OX (routine_info.set_schema_version(new_schema_version));
|
||||
OZ (schema_service->get_routine_sql_service().update_routine(routine_info, &trans));
|
||||
|
||||
@ -1015,7 +1015,8 @@ private:
|
||||
int64_t tenant_id,
|
||||
int64_t parent_id,
|
||||
int64_t owner_id,
|
||||
int64_t database_id);
|
||||
int64_t database_id,
|
||||
int64_t routine_id);
|
||||
|
||||
private:
|
||||
int drop_fk_cascade(
|
||||
|
||||
@ -200,7 +200,7 @@ int ObRoutineSqlService::update_routine(ObRoutineInfo &routine_info,
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
CK (OB_NOT_NULL(sql_client));
|
||||
CK (routine_info.is_valid());
|
||||
OV (routine_info.is_valid(), OB_ERR_UNEXPECTED, K(routine_info));
|
||||
OZ (add_routine(*sql_client, routine_info, true));
|
||||
if (OB_SUCC(ret)) {
|
||||
ObSchemaOperation opt;
|
||||
|
||||
@ -167,10 +167,9 @@ int ObCreatePackageResolver::resolve(const ParseNode &parse_tree)
|
||||
} else {}
|
||||
}
|
||||
if (OB_SUCC(ret) && resolve_success) {
|
||||
if (OB_FAIL(resolve_functions_spec(package_info, create_package_arg.public_routine_infos_,
|
||||
package_ast.get_routine_table()))) {
|
||||
LOG_WARN("failed to resolve function spec", K(ret));
|
||||
}
|
||||
OZ (resolve_functions_spec(package_info,
|
||||
create_package_arg.public_routine_infos_,
|
||||
package_ast.get_routine_table()));
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
ObString dep_attr;
|
||||
@ -315,6 +314,8 @@ int ObCreatePackageResolver::resolve_functions_spec(const ObPackageInfo &package
|
||||
//process basic info
|
||||
routine_info.set_tenant_id(package_info.get_tenant_id());
|
||||
routine_info.set_owner_id(package_info.get_owner_id());
|
||||
routine_info.set_database_id(package_info.get_database_id());
|
||||
routine_info.set_package_id(package_info.get_package_id());
|
||||
routine_info.set_routine_type(routine_type);
|
||||
routine_info.set_subprogram_id(i);
|
||||
routine_info.set_exec_env(package_info.get_exec_env());
|
||||
@ -563,13 +564,25 @@ int ObCreatePackageBodyResolver::resolve(const ParseNode &parse_tree)
|
||||
const ObPLRoutineTable &body_routine_table = package_body_ast.get_routine_table();
|
||||
ObRoutineInfo routine_info;
|
||||
const ObPLRoutineInfo *pl_routine_info = NULL;
|
||||
ObArray<const ObRoutineInfo *> routine_infos;
|
||||
ObSEArray<const ObRoutineInfo *, 2> routine_infos;
|
||||
ObSEArray<ObRoutineInfo, 2> routine_spec_infos;
|
||||
uint64_t database_id = OB_INVALID_ID;
|
||||
OZ (schema_checker_->get_schema_guard()->get_database_id(
|
||||
session_info_->get_effective_tenant_id(), db_name, database_id));
|
||||
OZ (schema_checker_->get_schema_guard()->get_routine_infos_in_package(
|
||||
session_info_->get_effective_tenant_id(), package_spec_info->get_package_id(),
|
||||
routine_infos));
|
||||
|
||||
if (OB_SUCC(ret) && routine_infos.empty() && package_spec_ast.get_routine_table().get_count() > 1) {
|
||||
OZ (ObCreatePackageResolver::resolve_functions_spec(
|
||||
*package_spec_info, routine_spec_infos, package_spec_ast.get_routine_table()));
|
||||
CK (routine_spec_infos.count() > 0);
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < routine_spec_infos.count(); ++i) {
|
||||
OZ (routine_infos.push_back(&routine_spec_infos.at(i)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
OZ (update_routine_route_sql(*allocator_, *session_info_, routine_list,
|
||||
spec_routine_table, body_routine_table, routine_infos));
|
||||
}
|
||||
@ -659,7 +672,7 @@ int ObCreatePackageBodyResolver::update_routine_route_sql(ObIAllocator &allocato
|
||||
ObIArray<ObRoutineInfo> &public_routine_list,
|
||||
const ObPLRoutineTable &spec_routine_table,
|
||||
const ObPLRoutineTable &body_routine_table,
|
||||
ObArray<const ObRoutineInfo *> &routine_infos)
|
||||
ObIArray<const ObRoutineInfo *> &routine_infos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const ObPLRoutineInfo *pl_routine_info = NULL;
|
||||
|
||||
@ -58,7 +58,7 @@ public:
|
||||
ObIArray<ObRoutineInfo> &public_routine_list,
|
||||
const pl::ObPLRoutineTable &spec_routine_table,
|
||||
const pl::ObPLRoutineTable &body_routine_table,
|
||||
ObArray<const ObRoutineInfo *> &routine_infos);
|
||||
ObIArray<const ObRoutineInfo *> &routine_infos);
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObCreatePackageBodyResolver);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user