Skip to content

Commit

Permalink
Merge pull request #2426 from actiontech/fix-reused-rule-ce
Browse files Browse the repository at this point in the history
fix: split DDLCheckDatabaseCollation
  • Loading branch information
LordofAvernus committed May 21, 2024
2 parents 0890631 + 1dafb8e commit 45b0dc3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
1 change: 1 addition & 0 deletions sqle/server/optimization/rule/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var OptimizationRuleMap map[string][]OptimizationRuleHandler // ruleCode与plugi
const (
DMLRuleNPERewrite = "dml_rule_npe_rewrite"
DMLRuleAllSubqueryRewrite = "dml_rule_all_subquery_rewrite"
DMLRuleDiffOrderingSpecTypeWarning = "dml_rule_diff_ordering_spec_type_warning"
DMLRuleDistinctEliminationRewrite = "dml_rule_distinct_elimination_rewrite"
DMLRuleExists2JoinRewrite = "dml_rule_exists_2_join_rewrite"
DMLRuleFilterPredicatePushDownRewrite = "dml_rule_filter_predicate_push_down_rewrite"
Expand Down
60 changes: 30 additions & 30 deletions sqle/server/optimization/rule/rule_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,6 @@ import (
)

var MySQLOptimizationRuleHandler = []OptimizationRuleHandler{
{
Rule: driverV2.Rule{
Name: DMLRuleNPERewrite,
Desc: "NPE重写",
Annotation: "SQL的NPE(Null Pointer Exception)问题是指在SQL查询中,当聚合列全为NULL时,SUM、AVG等聚合函数会返回NULL,这可能会导致后续的程序出现空指针异常。",
Level: driverV2.RuleLevelNotice,
Category: rulepkg.RuleTypeDMLConvention,
},
RuleCode: RuleNPERewrite,
},
{
Rule: driverV2.Rule{
Name: DMLRuleAllSubqueryRewrite,
Desc: "ALL修饰的子查询重写",
Annotation: "如果ALL子查询的结果中存在NULL,这个SQL永远返回为空。正确的写法应该是在子查询里加上非空限制,或使用max/min的写法。",
Level: driverV2.RuleLevelNotice,
Category: rulepkg.RuleTypeDMLConvention,
},
RuleCode: RuleAllQualifierSubQueryRewrite,
},
{
Rule: driverV2.Rule{
Name: rulepkg.DMLHintGroupByRequiresConditions,
Expand Down Expand Up @@ -67,16 +47,6 @@ var MySQLOptimizationRuleHandler = []OptimizationRuleHandler{
},
RuleCode: RuleDiffDataTypeInPredicateWrite,
},
{
Rule: driverV2.Rule{
Name: rulepkg.DDLCheckDatabaseCollation,
Desc: "排序字段方向不同导致索引失效",
Annotation: "ORDER BY 子句中的所有表达式需要按统一的 ASC 或 DESC 方向排序,才能利用索引来避免排序;如果ORDER BY 语句对多个不同条件使用不同方向的排序无法使用索引",
Level: driverV2.RuleLevelNotice,
Category: rulepkg.RuleTypeDDLConvention,
},
RuleCode: RuleDiffOrderingSpecTypeWarning,
},
{
Rule: driverV2.Rule{
Name: rulepkg.DMLCheckMathComputationOrFuncOnIndex,
Expand Down Expand Up @@ -157,6 +127,36 @@ var MySQLOptimizationRuleHandler = []OptimizationRuleHandler{
},
RuleCode: RuleLargeOffset,
},
{
Rule: driverV2.Rule{
Name: DMLRuleNPERewrite,
Desc: "NPE重写",
Annotation: "SQL的NPE(Null Pointer Exception)问题是指在SQL查询中,当聚合列全为NULL时,SUM、AVG等聚合函数会返回NULL,这可能会导致后续的程序出现空指针异常。",
Level: driverV2.RuleLevelNotice,
Category: rulepkg.RuleTypeDMLConvention,
},
RuleCode: RuleNPERewrite,
},
{
Rule: driverV2.Rule{
Name: DMLRuleAllSubqueryRewrite,
Desc: "ALL修饰的子查询重写",
Annotation: "如果ALL子查询的结果中存在NULL,这个SQL永远返回为空。正确的写法应该是在子查询里加上非空限制,或使用max/min的写法。",
Level: driverV2.RuleLevelNotice,
Category: rulepkg.RuleTypeDMLConvention,
},
RuleCode: RuleAllQualifierSubQueryRewrite,
},
{
Rule: driverV2.Rule{
Name: DMLRuleDiffOrderingSpecTypeWarning,
Desc: "排序字段方向不同导致索引失效",
Annotation: "ORDER BY 子句中的所有表达式需要按统一的 ASC 或 DESC 方向排序,才能利用索引来避免排序;如果ORDER BY 语句对多个不同条件使用不同方向的排序无法使用索引",
Level: driverV2.RuleLevelNotice,
Category: rulepkg.RuleTypeDMLConvention,
},
RuleCode: RuleDiffOrderingSpecTypeWarning,
},
{
Rule: driverV2.Rule{
Name: DMLRuleDistinctEliminationRewrite,
Expand Down

0 comments on commit 45b0dc3

Please sign in to comment.