Skip to content

Commit

Permalink
fix: 禁止一些会向数据库下发SQL的规则初始化在默认模版中 防止影响数据库性能
Browse files Browse the repository at this point in the history
  • Loading branch information
littleniannian committed Nov 27, 2024
1 parent b86dccb commit 4f9e557
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions sqle/model/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -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)
}
Expand Down

0 comments on commit 4f9e557

Please sign in to comment.