From 3d3303f429624d4f915a3858c74394a063bc815f Mon Sep 17 00:00:00 2001 From: iwanghc Date: Mon, 24 Jun 2024 15:54:46 +0800 Subject: [PATCH 1/5] add rule: precheck sql failure changed to rule check --- sqle/driver/mysql/audit.go | 10 ---------- sqle/driver/mysql/rule/rule.go | 8 ++++++++ sqle/driver/mysql/rule/rule_list.go | 12 ++++++++++++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/sqle/driver/mysql/audit.go b/sqle/driver/mysql/audit.go index d3e4f09562..1d10bfc50a 100644 --- a/sqle/driver/mysql/audit.go +++ b/sqle/driver/mysql/audit.go @@ -64,8 +64,6 @@ func (i *MysqlDriverImpl) CheckInvalid(node ast.Node) error { err = i.checkInvalidDelete(stmt) case *ast.SelectStmt: err = i.checkInvalidSelect(stmt) - case *ast.UnparsedStmt: - err = i.checkUnparsedStmt(stmt) } if err != nil && session.IsParseShowCreateTableContentErr(err) { @@ -104,8 +102,6 @@ func (i *MysqlDriverImpl) CheckInvalidOffline(node ast.Node) error { err = i.checkInvalidCreateIndexOffline(stmt) case *ast.InsertStmt: err = i.checkInvalidInsertOffline(stmt) - case *ast.UnparsedStmt: - err = i.checkUnparsedStmt(stmt) } if err != nil { return fmt.Errorf(CheckInvalidErrorFormat, err) @@ -1174,9 +1170,3 @@ func (i *MysqlDriverImpl) checkInvalidSelect(stmt *ast.SelectStmt) error { } return nil } - -// checkUnparsedStmt might add more check in future. -func (i *MysqlDriverImpl) checkUnparsedStmt(stmt *ast.UnparsedStmt) error { - i.result.Add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性") - return nil -} diff --git a/sqle/driver/mysql/rule/rule.go b/sqle/driver/mysql/rule/rule.go index 1153cbdc27..432d83e0fe 100644 --- a/sqle/driver/mysql/rule/rule.go +++ b/sqle/driver/mysql/rule/rule.go @@ -207,6 +207,7 @@ const ( ConfigOptimizeIndexEnabled = "optimize_index_enabled" ConfigDMLExplainPreCheckEnable = "dml_enable_explain_pre_check" ConfigSQLIsExecuted = "sql_is_executed" + ConfigParsingSQLFailure = "parsing_sql_failure" ) // 计算单位 @@ -5992,3 +5993,10 @@ func checkCharLength(input *RuleHandlerInput) error { } return nil } + +func checkSQLParsing(input *RuleHandlerInput) error { + if _, ok := input.Node.(*ast.UnparsedStmt); ok { + addResult(input.Res, input.Rule, input.Rule.Name) + } + return nil +} diff --git a/sqle/driver/mysql/rule/rule_list.go b/sqle/driver/mysql/rule/rule_list.go index edac7cd5c1..dc85d30bb4 100644 --- a/sqle/driver/mysql/rule/rule_list.go +++ b/sqle/driver/mysql/rule/rule_list.go @@ -2134,4 +2134,16 @@ var RuleHandlers = []RuleHandler{ Message: "禁止char, varchar类型字段字符长度总和超过阈值 %v", Func: checkCharLength, }, + { + Rule: driverV2.Rule{ + Name: ConfigParsingSQLFailure, + Desc: "语法错误或者解析器不支持", + Annotation: "语法错误或者解析器不支持,请人工确认SQL正确性。", + Level: driverV2.RuleLevelError, + Category: RuleTypeGlobalConfig, + }, + AllowOffline: false, + Message: "语法错误或者解析器不支持,请人工确认SQL正确性。", + Func: checkSQLParsing, + }, } From 39557502fedd737269016e2c376496bf52fb012e Mon Sep 17 00:00:00 2001 From: iwanghc Date: Mon, 24 Jun 2024 18:15:14 +0800 Subject: [PATCH 2/5] fix: fix test and modify parsing sql failure rule allow offline is true --- sqle/driver/mysql/audit_offline_test.go | 26 ++++++++++++------------- sqle/driver/mysql/audit_test.go | 17 ++++++++-------- sqle/driver/mysql/rule/rule_list.go | 2 +- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/sqle/driver/mysql/audit_offline_test.go b/sqle/driver/mysql/audit_offline_test.go index 8fe23cf0f0..7ce178dde0 100644 --- a/sqle/driver/mysql/audit_offline_test.go +++ b/sqle/driver/mysql/audit_offline_test.go @@ -2396,7 +2396,7 @@ SELECT * FROM exist_db.exist_tb_1; OPTIMIZE TABLE exist_db.exist_tb_1; SELECT * FROM exist_db.exist_tb_2; `, newTestResult().addResult(rulepkg.DMLCheckWhereIsInvalid), - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性"), + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure), newTestResult().addResult(rulepkg.DMLCheckWhereIsInvalid)) } @@ -2428,7 +2428,7 @@ CREATE `, } { runSingleRuleInspectCase(rulepkg.RuleHandlerMap[rulepkg.DDLCheckCreateTrigger].Rule, t, "", DefaultMysqlInspectOffline(), sql, - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性").addResult(rulepkg.DDLCheckCreateTrigger)) + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure).addResult(rulepkg.DDLCheckCreateTrigger)) } for _, sql := range []string{ @@ -2439,7 +2439,7 @@ CREATE `CREATE TRIGGER my_trigger BEEEFORE INSERT ON t1 FOR EACH ROW insert into t2(id, c1) values(1, '2');`, } { runSingleRuleInspectCase(rulepkg.RuleHandlerMap[rulepkg.DDLCheckCreateTrigger].Rule, t, "", DefaultMysqlInspectOffline(), sql, - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性")) + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure)) } } @@ -2457,7 +2457,7 @@ CREATE `, } { runSingleRuleInspectCase(rulepkg.RuleHandlerMap[rulepkg.DDLCheckCreateFunction].Rule, t, "", DefaultMysqlInspectOffline(), sql, - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性").addResult(rulepkg.DDLCheckCreateFunction)) + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure).addResult(rulepkg.DDLCheckCreateFunction)) } for _, sql := range []string{ @@ -2467,7 +2467,7 @@ CREATE `CREATE DEFINER='sqle_op'@'localhost' hello (s CHAR(20)) RETURNS CHAR(50) DETERMINISTIC RETURN CONCAT('Hello, ',s,'!');`, } { runSingleRuleInspectCase(rulepkg.RuleHandlerMap[rulepkg.DDLCheckCreateFunction].Rule, t, "", DefaultMysqlInspectOffline(), sql, - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性")) + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure)) } } @@ -2514,7 +2514,7 @@ select * from t1;`, runSingleRuleInspectCase( rulepkg.RuleHandlerMap[rulepkg.DDLCheckCreateProcedure].Rule, t, "", DefaultMysqlInspectOffline(), sql, - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性"). + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure). addResult(rulepkg.DDLCheckCreateProcedure)) } @@ -2549,7 +2549,7 @@ end;`, runSingleRuleInspectCase( rulepkg.RuleHandlerMap[rulepkg.DDLCheckCreateProcedure].Rule, t, "", DefaultMysqlInspectOffline(), sql, - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性")) + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure)) } } @@ -3746,7 +3746,7 @@ func TestDDLAvoidEvent(t *testing.T) { ``, DefaultMysqlInspectOffline(), `create event my_event on schedule every 10 second do update schema.table set mycol = mycol + 1;`, - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性").addResult(rulepkg.DDLAvoidEvent)) + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure).addResult(rulepkg.DDLAvoidEvent)) }) t.Run(`create event with DEFINER`, func(t *testing.T) { runSingleRuleInspectCase( @@ -3755,7 +3755,7 @@ func TestDDLAvoidEvent(t *testing.T) { ``, DefaultMysqlInspectOffline(), `create DEFINER=user event my_event on schedule every 10 second do update schema.table set mycol = mycol + 1;`, - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性").addResult(rulepkg.DDLAvoidEvent)) + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure).addResult(rulepkg.DDLAvoidEvent)) }) t.Run(`alter event`, func(t *testing.T) { runSingleRuleInspectCase( @@ -3771,7 +3771,7 @@ func TestDDLAvoidEvent(t *testing.T) { -- 修改事件的具体操作 UPDATE your_table SET your_column = your_value WHERE your_condition; `, - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性").addResult(rulepkg.DDLAvoidEvent)) + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure).addResult(rulepkg.DDLAvoidEvent)) }) t.Run(`alter event with DEFINER`, func(t *testing.T) { runSingleRuleInspectCase( @@ -3787,7 +3787,7 @@ func TestDDLAvoidEvent(t *testing.T) { -- 修改事件的具体操作 UPDATE your_table SET your_column = your_value WHERE your_condition; `, - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性").addResult(rulepkg.DDLAvoidEvent)) + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure).addResult(rulepkg.DDLAvoidEvent)) }) t.Run(`create event with blank line`, func(t *testing.T) { runSingleRuleInspectCase( @@ -3799,7 +3799,7 @@ func TestDDLAvoidEvent(t *testing.T) { create event my_event on schedule every 10 second do update schema.table set mycol = mycol + 1;`, - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性").addResult(rulepkg.DDLAvoidEvent)) + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure).addResult(rulepkg.DDLAvoidEvent)) }) t.Run(`create event with space`, func(t *testing.T) { runSingleRuleInspectCase( @@ -3808,6 +3808,6 @@ func TestDDLAvoidEvent(t *testing.T) { ``, DefaultMysqlInspectOffline(), ` create event my_event on schedule every 10 second do update schema.table set mycol = mycol + 1;`, - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性").addResult(rulepkg.DDLAvoidEvent)) + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure).addResult(rulepkg.DDLAvoidEvent)) }) } diff --git a/sqle/driver/mysql/audit_test.go b/sqle/driver/mysql/audit_test.go index e700a296cd..5152b91151 100644 --- a/sqle/driver/mysql/audit_test.go +++ b/sqle/driver/mysql/audit_test.go @@ -120,7 +120,8 @@ func NewMockInspectWithIsExecutedSQL(e *executor.Executor) *MysqlDriverImpl { } func runSingleRuleInspectCase(rule driverV2.Rule, t *testing.T, desc string, i *MysqlDriverImpl, sql string, results ...*testResult) { - i.rules = []*driverV2.Rule{&rule} + parsingSQLFailureRule := rulepkg.RuleHandlerMap[rulepkg.ConfigParsingSQLFailure].Rule + i.rules = []*driverV2.Rule{&parsingSQLFailureRule, &rule} inspectCase(t, desc, i, sql, results...) } @@ -4434,7 +4435,7 @@ SELECT * FROM exist_db.exist_tb_1; OPTIMIZE TABLE exist_db.exist_tb_1; SELECT * FROM exist_db.exist_tb_2; `, newTestResult().addResult(rulepkg.DMLCheckWhereIsInvalid), - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性"), + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure), newTestResult().addResult(rulepkg.DMLCheckWhereIsInvalid)) } @@ -4467,7 +4468,7 @@ CREATE `, } { runSingleRuleInspectCase(rulepkg.RuleHandlerMap[rulepkg.DDLCheckCreateTrigger].Rule, t, "", DefaultMysqlInspect(), sql, - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性").addResult(rulepkg.DDLCheckCreateTrigger)) + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure).addResult(rulepkg.DDLCheckCreateTrigger)) } for _, sql := range []string{ @@ -4480,7 +4481,7 @@ CREATE `AFTER CREATE`, } { runSingleRuleInspectCase(rulepkg.RuleHandlerMap[rulepkg.DDLCheckCreateTrigger].Rule, t, "", DefaultMysqlInspect(), sql, - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性")) + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure)) } } @@ -4498,7 +4499,7 @@ CREATE `, } { runSingleRuleInspectCase(rulepkg.RuleHandlerMap[rulepkg.DDLCheckCreateFunction].Rule, t, "", DefaultMysqlInspect(), sql, - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性").addResult(rulepkg.DDLCheckCreateFunction)) + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure).addResult(rulepkg.DDLCheckCreateFunction)) } for _, sql := range []string{ @@ -4508,7 +4509,7 @@ CREATE `CREATE DEFINER='sqle_op'@'localhost' hello (s CHAR(20)) RETURNS CHAR(50) DETERMINISTIC RETURN CONCAT('Hello, ',s,'!');`, } { runSingleRuleInspectCase(rulepkg.RuleHandlerMap[rulepkg.DDLCheckCreateFunction].Rule, t, "", DefaultMysqlInspect(), sql, - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性")) + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure)) } } @@ -4555,7 +4556,7 @@ select * from t1;`, runSingleRuleInspectCase( rulepkg.RuleHandlerMap[rulepkg.DDLCheckCreateProcedure].Rule, t, "", DefaultMysqlInspect(), sql, - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性"). + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure). addResult(rulepkg.DDLCheckCreateProcedure)) } @@ -4590,7 +4591,7 @@ end;`, runSingleRuleInspectCase( rulepkg.RuleHandlerMap[rulepkg.DDLCheckCreateProcedure].Rule, t, "", DefaultMysqlInspect(), sql, - newTestResult().add(driverV2.RuleLevelWarn, "", "语法错误或者解析器不支持,请人工确认SQL正确性")) + newTestResult().addResult(rulepkg.ConfigParsingSQLFailure)) } } diff --git a/sqle/driver/mysql/rule/rule_list.go b/sqle/driver/mysql/rule/rule_list.go index dc85d30bb4..eb5dcd0c86 100644 --- a/sqle/driver/mysql/rule/rule_list.go +++ b/sqle/driver/mysql/rule/rule_list.go @@ -2142,7 +2142,7 @@ var RuleHandlers = []RuleHandler{ Level: driverV2.RuleLevelError, Category: RuleTypeGlobalConfig, }, - AllowOffline: false, + AllowOffline: true, Message: "语法错误或者解析器不支持,请人工确认SQL正确性。", Func: checkSQLParsing, }, From a859dd1012382521f8b57d21bdfd5a2be0585525 Mon Sep 17 00:00:00 2001 From: iwanghc Date: Wed, 3 Jul 2024 14:09:51 +0800 Subject: [PATCH 3/5] modify: parsing sql failure in pre check --- sqle/driver/mysql/audit.go | 12 ++++++++++++ sqle/driver/mysql/audit_test.go | 2 ++ sqle/driver/mysql/mysql.go | 16 +++++++++++----- sqle/driver/mysql/rule/rule.go | 7 ------- sqle/driver/mysql/rule/rule_list.go | 2 +- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/sqle/driver/mysql/audit.go b/sqle/driver/mysql/audit.go index 1d10bfc50a..d04dd55a98 100644 --- a/sqle/driver/mysql/audit.go +++ b/sqle/driver/mysql/audit.go @@ -64,6 +64,8 @@ func (i *MysqlDriverImpl) CheckInvalid(node ast.Node) error { err = i.checkInvalidDelete(stmt) case *ast.SelectStmt: err = i.checkInvalidSelect(stmt) + case *ast.UnparsedStmt: + err = i.checkUnparsedStmt(stmt) } if err != nil && session.IsParseShowCreateTableContentErr(err) { @@ -102,6 +104,8 @@ func (i *MysqlDriverImpl) CheckInvalidOffline(node ast.Node) error { err = i.checkInvalidCreateIndexOffline(stmt) case *ast.InsertStmt: err = i.checkInvalidInsertOffline(stmt) + case *ast.UnparsedStmt: + err = i.checkUnparsedStmt(stmt) } if err != nil { return fmt.Errorf(CheckInvalidErrorFormat, err) @@ -1170,3 +1174,11 @@ func (i *MysqlDriverImpl) checkInvalidSelect(stmt *ast.SelectStmt) error { } return nil } + +// checkUnparsedStmt might add more check in future. +func (i *MysqlDriverImpl) checkUnparsedStmt(stmt *ast.UnparsedStmt) error { + if i.cnf.parsingSQLFailureCheckEnable { + i.result.Add(i.cnf.parsingSQLFailureLevel, rulepkg.ConfigParsingSQLFailure, "语法错误或者解析器不支持,请人工确认SQL正确性。") + } + return nil +} diff --git a/sqle/driver/mysql/audit_test.go b/sqle/driver/mysql/audit_test.go index 5152b91151..215bd1d967 100644 --- a/sqle/driver/mysql/audit_test.go +++ b/sqle/driver/mysql/audit_test.go @@ -121,6 +121,8 @@ func NewMockInspectWithIsExecutedSQL(e *executor.Executor) *MysqlDriverImpl { func runSingleRuleInspectCase(rule driverV2.Rule, t *testing.T, desc string, i *MysqlDriverImpl, sql string, results ...*testResult) { parsingSQLFailureRule := rulepkg.RuleHandlerMap[rulepkg.ConfigParsingSQLFailure].Rule + i.cnf.parsingSQLFailureCheckEnable = true + i.cnf.parsingSQLFailureLevel = parsingSQLFailureRule.Level i.rules = []*driverV2.Rule{&parsingSQLFailureRule, &rule} inspectCase(t, desc, i, sql, results...) } diff --git a/sqle/driver/mysql/mysql.go b/sqle/driver/mysql/mysql.go index ed0d1b0e8b..b0e3b6d3b1 100644 --- a/sqle/driver/mysql/mysql.go +++ b/sqle/driver/mysql/mysql.go @@ -103,6 +103,10 @@ func NewInspect(log *logrus.Entry, cfg *driverV2.Config) (*MysqlDriverImpl, erro if rule.Name == rulepkg.ConfigSQLIsExecuted { inspect.cnf.isExecutedSQL = true } + if rule.Name == rulepkg.ConfigParsingSQLFailure { + inspect.cnf.parsingSQLFailureCheckEnable = true + inspect.cnf.parsingSQLFailureLevel = rule.Level + } } return inspect, nil @@ -515,11 +519,13 @@ type Config struct { DDLOSCMinSize int64 DDLGhostMinSize int64 - optimizeIndexEnabled bool - dmlExplainPreCheckEnable bool - compositeIndexMaxColumn int - indexSelectivityMinValue float64 - isExecutedSQL bool + optimizeIndexEnabled bool + dmlExplainPreCheckEnable bool + compositeIndexMaxColumn int + indexSelectivityMinValue float64 + isExecutedSQL bool + parsingSQLFailureCheckEnable bool + parsingSQLFailureLevel driverV2.RuleLevel } func (i *MysqlDriverImpl) Context() *session.Context { diff --git a/sqle/driver/mysql/rule/rule.go b/sqle/driver/mysql/rule/rule.go index 432d83e0fe..a8a63d2a23 100644 --- a/sqle/driver/mysql/rule/rule.go +++ b/sqle/driver/mysql/rule/rule.go @@ -5993,10 +5993,3 @@ func checkCharLength(input *RuleHandlerInput) error { } return nil } - -func checkSQLParsing(input *RuleHandlerInput) error { - if _, ok := input.Node.(*ast.UnparsedStmt); ok { - addResult(input.Res, input.Rule, input.Rule.Name) - } - return nil -} diff --git a/sqle/driver/mysql/rule/rule_list.go b/sqle/driver/mysql/rule/rule_list.go index eb5dcd0c86..67397cb0c6 100644 --- a/sqle/driver/mysql/rule/rule_list.go +++ b/sqle/driver/mysql/rule/rule_list.go @@ -2144,6 +2144,6 @@ var RuleHandlers = []RuleHandler{ }, AllowOffline: true, Message: "语法错误或者解析器不支持,请人工确认SQL正确性。", - Func: checkSQLParsing, + Func: nil, }, } From d72901260f10aed44be816571b55762f900a9d0a Mon Sep 17 00:00:00 2001 From: iwanghc Date: Wed, 3 Jul 2024 15:19:17 +0800 Subject: [PATCH 4/5] del: unuse rule property --- sqle/driver/mysql/rule/rule_list.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/sqle/driver/mysql/rule/rule_list.go b/sqle/driver/mysql/rule/rule_list.go index 67397cb0c6..0fb0c24395 100644 --- a/sqle/driver/mysql/rule/rule_list.go +++ b/sqle/driver/mysql/rule/rule_list.go @@ -2142,8 +2142,6 @@ var RuleHandlers = []RuleHandler{ Level: driverV2.RuleLevelError, Category: RuleTypeGlobalConfig, }, - AllowOffline: true, - Message: "语法错误或者解析器不支持,请人工确认SQL正确性。", Func: nil, }, } From a761cb0242762bac2d31dfee27bf80d1d4f00f48 Mon Sep 17 00:00:00 2001 From: iwanghc Date: Wed, 3 Jul 2024 16:15:20 +0800 Subject: [PATCH 5/5] modify: add rule message for pre check unparsed --- sqle/driver/mysql/audit.go | 3 ++- sqle/driver/mysql/rule/rule_list.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sqle/driver/mysql/audit.go b/sqle/driver/mysql/audit.go index d04dd55a98..bca88177a0 100644 --- a/sqle/driver/mysql/audit.go +++ b/sqle/driver/mysql/audit.go @@ -1178,7 +1178,8 @@ func (i *MysqlDriverImpl) checkInvalidSelect(stmt *ast.SelectStmt) error { // checkUnparsedStmt might add more check in future. func (i *MysqlDriverImpl) checkUnparsedStmt(stmt *ast.UnparsedStmt) error { if i.cnf.parsingSQLFailureCheckEnable { - i.result.Add(i.cnf.parsingSQLFailureLevel, rulepkg.ConfigParsingSQLFailure, "语法错误或者解析器不支持,请人工确认SQL正确性。") + parsingRule := rulepkg.RuleHandlerMap[rulepkg.ConfigParsingSQLFailure] + i.result.Add(i.cnf.parsingSQLFailureLevel, rulepkg.ConfigParsingSQLFailure, parsingRule.Message) } return nil } diff --git a/sqle/driver/mysql/rule/rule_list.go b/sqle/driver/mysql/rule/rule_list.go index 0fb0c24395..b82b2ba8a9 100644 --- a/sqle/driver/mysql/rule/rule_list.go +++ b/sqle/driver/mysql/rule/rule_list.go @@ -2142,6 +2142,7 @@ var RuleHandlers = []RuleHandler{ Level: driverV2.RuleLevelError, Category: RuleTypeGlobalConfig, }, - Func: nil, + Message: "语法错误或者解析器不支持,请人工确认SQL正确性。", + Func: nil, }, }