From 4f9e5575cab9f8ae98aba878a02badcdc66fc3a4 Mon Sep 17 00:00:00 2001 From: yuanjiawei Date: Wed, 27 Nov 2024 10:41:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A6=81=E6=AD=A2=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E4=BC=9A=E5=90=91=E6=95=B0=E6=8D=AE=E5=BA=93=E4=B8=8B=E5=8F=91?= =?UTF-8?q?SQL=E7=9A=84=E8=A7=84=E5=88=99=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E5=9C=A8=E9=BB=98=E8=AE=A4=E6=A8=A1=E7=89=88=E4=B8=AD=20?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E5=BD=B1=E5=93=8D=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sqle/model/utils.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/sqle/model/utils.go b/sqle/model/utils.go index 73ee87936..5d8e33bc3 100644 --- a/sqle/model/utils.go +++ b/sqle/model/utils.go @@ -13,6 +13,7 @@ import ( "text/template" "time" + mysqlRule "github.com/actiontech/sqle/sqle/driver/mysql/rule" driverV2 "github.com/actiontech/sqle/sqle/driver/v2" "github.com/actiontech/sqle/sqle/errors" "github.com/actiontech/sqle/sqle/log" @@ -441,6 +442,9 @@ func (s *Storage) CreateDefaultTemplateIfNotExist(projectId ProjectUID, rules ma if rule.Level != driverV2.RuleLevelError { continue } + if forbiddenRules[dbType+"_"+rule.Name] { + continue + } modelRule := GenerateRuleByDriverRule(rule, dbType) ruleList = append(ruleList, RuleTemplateRule{ RuleTemplateId: t.ID, @@ -458,6 +462,27 @@ func (s *Storage) CreateDefaultTemplateIfNotExist(projectId ProjectUID, rules ma return nil } +// 这里禁止了会向数据源下发SQL的规则,防止影响数据库性能 +var forbiddenRules = map[string]bool{ + "MySQL_" + mysqlRule.DMLCheckSelectRows: true, + "MySQL_" + mysqlRule.DMLCheckAffectedRows: true, + "MySQL_" + mysqlRule.ConfigOptimizeIndexEnabled: true, + "MySQL_" + mysqlRule.DDLCheckIndexOption: true, + "MySQL_" + mysqlRule.DDLCheckCompositeIndexDistinction: true, + "Oracle_011": true, + "Oracle_012": true, + "Oracle_017": true, + "Oracle_019": true, + "Oracle_044": true, + "Oracle_046": true, + "Oracle_050": true, + "Oracle_077": true, + "Oracle_078": true, + "Oracle_080": true, + "SQL Server_ddl_check_index_count": true, + "SQL Server_ddl_check_index_column_with_blob": true, +} + func (s *Storage) GetDefaultRuleTemplateName(dbType string) string { return fmt.Sprintf("default_%v", dbType) }