Skip to content

Commit

Permalink
Merge pull request #2783 from actiontech/fix_disable_db_performance_sql
Browse files Browse the repository at this point in the history
fix: rollback forbiddenRules and change rule level
  • Loading branch information
sjjian authored Nov 27, 2024
2 parents 63f8b06 + 314d58e commit b68ff29
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 27 deletions.
4 changes: 2 additions & 2 deletions sqle/driver/mysql/rule/rule_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -1857,7 +1857,7 @@ var sourceRuleHandlers = []*SourceHandler{
Name: DMLCheckAffectedRows,
Desc: plocale.DMLCheckAffectedRowsDesc,
Annotation: plocale.DMLCheckAffectedRowsAnnotation,
Level: driverV2.RuleLevelError,
Level: driverV2.RuleLevelWarn,
Category: plocale.RuleTypeDMLConvention,
Params: []*SourceParam{
{
Expand Down Expand Up @@ -2001,7 +2001,7 @@ var sourceRuleHandlers = []*SourceHandler{
Name: DMLCheckSelectRows,
Desc: plocale.DMLCheckSelectRowsDesc,
Annotation: plocale.DMLCheckSelectRowsAnnotation,
Level: driverV2.RuleLevelError,
Level: driverV2.RuleLevelWarn,
Category: plocale.RuleTypeDMLConvention,
Params: []*SourceParam{
{
Expand Down
25 changes: 0 additions & 25 deletions sqle/model/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ 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 @@ -442,9 +441,6 @@ 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 @@ -462,27 +458,6 @@ 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_Oracle_011": true,
"Oracle_Oracle_012": true,
"Oracle_Oracle_017": true,
"Oracle_Oracle_019": true,
"Oracle_Oracle_044": true,
"Oracle_Oracle_046": true,
"Oracle_Oracle_050": true,
"Oracle_Oracle_077": true,
"Oracle_Oracle_078": true,
"Oracle_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 b68ff29

Please sign in to comment.