to issue<50056402>:fix core when package var sync
This commit is contained in:
@ -375,5 +375,40 @@ int ObPLPackageState::remove_user_variables_for_package_state(ObSQLSessionInfo &
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObPLPackageState::check_package_state_valid(ObExecContext &exec_ctx, bool &valid)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
valid = false;
|
||||
ObSQLSessionInfo *sql_session = exec_ctx.get_my_session();
|
||||
if (OB_ISNULL(sql_session) || OB_ISNULL(sql_session->get_pl_engine())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("sql session is null.", K(ret));
|
||||
} else if (OB_ISNULL(exec_ctx.get_sql_ctx()) || OB_ISNULL(exec_ctx.get_sql_ctx()->schema_guard_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("sql ctx or schema guard is null.", K(ret));
|
||||
} else {
|
||||
const ObPackageInfo *package_spec_info = NULL;
|
||||
const ObPackageInfo *package_body_info = NULL;
|
||||
if (OB_FAIL(sql_session->get_pl_engine()->get_package_manager().get_package_schema_info(*exec_ctx.get_sql_ctx()->schema_guard_,
|
||||
package_id_,
|
||||
package_spec_info,
|
||||
package_body_info))) {
|
||||
LOG_WARN("package not exist", K(ret), K(package_id_));
|
||||
ret = OB_SUCCESS;
|
||||
} else if (OB_ISNULL(package_spec_info)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("package info is null", K(ret), K(package_id_));
|
||||
} else {
|
||||
ObPackageStateVersion package_version(common::OB_INVALID_VERSION, common::OB_INVALID_VERSION);
|
||||
package_version.package_version_ = package_spec_info->get_schema_version();
|
||||
if (OB_NOT_NULL(package_body_info)) {
|
||||
package_version.package_body_version_ = package_body_info->get_schema_version();
|
||||
}
|
||||
valid = check_version(package_version);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // end namespace pl
|
||||
} // end namespace oceanbase
|
||||
|
||||
@ -167,6 +167,7 @@ public:
|
||||
common::ObObj &value);
|
||||
inline bool get_serially_reusable() const { return serially_reusable_; }
|
||||
int remove_user_variables_for_package_state(ObSQLSessionInfo &session);
|
||||
int check_package_state_valid(ObExecContext &exec_ctx, bool &valid);
|
||||
uint64_t get_package_id() { return package_id_; }
|
||||
|
||||
ObIArray<ObObj> &get_vars() { return vars_; }
|
||||
|
||||
@ -1909,7 +1909,12 @@ int ObSQLSessionInfo::add_changed_package_info(ObExecContext &exec_ctx)
|
||||
if (package_state->is_package_info_changed()) {
|
||||
ObSEArray<ObString, 4> key;
|
||||
ObSEArray<ObObj, 4> value;
|
||||
if (OB_FAIL(package_state->convert_changed_info_to_string_kvs(pl_ctx, key, value))) {
|
||||
bool is_valid = false;
|
||||
if (OB_FAIL(package_state->check_package_state_valid(exec_ctx, is_valid))) {
|
||||
LOG_WARN("check package state failed", K(ret), KPC(package_state));
|
||||
} else if (!is_valid) {
|
||||
LOG_INFO("package state is invalid, ignore this package.", KPC(package_state));
|
||||
} else if (OB_FAIL(package_state->convert_changed_info_to_string_kvs(pl_ctx, key, value))) {
|
||||
LOG_WARN("convert package state to string kv failed", K(ret));
|
||||
} else {
|
||||
ObSessionVariable sess_var;
|
||||
|
||||
Reference in New Issue
Block a user