[CP] [to #49900376]check base table version when create trigger
This commit is contained in:
@ -16052,8 +16052,9 @@ int ObDDLService::rebuild_triggers_on_hidden_table(
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
ObSEArray<ObDependencyInfo, 1> dep_infos;
|
||||
int64_t table_schema_version = OB_INVALID_VERSION;
|
||||
OZ (ddl_operator.create_trigger(new_trigger_info, trans, error_info, dep_infos,
|
||||
nullptr, false/*is_update_table_schema_version*/));
|
||||
table_schema_version, nullptr, false/*is_update_table_schema_version*/));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -30701,10 +30702,11 @@ int ObDDLService::drop_package(const ObPackageInfo &package_info,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDDLService::create_trigger(const ObCreateTriggerArg &arg)
|
||||
int ObDDLService::create_trigger(const ObCreateTriggerArg &arg,
|
||||
ObSchemaGetterGuard &schema_guard,
|
||||
ObCreateTriggerRes *res)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSchemaGetterGuard schema_guard;
|
||||
ObTriggerInfo new_trigger_info;
|
||||
//in_second_stage_ is false, Indicates that the trigger is created normally
|
||||
//true Indicates that the error message is inserted into the system table after the trigger is created
|
||||
@ -30719,8 +30721,6 @@ int ObDDLService::create_trigger(const ObCreateTriggerArg &arg)
|
||||
if (OB_FAIL(new_trigger_info.assign(arg.trigger_info_))) {
|
||||
LOG_WARN("assign trigger_info failed", K(ret));
|
||||
} else if (FALSE_IT(tenant_id = new_trigger_info.get_tenant_id())) {
|
||||
} else if (OB_FAIL(get_tenant_schema_guard_with_version_in_inner_table(tenant_id, schema_guard))) {
|
||||
LOG_WARN("o get schema guard in inner table failed", KR(ret), K(tenant_id));
|
||||
} else {
|
||||
const ObTriggerInfo *old_trigger_info = NULL;
|
||||
if (!arg.is_valid()) {
|
||||
@ -30744,14 +30744,24 @@ int ObDDLService::create_trigger(const ObCreateTriggerArg &arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) &&
|
||||
OB_FAIL(create_trigger_in_trans(new_trigger_info,
|
||||
const_cast<ObErrorInfo &>(arg.error_info_),
|
||||
const_cast<ObSArray<ObDependencyInfo> &>(arg.dependency_infos_),
|
||||
&arg.ddl_stmt_str_,
|
||||
arg.in_second_stage_,
|
||||
schema_guard))) {
|
||||
LOG_WARN("create trigger in trans failed", K(ret));
|
||||
if (OB_SUCC(ret)) {
|
||||
bool with_res = (GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_4_2_1_2);
|
||||
int64_t table_schema_version = OB_INVALID_VERSION;
|
||||
if (with_res && OB_ISNULL(res)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("res is NULL", K(ret));
|
||||
} else if (OB_FAIL(create_trigger_in_trans(new_trigger_info,
|
||||
const_cast<ObErrorInfo &>(arg.error_info_),
|
||||
const_cast<ObSArray<ObDependencyInfo> &>(arg.dependency_infos_),
|
||||
&arg.ddl_stmt_str_,
|
||||
arg.in_second_stage_,
|
||||
schema_guard,
|
||||
table_schema_version))) {
|
||||
LOG_WARN("create trigger in trans failed", K(ret));
|
||||
} else if (with_res && !arg.in_second_stage_) {
|
||||
res->table_schema_version_ = table_schema_version;
|
||||
res->trigger_schema_version_ = new_trigger_info.get_schema_version();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -30761,7 +30771,8 @@ int ObDDLService::create_trigger_in_trans(ObTriggerInfo &trigger_info,
|
||||
ObIArray<ObDependencyInfo> &dep_infos,
|
||||
const ObString *ddl_stmt_str,
|
||||
bool in_second_stage,
|
||||
share::schema::ObSchemaGetterGuard &schema_guard)
|
||||
share::schema::ObSchemaGetterGuard &schema_guard,
|
||||
int64_t &table_schema_version)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const uint64_t tenant_id = trigger_info.get_tenant_id();
|
||||
@ -30776,7 +30787,7 @@ int ObDDLService::create_trigger_in_trans(ObTriggerInfo &trigger_info,
|
||||
if (OB_SUCC(ret) && !in_second_stage) {
|
||||
OZ (adjust_trigger_action_order(schema_guard, trans, ddl_operator, trigger_info, true));
|
||||
}
|
||||
OZ (ddl_operator.create_trigger(trigger_info, trans, error_info, dep_infos, ddl_stmt_str));
|
||||
OZ (ddl_operator.create_trigger(trigger_info, trans, error_info, dep_infos, table_schema_version, ddl_stmt_str));
|
||||
if (trans.is_started()) {
|
||||
int temp_ret = OB_SUCCESS;
|
||||
if (OB_SUCCESS != (temp_ret = trans.end(OB_SUCC(ret)))) {
|
||||
@ -31029,7 +31040,9 @@ int ObDDLService::create_trigger_for_truncate_table(ObSchemaGetterGuard &schema_
|
||||
new_table_schema.get_trigger_list().push_back(new_trigger_id);
|
||||
if (OB_SUCC(ret)) {
|
||||
ObSEArray<ObDependencyInfo, 1> dep_infos;
|
||||
int64_t table_schema_version = OB_INVALID_VERSION;
|
||||
if (OB_FAIL(ddl_operator.create_trigger(new_trigger_info, trans, error_info, dep_infos,
|
||||
table_schema_version,
|
||||
&origin_trigger_info->get_trigger_body(),
|
||||
is_update_table_schema_version,
|
||||
true))) {
|
||||
|
||||
Reference in New Issue
Block a user