[CP] Foreign key check of insertup statement cannot use das_scan

This commit is contained in:
yishenglanlingzui
2025-03-15 00:45:58 +00:00
committed by ob-robot
parent a955161d5a
commit 432a373177
2 changed files with 15 additions and 1 deletions

View File

@ -3682,6 +3682,8 @@ int ObDmlCgService::generate_fk_arg(ObForeignKeyArg &fk_arg,
LOG_WARN("failed to check foreign key check ctdef", K(ret));
} else if (OB_FAIL(dml_ctdef.fk_args_.push_back(fk_arg))) {
LOG_WARN("failed to add foreign key arg", K(fk_arg), K(ret));
} else {
cg_.phy_plan_->set_has_nested_sql(true);
}
} else {
if (OB_FAIL(dml_ctdef.fk_args_.push_back(fk_arg))) {

View File

@ -159,7 +159,16 @@ int ForeignKeyHandle::check_exist(ObTableModifyOp &modify_op, const ObForeignKey
{
int ret = OB_SUCCESS;
DEBUG_SYNC(BEFORE_FOREIGN_KEY_CONSTRAINT_CHECK);
if (use_das_scan) {
// insertup and merge_into currently have a core problem when checking foreign keys through das_scan_task.
// Because both insertup and merge_into have both INSERT and UPDATE semantics,
// the data may come from the new_row of INSERT or the new_row of UPDATE during the operation.
// Earlier versions did not consider this problem, so there is a possibility of core
bool is_merge_or_insertup = false;
ObPhyOperatorType op_type = modify_op.get_spec().get_type();
if (op_type == PHY_INSERT_ON_DUP || op_type == PHY_MERGE) {
is_merge_or_insertup = true;
}
if (use_das_scan && !is_merge_or_insertup) {
ret = check_exist_scan_task(modify_op, fk_arg, row, fk_checker);
} else {
if (OB_FAIL(check_exist_inner_sql(modify_op, fk_arg, row, expect_zero, true))) {
@ -179,6 +188,9 @@ int ForeignKeyHandle::check_exist_scan_task(ObTableModifyOp &modify_op, const Ob
if (OB_ISNULL(fk_checker)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("foreign key checker is nullptr", K(ret));
} else if (!fk_arg.use_das_scan_) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("foreign key checker is nullptr", K(ret));
} else if (OB_FAIL(fk_checker->do_fk_check_single_row(fk_arg.columns_, row, has_result))) {
LOG_WARN("failed to perform foreign key check by das scan tasks", K(ret));
} else {