diff --git a/sqle/driver/mysql/rule/ai/rule_00097.go b/sqle/driver/mysql/rule/ai/rule_00097.go index ab2f78ea4..1c036a93e 100644 --- a/sqle/driver/mysql/rule/ai/rule_00097.go +++ b/sqle/driver/mysql/rule/ai/rule_00097.go @@ -108,7 +108,7 @@ func RuleSQLE00097(input *rulepkg.RuleHandlerInput) error { checkViolate := func(table *ast.TableName, col string) (bool, error) { createTableStmt, err := getCreateTableStmt(table) if err != nil { - return false, fmt.Errorf("Failed to get CREATE TABLE statement for table %s: %v", table, err) + return false, fmt.Errorf("Failed to get CREATE TABLE statement for table %s: %v", table.Name.String(), err) } columnDef := getColumnDef(createTableStmt, col) diff --git a/sqle/driver/mysql/rule/ai/rule_00100.go b/sqle/driver/mysql/rule/ai/rule_00100.go index 8d6cd54ba..ab61ef4a7 100644 --- a/sqle/driver/mysql/rule/ai/rule_00100.go +++ b/sqle/driver/mysql/rule/ai/rule_00100.go @@ -95,7 +95,10 @@ func RuleSQLE00100(input *rulepkg.RuleHandlerInput) error { case *ast.SelectStmt, *ast.UnionStmt: // 当sql是insert ... select语句中的SelectStmt/UnionStmt的Text() 为'', 因此这里改用Restore方式获取sqlText sqlBuilder := new(strings.Builder) - node.Restore(format.NewRestoreCtx((format.RestoreStringSingleQuotes), sqlBuilder)) + err := node.Restore(format.NewRestoreCtx((format.RestoreStringSingleQuotes), sqlBuilder)) + if err != nil { + return false, err + } sqlText := sqlBuilder.String() executionPlan, err := util.GetExecutionPlan(input.Ctx, sqlText) if err != nil { diff --git a/sqle/driver/mysql/rule/ai/rule_00110.go b/sqle/driver/mysql/rule/ai/rule_00110.go index 56102950b..d17f695c6 100644 --- a/sqle/driver/mysql/rule/ai/rule_00110.go +++ b/sqle/driver/mysql/rule/ai/rule_00110.go @@ -164,7 +164,7 @@ func RuleSQLE00110(input *rulepkg.RuleHandlerInput) error { indexes, err := util.GetTableIndexes(input.Ctx, table.Name.String(), table.Schema.String()) if err != nil { // 记录错误日志并继续检查下一个表 - log.NewEntry().Errorf("获取表 %s 的索引失败: %v", table, err) + log.NewEntry().Errorf("获取表 %s 的索引失败: %v", table.Name.String(), err) continue } diff --git a/sqle/driver/mysql/session/mock_context.go b/sqle/driver/mysql/session/mock_context.go index 3a1f3e091..49fa558ee 100644 --- a/sqle/driver/mysql/session/mock_context.go +++ b/sqle/driver/mysql/session/mock_context.go @@ -589,7 +589,10 @@ func InitializeMockContext(e *executor.Executor, context *AIMockContext) (*Conte } } for tableName, sizeGB := range context.tableSize { - ctx.SetTableSize(ctx.currentSchema, tableName, sizeGB*1024 /*size MB*/) + err := ctx.SetTableSize(ctx.currentSchema, tableName, sizeGB*1024 /*size MB*/) + if err != nil { + return nil, err + } } return ctx, nil }