From 1e5bc605732aa2f0f92204f6ebed857a061cff90 Mon Sep 17 00:00:00 2001 From: wangfeihuo Date: Thu, 24 Apr 2025 09:22:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AA=E6=9C=89=E5=A4=96=E9=94=AE=E7=BA=A6?= =?UTF-8?q?=E6=9D=9F=E5=B9=B6=E4=B8=94=E5=A4=96=E9=94=AE=E6=A3=80=E6=9F=A5?= =?UTF-8?q?disable=E7=9A=84=E6=97=B6=E5=80=99=E5=BA=94=E5=BD=93=E5=85=81?= =?UTF-8?q?=E8=AE=B8=E8=B5=B0opfusion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../runtime/opfusion/opfusion_util.cpp | 24 ++++++++++++++++++- src/include/opfusion/opfusion_util.h | 2 ++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/gausskernel/runtime/opfusion/opfusion_util.cpp b/src/gausskernel/runtime/opfusion/opfusion_util.cpp index 24fa051423..dad3c7374d 100644 --- a/src/gausskernel/runtime/opfusion/opfusion_util.cpp +++ b/src/gausskernel/runtime/opfusion/opfusion_util.cpp @@ -729,14 +729,36 @@ bool checkPartitionType(const Relation rel) return true; } } + +bool CheckIsRIConstraintTrigger(const TriggerDesc* trigdesc) +{ + if (trigdesc == NULL) { + return true; + } + for (int i = 0; i < trigdesc->numtriggers; i++) { + if (!(trigdesc->triggers[i].tgisinternal && + strncmp(trigdesc->triggers[i].tgname, "RI_ConstraintTrigger", RI_CONSTRAINT_TRIGGER_NAME_LEN) == 0)) { + return false; + } + } + return true; +} + bool checkDMLRelation(const Relation rel, const PlannedStmt *plannedstmt, bool isInsert, bool isPartTbl) { bool result = false; - if (rel->rd_rel->relkind != RELKIND_RELATION || rel->rd_rel->relhasrules || rel->rd_rel->relhastriggers || + if (rel->rd_rel->relkind != RELKIND_RELATION || rel->rd_rel->relhasrules || rel->rd_rel->relhasoids || rel->rd_rel->relhassubclass || RelationIsColStore(rel) || RelationIsTsStore(rel) || RelationInRedistribute(rel) || plannedstmt->hasReturning || RelationIsSubPartitioned(rel)) { result = true; } + if (rel->rd_rel->relhastriggers) { + if (DB_IS_CMPT(B_FORMAT) && !u_sess->attr.attr_common.foreign_key_checks) { + result = !CheckIsRIConstraintTrigger(rel->trigdesc); + } else { + result = true; + } + } if (isInsert) { return result; diff --git a/src/include/opfusion/opfusion_util.h b/src/include/opfusion/opfusion_util.h index 7246dc7204..64d012e044 100644 --- a/src/include/opfusion/opfusion_util.h +++ b/src/include/opfusion/opfusion_util.h @@ -271,4 +271,6 @@ void InitPartitionRelationInFusion(Oid partOid, Relation parentRel, Partition *p void ExeceDoneInIndexFusionConstruct(bool isPartTbl, Relation *parentRel, Partition *part, Relation *index, Relation *rel); +#define RI_CONSTRAINT_TRIGGER_NAME_LEN 20 //trigger name must begin with RI_ConstraintTrigger + #endif /* SRC_INCLUDE_OPFUSION_OPFUSION_UTIL_H_ */ -- Gitee