Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: crying advisor (#12279)
Danny Xu566a8aaa9943
diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.goindex 2fa2f6682e..cfb14e7317 100644--- a/backend/api/v1/sql_service.go+++ b/backend/api/v1/sql_service.go@@ -188,7 +188,7 @@ func (s *SQLService) Execute(ctx context.Context, request *v1pb.ExecuteRequest)}var results []*v1pb.QueryResult- if adviceStatus != advisor.Error {+ if adviceStatus != storepb.Advice_ERROR {var queryErr errorresults, _, queryErr = s.doExecute(ctx, instance, database, request)if queryErr != nil {@@ -731,7 +731,7 @@ func (s *SQLService) Query(ctx context.Context, request *v1pb.QueryRequest) (*v1var results []*v1pb.QueryResultvar queryErr errorvar durationNs int64- if adviceStatus != advisor.Error {+ if adviceStatus != storepb.Advice_ERROR {results, durationNs, queryErr = s.doQuery(ctx, request, instance, database)if queryErr == nil && s.licenseService.IsFeatureEnabledForInstance(api.FeatureSensitiveData, instance) == nil {masker := NewQueryResultMasker(s.store)@@ -1226,27 +1226,27 @@ func (s *SQLService) Check(ctx context.Context, request *v1pb.CheckRequest) (*v1// sqlReviewCheck checks the SQL statement against the SQL review policy bind to given environment,// against the database schema bind to the given database, if the overrideMetadata is provided,// it will be used instead of fetching the database schema from the store.-func (s *SQLService) sqlReviewCheck(ctx context.Context, statement string, changeType v1pb.CheckRequest_ChangeType, environment *store.EnvironmentMessage, instance *store.InstanceMessage, database *store.DatabaseMessage, overrideMetadata *storepb.DatabaseSchemaMetadata) (advisor.Status, []*v1pb.Advice, error) {+func (s *SQLService) sqlReviewCheck(ctx context.Context, statement string, changeType v1pb.CheckRequest_ChangeType, environment *store.EnvironmentMessage, instance *store.InstanceMessage, database *store.DatabaseMessage, overrideMetadata *storepb.DatabaseSchemaMetadata) (storepb.Advice_Status, []*v1pb.Advice, error) {if !IsSQLReviewSupported(instance.Engine) || database == nil {- return advisor.Success, nil, nil+ return storepb.Advice_SUCCESS, nil, nil}dbMetadata := overrideMetadataif dbMetadata == nil {dbSchema, err := s.store.GetDBSchema(ctx, database.UID)if err != nil {- return advisor.Error, nil, status.Errorf(codes.Internal, "failed to fetch database schema: %v", err)+ return storepb.Advice_ERROR, nil, status.Errorf(codes.Internal, "failed to fetch database schema: %v", err)}if dbSchema == nil {if err := s.schemaSyncer.SyncDatabaseSchema(ctx, database, true /* force */); err != nil {- return advisor.Error, nil, status.Errorf(codes.Internal, "failed to sync database schema: %v", err)+ return storepb.Advice_ERROR, nil, status.Errorf(codes.Internal, "failed to sync database schema: %v", err)}dbSchema, err = s.store.GetDBSchema(ctx, database.UID)if err != nil {- return advisor.Error, nil, status.Errorf(codes.Internal, "failed to fetch database schema: %v", err)+ return storepb.Advice_ERROR, nil, status.Errorf(codes.Internal, "failed to fetch database schema: %v", err)}if dbSchema == nil {- return advisor.Error, nil, status.Errorf(codes.NotFound, "database schema not found: %v", database.UID)+ return storepb.Advice_ERROR, nil, status.Errorf(codes.NotFound, "database schema not found: %v", database.UID)}}dbMetadata = dbSchema.GetMetadata()@@ -1254,12 +1254,12 @@ func (s *SQLService) sqlReviewCheck(ctx context.Context, statement string, changcatalog, err := s.store.NewCatalog(ctx, database.UID, instance.Engine, store.IgnoreDatabaseAndTableCaseSensitive(instance), overrideMetadata, advisor.SyntaxModeNormal)if err != nil {- return advisor.Error, nil, status.Errorf(codes.Internal, "Failed to create a catalog: %v", err)+ return storepb.Advice_ERROR, nil, status.Errorf(codes.Internal, "Failed to create a catalog: %v", err)}driver, err := s.dbFactory.GetAdminDatabaseDriver(ctx, instance, database, db.ConnectionContext{UseDatabaseOwner: true})if err != nil {- return advisor.Error, nil, status.Errorf(codes.Internal, "Failed to get database driver: %v", err)+ return storepb.Advice_ERROR, nil, status.Errorf(codes.Internal, "Failed to get database driver: %v", err)}defer driver.Close(ctx)connection := driver.GetDB()@@ -1275,13 +1275,13 @@ func (s *SQLService) sqlReviewCheck(ctx context.Context, statement string, changdatabase.DatabaseName,)if err != nil {- return advisor.Error, nil, status.Errorf(codes.Internal, "Failed to check SQL review policy: %v", err)+ return storepb.Advice_ERROR, nil, status.Errorf(codes.Internal, "Failed to check SQL review policy: %v", err)}return adviceLevel, convertAdviceList(adviceList), nil}-func convertAdviceList(list []advisor.Advice) []*v1pb.Advice {+func convertAdviceList(list []*storepb.Advice) []*v1pb.Advice {var result []*v1pb.Advicefor _, advice := range list {result = append(result, &v1pb.Advice{@@ -1289,21 +1289,21 @@ func convertAdviceList(list []advisor.Advice) []*v1pb.Advice {Code: int32(advice.Code),Title: advice.Title,Content: advice.Content,- Line: int32(advice.Line),- Column: int32(advice.Column),- Detail: advice.Details,+ Line: int32(advice.GetStartPosition().Line),+ Column: int32(advice.GetStartPosition().Column),+ Detail: advice.Detail,})}return result}-func convertAdviceStatus(status advisor.Status) v1pb.Advice_Status {+func convertAdviceStatus(status storepb.Advice_Status) v1pb.Advice_Status {switch status {- case advisor.Success:+ case storepb.Advice_SUCCESS:return v1pb.Advice_SUCCESS- case advisor.Warn:+ case storepb.Advice_WARNING:return v1pb.Advice_WARNING- case advisor.Error:+ case storepb.Advice_ERROR:return v1pb.Advice_ERRORdefault:return v1pb.Advice_STATUS_UNSPECIFIED@@ -1320,14 +1320,14 @@ func (s *SQLService) sqlCheck(catalog catalog.Catalog,driver *sql.DB,currentDatabase string,-) (advisor.Status, []advisor.Advice, error) {- var adviceList []advisor.Advice+) (storepb.Advice_Status, []*storepb.Advice, error) {+ var adviceList []*storepb.Advicepolicy, err := s.store.GetSQLReviewPolicy(ctx, environmentID)if err != nil {if e, ok := err.(*common.Error); ok && e.Code == common.NotFound {- return advisor.Success, nil, nil+ return storepb.Advice_SUCCESS, nil, nil}- return advisor.Error, nil, err+ return storepb.Advice_ERROR, nil, err}res, err := advisor.SQLReviewCheck(statement, policy.RuleList, advisor.SQLReviewCheckContext{@@ -1342,19 +1342,19 @@ func (s *SQLService) sqlCheck(CurrentDatabase: currentDatabase,})if err != nil {- return advisor.Error, nil, err+ return storepb.Advice_ERROR, nil, err}- adviceLevel := advisor.Success+ adviceLevel := storepb.Advice_SUCCESSfor _, advice := range res {switch advice.Status {- case advisor.Warn:- if adviceLevel != advisor.Error {- adviceLevel = advisor.Warn+ case storepb.Advice_WARNING:+ if adviceLevel != storepb.Advice_ERROR {+ adviceLevel = storepb.Advice_WARNING}- case advisor.Error:- adviceLevel = advisor.Error- case advisor.Success:+ case storepb.Advice_ERROR:+ adviceLevel = storepb.Advice_ERROR+ case storepb.Advice_SUCCESS:continue}diff --git a/backend/plugin/advisor/advisor.go b/backend/plugin/advisor/advisor.goindex 48a0149a05..382938145c 100644--- a/backend/plugin/advisor/advisor.go+++ b/backend/plugin/advisor/advisor.go@@ -32,14 +32,14 @@ const ()// NewStatusBySQLReviewRuleLevel returns status by SQLReviewRuleLevel.-func NewStatusBySQLReviewRuleLevel(level storepb.SQLReviewRuleLevel) (Status, error) {+func NewStatusBySQLReviewRuleLevel(level storepb.SQLReviewRuleLevel) (storepb.Advice_Status, error) {switch level {case storepb.SQLReviewRuleLevel_ERROR:- return Error, nil+ return storepb.Advice_ERROR, nilcase storepb.SQLReviewRuleLevel_WARNING:- return Warn, nil+ return storepb.Advice_WARNING, nil}- return "", errors.Errorf("unexpected rule level type: %s", level)+ return storepb.Advice_STATUS_UNSPECIFIED, errors.Errorf("unexpected rule level type: %s", level)}// GetPriority returns the priority of status.@@ -673,7 +673,7 @@ type Context struct {// Advisor is the interface for advisor.type Advisor interface {- Check(ctx Context, statement string) ([]Advice, error)+ Check(ctx Context, statement string) ([]*storepb.Advice, error)}var (@@ -704,7 +704,7 @@ func Register(dbType storepb.Engine, advType Type, f Advisor) {}// Check runs the advisor and returns the advices.-func Check(dbType storepb.Engine, advType Type, ctx Context, statement string) (adviceList []Advice, err error) {+func Check(dbType storepb.Engine, advType Type, ctx Context, statement string) (adviceList []*storepb.Advice, err error) {defer func() {if panicErr := recover(); panicErr != nil {panicErr, ok := panicErr.(error)diff --git a/backend/plugin/advisor/generator/mssql.template b/backend/plugin/advisor/generator/mssql.templateindex e639f3ae51..3a37605151 100644--- a/backend/plugin/advisor/generator/mssql.template+++ b/backend/plugin/advisor/generator/mssql.template@@ -23,7 +23,7 @@ type %AdvisorName struct {}// Check checks for %AdvisorComment.-func (*%AdvisorName) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*%AdvisorName) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -48,18 +48,18 @@ func (*%AdvisorName) Check(ctx advisor.Context, _ string) ([]advisor.Advice, errtype %CheckerName struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *%CheckerName) generateAdvice() ([]advisor.Advice, error) {+func (l *%CheckerName) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/generator/mysql.template b/backend/plugin/advisor/generator/mysql.templateindex 5537c1e711..a82cff28ac 100644--- a/backend/plugin/advisor/generator/mysql.template+++ b/backend/plugin/advisor/generator/mysql.template@@ -25,7 +25,7 @@ type %AdvisorName struct {}// Check checks for %AdvisorComment-func (*%AdvisorName) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*%AdvisorName) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -47,9 +47,9 @@ func (*%AdvisorName) Check(ctx advisor.Context, _ string) ([]advisor.Advice, err}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -58,8 +58,8 @@ func (*%AdvisorName) Check(ctx advisor.Context, _ string) ([]advisor.Advice, err}type %CheckerName struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline intdiff --git a/backend/plugin/advisor/generator/oracle.template b/backend/plugin/advisor/generator/oracle.templateindex 894f2b2a9d..4a381fdc19 100644--- a/backend/plugin/advisor/generator/oracle.template+++ b/backend/plugin/advisor/generator/oracle.template@@ -24,7 +24,7 @@ type %AdvisorName struct {}// Check checks for %AdvisorComment-func (*%AdvisorName) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*%AdvisorName) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -50,18 +50,18 @@ func (*%AdvisorName) Check(ctx advisor.Context, _ string) ([]advisor.Advice, errtype %CheckerName struct {*parser.BasePlSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcurrentSchema string}-func (l *%CheckerName) generateAdvice() ([]advisor.Advice, error) {- advice := []advisor.Advice{}+func (l *%CheckerName) generateAdvice() ([]*storepb.Advice, error) {+ advice := []*storepb.Advice{}if len(advice) == 0 {- advice = append(advice, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ advice = append(advice, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/generator/postgresql.template b/backend/plugin/advisor/generator/postgresql.templateindex 7d46c2f655..a99aff7037 100644--- a/backend/plugin/advisor/generator/postgresql.template+++ b/backend/plugin/advisor/generator/postgresql.template@@ -24,7 +24,7 @@ type %AdvisorName struct {}// Check checks for %AdvisorComment-func (*%AdvisorName) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*%AdvisorName) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -44,9 +44,9 @@ func (*%AdvisorName) Check(ctx advisor.Context, _ string) ([]advisor.Advice, err}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -55,8 +55,8 @@ func (*%AdvisorName) Check(ctx advisor.Context, _ string) ([]advisor.Advice, err}type %CheckerName struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle string}diff --git a/backend/plugin/advisor/generator/snowflake.template b/backend/plugin/advisor/generator/snowflake.templateindex e332bbb099..df3714457a 100644--- a/backend/plugin/advisor/generator/snowflake.template+++ b/backend/plugin/advisor/generator/snowflake.template@@ -23,7 +23,7 @@ type %AdvisorName struct {}// Check checks for %AdvisorComment-func (*%AdvisorName) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*%AdvisorName) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -48,18 +48,18 @@ func (*%AdvisorName) Check(ctx advisor.Context, _ string) ([]advisor.Advice, errtype %CheckerName struct {*parser.BaseSnowflakeParserListener- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *%CheckerName) generateAdvice() ([]advisor.Advice, error) {+func (l *%CheckerName) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/mssql/advisor_column_maximum_varchar_length.go b/backend/plugin/advisor/mssql/advisor_column_maximum_varchar_length.goindex ca993704cf..6335d60aec 100644--- a/backend/plugin/advisor/mssql/advisor_column_maximum_varchar_length.go+++ b/backend/plugin/advisor/mssql/advisor_column_maximum_varchar_length.go@@ -30,7 +30,7 @@ type ColumnMaximumVarcharLengthAdvisor struct {}// Check checks for maximum varchar length..-func (*ColumnMaximumVarcharLengthAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnMaximumVarcharLengthAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -68,20 +68,20 @@ func (*ColumnMaximumVarcharLengthAdvisor) Check(ctx advisor.Context, _ string) (type columnMaximumVarcharLengthChecker struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcheckTypeString map[string]anymaximum int- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *columnMaximumVarcharLengthChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *columnMaximumVarcharLengthChecker) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -115,12 +115,14 @@ func (l *columnMaximumVarcharLengthChecker) EnterData_type(ctx *parser.Data_typeline = ctx.GetUnscaled_type().GetStart().GetLine()}if currentLength > l.maximum {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.VarcharLengthExceedsLimit,+ Code: advisor.VarcharLengthExceedsLimit.Int32(),Title: l.title,Content: fmt.Sprintf("The maximum varchar length is %d.", l.maximum),- Line: line,+ StartPosition: &storepb.Position{+ Line: int32(line),+ },})}}diff --git a/backend/plugin/advisor/mssql/advisor_column_no_null.go b/backend/plugin/advisor/mssql/advisor_column_no_null.goindex 6f1ccfcc0d..692abb4c38 100644--- a/backend/plugin/advisor/mssql/advisor_column_no_null.go+++ b/backend/plugin/advisor/mssql/advisor_column_no_null.go@@ -26,7 +26,7 @@ type ColumnNoNullAdvisor struct {}// Check checks for column no NULL value..-func (*ColumnNoNullAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnNoNullAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -43,7 +43,7 @@ func (*ColumnNoNullAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.AdvicurrentNormalizedTableName: "",isCurrentTableColumnNullable: make(map[string]bool),currentTableColumnIsNullableLine: make(map[string]int),- adviceList: make([]advisor.Advice, 0),+ adviceList: make([]*storepb.Advice, 0),}antlr.ParseTreeWalkerDefault.Walk(listener, tree)@@ -55,7 +55,7 @@ func (*ColumnNoNullAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advitype columnNoNullChecker struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle string// currentNormalizedTableName is the normalized table name of the current table.currentNormalizedTableName string@@ -64,15 +64,15 @@ type columnNoNullChecker struct {// currentTableColumnIsNullableLine is the map of column name to the line number of the column definition.currentTableColumnIsNullableLine map[string]int- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *columnNoNullChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *columnNoNullChecker) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -98,12 +98,14 @@ func (l *columnNoNullChecker) ExitCreate_table(_ *parser.Create_tableContext) {if !isNullable {continue}- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.ColumnCannotNull,+ Code: advisor.ColumnCannotNull.Int32(),Title: l.title,Content: fmt.Sprintf("Column [%s] is nullable, which is not allowed.", columnName),- Line: l.currentTableColumnIsNullableLine[columnName],+ StartPosition: &storepb.Position{+ Line: int32(l.currentTableColumnIsNullableLine[columnName]),+ },})}@@ -174,12 +176,14 @@ func (l *columnNoNullChecker) ExitAlter_table(_ *parser.Alter_tableContext) {if !isNullable {continue}- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.ColumnCannotNull,+ Code: advisor.ColumnCannotNull.Int32(),Title: l.title,Content: fmt.Sprintf("Column [%s] is nullable, which is not allowed.", columnName),- Line: l.currentTableColumnIsNullableLine[columnName],+ StartPosition: &storepb.Position{+ Line: int32(l.currentTableColumnIsNullableLine[columnName]),+ },})}diff --git a/backend/plugin/advisor/mssql/advisor_column_require.go b/backend/plugin/advisor/mssql/advisor_column_require.goindex 93f15bdd91..57cf065b37 100644--- a/backend/plugin/advisor/mssql/advisor_column_require.go+++ b/backend/plugin/advisor/mssql/advisor_column_require.go@@ -27,7 +27,7 @@ type ColumnRequireAdvisor struct {}// Check checks for column requirement..-func (*ColumnRequireAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnRequireAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -62,10 +62,10 @@ func (*ColumnRequireAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advtype columnRequireChecker struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.Advice// requireColumns is the required columns, the key is the normalized column name.requireColumns map[string]any@@ -79,11 +79,11 @@ type columnRequireChecker struct {}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *columnRequireChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *columnRequireChecker) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -121,12 +121,14 @@ func (l *columnRequireChecker) ExitCreate_table(ctx *parser.Create_tableContext)return columnNames[i] < columnNames[j]})for _, column := range columnNames {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NoRequiredColumn,+ Code: advisor.NoRequiredColumn.Int32(),Title: l.title,Content: fmt.Sprintf("Table %s missing required column %q", l.currentOriginalTableName, column),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}@@ -144,12 +146,14 @@ func (l *columnRequireChecker) EnterAlter_table(ctx *parser.Alter_tableContext)for _, columnName := range allColumnNames {_, normalizedColumnName := tsqlparser.NormalizeTSQLIdentifier(columnName)if _, ok := l.requireColumns[normalizedColumnName]; ok {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NoRequiredColumn,+ Code: advisor.NoRequiredColumn.Int32(),Title: l.title,Content: fmt.Sprintf("Table %s missing required column %q", tableName, normalizedColumnName),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mssql/advisor_column_type_disallow_list.go b/backend/plugin/advisor/mssql/advisor_column_type_disallow_list.goindex d109115839..260347e320 100644--- a/backend/plugin/advisor/mssql/advisor_column_type_disallow_list.go+++ b/backend/plugin/advisor/mssql/advisor_column_type_disallow_list.go@@ -25,7 +25,7 @@ func init() {type ColumnTypeDisallowListAdvisor struct {}-func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -51,9 +51,9 @@ func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]adantlr.ParseTreeWalkerDefault.Walk(checker, tree)if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,21 +65,23 @@ func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]adtype columnTypeDisallowListChecker struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.AdvicedisallowTypes []string}func (checker *columnTypeDisallowListChecker) EnterData_type(ctx *parser.Data_typeContext) {formatedDataType := strings.ToUpper(ctx.GetText())if slices.Contains(checker.disallowTypes, formatedDataType) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DisabledColumnType,+ Code: advisor.DisabledColumnType.Int32(),Title: checker.title,Content: "Column type " + formatedDataType + " is disallowed",- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mssql/advisor_function_disallow_create_or_alter.go b/backend/plugin/advisor/mssql/advisor_function_disallow_create_or_alter.goindex 0216ffd8bb..b33f596c53 100644--- a/backend/plugin/advisor/mssql/advisor_function_disallow_create_or_alter.go+++ b/backend/plugin/advisor/mssql/advisor_function_disallow_create_or_alter.go@@ -6,11 +6,11 @@ import ("github.com/pkg/errors""github.com/bytebase/bytebase/backend/plugin/advisor"- "github.com/bytebase/bytebase/proto/generated-go/store"+ storepb "github.com/bytebase/bytebase/proto/generated-go/store")func init() {- advisor.Register(store.Engine_MSSQL, advisor.MSSQLFunctionDisallowCreateOrAlter, &FunctionDisallowCreateOrAlterAdvisor{})+ advisor.Register(storepb.Engine_MSSQL, advisor.MSSQLFunctionDisallowCreateOrAlter, &FunctionDisallowCreateOrAlterAdvisor{})}type FunctionDisallowCreateOrAlterAdvisor struct{}@@ -18,13 +18,13 @@ type FunctionDisallowCreateOrAlterAdvisor struct{}type FunctionDisallowCreateOrAlterChecker struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// Check implements advisor.Advisor.-func (*FunctionDisallowCreateOrAlterAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*FunctionDisallowCreateOrAlterAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -43,9 +43,9 @@ func (*FunctionDisallowCreateOrAlterAdvisor) Check(ctx advisor.Context, _ stringantlr.ParseTreeWalkerDefault.Walk(checker, tree)if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -54,11 +54,13 @@ func (*FunctionDisallowCreateOrAlterAdvisor) Check(ctx advisor.Context, _ string}func (checker *FunctionDisallowCreateOrAlterChecker) EnterCreate_or_alter_function(ctx *parser.Create_or_alter_functionContext) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DisallowCreateFunction,+ Code: advisor.DisallowCreateFunction.Int32(),Title: checker.title,Content: "Creating or altering functions is prohibited",- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}diff --git a/backend/plugin/advisor/mssql/advisor_index_not_redundant.go b/backend/plugin/advisor/mssql/advisor_index_not_redundant.goindex cbcb68ed3b..137c044761 100644--- a/backend/plugin/advisor/mssql/advisor_index_not_redundant.go+++ b/backend/plugin/advisor/mssql/advisor_index_not_redundant.go@@ -10,11 +10,11 @@ import ("github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/parser/tsql"- "github.com/bytebase/bytebase/proto/generated-go/store"+ storepb "github.com/bytebase/bytebase/proto/generated-go/store")func init() {- advisor.Register(store.Engine_MSSQL, advisor.MSSQLIndexNotRedundant, IndexNotRedundantAdvisor{})+ advisor.Register(storepb.Engine_MSSQL, advisor.MSSQLIndexNotRedundant, IndexNotRedundantAdvisor{})}var dftMSSQLSchemaName = "dbo"@@ -27,15 +27,15 @@ type IndexNotRedundantAdvisor struct{}type IndexNotRedundantChecker struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcurDB stringindexMap *IndexMap- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// TODO(zp): we currently don't have runtime checks for indexes created in the statements.-func (IndexNotRedundantAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (IndexNotRedundantAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to AST tree")@@ -56,9 +56,9 @@ func (IndexNotRedundantAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.antlr.ParseTreeWalkerDefault.Walk(checker, tree)if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -102,11 +102,13 @@ func (checker *IndexNotRedundantChecker) EnterCreate_index(ctx *parser.Create_in// Get ordered column list from statement.statIdxColList := ctx.Column_name_list_with_order()if metaIdxName := containRedundantPrefix(metaIdxList, &statIdxColList); metaIdxName != "" {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,Title: checker.title,- Line: ctx.GetStart().GetLine(),- Code: advisor.RedundantIndex,+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },+ Code: advisor.RedundantIndex.Int32(),Content: fmt.Sprintf("Redundant indexes with the same prefix ('%s' and '%s') in '%s.%s' is not allowed",metaIdxName, statIdxName, findIdxKey.schemaName, findIdxKey.tblName),})@@ -119,10 +121,10 @@ type FindIndexesKey struct {}// The value in the map represents the column list of a certain index.-type IndexMap = map[FindIndexesKey][]*store.IndexMetadata+type IndexMap = map[FindIndexesKey][]*storepb.IndexMetadata// Return the name of the index if redundant prefixes are found.-func containRedundantPrefix(metaIdxList []*store.IndexMetadata, statColumnList *parser.IColumn_name_list_with_orderContext) string {+func containRedundantPrefix(metaIdxList []*storepb.IndexMetadata, statColumnList *parser.IColumn_name_list_with_orderContext) string {for _, metaIndex := range metaIdxList {if statColumnList != nil && len((*statColumnList).AllId_()) != 0 && len(metaIdxList) != 0 {statIdxCol, _ := tsql.NormalizeTSQLIdentifier((*statColumnList).AllId_()[0])@@ -134,7 +136,7 @@ func containRedundantPrefix(metaIdxList []*store.IndexMetadata, statColumnList *return ""}-func getIndexMapFromMetadata(dbMetadata *store.DatabaseSchemaMetadata) *IndexMap {+func getIndexMapFromMetadata(dbMetadata *storepb.DatabaseSchemaMetadata) *IndexMap {indexMap := IndexMap{}if dbMetadata == nil {return &indexMapdiff --git a/backend/plugin/advisor/mssql/advisor_migration_compatibility.go b/backend/plugin/advisor/mssql/advisor_migration_compatibility.goindex fd1d891d85..6eff287abb 100644--- a/backend/plugin/advisor/mssql/advisor_migration_compatibility.go+++ b/backend/plugin/advisor/mssql/advisor_migration_compatibility.go@@ -27,7 +27,7 @@ type MigrationCompatibilityAdvisor struct {}// Check checks for migration compatibility..-func (*MigrationCompatibilityAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*MigrationCompatibilityAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -56,7 +56,7 @@ func (*MigrationCompatibilityAdvisor) Check(ctx advisor.Context, _ string) ([]adtype migrationCompatibilityChecker struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle string// normalizedLastCreateTableNameMap contain the last created table name in normalized format.@@ -69,15 +69,15 @@ type migrationCompatibilityChecker struct {// currentDatabase is the current database name.currentDatabase string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *migrationCompatibilityChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *migrationCompatibilityChecker) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -119,12 +119,14 @@ func (l *migrationCompatibilityChecker) EnterDrop_table(ctx *parser.Drop_tableCo}normalizedTableName := tsqlparser.NormalizeTSQLTableName(tableName, l.currentDatabase, "dbo", false)if _, ok := l.normalizedNewCreateTableNameMap[normalizedTableName]; !ok {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.CompatibilityDropSchema,+ Code: advisor.CompatibilityDropSchema.Int32(),Title: l.title,Content: fmt.Sprintf("Drop table %s may cause incompatibility with the existing data and code", normalizedTableName),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}delete(l.normalizedNewCreateTableNameMap, normalizedTableName)@@ -136,12 +138,14 @@ func (l *migrationCompatibilityChecker) EnterDrop_schema(ctx *parser.Drop_schema_, normalizedSchemaName := tsqlparser.NormalizeTSQLIdentifier(schemaName)normalizedSchemaName = fmt.Sprintf("%s.%s", l.currentDatabase, normalizedSchemaName)if _, ok := l.normalizedNewCreateSchemaNameMap[normalizedSchemaName]; !ok {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.CompatibilityDropSchema,+ Code: advisor.CompatibilityDropSchema.Int32(),Title: l.title,Content: fmt.Sprintf("Drop schema %s may cause incompatibility with the existing data and code", normalizedSchemaName),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}delete(l.normalizedNewCreateSchemaNameMap, normalizedSchemaName)@@ -151,12 +155,14 @@ func (l *migrationCompatibilityChecker) EnterDrop_database(ctx *parser.Drop_datadatabaseName := ctx.GetDatabase_name_or_database_snapshot_name()_, normalizedDatabaseName := tsqlparser.NormalizeTSQLIdentifier(databaseName)if _, ok := l.normalizedNewCreateDatabaseNameMap[normalizedDatabaseName]; !ok {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.CompatibilityDropSchema,+ Code: advisor.CompatibilityDropSchema.Int32(),Title: l.title,Content: fmt.Sprintf("Drop database %s may cause incompatibility with the existing data and code", normalizedDatabaseName),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}delete(l.normalizedNewCreateDatabaseNameMap, normalizedDatabaseName)@@ -177,12 +183,14 @@ func (l *migrationCompatibilityChecker) EnterAlter_table(ctx *parser.Alter_tableallNormalizedDropColumnNames = append(allNormalizedDropColumnNames, normalizedDropColumnName)}placeholder := strings.Join(allNormalizedDropColumnNames, ", ")- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.CompatibilityDropSchema,+ Code: advisor.CompatibilityDropSchema.Int32(),Title: l.title,Content: fmt.Sprintf("Drop column %s may cause incompatibility with the existing data and code", placeholder),- Line: ctx.COLUMN().GetSymbol().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.COLUMN().GetSymbol().GetLine()),+ },})return}@@ -194,12 +202,14 @@ func (l *migrationCompatibilityChecker) EnterAlter_table(ctx *parser.Alter_table_, normalizedColumnName = tsqlparser.NormalizeTSQLIdentifier(ctx.Column_modifier().Id_())}- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.CompatibilityAlterColumn,+ Code: advisor.CompatibilityAlterColumn.Int32(),Title: l.title,Content: fmt.Sprintf("Alter COLUMN %s may cause incompatibility with the existing data and code", normalizedColumnName),- Line: ctx.COLUMN().GetSymbol().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.COLUMN().GetSymbol().GetLine()),+ },})return}@@ -224,34 +234,40 @@ func (l *migrationCompatibilityChecker) EnterAlter_table(ctx *parser.Alter_tablecode = advisor.CompatibilityAddCheckoperation = "Add CHECK"}- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: code,+ Code: code.Int32(),Title: l.title,Content: fmt.Sprintf("%s may cause incompatibility with the existing data and code", operation),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}return}if ctx.WITH() != nil && ctx.NOCHECK() != nil {if ctx.FOREIGN() != nil {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.CompatibilityAddForeignKey,+ Code: advisor.CompatibilityAddForeignKey.Int32(),Title: l.title,Content: "Add FOREIGN KEY WITH NO CHECK may cause incompatibility with the existing data and code",- Line: ctx.FOREIGN().GetSymbol().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.FOREIGN().GetSymbol().GetLine()),+ },})return}if len(ctx.AllCHECK()) == 1 {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.CompatibilityAddForeignKey,+ Code: advisor.CompatibilityAddForeignKey.Int32(),Title: l.title,Content: "Add CHECK WITH NO CHECK may cause incompatibility with the existing data and code",- Line: ctx.CHECK(0).GetSymbol().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.CHECK(0).GetSymbol().GetLine()),+ },})return}@@ -294,11 +310,13 @@ func (l *migrationCompatibilityChecker) EnterExecute_body(ctx *parser.Execute_boif firstArgument.Execute_parameter().Constant().STRING() == nil {return}- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.CompatibilityRenameTable,+ Code: advisor.CompatibilityRenameTable.Int32(),Title: l.title,Content: "sp_rename may cause incompatibility with the existing data and code, and break scripts and stored procedures.",- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}diff --git a/backend/plugin/advisor/mssql/advisor_naming_identifier_no_keyword.go b/backend/plugin/advisor/mssql/advisor_naming_identifier_no_keyword.goindex 3922272c05..8078a98078 100644--- a/backend/plugin/advisor/mssql/advisor_naming_identifier_no_keyword.go+++ b/backend/plugin/advisor/mssql/advisor_naming_identifier_no_keyword.go@@ -26,7 +26,7 @@ type NamingIdentifierNoKeywordAdvisor struct {}// Check checks for identifier naming convention without keyword..-func (*NamingIdentifierNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingIdentifierNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -51,18 +51,18 @@ func (*NamingIdentifierNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([type namingIdentifierNoKeywordChecker struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *namingIdentifierNoKeywordChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *namingIdentifierNoKeywordChecker) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -93,12 +93,14 @@ func (l *namingIdentifierNoKeywordChecker) EnterId_(ctx *parser.Id_Context) {_, normalizedID := tsqlparser.NormalizeTSQLIdentifier(ctx)if tsqlparser.IsTSQLReservedKeyword(normalizedID, false) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NameIsKeywordIdentifier,+ Code: advisor.NameIsKeywordIdentifier.Int32(),Title: l.title,Content: fmt.Sprintf("Identifier [%s] is a keyword identifier and should be avoided.", normalizedID),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mssql/advisor_naming_table.go b/backend/plugin/advisor/mssql/advisor_naming_table.goindex ea8a2af309..d1778beca9 100644--- a/backend/plugin/advisor/mssql/advisor_naming_table.go+++ b/backend/plugin/advisor/mssql/advisor_naming_table.go@@ -29,7 +29,7 @@ type NamingTableAdvisor struct {}// Check checks for table naming convention..-func (*NamingTableAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingTableAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -60,21 +60,21 @@ func (*NamingTableAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advictype namingTableListener struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringformat *regexp.Regexp// maxLength is the max length of the table name.maxLength int- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *namingTableListener) generateAdvice() ([]advisor.Advice, error) {+func (l *namingTableListener) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -87,21 +87,25 @@ func (l *namingTableListener) EnterCreate_table(ctx *parser.Create_tableContext)tableName := ctx.Table_name().GetTable().GetText()if !l.format.MatchString(tableName) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NamingTableConventionMismatch,+ Code: advisor.NamingTableConventionMismatch.Int32(),Title: l.title,Content: fmt.Sprintf(`%s mismatches table naming convention, naming format should be %q`, tableName, l.format),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}if l.maxLength > 0 && len(tableName) > l.maxLength {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NamingTableConventionMismatch,+ Code: advisor.NamingTableConventionMismatch.Int32(),Title: l.title,Content: fmt.Sprintf(`%s mismatches table naming convention, its length should be within %d characters`, tableName, l.maxLength),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}@@ -170,21 +174,25 @@ func (l *namingTableListener) EnterExecute_body(ctx *parser.Execute_bodyContext)}if !l.format.MatchString(newTableName) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NamingTableConventionMismatch,+ Code: advisor.NamingTableConventionMismatch.Int32(),Title: l.title,Content: fmt.Sprintf(`%s mismatches table naming convention, naming format should be %q`, newTableName, l.format),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}if l.maxLength > 0 && len(newTableName) > l.maxLength {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NamingTableConventionMismatch,+ Code: advisor.NamingTableConventionMismatch.Int32(),Title: l.title,Content: fmt.Sprintf(`%s mismatches table naming convention, its length should be within %d characters`, newTableName, l.maxLength),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mssql/advisor_naming_table_no_keyword.go b/backend/plugin/advisor/mssql/advisor_naming_table_no_keyword.goindex 700d606d8e..a8ca25f2af 100644--- a/backend/plugin/advisor/mssql/advisor_naming_table_no_keyword.go+++ b/backend/plugin/advisor/mssql/advisor_naming_table_no_keyword.go@@ -26,7 +26,7 @@ type NamingTableNoKeywordAdvisor struct {}// Check checks for table naming convention without keyword..-func (*NamingTableNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingTableNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -51,18 +51,18 @@ func (*NamingTableNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([]advitype namingTableNoKeywordChecker struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *namingTableNoKeywordChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *namingTableNoKeywordChecker) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -75,12 +75,14 @@ func (l *namingTableNoKeywordChecker) EnterCreate_table(ctx *parser.Create_tabletableName := ctx.Table_name().GetTable()_, normalizedTableName := tsqlparser.NormalizeTSQLIdentifier(tableName)if tsqlparser.IsTSQLReservedKeyword(normalizedTableName, false) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NameIsKeywordIdentifier,+ Code: advisor.NameIsKeywordIdentifier.Int32(),Title: l.title,Content: fmt.Sprintf("Table name [%s] is a reserved keyword and should be avoided.", normalizedTableName),- Line: tableName.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(tableName.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mssql/advisor_procedure_disallow_create_or_alter.go b/backend/plugin/advisor/mssql/advisor_procedure_disallow_create_or_alter.goindex 001aebc83b..58a38ef977 100644--- a/backend/plugin/advisor/mssql/advisor_procedure_disallow_create_or_alter.go+++ b/backend/plugin/advisor/mssql/advisor_procedure_disallow_create_or_alter.go@@ -6,11 +6,11 @@ import ("github.com/pkg/errors""github.com/bytebase/bytebase/backend/plugin/advisor"- "github.com/bytebase/bytebase/proto/generated-go/store"+ storepb "github.com/bytebase/bytebase/proto/generated-go/store")func init() {- advisor.Register(store.Engine_MSSQL, advisor.MSSQLProcedureDisallowCreateOrAlter, &FunctionDisallowCreateOrAlterAdvisor{})+ advisor.Register(storepb.Engine_MSSQL, advisor.MSSQLProcedureDisallowCreateOrAlter, &FunctionDisallowCreateOrAlterAdvisor{})}type ProcedureDisallowCreateOrAlterAdvisor struct{}@@ -18,12 +18,12 @@ type ProcedureDisallowCreateOrAlterAdvisor struct{}type ProcedureDisallowCreateOrAlterChecker struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}-func (*ProcedureDisallowCreateOrAlterAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ProcedureDisallowCreateOrAlterAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -42,9 +42,9 @@ func (*ProcedureDisallowCreateOrAlterAdvisor) Check(ctx advisor.Context, _ strinantlr.ParseTreeWalkerDefault.Walk(checker, tree)if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -53,11 +53,13 @@ func (*ProcedureDisallowCreateOrAlterAdvisor) Check(ctx advisor.Context, _ strin}func (checker *FunctionDisallowCreateOrAlterChecker) EnterCreate_or_alter_procedure(ctx *parser.Create_or_alter_procedureContext) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DisallowCreateFunction,+ Code: advisor.DisallowCreateFunction.Int32(),Title: checker.title,Content: "Creating or altering procedures is prohibited",- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}diff --git a/backend/plugin/advisor/mssql/advisor_select_no_select_all.go b/backend/plugin/advisor/mssql/advisor_select_no_select_all.goindex 059511c1eb..f2259032ce 100644--- a/backend/plugin/advisor/mssql/advisor_select_no_select_all.go+++ b/backend/plugin/advisor/mssql/advisor_select_no_select_all.go@@ -23,7 +23,7 @@ type SelectNoSelectAllAdvisor struct {}// Check checks for no select all.-func (*SelectNoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*SelectNoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -48,18 +48,18 @@ func (*SelectNoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]advisortype selectNoSelectAllChecker struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *selectNoSelectAllChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *selectNoSelectAllChecker) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -71,12 +71,14 @@ func (l *selectNoSelectAllChecker) generateAdvice() ([]advisor.Advice, error) {func (l *selectNoSelectAllChecker) EnterSelect_list_elem(ctx *parser.Select_list_elemContext) {if v := ctx.Asterisk(); v != nil {if v.STAR() != nil {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.StatementSelectAll,+ Code: advisor.StatementSelectAll.Int32(),Title: l.title,Content: "Avoid using SELECT *.",- Line: v.STAR().GetSymbol().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(v.STAR().GetSymbol().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mssql/advisor_statement_disallow_cross_db_queries.go b/backend/plugin/advisor/mssql/advisor_statement_disallow_cross_db_queries.goindex 0ceb79b80e..f307e51793 100644--- a/backend/plugin/advisor/mssql/advisor_statement_disallow_cross_db_queries.go+++ b/backend/plugin/advisor/mssql/advisor_statement_disallow_cross_db_queries.go@@ -10,11 +10,11 @@ import ("github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/parser/tsql"- "github.com/bytebase/bytebase/proto/generated-go/store"+ storepb "github.com/bytebase/bytebase/proto/generated-go/store")func init() {- advisor.Register(store.Engine_MSSQL, advisor.MSSQLStatementDisallowCrossDBQueries, &DisallowCrossDBQueriesAdvisor{})+ advisor.Register(storepb.Engine_MSSQL, advisor.MSSQLStatementDisallowCrossDBQueries, &DisallowCrossDBQueriesAdvisor{})}type DisallowCrossDBQueriesAdvisor struct{}@@ -22,12 +22,12 @@ type DisallowCrossDBQueriesAdvisor struct{}type DisallowCrossDBQueriesChecker struct {*parser.BaseTSqlParserListenercurDB string- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}-func (*DisallowCrossDBQueriesAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*DisallowCrossDBQueriesAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -47,9 +47,9 @@ func (*DisallowCrossDBQueriesAdvisor) Check(ctx advisor.Context, _ string) ([]adantlr.ParseTreeWalkerDefault.Walk(checker, tree)if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -62,12 +62,14 @@ func (checker *DisallowCrossDBQueriesChecker) EnterTable_source_item(ctx *parserif fullTblnameCtx := ctx.Full_table_name(); fullTblnameCtx != nil {// Case insensitive.if fullTblName, err := tsql.NormalizeFullTableName(fullTblnameCtx); err == nil && fullTblName.Database != "" && !strings.EqualFold(fullTblName.Database, checker.curDB) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementDisallowCrossDBQueries,+ Code: advisor.StatementDisallowCrossDBQueries.Int32(),Title: checker.title,Content: fmt.Sprintf("Cross database queries (target databse: '%s', current database: '%s') are prohibited", fullTblName.Database, checker.curDB),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}// Ignore internal error...diff --git a/backend/plugin/advisor/mssql/advisor_statement_where_disallow_functions_and_calculations.go b/backend/plugin/advisor/mssql/advisor_statement_where_disallow_functions_and_calculations.goindex d5be0ad3e3..4d289b9830 100644--- a/backend/plugin/advisor/mssql/advisor_statement_where_disallow_functions_and_calculations.go+++ b/backend/plugin/advisor/mssql/advisor_statement_where_disallow_functions_and_calculations.go@@ -8,18 +8,18 @@ import ("github.com/pkg/errors""github.com/bytebase/bytebase/backend/plugin/advisor"- "github.com/bytebase/bytebase/proto/generated-go/store"+ storepb "github.com/bytebase/bytebase/proto/generated-go/store")func init() {- advisor.Register(store.Engine_MSSQL, advisor.MSSQLStatementWhereDisallowFunctionsAndCalculations, &DisallowFuncAndCalculationsAdvisor{})+ advisor.Register(storepb.Engine_MSSQL, advisor.MSSQLStatementWhereDisallowFunctionsAndCalculations, &DisallowFuncAndCalculationsAdvisor{})}type DisallowFuncAndCalculationsAdvisor struct{}type DisallowFuncAndCalculationsChecker struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle string// We only check the 'WHERE' clause in a 'SELECT' statement.@@ -29,12 +29,12 @@ type DisallowFuncAndCalculationsChecker struct {havingCnt int// Each statement can only trigger the rule once.hasTriggeredRule bool- adviceList []advisor.Advice+ adviceList []*storepb.Advice}var _ advisor.Advisor = (*DisallowFuncAndCalculationsAdvisor)(nil)-func (*DisallowFuncAndCalculationsAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*DisallowFuncAndCalculationsAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to AST tree")@@ -57,9 +57,9 @@ func (*DisallowFuncAndCalculationsAdvisor) Check(ctx advisor.Context, _ string)antlr.ParseTreeWalkerDefault.Walk(checker, tree)if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -68,31 +68,35 @@ func (*DisallowFuncAndCalculationsAdvisor) Check(ctx advisor.Context, _ string)return checker.adviceList, nil}-func generateAdviceOnFunctionUsing(c *DisallowFuncAndCalculationsChecker, ctx antlr.BaseParserRuleContext) *advisor.Advice {+func generateAdviceOnFunctionUsing(c *DisallowFuncAndCalculationsChecker, ctx antlr.BaseParserRuleContext) *storepb.Advice {if c.whereCnt == 0 || c.hasTriggeredRule {return nil}c.hasTriggeredRule = true- return &advisor.Advice{+ return &storepb.Advice{Status: c.level,- Code: advisor.StatementDisallowFunctionsAndCalculations,+ Code: advisor.StatementDisallowFunctionsAndCalculations.Int32(),Title: c.title,Content: fmt.Sprintf("Calling function '%s' in 'WHERE' clause is not allowed", ctx.GetText()),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },}}-func generateAdviceOnPerformingCalculations(c *DisallowFuncAndCalculationsChecker, ctx antlr.BaseParserRuleContext) *advisor.Advice {+func generateAdviceOnPerformingCalculations(c *DisallowFuncAndCalculationsChecker, ctx antlr.BaseParserRuleContext) *storepb.Advice {if c.whereCnt == 0 || c.hasTriggeredRule {return nil}c.hasTriggeredRule = true- return &advisor.Advice{+ return &storepb.Advice{Status: c.level,- Code: advisor.StatementDisallowFunctionsAndCalculations,+ Code: advisor.StatementDisallowFunctionsAndCalculations.Int32(),Title: c.title,Content: "Performing calculations in 'WHERE' clause is not allowed",- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },}}@@ -126,49 +130,49 @@ func (c *DisallowFuncAndCalculationsChecker) ExitSearch_condition(_ *parser.Sear// Calling functions.func (c *DisallowFuncAndCalculationsChecker) EnterBUILT_IN_FUNC(ctx *parser.BUILT_IN_FUNCContext) {if advice := generateAdviceOnFunctionUsing(c, ctx.BaseParserRuleContext); advice != nil {- c.adviceList = append(c.adviceList, *advice)+ c.adviceList = append(c.adviceList, advice)}}func (c *DisallowFuncAndCalculationsChecker) EnterRANKING_WINDOWED_FUNC(ctx *parser.RANKING_WINDOWED_FUNCContext) {if advice := generateAdviceOnFunctionUsing(c, ctx.BaseParserRuleContext); advice != nil {- c.adviceList = append(c.adviceList, *advice)+ c.adviceList = append(c.adviceList, advice)}}func (c *DisallowFuncAndCalculationsChecker) EnterAGGREGATE_WINDOWED_FUNC(ctx *parser.AGGREGATE_WINDOWED_FUNCContext) {if advice := generateAdviceOnFunctionUsing(c, ctx.BaseParserRuleContext); advice != nil {- c.adviceList = append(c.adviceList, *advice)+ c.adviceList = append(c.adviceList, advice)}}func (c *DisallowFuncAndCalculationsChecker) EnterANALYTIC_WINDOWED_FUNC(ctx *parser.ANALYTIC_WINDOWED_FUNCContext) {if advice := generateAdviceOnFunctionUsing(c, ctx.BaseParserRuleContext); advice != nil {- c.adviceList = append(c.adviceList, *advice)+ c.adviceList = append(c.adviceList, advice)}}func (c *DisallowFuncAndCalculationsChecker) EnterSCALAR_FUNCTION(ctx *parser.SCALAR_FUNCTIONContext) {if advice := generateAdviceOnFunctionUsing(c, ctx.BaseParserRuleContext); advice != nil {- c.adviceList = append(c.adviceList, *advice)+ c.adviceList = append(c.adviceList, advice)}}func (c *DisallowFuncAndCalculationsChecker) EnterFREE_TEXT(ctx *parser.FREE_TEXTContext) {if advice := generateAdviceOnFunctionUsing(c, ctx.BaseParserRuleContext); advice != nil {- c.adviceList = append(c.adviceList, *advice)+ c.adviceList = append(c.adviceList, advice)}}func (c *DisallowFuncAndCalculationsChecker) EnterPARTITION_FUNC(ctx *parser.PARTITION_FUNCContext) {if advice := generateAdviceOnFunctionUsing(c, ctx.BaseParserRuleContext); advice != nil {- c.adviceList = append(c.adviceList, *advice)+ c.adviceList = append(c.adviceList, advice)}}func (c *DisallowFuncAndCalculationsChecker) EnterHIERARCHYID_METHOD(ctx *parser.HIERARCHYID_METHODContext) {if advice := generateAdviceOnFunctionUsing(c, ctx.BaseParserRuleContext); advice != nil {- c.adviceList = append(c.adviceList, *advice)+ c.adviceList = append(c.adviceList, advice)}}@@ -176,13 +180,13 @@ func (c *DisallowFuncAndCalculationsChecker) EnterHIERARCHYID_METHOD(ctx *parserfunc (c *DisallowFuncAndCalculationsChecker) EnterExpression(ctx *parser.ExpressionContext) {if ctx.GetOp() != nil {if advice := generateAdviceOnPerformingCalculations(c, ctx.BaseParserRuleContext); advice != nil {- c.adviceList = append(c.adviceList, *advice)+ c.adviceList = append(c.adviceList, advice)}}}func (c *DisallowFuncAndCalculationsChecker) EnterUnary_operator_expression(ctx *parser.Unary_operator_expressionContext) {if advice := generateAdviceOnPerformingCalculations(c, ctx.BaseParserRuleContext); advice != nil {- c.adviceList = append(c.adviceList, *advice)+ c.adviceList = append(c.adviceList, advice)}}diff --git a/backend/plugin/advisor/mssql/advisor_table_disallow_ddl.go b/backend/plugin/advisor/mssql/advisor_table_disallow_ddl.goindex 99fa176202..8b67691ec5 100644--- a/backend/plugin/advisor/mssql/advisor_table_disallow_ddl.go+++ b/backend/plugin/advisor/mssql/advisor_table_disallow_ddl.go@@ -25,7 +25,7 @@ func init() {type TableDisallowDDLAdvisor struct {}-func (*TableDisallowDDLAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableDisallowDDLAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -48,9 +48,9 @@ func (*TableDisallowDDLAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.antlr.ParseTreeWalkerDefault.Walk(checker, tree)if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -61,9 +61,9 @@ func (*TableDisallowDDLAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.type tableDisallowDDLChecker struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.Advice// disallowList is the list of table names that disallow DDL.disallowList []string}@@ -108,12 +108,14 @@ func (checker *tableDisallowDDLChecker) EnterTruncate_table(ctx *parser.Truncatefunc (checker *tableDisallowDDLChecker) checkTableName(normalizedTableName string, line int) {for _, disallow := range checker.disallowList {if normalizedTableName == disallow {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.TableDisallowDDL,+ Code: advisor.TableDisallowDDL.Int32(),Title: checker.title,Content: fmt.Sprintf("DDL is disallowed on table %s.", normalizedTableName),- Line: line,+ StartPosition: &storepb.Position{+ Line: int32(line),+ },})return}diff --git a/backend/plugin/advisor/mssql/advisor_table_disallow_dml.go b/backend/plugin/advisor/mssql/advisor_table_disallow_dml.goindex 1cd01136fa..82d051d9f6 100644--- a/backend/plugin/advisor/mssql/advisor_table_disallow_dml.go+++ b/backend/plugin/advisor/mssql/advisor_table_disallow_dml.go@@ -25,7 +25,7 @@ func init() {type TableDisallowDMLAdvisor struct {}-func (*TableDisallowDMLAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableDisallowDMLAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -48,9 +48,9 @@ func (*TableDisallowDMLAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.antlr.ParseTreeWalkerDefault.Walk(checker, tree)if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -61,9 +61,9 @@ func (*TableDisallowDMLAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.type tableDisallowDMLChecker struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.Advice// disallowList is the list of table names that disallow DML.disallowList []string}@@ -115,12 +115,14 @@ func (checker *tableDisallowDMLChecker) EnterSelect_statement_standalone(ctx *pafunc (checker *tableDisallowDMLChecker) checkTableName(normalizedTableName string, line int) {for _, disallow := range checker.disallowList {if normalizedTableName == disallow {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.TableDisallowDML,+ Code: advisor.TableDisallowDML.Int32(),Title: checker.title,Content: fmt.Sprintf("DML is disallowed on table %s.", normalizedTableName),- Line: line,+ StartPosition: &storepb.Position{+ Line: int32(line),+ },})return}diff --git a/backend/plugin/advisor/mssql/advisor_table_drop_naming_convention.go b/backend/plugin/advisor/mssql/advisor_table_drop_naming_convention.goindex 5d86ac5e00..179203b6c3 100644--- a/backend/plugin/advisor/mssql/advisor_table_drop_naming_convention.go+++ b/backend/plugin/advisor/mssql/advisor_table_drop_naming_convention.go@@ -27,7 +27,7 @@ type TableDropNamingConventionAdvisor struct {}// Check checks for table drop with naming convention..-func (*TableDropNamingConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableDropNamingConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -57,19 +57,19 @@ func (*TableDropNamingConventionAdvisor) Check(ctx advisor.Context, _ string) ([type tableDropNamingConventionChecker struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringformat *regexp.Regexp- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *tableDropNamingConventionChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *tableDropNamingConventionChecker) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -87,12 +87,14 @@ func (l *tableDropNamingConventionChecker) EnterDrop_table(ctx *parser.Drop_tabl}_, normalizedTableName := tsqlparser.NormalizeTSQLIdentifier(table)if !l.format.MatchString(normalizedTableName) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.TableDropNamingConventionMismatch,+ Code: advisor.TableDropNamingConventionMismatch.Int32(),Title: l.title,Content: fmt.Sprintf("[%s] mismatches drop table naming convention, naming format should be %q", normalizedTableName, l.format),- Line: table.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(table.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mssql/advisor_table_no_foreign_key.go b/backend/plugin/advisor/mssql/advisor_table_no_foreign_key.goindex c07af2a1bc..6c93ec8af8 100644--- a/backend/plugin/advisor/mssql/advisor_table_no_foreign_key.go+++ b/backend/plugin/advisor/mssql/advisor_table_no_foreign_key.go@@ -26,7 +26,7 @@ type TableNoForeignKeyAdvisor struct {}// Check checks for table disallow foreign key..-func (*TableNoForeignKeyAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableNoForeignKeyAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -55,7 +55,7 @@ func (*TableNoForeignKeyAdvisor) Check(ctx advisor.Context, _ string) ([]advisortype tableNoForeignKeyChecker struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle string// currentNormalizedTableName is the normalized table name of the current table.@@ -69,27 +69,29 @@ type tableNoForeignKeyChecker struct {// tableLine is the line number of the current table.tableLine map[string]int- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *tableNoForeignKeyChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *tableNoForeignKeyChecker) generateAdvice() ([]*storepb.Advice, error) {for tableName, hasForeignKey := range l.tableHasForeignKey {if hasForeignKey {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.TableHasFK,+ Code: advisor.TableHasFK.Int32(),Title: l.title,Content: fmt.Sprintf("FOREIGN KEY is not allowed in the table %s.", l.tableOriginalName[tableName]),- Line: l.tableLine[tableName],+ StartPosition: &storepb.Position{+ Line: int32(l.tableLine[tableName]),+ },})}}if len(l.adviceList) == 0 {- return []advisor.Advice{+ return []*storepb.Advice{{- Status: advisor.Success,- Code: advisor.Ok,+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",},diff --git a/backend/plugin/advisor/mssql/advisor_table_require_pk.go b/backend/plugin/advisor/mssql/advisor_table_require_pk.goindex e5cef36a1a..b45f0ab971 100644--- a/backend/plugin/advisor/mssql/advisor_table_require_pk.go+++ b/backend/plugin/advisor/mssql/advisor_table_require_pk.go@@ -26,7 +26,7 @@ type TableRequirePkAdvisor struct {}// Check checks for table require primary key..-func (*TableRequirePkAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableRequirePkAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -56,7 +56,7 @@ func (*TableRequirePkAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Adtype tableRequirePkChecker struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcurrentNormalizedTableName string@@ -69,26 +69,28 @@ type tableRequirePkChecker struct {// tableLine is a map from normalized table name to the line number of the table.tableLine map[string]int- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *tableRequirePkChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *tableRequirePkChecker) generateAdvice() ([]*storepb.Advice, error) {for tableName, hasPK := range l.tableHasPrimaryKey {if !hasPK {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.TableNoPK,+ Code: advisor.TableNoPK.Int32(),Title: l.title,Content: fmt.Sprintf("Table %s requires PRIMARY KEY.", l.tableOriginalName[tableName]),- Line: l.tableLine[tableName],+ StartPosition: &storepb.Position{+ Line: int32(l.tableLine[tableName]),+ },})}}if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/mssql/advisor_where_require.go b/backend/plugin/advisor/mssql/advisor_where_require.goindex 3e0051d842..543933d176 100644--- a/backend/plugin/advisor/mssql/advisor_where_require.go+++ b/backend/plugin/advisor/mssql/advisor_where_require.go@@ -23,7 +23,7 @@ type WhereRequireAdvisor struct {}// Check checks for WHERE clause requirement..-func (*WhereRequireAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*WhereRequireAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -48,18 +48,18 @@ func (*WhereRequireAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advitype whereRequireChecker struct {*parser.BaseTSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *whereRequireChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *whereRequireChecker) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -70,12 +70,14 @@ func (l *whereRequireChecker) generateAdvice() ([]advisor.Advice, error) {// EnterDelete_statement is called when production delete_statement is entered.func (l *whereRequireChecker) EnterDelete_statement(ctx *parser.Delete_statementContext) {if ctx.WHERE() == nil {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.StatementNoWhere,+ Code: advisor.StatementNoWhere.Int32(),Title: l.title,Content: "WHERE clause is required for DELETE statement.",- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}@@ -83,12 +85,14 @@ func (l *whereRequireChecker) EnterDelete_statement(ctx *parser.Delete_statement// EnterUpdate_statement is called when production update_statement is entered.func (l *whereRequireChecker) EnterUpdate_statement(ctx *parser.Update_statementContext) {if ctx.WHERE() == nil {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.StatementNoWhere,+ Code: advisor.StatementNoWhere.Int32(),Title: l.title,Content: "WHERE clause is required for UPDATE statement.",- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}@@ -97,12 +101,14 @@ func (l *whereRequireChecker) EnterUpdate_statement(ctx *parser.Update_statementfunc (l *whereRequireChecker) EnterQuery_specification(ctx *parser.Query_specificationContext) {// Allow SELECT queries without a FROM clause to proceed, e.g. SELECT 1.if ctx.WHERE() == nil && ctx.From_table_sources() != nil {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.StatementNoWhere,+ Code: advisor.StatementNoWhere.Int32(),Title: l.title,Content: "WHERE clause is required for query specification.",- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mssql/test/column_maximum_varchar_length.yaml b/backend/plugin/advisor/mssql/test/column_maximum_varchar_length.yamlindex b5c0105a06..6070c5af5e 100644--- a/backend/plugin/advisor/mssql/test/column_maximum_varchar_length.yaml+++ b/backend/plugin/advisor/mssql/test/column_maximum_varchar_length.yaml@@ -1,36 +1,38 @@- statement: CREATE TABLE MyTable(a VARCHAR(20));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE MyTable ADD b VARCHAR(3000);want:- - status: WARN+ - status: 2code: 422title: column.maximum-varchar-lengthcontent: The maximum varchar length is 2560.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE MyTable ALTER COLUMN a VARCHAR(MAX);want:- - status: WARN+ - status: 2code: 422title: column.maximum-varchar-lengthcontent: The maximum varchar length is 2560.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE MyTable ALTER COLUMN a NVARCHAR(MAX);want:- - status: WARN+ - status: 2code: 422title: column.maximum-varchar-lengthcontent: The maximum varchar length is 2560.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mssql/test/column_no_null.yaml b/backend/plugin/advisor/mssql/test/column_no_null.yamlindex 4c4e1d69f9..627578182b 100644--- a/backend/plugin/advisor/mssql/test/column_no_null.yaml+++ b/backend/plugin/advisor/mssql/test/column_no_null.yaml@@ -6,20 +6,22 @@Address VARCHAR(200));want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column [age] is nullable, which is not allowed.- line: 4- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 4+ column: 0+ - status: 2code: 402title: column.no-nullcontent: Column [address] is nullable, which is not allowed.- line: 5- column: 0- details: ""+ detail: ""+ startposition:+ line: 5+ column: 0- statement: |-CREATE TABLE MyTable (Id INT,@@ -29,55 +31,57 @@PRIMARY KEY (Id, Age));want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column [address] is nullable, which is not allowed.- line: 5- column: 0- details: ""+ detail: ""+ startposition:+ line: 5+ column: 0- statement: ALTER TABLE MyTable ALTER COLUMN Name VARCHAR(100) NULL;want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column [name] is nullable, which is not allowed.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE MyTable ALTER COLUMN Name VARCHAR(100) NOT NULL;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE MyTable ADD Age INT;want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column [age] is nullable, which is not allowed.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE MyTable ADD Age INT NULL;want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column [age] is nullable, which is not allowed.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE MyTable ADD Age INT NOT NULL;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mssql/test/column_required.yaml b/backend/plugin/advisor/mssql/test/column_required.yamlindex 75bddb74d9..a3a8c6741f 100644--- a/backend/plugin/advisor/mssql/test/column_required.yaml+++ b/backend/plugin/advisor/mssql/test/column_required.yaml@@ -7,54 +7,58 @@updater_id INT);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t (name TEXT,age INT);want:- - status: WARN+ - status: 2code: 401title: column.requiredcontent: Table t missing required column "created_ts"- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 401title: column.requiredcontent: Table t missing required column "creator_id"- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 401title: column.requiredcontent: Table t missing required column "id"- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 401title: column.requiredcontent: Table t missing required column "updated_ts"- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 401title: column.requiredcontent: Table t missing required column "updater_id"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t (id INT,@@ -63,28 +67,31 @@updater_id INT);want:- - status: WARN+ - status: 2code: 401title: column.requiredcontent: Table t missing required column "updated_ts"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE t DROP COLUMN created_ts;want:- - status: WARN+ - status: 2code: 401title: column.requiredcontent: Table t missing required column "created_ts"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE t DROP COLUMN creator_id;want:- - status: WARN+ - status: 2code: 401title: column.requiredcontent: Table t missing required column "creator_id"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mssql/test/column_type_disallow_list.yaml b/backend/plugin/advisor/mssql/test/column_type_disallow_list.yamlindex 56984fbb70..b9a82e286c 100644--- a/backend/plugin/advisor/mssql/test/column_type_disallow_list.yaml+++ b/backend/plugin/advisor/mssql/test/column_type_disallow_list.yaml@@ -5,10 +5,11 @@payload JSON);want:- - status: WARN+ - status: 2code: 411title: column.type-disallow-listcontent: Column type JSON is disallowed- line: 4- column: 0- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0diff --git a/backend/plugin/advisor/mssql/test/index_not_redundant.yaml b/backend/plugin/advisor/mssql/test/index_not_redundant.yamlindex 799e730c1a..777011de15 100644--- a/backend/plugin/advisor/mssql/test/index_not_redundant.yaml+++ b/backend/plugin/advisor/mssql/test/index_not_redundant.yaml@@ -1,27 +1,28 @@- statement: CREATE INDEX test_index ON dbo.pokes (c1, c2);want:- - status: WARN+ - status: 2code: 817title: index.not-redundantcontent: Redundant indexes with the same prefix ('idx_0' and 'test_index') in 'dbo.pokes' is not allowed- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE INDEX test_index ON dbo.pokes (c100, c200);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE INDEX test_index ON [dbo].[pokes] (c1, c2);want:- - status: WARN+ - status: 2code: 817title: index.not-redundantcontent: Redundant indexes with the same prefix ('idx_0' and 'test_index') in 'dbo.pokes' is not allowed- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mssql/test/naming_identifier_no_keyword.yaml b/backend/plugin/advisor/mssql/test/naming_identifier_no_keyword.yamlindex 3fc258aed3..6d5e00cff0 100644--- a/backend/plugin/advisor/mssql/test/naming_identifier_no_keyword.yaml+++ b/backend/plugin/advisor/mssql/test/naming_identifier_no_keyword.yaml@@ -2,31 +2,35 @@CREATE TABLE [Fillfactor](Id INT, [Exec] INT);CREATE INDEX [Add] ON [Fillfactor]([Exec]);want:- - status: WARN+ - status: 2code: 308title: naming.identifier.no-keywordcontent: Identifier [exec] is a keyword identifier and should be avoided.- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 308title: naming.identifier.no-keywordcontent: Identifier [fillfactor] is a keyword identifier and should be avoided.- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 308title: naming.identifier.no-keywordcontent: Identifier [add] is a keyword identifier and should be avoided.- line: 2- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 308title: naming.identifier.no-keywordcontent: Identifier [fillfactor] is a keyword identifier and should be avoided.- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mssql/test/naming_table.yaml b/backend/plugin/advisor/mssql/test/naming_table.yamlindex 87cd490130..2926e0b57d 100644--- a/backend/plugin/advisor/mssql/test/naming_table.yaml+++ b/backend/plugin/advisor/mssql/test/naming_table.yaml@@ -1,54 +1,54 @@- statement: CREATE TABLE ALL_UPPERCASE(ID INT);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE [\\](ID INT);want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '[\\] mismatches table naming convention, naming format should be "^[A-Z]([_A-Za-z])*$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE all_lowercase(ID INT);want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: all_lowercase mismatches table naming convention, naming format should be "^[A-Z]([_A-Za-z])*$"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE PascalCase(ID INT);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: execute sp_rename 'Sales.SalesTerritory', 'SALESTERR';want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: execute sp_rename 'Sales.SalesTerritory', 'salesTerr';want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: salesTerr mismatches table naming convention, naming format should be "^[A-Z]([_A-Za-z])*$"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mssql/test/naming_table_no_keyword.yaml b/backend/plugin/advisor/mssql/test/naming_table_no_keyword.yamlindex d1c0da8242..f9ac2a2a83 100644--- a/backend/plugin/advisor/mssql/test/naming_table_no_keyword.yaml+++ b/backend/plugin/advisor/mssql/test/naming_table_no_keyword.yaml@@ -1,27 +1,28 @@- statement: CREATE TABLE [fillfactor] (id INT);want:- - status: WARN+ - status: 2code: 308title: naming.table.no-keywordcontent: Table name [fillfactor] is a reserved keyword and should be avoided.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE MyDB.MySchema.[fillfactor] (id INT);want:- - status: WARN+ - status: 2code: 308title: naming.table.no-keywordcontent: Table name [fillfactor] is a reserved keyword and should be avoided.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE Person(id INT);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mssql/test/schema_backward_compatibility.yaml b/backend/plugin/advisor/mssql/test/schema_backward_compatibility.yamlindex 75da2ca6c6..5135d13725 100644--- a/backend/plugin/advisor/mssql/test/schema_backward_compatibility.yaml+++ b/backend/plugin/advisor/mssql/test/schema_backward_compatibility.yaml@@ -1,72 +1,73 @@- statement: EXEC sp_rename N'Phone', N'Telephone', N'USERDATATYPE';want:- - status: WARN+ - status: 2code: 102title: schema.backward-compatibilitycontent: sp_rename may cause incompatibility with the existing data and code, and break scripts and stored procedures.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: DROP TABLE MyTable;want:- - status: WARN+ - status: 2code: 112title: schema.backward-compatibilitycontent: Drop table master.dbo.MyTable may cause incompatibility with the existing data and code- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE MyTable(Id INT PRIMARY KEY);DROP TABLE MyTable;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: DROP SCHEMA MySchema;want:- - status: WARN+ - status: 2code: 112title: schema.backward-compatibilitycontent: Drop schema master.myschema may cause incompatibility with the existing data and code- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE SCHEMA AUTHORIZATION dbo;DROP SCHEMA dbo;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: DROP DATABASE MyDB;want:- - status: WARN+ - status: 2code: 112title: schema.backward-compatibilitycontent: Drop database mydb may cause incompatibility with the existing data and code- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE DATABASE MyDB;DROP DATABASE MyDB;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-ALTER TABLE MyTable DROP COLUMN MyColumnOne, MyColumnTwo;ALTER TABLE MyTable ALTER COLUMN MyColumnOne INT NOT NULL;@@ -78,70 +79,79 @@ALTER TABLE MyTable WITH NOCHECK ADD FOREIGN KEY (MyColumnOne) REFERENCES MyTableTwo(MyColumnTwo);ALTER TABLE MyTable WITH CHECK ADD FOREIGN KEY (MyColumnOne) REFERENCES MyTableTwo(MyColumnTwo);want:- - status: WARN+ - status: 2code: 112title: schema.backward-compatibilitycontent: Drop column mycolumnone, mycolumntwo may cause incompatibility with the existing data and code- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 111title: schema.backward-compatibilitycontent: Alter COLUMN mycolumnone may cause incompatibility with the existing data and code- line: 2- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 106title: schema.backward-compatibilitycontent: Add PRIMARY KEY may cause incompatibility with the existing data and code- line: 3- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 107title: schema.backward-compatibilitycontent: Add UNIQUE KEY may cause incompatibility with the existing data and code- line: 4- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 4+ column: 0+ - status: 2code: 109title: schema.backward-compatibilitycontent: Add CHECK may cause incompatibility with the existing data and code- line: 5- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 5+ column: 0+ - status: 2code: 108title: schema.backward-compatibilitycontent: Add CHECK WITH NO CHECK may cause incompatibility with the existing data and code- line: 6- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 6+ column: 0+ - status: 2code: 108title: schema.backward-compatibilitycontent: Add FOREIGN KEY WITH NO CHECK may cause incompatibility with the existing data and code- line: 8- column: 0- details: ""+ detail: ""+ startposition:+ line: 8+ column: 0- statement: EXEC sp_rename 'Sales.SalesTerritory', 'SalesTerr';want:- - status: WARN+ - status: 2code: 102title: schema.backward-compatibilitycontent: sp_rename may cause incompatibility with the existing data and code, and break scripts and stored procedures.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: EXEC sp_rename 'dbo.ErrorLog.ErrorTime', 'ErrorDateTime', 'COLUMN';want:- - status: WARN+ - status: 2code: 102title: schema.backward-compatibilitycontent: sp_rename may cause incompatibility with the existing data and code, and break scripts and stored procedures.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mssql/test/statement_disallow_cross_db_queries.yaml b/backend/plugin/advisor/mssql/test/statement_disallow_cross_db_queries.yamlindex 0e38ff0a32..b293128cf7 100644--- a/backend/plugin/advisor/mssql/test/statement_disallow_cross_db_queries.yaml+++ b/backend/plugin/advisor/mssql/test/statement_disallow_cross_db_queries.yaml@@ -1,32 +1,33 @@- statement: SELECT * FROM MASTER.dbo.pokes;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-WITH foo1 AS (SELECT * FROM master2.dbo.tech_book)SELECT * FROM master.dbo.pokes;CREATE TABLE pokes (foo int);want:- - status: WARN+ - status: 2code: 233title: statement.disallow-cross-db-queriescontent: 'Cross database queries (target databse: ''master2'', current database: ''master'') are prohibited'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-USE master2;SELECT * FROM master.dbo.pokes;want:- - status: WARN+ - status: 2code: 233title: statement.disallow-cross-db-queriescontent: 'Cross database queries (target databse: ''master'', current database: ''master2'') are prohibited'- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mssql/test/statement_select_no_select_all.yaml b/backend/plugin/advisor/mssql/test/statement_select_no_select_all.yamlindex 31d8e275aa..da283d21ee 100644--- a/backend/plugin/advisor/mssql/test/statement_select_no_select_all.yaml+++ b/backend/plugin/advisor/mssql/test/statement_select_no_select_all.yaml@@ -1,36 +1,38 @@- statement: SELECT * FROM twant:- - status: WARN+ - status: 2code: 203title: statement.select.no-select-allcontent: Avoid using SELECT *.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT a, b FROM twant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: SELECT a, b FROM (SELECT * from t1, t2) twant:- - status: WARN+ - status: 2code: 203title: statement.select.no-select-allcontent: Avoid using SELECT *.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: INSERT INTO t SELECT * FROM t1want:- - status: WARN+ - status: 2code: 203title: statement.select.no-select-allcontent: Avoid using SELECT *.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mssql/test/statement_where_disallow_functions_and_calculations.yaml b/backend/plugin/advisor/mssql/test/statement_where_disallow_functions_and_calculations.yamlindex b193722be9..5b7ed45615 100644--- a/backend/plugin/advisor/mssql/test/statement_where_disallow_functions_and_calculations.yaml+++ b/backend/plugin/advisor/mssql/test/statement_where_disallow_functions_and_calculations.yaml@@ -4,66 +4,69 @@INSERT INTO pokes VALUES(1);SELECT foo FROM pokes WHERE ~foo > 0;want:- - status: WARN+ - status: 2code: 234title: statement.where.disallow-functions-and-calculationscontent: Performing calculations in 'WHERE' clause is not allowed- line: 2- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 234title: statement.where.disallow-functions-and-calculationscontent: Performing calculations in 'WHERE' clause is not allowed- line: 4- column: 0- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0- statement: |-SELECT foo FROM pokes WHERE foo | -foo > 0;SELECT bar FROM pokes WHERE bar > AVG(bar);want:- - status: WARN+ - status: 2code: 234title: statement.where.disallow-functions-and-calculationscontent: Performing calculations in 'WHERE' clause is not allowed- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 234title: statement.where.disallow-functions-and-calculationscontent: Calling function 'AVG(bar)' in 'WHERE' clause is not allowed- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: SELECT bar FROM pokes WHERE bar > 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-SELECT Department, AVG(Salary) AS AvgSalaryFROM EmployeesGROUP BY DepartmentHAVING AVG(Salary) * 3 + 1 > 50000;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: select * from (select * from t where t.a > 1) t1 where a > AVG(a);want:- - status: WARN+ - status: 2code: 234title: statement.where.disallow-functions-and-calculationscontent: Calling function 'AVG(a)' in 'WHERE' clause is not allowed- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mssql/test/statement_where_require.yaml b/backend/plugin/advisor/mssql/test/statement_where_require.yamlindex 297cd8670a..5cea807206 100644--- a/backend/plugin/advisor/mssql/test/statement_where_require.yaml+++ b/backend/plugin/advisor/mssql/test/statement_where_require.yaml@@ -1,82 +1,83 @@- statement: SELECT * FROM MyTable;want:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: WHERE clause is required for query specification.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT * FROM MyTable WHERE a = 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: UPDATE MyTable SET a = 1;want:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: WHERE clause is required for UPDATE statement.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: UPDATE MyTable SET a = 1 WHERE a = 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: DELETE FROM MyTable;want:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: WHERE clause is required for DELETE statement.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: DELETE FROM MyTable WHERE a = 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-WITH CteA AS (SELECT * FROM TableA WHERE a = 1),CteB AS (SELECT * FROM TableB)SELECT * FROM CteA INNER JOIN CteB ON CteA.a = CteB.b;want:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: WHERE clause is required for query specification.- line: 2- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 202title: statement.where.requirecontent: WHERE clause is required for query specification.- line: 3- column: 0- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: SELECT 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mssql/test/system_function_disallow_create.yaml b/backend/plugin/advisor/mssql/test/system_function_disallow_create.yamlindex feab254edc..f132aece0b 100644--- a/backend/plugin/advisor/mssql/test/system_function_disallow_create.yaml+++ b/backend/plugin/advisor/mssql/test/system_function_disallow_create.yaml@@ -14,10 +14,11 @@RETURN @ret;END;want:- - status: WARN+ - status: 2code: 1701title: system.function.disallow-createcontent: Creating or altering functions is prohibited- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mssql/test/system_procedure_disallow_create.yaml b/backend/plugin/advisor/mssql/test/system_procedure_disallow_create.yamlindex e2f5f29bfa..b325c85610 100644--- a/backend/plugin/advisor/mssql/test/system_procedure_disallow_create.yaml+++ b/backend/plugin/advisor/mssql/test/system_procedure_disallow_create.yaml@@ -18,10 +18,11 @@ENDGOwant:- - status: WARN+ - status: 2code: 1701title: system.procedure.disallow-createcontent: Creating or altering procedures is prohibited- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mssql/test/table_disallow_ddl.yaml b/backend/plugin/advisor/mssql/test/table_disallow_ddl.yamlindex 3f51f936be..9e9957fe99 100644--- a/backend/plugin/advisor/mssql/test/table_disallow_ddl.yaml+++ b/backend/plugin/advisor/mssql/test/table_disallow_ddl.yaml@@ -8,10 +8,11 @@Name VARCHAR(50) NOT NULL);want:- - status: WARN+ - status: 2code: 613title: table.disallow-ddlcontent: DDL is disallowed on table MySchema.Identifier.- line: 5- column: 0- details: ""+ detail: ""+ startposition:+ line: 5+ column: 0diff --git a/backend/plugin/advisor/mssql/test/table_disallow_dml.yaml b/backend/plugin/advisor/mssql/test/table_disallow_dml.yamlindex 72ecb91d1a..ba81cde93c 100644--- a/backend/plugin/advisor/mssql/test/table_disallow_dml.yaml+++ b/backend/plugin/advisor/mssql/test/table_disallow_dml.yaml@@ -3,48 +3,53 @@WHEN MATCHED THEN UPDATE SET Identifier.Name = MyTable.NameWHEN NOT MATCHED THEN INSERT (Id, Name) VALUES (MyTable.Id, MyTable.Name);want:- - status: WARN+ - status: 2code: 614title: table.disallow-dmlcontent: DML is disallowed on table MySchema.Identifier.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-INSERT INTO MySchema.MyTable (Id, Name) VALUES (1, 'Alice');INSERT INTO MySchema.Identifier (Id, Name) VALUES (1, 'Alice');want:- - status: WARN+ - status: 2code: 614title: table.disallow-dmlcontent: DML is disallowed on table MySchema.Identifier.- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: DELETE FROM MySchema.Identifier WHERE Id = 1;want:- - status: WARN+ - status: 2code: 614title: table.disallow-dmlcontent: DML is disallowed on table MySchema.Identifier.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: UPDATE MySchema.Identifier SET Name = 'Bob' WHERE Id = 1;want:- - status: WARN+ - status: 2code: 614title: table.disallow-dmlcontent: DML is disallowed on table MySchema.Identifier.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT * INTO MySchema.Identifier FROM MySchema.MyTable;want:- - status: WARN+ - status: 2code: 614title: table.disallow-dmlcontent: DML is disallowed on table MySchema.Identifier.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mssql/test/table_drop_naming_convention.yaml b/backend/plugin/advisor/mssql/test/table_drop_naming_convention.yamlindex 5c3c2f67a0..a310421168 100644--- a/backend/plugin/advisor/mssql/test/table_drop_naming_convention.yaml+++ b/backend/plugin/advisor/mssql/test/table_drop_naming_convention.yaml@@ -1,27 +1,28 @@- statement: DROP TABLE IF EXISTS [Foo_delete];want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: DROP TABLE Foo;want:- - status: WARN+ - status: 2code: 603title: table.drop-naming-conventioncontent: '[foo] mismatches drop table naming convention, naming format should be "_delete$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: DROP TABLE [Foo], [Bar_delete];want:- - status: WARN+ - status: 2code: 603title: table.drop-naming-conventioncontent: '[foo] mismatches drop table naming convention, naming format should be "_delete$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mssql/test/table_no_foreign_key.yaml b/backend/plugin/advisor/mssql/test/table_no_foreign_key.yamlindex e6e7922ffb..43cfab64dc 100644--- a/backend/plugin/advisor/mssql/test/table_no_foreign_key.yaml+++ b/backend/plugin/advisor/mssql/test/table_no_foreign_key.yaml@@ -6,13 +6,14 @@POSITION VARCHAR(100));want:- - status: WARN+ - status: 2code: 602title: table.no-foreign-keycontent: FOREIGN KEY is not allowed in the table MyTable.- line: 3- column: 0- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-CREATE TABLE Customer(@@ -22,13 +23,14 @@FOREIGN KEY (Id) REFERENCES PERSON(Id));want:- - status: WARN+ - status: 2code: 602title: table.no-foreign-keycontent: FOREIGN KEY is not allowed in the table Customer.- line: 6- column: 0- details: ""+ detail: ""+ startposition:+ line: 6+ column: 0- statement: |-CREATE TABLE Customer(@@ -38,13 +40,14 @@);ALTER TABLE Customer ADD FOREIGN KEY (Id) REFERENCES Person(Id);want:- - status: WARN+ - status: 2code: 602title: table.no-foreign-keycontent: FOREIGN KEY is not allowed in the table Customer.- line: 7- column: 0- details: ""+ detail: ""+ startposition:+ line: 7+ column: 0- statement: |-CREATE TABLE Customer(@@ -59,10 +62,9 @@Position VARCHAR(100));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mssql/test/table_require_pk.yaml b/backend/plugin/advisor/mssql/test/table_require_pk.yamlindex 6f6abc2aea..ec3092c4a4 100644--- a/backend/plugin/advisor/mssql/test/table_require_pk.yaml+++ b/backend/plugin/advisor/mssql/test/table_require_pk.yaml@@ -4,26 +4,26 @@Name VARCHAR(50) NOT NULL);want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table MySchema.MyTable requires PRIMARY KEY.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE MySchema.MyTable (Id INT NOT NULL PRIMARY KEY,Name VARCHAR(50) NOT NULL);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE MySchema.MyTable (Id INT NOT NULL,@@ -31,19 +31,17 @@PRIMARY KEY (Id));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE MySchema.MyTable ADD CONSTRAINT PK_MyTable PRIMARY KEY (Id);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/advisor_charset_allowlist.go b/backend/plugin/advisor/mysql/advisor_charset_allowlist.goindex 9b3ace25d6..f329561f08 100644--- a/backend/plugin/advisor/mysql/advisor_charset_allowlist.go+++ b/backend/plugin/advisor/mysql/advisor_charset_allowlist.go@@ -28,7 +28,7 @@ type CharsetAllowlistAdvisor struct {}// Check checks for charset allowlist.-func (*CharsetAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*CharsetAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -56,9 +56,9 @@ func (*CharsetAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -70,8 +70,8 @@ type charsetAllowlistChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringallowList map[string]bool@@ -98,12 +98,14 @@ func (checker *charsetAllowlistChecker) EnterCreateDatabase(ctx *mysql.CreateDatfunc (checker *charsetAllowlistChecker) checkCharset(charset string, lineNumber int) {if _, exists := checker.allowList[charset]; charset != "" && !exists {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DisabledCharset,+ Code: advisor.DisabledCharset.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" used disabled charset '%s'", checker.text, charset),- Line: checker.baseLine + lineNumber,+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + lineNumber),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_collation_allowlist.go b/backend/plugin/advisor/mysql/advisor_collation_allowlist.goindex 691d9d1b38..e200bf81a7 100644--- a/backend/plugin/advisor/mysql/advisor_collation_allowlist.go+++ b/backend/plugin/advisor/mysql/advisor_collation_allowlist.go@@ -28,7 +28,7 @@ type CollationAllowlistAdvisor struct {}// Check checks for collation allowlist.-func (*CollationAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*CollationAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -57,9 +57,9 @@ func (*CollationAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -71,8 +71,8 @@ type collationAllowlistChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringallowList map[string]bool@@ -98,12 +98,14 @@ func (checker *collationAllowlistChecker) EnterCreateDatabase(ctx *mysql.CreateDfunc (checker *collationAllowlistChecker) checkCollation(collation string, lineNumber int) {collation = strings.ToLower(collation)if _, exists := checker.allowList[collation]; collation != "" && !exists {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DisabledCollation,+ Code: advisor.DisabledCollation.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" used disabled collation '%s'", checker.text, collation),- Line: checker.baseLine + lineNumber,+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + lineNumber),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_colum_require_default.go b/backend/plugin/advisor/mysql/advisor_colum_require_default.goindex 26bd4be4fa..c5e50e1308 100644--- a/backend/plugin/advisor/mysql/advisor_colum_require_default.go+++ b/backend/plugin/advisor/mysql/advisor_colum_require_default.go@@ -27,7 +27,7 @@ type ColumnRequireDefaultAdvisor struct {}// Check checks for column default requirement.-func (*ColumnRequireDefaultAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnRequireDefaultAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -48,9 +48,9 @@ func (*ColumnRequireDefaultAdvisor) Check(ctx advisor.Context, _ string) ([]advi}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -62,8 +62,8 @@ type columnRequireDefaultChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle string}@@ -151,12 +151,14 @@ func (checker *columnRequireDefaultChecker) EnterAlterTable(ctx *mysql.AlterTablfunc (checker *columnRequireDefaultChecker) checkFieldDefinition(tableName, columnName string, ctx mysql.IFieldDefinitionContext) {if !checker.hasDefault(ctx) && checker.needDefault(ctx) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NoDefault,+ Code: advisor.NoDefault.Int32(),Title: checker.title,Content: fmt.Sprintf("Column `%s`.`%s` doesn't have DEFAULT.", tableName, columnName),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_column_auto_increment_initial_value.go b/backend/plugin/advisor/mysql/advisor_column_auto_increment_initial_value.goindex 339eb3b455..f86ac916ae 100644--- a/backend/plugin/advisor/mysql/advisor_column_auto_increment_initial_value.go+++ b/backend/plugin/advisor/mysql/advisor_column_auto_increment_initial_value.go@@ -31,7 +31,7 @@ type ColumnAutoIncrementInitialValueAdvisor struct {}// Check checks for auto-increment column initial value.-func (*ColumnAutoIncrementInitialValueAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnAutoIncrementInitialValueAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -57,9 +57,9 @@ func (*ColumnAutoIncrementInitialValueAdvisor) Check(ctx advisor.Context, _ stri}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -71,8 +71,8 @@ type columnAutoIncrementInitialValueChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringvalue int}@@ -98,12 +98,14 @@ func (checker *columnAutoIncrementInitialValueChecker) EnterCreateTable(ctx *myscontinue}if value != uint64(checker.value) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.AutoIncrementColumnInitialValueNotMatch,+ Code: advisor.AutoIncrementColumnInitialValueNotMatch.Int32(),Title: checker.title,Content: fmt.Sprintf("The initial auto-increment value in table `%s` is %v, which doesn't equal %v", tableName, value, checker.value),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}@@ -145,12 +147,14 @@ func (checker *columnAutoIncrementInitialValueChecker) EnterAlterTable(ctx *mysqcontinue}if value != uint64(checker.value) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.AutoIncrementColumnInitialValueNotMatch,+ Code: advisor.AutoIncrementColumnInitialValueNotMatch.Int32(),Title: checker.title,Content: fmt.Sprintf("The initial auto-increment value in table `%s` is %v, which doesn't equal %v", tableName, value, checker.value),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_column_auto_increment_must_integer.go b/backend/plugin/advisor/mysql/advisor_column_auto_increment_must_integer.goindex cd3fb5c028..a944950967 100644--- a/backend/plugin/advisor/mysql/advisor_column_auto_increment_must_integer.go+++ b/backend/plugin/advisor/mysql/advisor_column_auto_increment_must_integer.go@@ -30,7 +30,7 @@ type ColumnAutoIncrementMustIntegerAdvisor struct {}// Check checks for auto-increment column type.-func (*ColumnAutoIncrementMustIntegerAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnAutoIncrementMustIntegerAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -51,9 +51,9 @@ func (*ColumnAutoIncrementMustIntegerAdvisor) Check(ctx advisor.Context, _ strin}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,8 +65,8 @@ type columnAutoIncrementMustIntegerChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle string}@@ -150,12 +150,14 @@ func (checker *columnAutoIncrementMustIntegerChecker) EnterAlterTable(ctx *mysqlfunc (checker *columnAutoIncrementMustIntegerChecker) checkFieldDefinition(tableName, columnName string, ctx mysql.IFieldDefinitionContext) {if !checker.isAutoIncrementColumnIsInteger(ctx) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.AutoIncrementColumnNotInteger,+ Code: advisor.AutoIncrementColumnNotInteger.Int32(),Title: checker.title,Content: fmt.Sprintf("Auto-increment column `%s`.`%s` requires integer type", tableName, columnName),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_column_auto_increment_must_unsigned.go b/backend/plugin/advisor/mysql/advisor_column_auto_increment_must_unsigned.goindex 42a7d7d6f9..d1358ae732 100644--- a/backend/plugin/advisor/mysql/advisor_column_auto_increment_must_unsigned.go+++ b/backend/plugin/advisor/mysql/advisor_column_auto_increment_must_unsigned.go@@ -30,7 +30,7 @@ type ColumnAutoIncrementMustUnsignedAdvisor struct {}// Check checks for unsigned auto-increment column.-func (*ColumnAutoIncrementMustUnsignedAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnAutoIncrementMustUnsignedAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -51,9 +51,9 @@ func (*ColumnAutoIncrementMustUnsignedAdvisor) Check(ctx advisor.Context, _ stri}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,8 +65,8 @@ type columnAutoIncrementMustUnsignedChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle string}@@ -152,12 +152,14 @@ func (checker *columnAutoIncrementMustUnsignedChecker) EnterAlterTable(ctx *mysqfunc (checker *columnAutoIncrementMustUnsignedChecker) checkFieldDefinition(tableName, columnName string, ctx mysql.IFieldDefinitionContext) {if !checker.isAutoIncrementColumnIsInteger(ctx) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.AutoIncrementColumnSigned,+ Code: advisor.AutoIncrementColumnSigned.Int32(),Title: checker.title,Content: fmt.Sprintf("Auto-increment column `%s`.`%s` is not UNSIGNED type", tableName, columnName),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_column_comment_convention.go b/backend/plugin/advisor/mysql/advisor_column_comment_convention.goindex 16748c2e96..575909a2c8 100644--- a/backend/plugin/advisor/mysql/advisor_column_comment_convention.go+++ b/backend/plugin/advisor/mysql/advisor_column_comment_convention.go@@ -30,7 +30,7 @@ type ColumnCommentConventionAdvisor struct {}// Check checks for column comment convention.-func (*ColumnCommentConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnCommentConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -57,9 +57,9 @@ func (*ColumnCommentConventionAdvisor) Check(ctx advisor.Context, _ string) ([]a}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -71,8 +71,8 @@ type columnCommentConventionChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringrequired boolmaxLength int@@ -170,23 +170,27 @@ func (checker *columnCommentConventionChecker) checkFieldDefinition(tableName, c}comment = mysqlparser.NormalizeMySQLTextLiteral(attribute.TextLiteral())if checker.maxLength >= 0 && len(comment) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.ColumnCommentTooLong,+ Code: advisor.ColumnCommentTooLong.Int32(),Title: checker.title,Content: fmt.Sprintf("The length of column `%s`.`%s` comment should be within %d characters", tableName, columnName, checker.maxLength),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}if len(comment) == 0 {if checker.required {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NoColumnComment,+ Code: advisor.NoColumnComment.Int32(),Title: checker.title,Content: fmt.Sprintf("Column `%s`.`%s` requires comments", tableName, columnName),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_column_current_time_count_limit.go b/backend/plugin/advisor/mysql/advisor_column_current_time_count_limit.goindex dbf5b0ec08..608eecc3f2 100644--- a/backend/plugin/advisor/mysql/advisor_column_current_time_count_limit.go+++ b/backend/plugin/advisor/mysql/advisor_column_current_time_count_limit.go@@ -36,7 +36,7 @@ type ColumnCurrentTimeCountLimitAdvisor struct {}// Check checks for current time column count limit.-func (*ColumnCurrentTimeCountLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnCurrentTimeCountLimitAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -64,8 +64,8 @@ type columnCurrentTimeCountLimitChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtableSet map[string]tableData}@@ -206,7 +206,7 @@ func (*columnCurrentTimeCountLimitChecker) isOnUpdateCurrentTime(ctx mysql.IFielreturn false}-func (checker *columnCurrentTimeCountLimitChecker) generateAdvice() []advisor.Advice {+func (checker *columnCurrentTimeCountLimitChecker) generateAdvice() []*storepb.Advice {var tableList []tableDatafor _, table := range checker.tableSet {tableList = append(tableList, table)@@ -216,28 +216,32 @@ func (checker *columnCurrentTimeCountLimitChecker) generateAdvice() []advisor.Ad})for _, table := range tableList {if table.defaultCurrentTimeCount > maxDefaultCurrentTimeColumCount {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DefaultCurrentTimeColumnCountExceedsLimit,+ Code: advisor.DefaultCurrentTimeColumnCountExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("Table `%s` has %d DEFAULT CURRENT_TIMESTAMP() columns. The count greater than %d.", table.tableName, table.defaultCurrentTimeCount, maxDefaultCurrentTimeColumCount),- Line: table.line,+ StartPosition: &storepb.Position{+ Line: int32(table.line),+ },})}if table.onUpdateCurrentTimeCount > maxOnUpdateCurrentTimeColumnCount {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.OnUpdateCurrentTimeColumnCountExceedsLimit,+ Code: advisor.OnUpdateCurrentTimeColumnCountExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("Table `%s` has %d ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than %d.", table.tableName, table.onUpdateCurrentTimeCount, maxOnUpdateCurrentTimeColumnCount),- Line: table.line,+ StartPosition: &storepb.Position{+ Line: int32(table.line),+ },})}}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/mysql/advisor_column_disallow_changing.go b/backend/plugin/advisor/mysql/advisor_column_disallow_changing.goindex 99ee9d586b..ab791f303f 100644--- a/backend/plugin/advisor/mysql/advisor_column_disallow_changing.go+++ b/backend/plugin/advisor/mysql/advisor_column_disallow_changing.go@@ -30,7 +30,7 @@ type ColumnDisallowChangingAdvisor struct {}// Check checks for disallow CHANGE COLUMN statement.-func (*ColumnDisallowChangingAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnDisallowChangingAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -51,9 +51,9 @@ func (*ColumnDisallowChangingAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,8 +65,8 @@ type columnDisallowChangingChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext string}@@ -96,12 +96,14 @@ func (checker *columnDisallowChangingChecker) EnterAlterTable(ctx *mysql.AlterTa// change columnif item.CHANGE_SYMBOL() != nil && item.ColumnInternalRef() != nil && item.Identifier() != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.UseChangeColumnStatement,+ Code: advisor.UseChangeColumnStatement.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" contains CHANGE COLUMN statement", checker.text),- Line: checker.baseLine + item.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_column_disallow_changing_order.go b/backend/plugin/advisor/mysql/advisor_column_disallow_changing_order.goindex e1a4e29801..9e7c88408e 100644--- a/backend/plugin/advisor/mysql/advisor_column_disallow_changing_order.go+++ b/backend/plugin/advisor/mysql/advisor_column_disallow_changing_order.go@@ -30,7 +30,7 @@ type ColumnDisallowChangingOrderAdvisor struct {}// Check checks for disallow changing column order.-func (*ColumnDisallowChangingOrderAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnDisallowChangingOrderAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -51,9 +51,9 @@ func (*ColumnDisallowChangingOrderAdvisor) Check(ctx advisor.Context, _ string)}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,8 +65,8 @@ type columnDisallowChangingOrderChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext string}@@ -106,12 +106,14 @@ func (checker *columnDisallowChangingOrderChecker) EnterAlterTable(ctx *mysql.Al}if item.Place() != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.ChangeColumnOrder,+ Code: advisor.ChangeColumnOrder.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" changes column order", checker.text),- Line: checker.baseLine + item.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_column_disallow_changing_type.go b/backend/plugin/advisor/mysql/advisor_column_disallow_changing_type.goindex 90935ad237..526f3309c4 100644--- a/backend/plugin/advisor/mysql/advisor_column_disallow_changing_type.go+++ b/backend/plugin/advisor/mysql/advisor_column_disallow_changing_type.go@@ -32,7 +32,7 @@ type ColumnDisallowChangingTypeAdvisor struct {}// Check checks for disallow changing column type..-func (*ColumnDisallowChangingTypeAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnDisallowChangingTypeAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -54,9 +54,9 @@ func (*ColumnDisallowChangingTypeAdvisor) Check(ctx advisor.Context, _ string) (}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -68,8 +68,8 @@ type columnDisallowChangingTypeChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringcatalog *catalog.Finder@@ -156,12 +156,14 @@ func (checker *columnDisallowChangingTypeChecker) changeColumnType(tableName, co}if normalizeColumnType(column.Type()) != normalizeColumnType(tp) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.ChangeColumnType,+ Code: advisor.ChangeColumnType.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" changes column type", checker.text),- Line: checker.baseLine + dataType.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + dataType.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_column_disallow_drop.go b/backend/plugin/advisor/mysql/advisor_column_disallow_drop.goindex 34a773d231..c7cd0c9c33 100644--- a/backend/plugin/advisor/mysql/advisor_column_disallow_drop.go+++ b/backend/plugin/advisor/mysql/advisor_column_disallow_drop.go@@ -28,7 +28,7 @@ type ColumnDisallowDropAdvisor struct {}// Check checks for disallow DROP COLUMN statement.-func (*ColumnDisallowDropAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnDisallowDropAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -50,9 +50,9 @@ func (*ColumnDisallowDropAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,8 +65,8 @@ type columnDisallowDropChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle string}@@ -91,12 +91,14 @@ func (checker *columnDisallowDropChecker) EnterAlterTable(ctx *mysql.AlterTableC}columnName := mysqlparser.NormalizeMySQLColumnInternalRef(item.ColumnInternalRef())- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DropColumn,+ Code: advisor.DropColumn.Int32(),Title: checker.title,Content: fmt.Sprintf("drops column \"%s\" of table \"%s\"", columnName, tableName),- Line: checker.baseLine + item.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + item.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_column_disallow_drop_in_index.go b/backend/plugin/advisor/mysql/advisor_column_disallow_drop_in_index.goindex ab1a369d48..e4ee8d4efa 100644--- a/backend/plugin/advisor/mysql/advisor_column_disallow_drop_in_index.go+++ b/backend/plugin/advisor/mysql/advisor_column_disallow_drop_in_index.go@@ -31,7 +31,7 @@ type ColumnDisallowDropInIndexAdvisor struct {}// Check checks for disallow Drop COLUMN in index statement.-func (*ColumnDisallowDropInIndexAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnDisallowDropInIndexAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -55,9 +55,9 @@ func (*ColumnDisallowDropInIndexAdvisor) Check(ctx advisor.Context, _ string) ([}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -70,8 +70,8 @@ type columnDisallowDropInIndexChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtables tableState // the variable mean whether the column in index.catalog *catalog.Finder@@ -155,12 +155,14 @@ func (checker *columnDisallowDropInIndexChecker) EnterAlterTable(ctx *mysql.AltecolumnName := mysqlparser.NormalizeMySQLColumnInternalRef(item.ColumnInternalRef())if !checker.canDrop(tableName, columnName) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DropIndexColumn,+ Code: advisor.DropIndexColumn.Int32(),Title: checker.title,Content: fmt.Sprintf("`%s`.`%s` cannot drop index column", tableName, columnName),- Line: checker.baseLine + item.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + item.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_column_disallow_set_charset.go b/backend/plugin/advisor/mysql/advisor_column_disallow_set_charset.goindex 6aa20496c9..97dbed726a 100644--- a/backend/plugin/advisor/mysql/advisor_column_disallow_set_charset.go+++ b/backend/plugin/advisor/mysql/advisor_column_disallow_set_charset.go@@ -30,7 +30,7 @@ type ColumnDisallowSetCharsetAdvisor struct {}// Check checks for disallow set column charset.-func (*ColumnDisallowSetCharsetAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnDisallowSetCharsetAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -51,9 +51,9 @@ func (*ColumnDisallowSetCharsetAdvisor) Check(ctx advisor.Context, _ string) ([]}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,8 +65,8 @@ type columnDisallowSetCharsetChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext string}@@ -95,12 +95,14 @@ func (checker *columnDisallowSetCharsetChecker) EnterCreateTable(ctx *mysql.Crea}charset := checker.getCharSet(tableElement.ColumnDefinition().FieldDefinition().DataType())if !checker.checkCharset(charset) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.SetColumnCharset,+ Code: advisor.SetColumnCharset.Int32(),Title: checker.title,Content: fmt.Sprintf("Disallow set column charset but \"%s\" does", checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}@@ -172,12 +174,14 @@ func (checker *columnDisallowSetCharsetChecker) EnterAlterTable(ctx *mysql.Alterfor _, charsetName := range charsetList {if !checker.checkCharset(charsetName) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.SetColumnCharset,+ Code: advisor.SetColumnCharset.Int32(),Title: checker.title,Content: fmt.Sprintf("Disallow set column charset but \"%s\" does", checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_column_maximum_character_length.go b/backend/plugin/advisor/mysql/advisor_column_maximum_character_length.goindex 011e8efb77..532ccc9380 100644--- a/backend/plugin/advisor/mysql/advisor_column_maximum_character_length.go+++ b/backend/plugin/advisor/mysql/advisor_column_maximum_character_length.go@@ -29,7 +29,7 @@ type ColumnMaximumCharacterLengthAdvisor struct {}// Check checks for maximum character length.-func (*ColumnMaximumCharacterLengthAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnMaximumCharacterLengthAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -55,9 +55,9 @@ func (*ColumnMaximumCharacterLengthAdvisor) Check(ctx advisor.Context, _ string)}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -68,8 +68,8 @@ func (*ColumnMaximumCharacterLengthAdvisor) Check(ctx advisor.Context, _ string)type columnMaximumCharacterLengthChecker struct {*mysql.BaseMySQLParserListener- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringbaseLine intmaximum int@@ -100,12 +100,14 @@ func (checker *columnMaximumCharacterLengthChecker) EnterCreateTable(ctx *mysql._, _, columnName := mysqlparser.NormalizeMySQLColumnName(tableElement.ColumnDefinition().ColumnName())charLength := checker.getCharLength(tableElement.ColumnDefinition().FieldDefinition().DataType())if checker.maximum > 0 && charLength > checker.maximum {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.CharLengthExceedsLimit,+ Code: advisor.CharLengthExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("The length of the CHAR column `%s.%s` is bigger than %d, please use VARCHAR instead", tableName, columnName, checker.maximum),- Line: checker.baseLine + tableElement.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + tableElement.GetStart().GetLine()),+ },})}}@@ -186,12 +188,14 @@ func (checker *columnMaximumCharacterLengthChecker) EnterAlterTable(ctx *mysql.A}for _, columnName := range columnList {if charLength, ok := charLengthMap[columnName]; ok && checker.maximum > 0 && charLength > checker.maximum {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.CharLengthExceedsLimit,+ Code: advisor.CharLengthExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("The length of the CHAR column `%s.%s` is bigger than %d, please use VARCHAR instead", tableName, columnName, checker.maximum),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_column_maximum_varchar_length.go b/backend/plugin/advisor/mysql/advisor_column_maximum_varchar_length.goindex 80201eab34..044e644fc3 100644--- a/backend/plugin/advisor/mysql/advisor_column_maximum_varchar_length.go+++ b/backend/plugin/advisor/mysql/advisor_column_maximum_varchar_length.go@@ -29,7 +29,7 @@ type ColumnMaximumVarcharLengthAdvisor struct {}// Check checks for maximum varchar length.-func (*ColumnMaximumVarcharLengthAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnMaximumVarcharLengthAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -55,9 +55,9 @@ func (*ColumnMaximumVarcharLengthAdvisor) Check(ctx advisor.Context, _ string) (}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -68,8 +68,8 @@ func (*ColumnMaximumVarcharLengthAdvisor) Check(ctx advisor.Context, _ string) (type columnMaximumVarcharLengthChecker struct {*mysql.BaseMySQLParserListener- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringbaseLine intmaximum int@@ -100,12 +100,14 @@ func (checker *columnMaximumVarcharLengthChecker) EnterCreateTable(ctx *mysql.Cr_, _, columnName := mysqlparser.NormalizeMySQLColumnName(tableElement.ColumnDefinition().ColumnName())length := getVarcharLength(tableElement.ColumnDefinition().FieldDefinition().DataType())if checker.maximum > 0 && length > checker.maximum {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.VarcharLengthExceedsLimit,+ Code: advisor.VarcharLengthExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("The length of the VARCHAR column `%s.%s` is bigger than %d", tableName, columnName, checker.maximum),- Line: checker.baseLine + tableElement.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + tableElement.GetStart().GetLine()),+ },})}}@@ -185,12 +187,14 @@ func (checker *columnMaximumVarcharLengthChecker) EnterAlterTable(ctx *mysql.Alt}for _, columnName := range columnList {if length, ok := varcharLengthMap[columnName]; ok && checker.maximum > 0 && length > checker.maximum {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.VarcharLengthExceedsLimit,+ Code: advisor.VarcharLengthExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("The length of the VARCHAR column `%s.%s` is bigger than %d", tableName, columnName, checker.maximum),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_column_no_null.go b/backend/plugin/advisor/mysql/advisor_column_no_null.goindex d5f18306b9..81f1d97486 100644--- a/backend/plugin/advisor/mysql/advisor_column_no_null.go+++ b/backend/plugin/advisor/mysql/advisor_column_no_null.go@@ -29,7 +29,7 @@ type ColumnNoNullAdvisor struct {}// Check checks for column no NULL value.-func (*ColumnNoNullAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnNoNullAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -68,14 +68,14 @@ type columnNoNullChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringcolumnSet map[string]columnNamecatalog *catalog.Finder}-func (checker *columnNoNullChecker) generateAdvice() []advisor.Advice {+func (checker *columnNoNullChecker) generateAdvice() []*storepb.Advice {var columnList []columnNamefor _, column := range checker.columnSet {columnList = append(columnList, column)@@ -93,20 +93,22 @@ func (checker *columnNoNullChecker) generateAdvice() []advisor.Advice {ColumnName: column.columnName,})if col != nil && col.Nullable() {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.ColumnCannotNull,+ Code: advisor.ColumnCannotNull.Int32(),Title: checker.title,Content: fmt.Sprintf("`%s`.`%s` cannot have NULL value", column.tableName, column.columnName),- Line: column.line,+ StartPosition: &storepb.Position{+ Line: int32(column.line),+ },})}}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/mysql/advisor_column_required.go b/backend/plugin/advisor/mysql/advisor_column_required.goindex 30fd5410f2..64b9e6212a 100644--- a/backend/plugin/advisor/mysql/advisor_column_required.go+++ b/backend/plugin/advisor/mysql/advisor_column_required.go@@ -29,7 +29,7 @@ type ColumnRequirementAdvisor struct {}// Check checks for the column requirement.-func (*ColumnRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {list, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -69,8 +69,8 @@ type columnRequirementChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringrequiredColumns columnSettables tableState@@ -162,7 +162,7 @@ func (checker *columnRequirementChecker) EnterAlterTable(ctx *mysql.AlterTableCo}}-func (checker *columnRequirementChecker) generateAdviceList() []advisor.Advice {+func (checker *columnRequirementChecker) generateAdviceList() []*storepb.Advice {// Order it cause the random iteration order in Go, see https://go.dev/blog/mapstableList := checker.tables.tableList()for _, tableName := range tableList {@@ -177,20 +177,22 @@ func (checker *columnRequirementChecker) generateAdviceList() []advisor.Advice {if len(missingColumns) > 0 {// Order it cause the random iteration order in Go, see https://go.dev/blog/mapssort.Strings(missingColumns)- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NoRequiredColumn,+ Code: advisor.NoRequiredColumn.Int32(),Title: checker.title,Content: fmt.Sprintf("Table `%s` requires columns: %s", tableName, strings.Join(missingColumns, ", ")),- Line: checker.line[tableName],+ StartPosition: &storepb.Position{+ Line: int32(checker.line[tableName]),+ },})}}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/mysql/advisor_column_set_default_for_not_null.go b/backend/plugin/advisor/mysql/advisor_column_set_default_for_not_null.goindex 1271d732d4..8880199413 100644--- a/backend/plugin/advisor/mysql/advisor_column_set_default_for_not_null.go+++ b/backend/plugin/advisor/mysql/advisor_column_set_default_for_not_null.go@@ -30,7 +30,7 @@ type ColumnSetDefaultForNotNullAdvisor struct {}// Check checks for set default value for not null column.-func (*ColumnSetDefaultForNotNullAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnSetDefaultForNotNullAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -51,9 +51,9 @@ func (*ColumnSetDefaultForNotNullAdvisor) Check(ctx advisor.Context, _ string) (}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,8 +65,8 @@ type columnSetDefaultForNotNullChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle string}@@ -125,12 +125,14 @@ func (checker *columnSetDefaultForNotNullChecker) EnterCreateTable(ctx *mysql.Crcontinue}if !checker.canNull(filed) && !checker.hasDefault(filed) && checker.needDefault(filed) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NotNullColumnWithNoDefault,+ Code: advisor.NotNullColumnWithNoDefault.Int32(),Title: checker.title,Content: fmt.Sprintf("Column `%s`.`%s` is NOT NULL but doesn't have DEFAULT", tableName, columnName),- Line: checker.baseLine + tableElement.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + tableElement.GetStart().GetLine()),+ },})}}@@ -138,12 +140,14 @@ func (checker *columnSetDefaultForNotNullChecker) EnterCreateTable(ctx *mysql.Crfunc (checker *columnSetDefaultForNotNullChecker) checkFieldDefinition(tableName, columnName string, ctx mysql.IFieldDefinitionContext) {if !checker.canNull(ctx) && checker.needDefault(ctx) && !checker.hasDefault(ctx) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NotNullColumnWithNoDefault,+ Code: advisor.NotNullColumnWithNoDefault.Int32(),Title: checker.title,Content: fmt.Sprintf("Column `%s`.`%s` is NOT NULL but doesn't have DEFAULT", tableName, columnName),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_column_type_disallow_list.go b/backend/plugin/advisor/mysql/advisor_column_type_disallow_list.goindex 20428268ec..784fee7815 100644--- a/backend/plugin/advisor/mysql/advisor_column_type_disallow_list.go+++ b/backend/plugin/advisor/mysql/advisor_column_type_disallow_list.go@@ -31,7 +31,7 @@ type ColumnTypeDisallowListAdvisor struct {}// Check checks for column type restriction.-func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -60,9 +60,9 @@ func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -74,8 +74,8 @@ type columnTypeDisallowListChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtypeRestriction map[string]bool}@@ -115,12 +115,14 @@ func (checker *columnTypeDisallowListChecker) checkFieldDefinition(tableName, cocolumnType := mysqlparser.NormalizeMySQLDataType(ctx.DataType(), true /* compact */)columnType = strings.ToUpper(columnType)if _, exists := checker.typeRestriction[columnType]; exists {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DisabledColumnType,+ Code: advisor.DisabledColumnType.Int32(),Title: checker.title,Content: fmt.Sprintf("Disallow column type %s but column `%s`.`%s` is", columnType, tableName, columnName),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_database_drop_empty_db.go b/backend/plugin/advisor/mysql/advisor_database_drop_empty_db.goindex 980c132fa4..e70874b56d 100644--- a/backend/plugin/advisor/mysql/advisor_database_drop_empty_db.go+++ b/backend/plugin/advisor/mysql/advisor_database_drop_empty_db.go@@ -28,7 +28,7 @@ type DatabaseAllowDropIfEmptyAdvisor struct {}// Check checks for drop table naming convention.-func (*DatabaseAllowDropIfEmptyAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*DatabaseAllowDropIfEmptyAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {list, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql ParseResult")@@ -51,9 +51,9 @@ func (*DatabaseAllowDropIfEmptyAdvisor) Check(ctx advisor.Context, _ string) ([]}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,8 +65,8 @@ type allowDropEmptyDBChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringcatalog *catalog.Finder}@@ -82,20 +82,24 @@ func (checker *allowDropEmptyDBChecker) EnterDropDatabase(ctx *mysql.DropDatabasdbName := mysqlparser.NormalizeMySQLSchemaRef(ctx.SchemaRef())if checker.catalog.Origin.DatabaseName() != dbName {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NotCurrentDatabase,+ Code: advisor.NotCurrentDatabase.Int32(),Title: checker.title,Content: fmt.Sprintf("Database `%s` that is trying to be deleted is not the current database `%s`", dbName, checker.catalog.Origin.DatabaseName()),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})} else if !checker.catalog.Origin.HasNoTable() {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DatabaseNotEmpty,+ Code: advisor.DatabaseNotEmpty.Int32(),Title: checker.title,Content: fmt.Sprintf("Database `%s` is not allowed to drop if not empty", dbName),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_disallow_procedure.go b/backend/plugin/advisor/mysql/advisor_disallow_procedure.goindex 183f57b127..755a58a7ab 100644--- a/backend/plugin/advisor/mysql/advisor_disallow_procedure.go+++ b/backend/plugin/advisor/mysql/advisor_disallow_procedure.go@@ -26,7 +26,7 @@ type ProcedureDisallowCreateAdvisor struct {}// Check checks for disallow create procedure.-func (*ProcedureDisallowCreateAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ProcedureDisallowCreateAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -47,9 +47,9 @@ func (*ProcedureDisallowCreateAdvisor) Check(ctx advisor.Context, _ string) ([]a}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -61,8 +61,8 @@ type procedureDisallowCreateChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext string}@@ -82,12 +82,14 @@ func (checker *procedureDisallowCreateChecker) EnterCreateProcedure(ctx *mysql.C}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("Procedure is forbidden, but \"%s\" creates", checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_event_disallow_create.go b/backend/plugin/advisor/mysql/advisor_event_disallow_create.goindex 6f0c5f4e9c..581f82b81b 100644--- a/backend/plugin/advisor/mysql/advisor_event_disallow_create.go+++ b/backend/plugin/advisor/mysql/advisor_event_disallow_create.go@@ -26,7 +26,7 @@ type EventDisallowCreateAdvisor struct {}// Check checks for disallow creating event.-func (*EventDisallowCreateAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*EventDisallowCreateAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -47,9 +47,9 @@ func (*EventDisallowCreateAdvisor) Check(ctx advisor.Context, _ string) ([]advis}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -61,8 +61,8 @@ type eventDisallowCreateChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext string}@@ -81,12 +81,14 @@ func (checker *eventDisallowCreateChecker) EnterCreateEvent(ctx *mysql.CreateEve}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("Event is forbidden, but \"%s\" creates", checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_function_disallow_create.go b/backend/plugin/advisor/mysql/advisor_function_disallow_create.goindex f014732c92..d68b2871ce 100644--- a/backend/plugin/advisor/mysql/advisor_function_disallow_create.go+++ b/backend/plugin/advisor/mysql/advisor_function_disallow_create.go@@ -26,7 +26,7 @@ type FunctionDisallowCreateAdvisor struct {}// Check checks for disallow creating function.-func (*FunctionDisallowCreateAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*FunctionDisallowCreateAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -47,9 +47,9 @@ func (*FunctionDisallowCreateAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -61,8 +61,8 @@ type functionDisallowCreateChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext string}@@ -81,12 +81,14 @@ func (checker *functionDisallowCreateChecker) EnterCreateFunction(ctx *mysql.Cre}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("Function is forbidden, but \"%s\" creates", checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_function_disallowed_list.go b/backend/plugin/advisor/mysql/advisor_function_disallowed_list.goindex 77709486a6..5914b512b7 100644--- a/backend/plugin/advisor/mysql/advisor_function_disallowed_list.go+++ b/backend/plugin/advisor/mysql/advisor_function_disallowed_list.go@@ -27,7 +27,7 @@ func init() {type FunctionDisallowedListAdvisor struct {}-func (*FunctionDisallowedListAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*FunctionDisallowedListAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -55,9 +55,9 @@ func (*FunctionDisallowedListAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -69,8 +69,8 @@ type functionDisallowedListChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringdisallowList []string@@ -85,12 +85,14 @@ func (checker *functionDisallowedListChecker) EnterFunctionCall(ctx *mysql.Functif pi != nil {functionName := pi.IDENTIFIER().GetText()if slices.Contains(checker.disallowList, strings.ToUpper(functionName)) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DisabledFunction,+ Code: advisor.DisabledFunction.Int32(),Title: checker.title,Content: fmt.Sprintf("Function \"%s\" is disallowed, but \"%s\" uses", functionName, checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_index_key_number_limit.go b/backend/plugin/advisor/mysql/advisor_index_key_number_limit.goindex 5632b6b961..231095f4c1 100644--- a/backend/plugin/advisor/mysql/advisor_index_key_number_limit.go+++ b/backend/plugin/advisor/mysql/advisor_index_key_number_limit.go@@ -30,7 +30,7 @@ type IndexKeyNumberLimitAdvisor struct {}// Check checks for index key number limit.-func (*IndexKeyNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*IndexKeyNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -56,9 +56,9 @@ func (*IndexKeyNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advis}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -70,8 +70,8 @@ type indexKeyNumberLimitChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringmax int}@@ -125,12 +125,14 @@ func (checker *indexKeyNumberLimitChecker) handleConstraintDef(tableName string,}if checker.max > 0 && len(columnList) > checker.max {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.IndexKeyNumberExceedsLimit,+ Code: advisor.IndexKeyNumberExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("The number of index `%s` in table `%s` should be not greater than %d", indexName, tableName, checker.max),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}@@ -158,12 +160,14 @@ func (checker *indexKeyNumberLimitChecker) EnterCreateIndex(ctx *mysql.CreateInd_, tableName := mysqlparser.NormalizeMySQLTableRef(ctx.CreateIndexTarget().TableRef())columnList := mysqlparser.NormalizeKeyListVariants(ctx.CreateIndexTarget().KeyListVariants())if checker.max > 0 && len(columnList) > checker.max {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.IndexKeyNumberExceedsLimit,+ Code: advisor.IndexKeyNumberExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("The number of index `%s` in table `%s` should be not greater than %d", indexName, tableName, checker.max),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_index_no_duplicate_column.go b/backend/plugin/advisor/mysql/advisor_index_no_duplicate_column.goindex 98d72290e4..d3a28d1ab8 100644--- a/backend/plugin/advisor/mysql/advisor_index_no_duplicate_column.go+++ b/backend/plugin/advisor/mysql/advisor_index_no_duplicate_column.go@@ -30,7 +30,7 @@ type IndexNoDuplicateColumnAdvisor struct {}// Check checks for no duplicate columns in index.-func (*IndexNoDuplicateColumnAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*IndexNoDuplicateColumnAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -51,9 +51,9 @@ func (*IndexNoDuplicateColumnAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,8 +65,8 @@ type indexNoDuplicateColumnChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle string}@@ -161,12 +161,14 @@ func (checker *indexNoDuplicateColumnChecker) EnterCreateIndex(ctx *mysql.Create_, tableName := mysqlparser.NormalizeMySQLTableRef(ctx.CreateIndexTarget().TableRef())columnList := mysqlparser.NormalizeKeyListVariants(ctx.CreateIndexTarget().KeyListVariants())if column, duplicate := checker.hasDuplicateColumn(columnList); duplicate {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DuplicateColumnInIndex,+ Code: advisor.DuplicateColumnInIndex.Int32(),Title: checker.title,Content: fmt.Sprintf("%s`%s` has duplicate column `%s`.`%s`", indexType, indexName, tableName, column),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}@@ -213,12 +215,14 @@ func (checker *indexNoDuplicateColumnChecker) handleConstraintDef(tableName stri))}if column, duplicate := checker.hasDuplicateColumn(columnList); duplicate {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DuplicateColumnInIndex,+ Code: advisor.DuplicateColumnInIndex.Int32(),Title: checker.title,Content: fmt.Sprintf("%s`%s` has duplicate column `%s`.`%s`", indexType, indexName, tableName, column),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_index_pk_type.go b/backend/plugin/advisor/mysql/advisor_index_pk_type.goindex 2dabcfea59..ab9606b46e 100644--- a/backend/plugin/advisor/mysql/advisor_index_pk_type.go+++ b/backend/plugin/advisor/mysql/advisor_index_pk_type.go@@ -32,7 +32,7 @@ type IndexPkTypeAdvisor struct {}// Check checks for correct type of PK.-func (*IndexPkTypeAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*IndexPkTypeAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -56,9 +56,9 @@ func (*IndexPkTypeAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advic}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -70,8 +70,8 @@ type indexPkTypeChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringline map[string]intcatalog *catalog.Finder@@ -196,12 +196,14 @@ func (checker *indexPkTypeChecker) checkConstraintDef(tableName string, ctx mysqfunc (checker *indexPkTypeChecker) addAdvice(tableName, columnName, columnType string, lineNumber int) {if !strings.EqualFold(columnType, "INT") && !strings.EqualFold(columnType, "BIGINT") {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.IndexPKType,+ Code: advisor.IndexPKType.Int32(),Title: checker.title,Content: fmt.Sprintf("Columns in primary key must be INT/BIGINT but `%s`.`%s` is %s", tableName, columnName, columnType),- Line: lineNumber,+ StartPosition: &storepb.Position{+ Line: int32(lineNumber),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_index_primary_key_type_allowlist.go b/backend/plugin/advisor/mysql/advisor_index_primary_key_type_allowlist.goindex 22c58bf456..99d70a8aeb 100644--- a/backend/plugin/advisor/mysql/advisor_index_primary_key_type_allowlist.go+++ b/backend/plugin/advisor/mysql/advisor_index_primary_key_type_allowlist.go@@ -31,7 +31,7 @@ type IndexPrimaryKeyTypeAllowlistAdvisor struct {}// Check checks for primary key type allowlist.-func (*IndexPrimaryKeyTypeAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*IndexPrimaryKeyTypeAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -63,9 +63,9 @@ func (*IndexPrimaryKeyTypeAllowlistAdvisor) Check(ctx advisor.Context, _ string)}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -77,8 +77,8 @@ type indexPrimaryKeyTypeAllowlistChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringallowlist map[string]boolcatalog *catalog.Finder@@ -180,12 +180,14 @@ func (checker *indexPrimaryKeyTypeAllowlistChecker) checkFieldDefinition(tableNafor _, attribute := range ctx.AllColumnAttribute() {if attribute.PRIMARY_SYMBOL() != nil {if _, exists := checker.allowlist[columnType]; !exists {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.IndexPKType,+ Code: advisor.IndexPKType.Int32(),Title: checker.title,Content: fmt.Sprintf("The column `%s` in table `%s` is one of the primary key, but its type \"%s\" is not in allowlist", columnName, tableName, columnType),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}@@ -209,12 +211,14 @@ func (checker *indexPrimaryKeyTypeAllowlistChecker) checkConstraintDef(tableName}columnType = strings.ToLower(columnType)if _, exists := checker.allowlist[columnType]; !exists {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.IndexPKType,+ Code: advisor.IndexPKType.Int32(),Title: checker.title,Content: fmt.Sprintf("The column `%s` in table `%s` is one of the primary key, but its type \"%s\" is not in allowlist", columnName, tableName, columnType),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_index_total_number_limit.go b/backend/plugin/advisor/mysql/advisor_index_total_number_limit.goindex 3a658d5e75..21df49d688 100644--- a/backend/plugin/advisor/mysql/advisor_index_total_number_limit.go+++ b/backend/plugin/advisor/mysql/advisor_index_total_number_limit.go@@ -32,7 +32,7 @@ type IndexTotalNumberLimitAdvisor struct {}// Check checks for index total number limit.-func (*IndexTotalNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*IndexTotalNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -66,15 +66,15 @@ type indexTotalNumberLimitChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringmax intlineForTable map[string]intcatalog *catalog.Finder}-func (checker *indexTotalNumberLimitChecker) generateAdvice() []advisor.Advice {+func (checker *indexTotalNumberLimitChecker) generateAdvice() []*storepb.Advice {type tableName struct {name stringline int@@ -94,20 +94,22 @@ func (checker *indexTotalNumberLimitChecker) generateAdvice() []advisor.Advice {for _, table := range tableList {tableInfo := checker.catalog.Final.FindTable(&catalog.TableFind{TableName: table.name})if tableInfo != nil && tableInfo.CountIndex() > checker.max {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.IndexCountExceedsLimit,+ Code: advisor.IndexCountExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("The count of index in table `%s` should be no more than %d, but found %d", table.name, checker.max, tableInfo.CountIndex()),- Line: table.line,+ StartPosition: &storepb.Position{+ Line: int32(table.line),+ },})}}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/mysql/advisor_index_type_allow_list.go b/backend/plugin/advisor/mysql/advisor_index_type_allow_list.goindex 58897de229..7952afa9ae 100644--- a/backend/plugin/advisor/mysql/advisor_index_type_allow_list.go+++ b/backend/plugin/advisor/mysql/advisor_index_type_allow_list.go@@ -28,7 +28,7 @@ func init() {type IndexTypeAllowListAdvisor struct {}-func (*IndexTypeAllowListAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*IndexTypeAllowListAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -55,9 +55,9 @@ func (*IndexTypeAllowListAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -69,8 +69,8 @@ type indexTypeAllowListChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringallowList []string}@@ -162,11 +162,13 @@ func (checker *indexTypeAllowListChecker) validateIndexType(indexType string, lireturn}- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.IndexTypeNotAllowed,+ Code: advisor.IndexTypeNotAllowed.Int32(),Title: checker.title,Content: fmt.Sprintf("Index type `%s` is not allowed", indexType),- Line: checker.baseLine + line,+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + line),+ },})}diff --git a/backend/plugin/advisor/mysql/advisor_index_type_no_blob.go b/backend/plugin/advisor/mysql/advisor_index_type_no_blob.goindex 7d08a88505..e02b874b66 100644--- a/backend/plugin/advisor/mysql/advisor_index_type_no_blob.go+++ b/backend/plugin/advisor/mysql/advisor_index_type_no_blob.go@@ -32,7 +32,7 @@ type IndexTypeNoBlobAdvisor struct {}// Check checks for index type no blob.-func (*IndexTypeNoBlobAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*IndexTypeNoBlobAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -55,9 +55,9 @@ func (*IndexTypeNoBlobAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.A}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -69,8 +69,8 @@ type indexTypeNoBlobChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringcatalog *catalog.FindertablesNewColumns tableColumnTypes@@ -242,12 +242,14 @@ func (checker *indexTypeNoBlobChecker) checkConstraintDef(tableName string, ctxfunc (checker *indexTypeNoBlobChecker) addAdvice(tableName, columnName, columnType string, lineNumber int) {if checker.isBlob(columnType) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.IndexTypeNoBlob,+ Code: advisor.IndexTypeNoBlob.Int32(),Title: checker.title,Content: fmt.Sprintf("Columns in index must not be BLOB but `%s`.`%s` is %s", tableName, columnName, columnType),- Line: checker.baseLine + lineNumber,+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + lineNumber),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_insert_disallow_order_by_rand.go b/backend/plugin/advisor/mysql/advisor_insert_disallow_order_by_rand.goindex ea7fb79335..694446dbd3 100644--- a/backend/plugin/advisor/mysql/advisor_insert_disallow_order_by_rand.go+++ b/backend/plugin/advisor/mysql/advisor_insert_disallow_order_by_rand.go@@ -33,7 +33,7 @@ type InsertDisallowOrderByRandAdvisor struct {}// Check checks for to disallow order by rand in INSERT statements.-func (*InsertDisallowOrderByRandAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*InsertDisallowOrderByRandAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -54,9 +54,9 @@ func (*InsertDisallowOrderByRandAdvisor) Check(ctx advisor.Context, _ string) ([}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -69,8 +69,8 @@ type insertDisallowOrderByRandChecker struct {isInsertStmt boolbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext string}@@ -107,12 +107,14 @@ func (checker *insertDisallowOrderByRandChecker) EnterQueryExpression(ctx *mysqlfor _, expr := range ctx.OrderClause().OrderList().AllOrderExpression() {text := expr.GetText()if strings.EqualFold(text, RandFn) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.InsertUseOrderByRand,+ Code: advisor.InsertUseOrderByRand.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" uses ORDER BY RAND in the INSERT statement", checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_insert_must_specify_column.go b/backend/plugin/advisor/mysql/advisor_insert_must_specify_column.goindex 3cc8a88fa4..1940d3f26c 100644--- a/backend/plugin/advisor/mysql/advisor_insert_must_specify_column.go+++ b/backend/plugin/advisor/mysql/advisor_insert_must_specify_column.go@@ -30,7 +30,7 @@ type InsertMustSpecifyColumnAdvisor struct {}// Check checks for to enforce column specified.-func (*InsertMustSpecifyColumnAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*InsertMustSpecifyColumnAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -51,9 +51,9 @@ func (*InsertMustSpecifyColumnAdvisor) Check(ctx advisor.Context, _ string) ([]a}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -66,8 +66,8 @@ type insertMustSpecifyColumnChecker struct {baseLine inthasSelect bool- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext string}@@ -93,23 +93,27 @@ func (checker *insertMustSpecifyColumnChecker) EnterInsertStatement(ctx *mysql.I// has columns.return}- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.InsertNotSpecifyColumn,+ Code: advisor.InsertNotSpecifyColumn.Int32(),Title: checker.title,Content: fmt.Sprintf("The INSERT statement must specify columns but \"%s\" does not", checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}func (checker *insertMustSpecifyColumnChecker) EnterSelectItemList(ctx *mysql.SelectItemListContext) {if checker.hasSelect && ctx.MULT_OPERATOR() != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.InsertNotSpecifyColumn,+ Code: advisor.InsertNotSpecifyColumn.Int32(),Title: checker.title,Content: fmt.Sprintf("The INSERT statement must specify columns but \"%s\" does not", checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_insert_row_limit.go b/backend/plugin/advisor/mysql/advisor_insert_row_limit.goindex c9b93f6333..9215dab9ef 100644--- a/backend/plugin/advisor/mysql/advisor_insert_row_limit.go+++ b/backend/plugin/advisor/mysql/advisor_insert_row_limit.go@@ -30,7 +30,7 @@ type InsertRowLimitAdvisor struct {}// Check checks for table naming convention.-func (*InsertRowLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*InsertRowLimitAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {list, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql ParseResult")@@ -65,8 +65,8 @@ type insertRowLimitChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -75,11 +75,11 @@ type insertRowLimitChecker struct {ctx context.Context}-func (checker *insertRowLimitChecker) generateAdvice() ([]advisor.Advice, error) {+func (checker *insertRowLimitChecker) generateAdvice() ([]*storepb.Advice, error) {if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -110,31 +110,37 @@ func (checker *insertRowLimitChecker) handleInsertQueryExpression(ctx mysql.IInsres, err := advisor.Query(checker.ctx, checker.driver, fmt.Sprintf("EXPLAIN %s", checker.text))if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.InsertTooManyRows,+ Code: advisor.InsertTooManyRows.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" dry runs failed: %s", checker.text, err.Error()),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})return}rowCount, err := getInsertRows(res)if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: checker.title,Content: fmt.Sprintf("failed to get row count for \"%s\": %s", checker.text, err.Error()),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})} else if rowCount > int64(checker.maxRow) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.InsertTooManyRows,+ Code: advisor.InsertTooManyRows.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" inserts %d rows. The count exceeds %d.", checker.text, rowCount, checker.maxRow),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}}@@ -152,12 +158,14 @@ func (checker *insertRowLimitChecker) handleNoInsertQueryExpression(ctx mysql.IIallValues := ctx.InsertFromConstructor().InsertValues().ValueList().AllValues()if len(allValues) > checker.maxRow {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.InsertTooManyRows,+ Code: advisor.InsertTooManyRows.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" inserts %d rows. The count exceeds %d.", checker.text, len(allValues), checker.maxRow),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_migration_compatibility.go b/backend/plugin/advisor/mysql/advisor_migration_compatibility.goindex 83776ebec7..468341e20a 100644--- a/backend/plugin/advisor/mysql/advisor_migration_compatibility.go+++ b/backend/plugin/advisor/mysql/advisor_migration_compatibility.go@@ -28,7 +28,7 @@ type CompatibilityAdvisor struct {}// Check checks schema backward compatibility.-func (*CompatibilityAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*CompatibilityAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -49,9 +49,9 @@ func (*CompatibilityAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Adv}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -63,8 +63,8 @@ type compatibilityChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringlastCreateTable stringcode advisor.Code@@ -79,12 +79,14 @@ func (checker *compatibilityChecker) EnterQuery(_ *mysql.QueryContext) {func (checker *compatibilityChecker) ExitQuery(ctx *mysql.QueryContext) {if checker.code != advisor.Ok {text := ctx.GetParser().GetTokenStream().GetTextFromRuleContext(ctx)- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: checker.code,+ Code: checker.code.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" may cause incompatibility with the existing data and code", text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_naming_auto_increment_column.go b/backend/plugin/advisor/mysql/advisor_naming_auto_increment_column.goindex c102151371..41e385ba08 100644--- a/backend/plugin/advisor/mysql/advisor_naming_auto_increment_column.go+++ b/backend/plugin/advisor/mysql/advisor_naming_auto_increment_column.go@@ -31,7 +31,7 @@ type NamingAutoIncrementColumnAdvisor struct {}// Check checks for auto-increment naming convention.-func (*NamingAutoIncrementColumnAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingAutoIncrementColumnAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -58,9 +58,9 @@ func (*NamingAutoIncrementColumnAdvisor) Check(ctx advisor.Context, _ string) ([}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -72,8 +72,8 @@ type namingAutoIncrementColumnChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat *regexp.RegexpmaxLength int@@ -169,21 +169,25 @@ func (checker *namingAutoIncrementColumnChecker) checkFieldDefinition(tableName,}if !checker.format.MatchString(columnName) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingAutoIncrementColumnConventionMismatch,+ Code: advisor.NamingAutoIncrementColumnConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("`%s`.`%s` mismatches auto_increment column naming convention, naming format should be %q", tableName, columnName, checker.format),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}if checker.maxLength > 0 && len(columnName) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingAutoIncrementColumnConventionMismatch,+ Code: advisor.NamingAutoIncrementColumnConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("`%s`.`%s` mismatches auto_increment column naming convention, its length should be within %d characters", tableName, columnName, checker.maxLength),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_naming_column.go b/backend/plugin/advisor/mysql/advisor_naming_column.goindex 1bb940b64c..1029a56446 100644--- a/backend/plugin/advisor/mysql/advisor_naming_column.go+++ b/backend/plugin/advisor/mysql/advisor_naming_column.go@@ -26,7 +26,7 @@ type NamingColumnConventionAdvisor struct {}// Check checks for column naming convention.-func (*NamingColumnConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingColumnConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {list, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql ParseResult")@@ -54,9 +54,9 @@ func (*NamingColumnConventionAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -69,8 +69,8 @@ type namingColumnConventionChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat *regexp.RegexpmaxLength int@@ -164,21 +164,25 @@ func (checker *namingColumnConventionChecker) handleColumn(tableName string, col// we need to accumulate line number for each statement and elements of statements.lineNumber += checker.baseLineif !checker.format.MatchString(columnName) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingColumnConventionMismatch,+ Code: advisor.NamingColumnConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("`%s`.`%s` mismatches column naming convention, naming format should be %q", tableName, columnName, checker.format),- Line: lineNumber,+ StartPosition: &storepb.Position{+ Line: int32(lineNumber),+ },})}if checker.maxLength > 0 && len(columnName) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingColumnConventionMismatch,+ Code: advisor.NamingColumnConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("`%s`.`%s` mismatches column naming convention, its length should be within %d characters", tableName, columnName, checker.maxLength),- Line: lineNumber,+ StartPosition: &storepb.Position{+ Line: int32(lineNumber),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_naming_foreign_key_convention.go b/backend/plugin/advisor/mysql/advisor_naming_foreign_key_convention.goindex 68821b8d8c..0156bd59c3 100644--- a/backend/plugin/advisor/mysql/advisor_naming_foreign_key_convention.go+++ b/backend/plugin/advisor/mysql/advisor_naming_foreign_key_convention.go@@ -29,7 +29,7 @@ type NamingFKConventionAdvisor struct {}// Check checks for foreign key naming convention.-func (*NamingFKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingFKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -57,9 +57,9 @@ func (*NamingFKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -73,8 +73,8 @@ type namingFKConventionChecker struct {baseLine inttext string- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat stringmaxLength int@@ -151,30 +151,34 @@ func (checker *namingFKConventionChecker) handleIndexList(indexDataList []*indexfor _, indexData := range indexDataList {regex, err := getTemplateRegexp(checker.format, checker.templateList, indexData.metaData)if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: "Internal error for foreign key naming convention rule",Content: fmt.Sprintf("%q meet internal error %q", checker.text, err.Error()),})continue}if !regex.MatchString(indexData.indexName) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingFKConventionMismatch,+ Code: advisor.NamingFKConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("Foreign key in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),- Line: indexData.line,+ StartPosition: &storepb.Position{+ Line: int32(indexData.line),+ },})}if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingFKConventionMismatch,+ Code: advisor.NamingFKConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("Foreign key `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),- Line: indexData.line,+ StartPosition: &storepb.Position{+ Line: int32(indexData.line),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_naming_identifier_no_keyword.go b/backend/plugin/advisor/mysql/advisor_naming_identifier_no_keyword.goindex 99d06c5400..567c509eca 100644--- a/backend/plugin/advisor/mysql/advisor_naming_identifier_no_keyword.go+++ b/backend/plugin/advisor/mysql/advisor_naming_identifier_no_keyword.go@@ -26,7 +26,7 @@ type NamingIdentifierNoKeywordAdvisor struct {}// Check checks for identifier naming convention without keyword.-func (*NamingIdentifierNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingIdentifierNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -47,9 +47,9 @@ func (*NamingIdentifierNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -61,8 +61,8 @@ type namingIdentifierNoKeywordChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle string}@@ -78,8 +78,8 @@ func (checker *namingIdentifierNoKeywordChecker) EnterPureIdentifier(ctx *mysql.identifier := trimBackTicks(textNode.GetText())advice := checker.checkIdentifier(identifier)if advice != nil {- advice.Line = ctx.GetStart().GetLine()- checker.adviceList = append(checker.adviceList, *advice)+ advice.StartPosition = &storepb.Position{Line: int32(ctx.GetStart().GetLine())}+ checker.adviceList = append(checker.adviceList, advice)}}@@ -88,16 +88,16 @@ func (checker *namingIdentifierNoKeywordChecker) EnterIdentifierKeyword(ctx *mysidentifier := ctx.GetText()advice := checker.checkIdentifier(identifier)if advice != nil {- advice.Line = ctx.GetStart().GetLine()- checker.adviceList = append(checker.adviceList, *advice)+ advice.StartPosition = &storepb.Position{Line: int32(ctx.GetStart().GetLine())}+ checker.adviceList = append(checker.adviceList, advice)}}-func (checker *namingIdentifierNoKeywordChecker) checkIdentifier(identifier string) *advisor.Advice {+func (checker *namingIdentifierNoKeywordChecker) checkIdentifier(identifier string) *storepb.Advice {if isKeyword(identifier) {- return &advisor.Advice{+ return &storepb.Advice{Status: checker.level,- Code: advisor.NameIsKeywordIdentifier,+ Code: advisor.NameIsKeywordIdentifier.Int32(),Title: checker.title,Content: fmt.Sprintf("Identifier %q is a keyword and should be avoided", identifier),}diff --git a/backend/plugin/advisor/mysql/advisor_naming_index_convention.go b/backend/plugin/advisor/mysql/advisor_naming_index_convention.goindex 049c9d7436..b587e54dcc 100644--- a/backend/plugin/advisor/mysql/advisor_naming_index_convention.go+++ b/backend/plugin/advisor/mysql/advisor_naming_index_convention.go@@ -37,7 +37,7 @@ type NamingIndexConventionAdvisor struct {}// Check checks for index naming convention.-func (*NamingIndexConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingIndexConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -66,9 +66,9 @@ func (*NamingIndexConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adv}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -82,8 +82,8 @@ type namingIndexConventionChecker struct {baseLine inttext string- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat stringmaxLength int@@ -230,30 +230,34 @@ func (checker *namingIndexConventionChecker) handleIndexList(indexDataList []*infor _, indexData := range indexDataList {regex, err := getTemplateRegexp(checker.format, checker.templateList, indexData.metaData)if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: "Internal error for unique key naming convention rule",Content: fmt.Sprintf("%q meet internal error %q", checker.text, err.Error()),})continue}if !regex.MatchString(indexData.indexName) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingIndexConventionMismatch,+ Code: advisor.NamingIndexConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("Index in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),- Line: indexData.line,+ StartPosition: &storepb.Position{+ Line: int32(indexData.line),+ },})}if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingIndexConventionMismatch,+ Code: advisor.NamingIndexConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("Index `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),- Line: indexData.line,+ StartPosition: &storepb.Position{+ Line: int32(indexData.line),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_naming_table.go b/backend/plugin/advisor/mysql/advisor_naming_table.goindex bbf2760725..b14b1ef1c9 100644--- a/backend/plugin/advisor/mysql/advisor_naming_table.go+++ b/backend/plugin/advisor/mysql/advisor_naming_table.go@@ -28,7 +28,7 @@ type NamingTableConventionAdvisor struct {}// Check checks for table naming convention.-func (*NamingTableConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingTableConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {list, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -62,18 +62,18 @@ type namingTableConventionChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat *regexp.RegexpmaxLength int}-func (checker *namingTableConventionChecker) generateAdvice() ([]advisor.Advice, error) {+func (checker *namingTableConventionChecker) generateAdvice() ([]*storepb.Advice, error) {if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -137,21 +137,25 @@ func (checker *namingTableConventionChecker) EnterRenameTableStatement(ctx *mysqfunc (checker *namingTableConventionChecker) handleTableName(tableName string, lineNumber int) {lineNumber += checker.baseLineif !checker.format.MatchString(tableName) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingTableConventionMismatch,+ Code: advisor.NamingTableConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("`%s` mismatches table naming convention, naming format should be %q", tableName, checker.format),- Line: lineNumber,+ StartPosition: &storepb.Position{+ Line: int32(lineNumber),+ },})}if checker.maxLength > 0 && len(tableName) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingTableConventionMismatch,+ Code: advisor.NamingTableConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("`%s` mismatches table naming convention, its length should be within %d characters", tableName, checker.maxLength),- Line: lineNumber,+ StartPosition: &storepb.Position{+ Line: int32(lineNumber),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_naming_unique_key_convention.go b/backend/plugin/advisor/mysql/advisor_naming_unique_key_convention.goindex 46b0da7e76..492e98dc22 100644--- a/backend/plugin/advisor/mysql/advisor_naming_unique_key_convention.go+++ b/backend/plugin/advisor/mysql/advisor_naming_unique_key_convention.go@@ -30,7 +30,7 @@ type NamingUKConventionAdvisor struct {}// Check checks for index naming convention.-func (*NamingUKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingUKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -59,9 +59,9 @@ func (*NamingUKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -74,8 +74,8 @@ type namingUKConventionChecker struct {baseLine inttext string- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat stringmaxLength int@@ -218,30 +218,34 @@ func (checker *namingUKConventionChecker) handleIndexList(indexDataList []*indexfor _, indexData := range indexDataList {regex, err := getTemplateRegexp(checker.format, checker.templateList, indexData.metaData)if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: "Internal error for unique key naming convention rule",Content: fmt.Sprintf("%q meet internal error %q", checker.text, err.Error()),})continue}if !regex.MatchString(indexData.indexName) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingUKConventionMismatch,+ Code: advisor.NamingUKConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("Unique key in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),- Line: indexData.line,+ StartPosition: &storepb.Position{+ Line: int32(indexData.line),+ },})}if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingUKConventionMismatch,+ Code: advisor.NamingUKConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("Unique key `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),- Line: indexData.line,+ StartPosition: &storepb.Position{+ Line: int32(indexData.line),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_online_migration.go b/backend/plugin/advisor/mysql/advisor_online_migration.goindex d5b19e98d5..95db301863 100644--- a/backend/plugin/advisor/mysql/advisor_online_migration.go+++ b/backend/plugin/advisor/mysql/advisor_online_migration.go@@ -30,12 +30,12 @@ type OnlineMigrationAdvisor struct {}// Check checks for using gh-ost to migrate large tables.-func (*OnlineMigrationAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*OnlineMigrationAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {if ctx.ChangeType == storepb.PlanCheckRunConfig_DDL_GHOST {- return []advisor.Advice{+ return []*storepb.Advice{{- Status: advisor.Success,- Code: advisor.Ok,+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",},@@ -75,9 +75,9 @@ func (*OnlineMigrationAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.AtableRows = table.GetRowCount()}if tableRows >= minRows {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.AdviseOnlineMigration,+ Code: advisor.AdviseOnlineMigration.Int32(),Title: checker.title,Content: fmt.Sprintf("Estimated table row count of %q is %d exceeding the set value %d. Consider enabling online migration", fmt.Sprintf("%s.%s", resource.Schema, resource.Table), tableRows, minRows),})@@ -85,9 +85,9 @@ func (*OnlineMigrationAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.A}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -98,8 +98,8 @@ func (*OnlineMigrationAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Atype useGhostChecker struct {*mysql.BaseMySQLParserListener- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringcurrentDatabase stringdiff --git a/backend/plugin/advisor/mysql/advisor_statement_add_column_without_position.go b/backend/plugin/advisor/mysql/advisor_statement_add_column_without_position.goindex cf9e5eba1f..03ba9c3991 100644--- a/backend/plugin/advisor/mysql/advisor_statement_add_column_without_position.go+++ b/backend/plugin/advisor/mysql/advisor_statement_add_column_without_position.go@@ -28,7 +28,7 @@ type StatementAddColumnWithoutPositionAdvisor struct {}// Check checks for checking no position in ADD COLUMN clause.-func (*StatementAddColumnWithoutPositionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementAddColumnWithoutPositionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -49,9 +49,9 @@ func (*StatementAddColumnWithoutPositionAdvisor) Check(ctx advisor.Context, _ st}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -63,8 +63,8 @@ type statementAddColumnWithoutPositionChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle string}@@ -117,12 +117,14 @@ func (checker *statementAddColumnWithoutPositionChecker) EnterAlterTable(ctx *my}if len(position) != 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementAddColumnWithPosition,+ Code: advisor.StatementAddColumnWithPosition.Int32(),Title: checker.title,Content: fmt.Sprintf("add column with position \"%s\"", position),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_statement_affected_row_limit.go b/backend/plugin/advisor/mysql/advisor_statement_affected_row_limit.goindex 058d5370c3..9705cf4692 100644--- a/backend/plugin/advisor/mysql/advisor_statement_affected_row_limit.go+++ b/backend/plugin/advisor/mysql/advisor_statement_affected_row_limit.go@@ -31,7 +31,7 @@ type StatementAffectedRowLimitAdvisor struct {}// Check checks for UPDATE/DELETE affected row limit.-func (*StatementAffectedRowLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementAffectedRowLimitAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -61,9 +61,9 @@ func (*StatementAffectedRowLimitAdvisor) Check(ctx advisor.Context, _ string) ([}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -75,8 +75,8 @@ type statementAffectedRowLimitChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringmaxRow int@@ -108,30 +108,36 @@ func (checker *statementAffectedRowLimitChecker) handleStmt(lineNumber int) {lineNumber += checker.baseLineres, err := advisor.Query(checker.ctx, checker.driver, fmt.Sprintf("EXPLAIN %s", checker.text))if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementAffectedRowExceedsLimit,+ Code: advisor.StatementAffectedRowExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" dry runs failed: %s", checker.text, err.Error()),- Line: lineNumber,+ StartPosition: &storepb.Position{+ Line: int32(lineNumber),+ },})} else {rowCount, err := getRows(res)if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: checker.title,Content: fmt.Sprintf("failed to get row count for \"%s\": %s", checker.text, err.Error()),- Line: lineNumber,+ StartPosition: &storepb.Position{+ Line: int32(lineNumber),+ },})} else if rowCount > int64(checker.maxRow) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementAffectedRowExceedsLimit,+ Code: advisor.StatementAffectedRowExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" affected %d rows (estimated). The count exceeds %d.", checker.text, rowCount, checker.maxRow),- Line: lineNumber,+ StartPosition: &storepb.Position{+ Line: int32(lineNumber),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_ddl_dml.go b/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_ddl_dml.goindex d3ed70a0d6..c7d12847b4 100644--- a/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_ddl_dml.go+++ b/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_ddl_dml.go@@ -22,7 +22,7 @@ func init() {type StatementDisallowmixDDLDMLAdvisor struct {}-func (*StatementDisallowmixDDLDMLAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementDisallowmixDDLDMLAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -34,7 +34,7 @@ func (*StatementDisallowmixDDLDMLAdvisor) Check(ctx advisor.Context, _ string) (}title := string(ctx.Rule.Type)- var adviceList []advisor.Advice+ var adviceList []*storepb.Advicevar hasDDL, hasDML boolfor _, stmt := range stmtList {checker := &mysqlparser.StatementTypeChecker{}@@ -43,22 +43,26 @@ func (*StatementDisallowmixDDLDMLAdvisor) Check(ctx advisor.Context, _ string) (switch ctx.ChangeType {case storepb.PlanCheckRunConfig_DDL, storepb.PlanCheckRunConfig_SDL, storepb.PlanCheckRunConfig_DDL_GHOST:if checker.IsDML {- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: level,Title: title,Content: fmt.Sprintf("Alter schema can only run DDL, \"%s\" is not DDL", checker.Text),- Code: advisor.StatementDisallowMixDDLDML,- Line: stmt.BaseLine,+ Code: advisor.StatementDisallowMixDDLDML.Int32(),+ StartPosition: &storepb.Position{+ Line: int32(stmt.BaseLine),+ },})}case storepb.PlanCheckRunConfig_DML:if checker.IsDDL {- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: level,Title: title,Content: fmt.Sprintf("Data change can only run DML, \"%s\" is not DML", checker.Text),- Code: advisor.StatementDisallowMixDDLDML,- Line: stmt.BaseLine,+ Code: advisor.StatementDisallowMixDDLDML.Int32(),+ StartPosition: &storepb.Position{+ Line: int32(stmt.BaseLine),+ },})}}@@ -72,18 +76,18 @@ func (*StatementDisallowmixDDLDMLAdvisor) Check(ctx advisor.Context, _ string) (}if hasDDL && hasDML {- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: level,Title: title,Content: "Mixing DDL with DML is not allowed",- Code: advisor.StatementDisallowMixDDLDML,+ Code: advisor.StatementDisallowMixDDLDML.Int32(),})}if len(adviceList) == 0 {- adviceList = append(adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ adviceList = append(adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/mysql/advisor_statement_disallow_using_filesort.go b/backend/plugin/advisor/mysql/advisor_statement_disallow_using_filesort.goindex c81455ddf4..4d0465a253 100644--- a/backend/plugin/advisor/mysql/advisor_statement_disallow_using_filesort.go+++ b/backend/plugin/advisor/mysql/advisor_statement_disallow_using_filesort.go@@ -27,7 +27,7 @@ func init() {type StatementDisallowUsingFilesortAdvisor struct {}-func (*StatementDisallowUsingFilesortAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementDisallowUsingFilesortAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql ParseResult")@@ -53,9 +53,9 @@ func (*StatementDisallowUsingFilesortAdvisor) Check(ctx advisor.Context, _ strin}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -67,8 +67,8 @@ type disallowUsingFilesortChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringdriver *sql.DBctx context.Context@@ -85,30 +85,36 @@ func (checker *disallowUsingFilesortChecker) EnterSelectStatement(ctx *mysql.Selquery := ctx.GetParser().GetTokenStream().GetTextFromRuleContext(ctx)res, err := advisor.Query(checker.ctx, checker.driver, fmt.Sprintf("EXPLAIN %s", query))if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementExplainQueryFailed,+ Code: advisor.StatementExplainQueryFailed.Int32(),Title: checker.title,Content: fmt.Sprintf("Failed to explain query: %s, with error: %s", query, err),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})} else {hasUsingFilesort, tables, err := hasUsingFilesortInExtraColumn(res)if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: checker.title,Content: fmt.Sprintf("Failed to check extra column: %s, with error: %s", query, err),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})} else if hasUsingFilesort {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementHasUsingFilesort,+ Code: advisor.StatementHasUsingFilesort.Int32(),Title: checker.title,Content: fmt.Sprintf("Using filesort detected on table(s): %s", tables),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_statement_disallow_using_temporary.go b/backend/plugin/advisor/mysql/advisor_statement_disallow_using_temporary.goindex 434a73c9d3..da1555b9a3 100644--- a/backend/plugin/advisor/mysql/advisor_statement_disallow_using_temporary.go+++ b/backend/plugin/advisor/mysql/advisor_statement_disallow_using_temporary.go@@ -27,7 +27,7 @@ func init() {type StatementDisallowUsingTemporaryAdvisor struct {}-func (*StatementDisallowUsingTemporaryAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementDisallowUsingTemporaryAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql ParseResult")@@ -53,9 +53,9 @@ func (*StatementDisallowUsingTemporaryAdvisor) Check(ctx advisor.Context, _ stri}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -67,8 +67,8 @@ type disallowUsingTemporaryChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringdriver *sql.DBctx context.Context@@ -85,30 +85,36 @@ func (checker *disallowUsingTemporaryChecker) EnterSelectStatement(ctx *mysql.Sequery := ctx.GetParser().GetTokenStream().GetTextFromRuleContext(ctx)res, err := advisor.Query(checker.ctx, checker.driver, fmt.Sprintf("EXPLAIN %s", query))if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementExplainQueryFailed,+ Code: advisor.StatementExplainQueryFailed.Int32(),Title: checker.title,Content: fmt.Sprintf("Failed to explain query: %s, with error: %s", query, err),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})} else {hasUsingTemporary, tables, err := hasUsingTemporaryInExtraColumn(res)if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: checker.title,Content: fmt.Sprintf("Failed to check extra column: %s, with error: %s", query, err),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})} else if hasUsingTemporary {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementHasUsingTemporary,+ Code: advisor.StatementHasUsingTemporary.Int32(),Title: checker.title,Content: fmt.Sprintf("Using temporary detected on table(s): %s", tables),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_statement_dml_dry_run.go b/backend/plugin/advisor/mysql/advisor_statement_dml_dry_run.goindex c28902d01d..dca05a4a66 100644--- a/backend/plugin/advisor/mysql/advisor_statement_dml_dry_run.go+++ b/backend/plugin/advisor/mysql/advisor_statement_dml_dry_run.go@@ -32,7 +32,7 @@ type StatementDmlDryRunAdvisor struct {}// Check checks for DML dry run.-func (*StatementDmlDryRunAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementDmlDryRunAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -57,9 +57,9 @@ func (*StatementDmlDryRunAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -71,8 +71,8 @@ type statementDmlDryRunChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringline intdriver *sql.DB@@ -106,12 +106,14 @@ func (checker *statementDmlDryRunChecker) EnterInsertStatement(ctx *mysql.Insert// Enter implements the ast.Visitor interface.func (checker *statementDmlDryRunChecker) handleStmt(text string, lineNumber int) {if _, err := advisor.Query(checker.ctx, checker.driver, fmt.Sprintf("EXPLAIN %s", text)); err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementDMLDryRunFailed,+ Code: advisor.StatementDMLDryRunFailed.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" dry runs failed: %s", text, err.Error()),- Line: checker.line + lineNumber,+ StartPosition: &storepb.Position{+ Line: int32(checker.line + lineNumber),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_statement_join_strict_column_attrs.go b/backend/plugin/advisor/mysql/advisor_statement_join_strict_column_attrs.goindex 372e6ae9d3..15afb51a5b 100644--- a/backend/plugin/advisor/mysql/advisor_statement_join_strict_column_attrs.go+++ b/backend/plugin/advisor/mysql/advisor_statement_join_strict_column_attrs.go@@ -26,7 +26,7 @@ func init() {type StatementJoinStrictColumnAttrsAdvisor struct {}-func (*StatementJoinStrictColumnAttrsAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementJoinStrictColumnAttrsAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -51,9 +51,9 @@ func (*StatementJoinStrictColumnAttrsAdvisor) Check(ctx advisor.Context, _ strin}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,8 +65,8 @@ type statementJoinStrictColumnAttrsChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringdbSchema *model.DBSchema@@ -206,12 +206,14 @@ func (checker *statementJoinStrictColumnAttrsChecker) checkColumnAttrs(leftColumreturn}if leftColumn.Type != rightColumn.Type || leftColumn.CharacterSet != rightColumn.CharacterSet || leftColumn.Collation != rightColumn.Collation {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementJoinColumnAttrsNotMatch,+ Code: advisor.StatementJoinColumnAttrsNotMatch.Int32(),Title: checker.title,Content: fmt.Sprintf("%s.%s and %s.%s column fields do not match", leftColumnAttr.Table, leftColumnAttr.Column, rightColumnAttr.Table, rightColumnAttr.Column),- Line: checker.baseLine,+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_statement_maximum_join_table_count.go b/backend/plugin/advisor/mysql/advisor_statement_maximum_join_table_count.goindex 09185c78a7..103f7bfe42 100644--- a/backend/plugin/advisor/mysql/advisor_statement_maximum_join_table_count.go+++ b/backend/plugin/advisor/mysql/advisor_statement_maximum_join_table_count.go@@ -24,7 +24,7 @@ func init() {type StatementMaximumJoinTableCountAdvisor struct {}-func (*StatementMaximumJoinTableCountAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementMaximumJoinTableCountAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -50,9 +50,9 @@ func (*StatementMaximumJoinTableCountAdvisor) Check(ctx advisor.Context, _ strin}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -64,8 +64,8 @@ type statementMaximumJoinTableCountChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringlimitMaxValue int@@ -80,12 +80,14 @@ func (checker *statementMaximumJoinTableCountChecker) EnterJoinedTable(ctx *mysqchecker.count++// The count starts from 0. We count the number of tables in the joins.if checker.count == checker.limitMaxValue {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementMaximumJoinTableCount,+ Code: advisor.StatementMaximumJoinTableCount.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" exceeds the maximum number of joins %d.", checker.text, checker.limitMaxValue),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_statement_maximum_limit_value.go b/backend/plugin/advisor/mysql/advisor_statement_maximum_limit_value.goindex 712aa3d817..c1be8eed64 100644--- a/backend/plugin/advisor/mysql/advisor_statement_maximum_limit_value.go+++ b/backend/plugin/advisor/mysql/advisor_statement_maximum_limit_value.go@@ -27,7 +27,7 @@ func init() {type StatementMaximumLimitValueAdvisor struct {}-func (*StatementMaximumLimitValueAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementMaximumLimitValueAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -53,9 +53,9 @@ func (*StatementMaximumLimitValueAdvisor) Check(ctx advisor.Context, _ string) (}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -67,8 +67,8 @@ type statementMaximumLimitValueChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringisSelect bool@@ -110,12 +110,14 @@ func (checker *statementMaximumLimitValueChecker) EnterLimitClause(ctx *mysql.Li}if limitValue > checker.limitMaxValue {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementExceedMaximumLimitValue,+ Code: advisor.StatementExceedMaximumLimitValue.Int32(),Title: checker.title,Content: fmt.Sprintf("The limit value %d exceeds the maximum allowed value %d", limitValue, checker.limitMaxValue),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_statement_maximum_statements_in_transaction.go b/backend/plugin/advisor/mysql/advisor_statement_maximum_statements_in_transaction.goindex baa36338d4..7edcf36529 100644--- a/backend/plugin/advisor/mysql/advisor_statement_maximum_statements_in_transaction.go+++ b/backend/plugin/advisor/mysql/advisor_statement_maximum_statements_in_transaction.go@@ -22,7 +22,7 @@ func init() {type StatementMaximumStatementsInTransactionAdvisor struct {}-func (*StatementMaximumStatementsInTransactionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementMaximumStatementsInTransactionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -48,9 +48,9 @@ func (*StatementMaximumStatementsInTransactionAdvisor) Check(ctx advisor.Context}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -62,8 +62,8 @@ type statementMaximumStatementsInTransactionChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringlimitMaxValue intdiff --git a/backend/plugin/advisor/mysql/advisor_statement_merge_alter_table.go b/backend/plugin/advisor/mysql/advisor_statement_merge_alter_table.goindex 4c946ec305..440424cc11 100644--- a/backend/plugin/advisor/mysql/advisor_statement_merge_alter_table.go+++ b/backend/plugin/advisor/mysql/advisor_statement_merge_alter_table.go@@ -31,7 +31,7 @@ type StatementMergeAlterTableAdvisor struct {}// Check checks for merging ALTER TABLE statements.-func (*StatementMergeAlterTableAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementMergeAlterTableAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -60,8 +60,8 @@ type statementMergeAlterTableChecker struct {baseLine inttext string- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtableMap map[string]tableStatement}@@ -114,7 +114,7 @@ func (checker *statementMergeAlterTableChecker) EnterAlterTable(ctx *mysql.Alterchecker.tableMap[tableName] = table}-func (checker *statementMergeAlterTableChecker) generateAdvice() []advisor.Advice {+func (checker *statementMergeAlterTableChecker) generateAdvice() []*storepb.Advice {var tableList []tableStatementfor _, table := range checker.tableMap {tableList = append(tableList, table)@@ -125,20 +125,22 @@ func (checker *statementMergeAlterTableChecker) generateAdvice() []advisor.Advicfor _, table := range tableList {if table.count > 1 {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementRedundantAlterTable,+ Code: advisor.StatementRedundantAlterTable.Int32(),Title: checker.title,Content: fmt.Sprintf("There are %d statements to modify table `%s`", table.count, table.name),- Line: table.lastLine,+ StartPosition: &storepb.Position{+ Line: int32(table.lastLine),+ },})}}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/mysql/advisor_statement_prior_backup_check.go b/backend/plugin/advisor/mysql/advisor_statement_prior_backup_check.goindex fd89e3025e..e2760421af 100644--- a/backend/plugin/advisor/mysql/advisor_statement_prior_backup_check.go+++ b/backend/plugin/advisor/mysql/advisor_statement_prior_backup_check.go@@ -26,12 +26,12 @@ func init() {type StatementPriorBackupCheckAdvisor struct {}-func (*StatementPriorBackupCheckAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {- var adviceList []advisor.Advice+func (*StatementPriorBackupCheckAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {+ var adviceList []*storepb.Adviceif ctx.PreUpdateBackupDetail == nil || ctx.ChangeType != storepb.PlanCheckRunConfig_DML {- adviceList = append(adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ adviceList = append(adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -54,23 +54,27 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx advisor.Context, _ string) ([antlr.ParseTreeWalkerDefault.Walk(checker, stmt.Tree)if checker.IsDDL {- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: level,Title: title,Content: "Prior backup cannot deal with mixed DDL and DML statements",- Code: advisor.StatementPriorBackupCheck,- Line: stmt.BaseLine,+ Code: advisor.StatementPriorBackupCheck.Int32(),+ StartPosition: &storepb.Position{+ Line: int32(stmt.BaseLine),+ },})}}if !databaseExists(ctx.Context, ctx.Driver, extractDatabaseName(ctx.PreUpdateBackupDetail.Database)) {- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: level,Title: title,Content: fmt.Sprintf("Need database %q to do prior backup but it does not exist", ctx.PreUpdateBackupDetail.Database),- Code: advisor.DatabaseNotExists,- Line: 0,+ Code: advisor.DatabaseNotExists.Int32(),+ StartPosition: &storepb.Position{+ Line: 0,+ },})}@@ -96,18 +100,18 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx advisor.Context, _ string) ([}content = strings.TrimSuffix(content, ",")content += fmt.Sprintf(" on table `%s`.`%s`, disallow mixing different types of DML statements", table.database, table.table)- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementPriorBackupCheck,+ Code: advisor.StatementPriorBackupCheck.Int32(),Title: checker.title,Content: content,})}}if len(adviceList) == 0 {- adviceList = append(adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ adviceList = append(adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -136,8 +140,8 @@ type statementDisallowMixDMLChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringdmlStatementCount map[table]map[string]int@@ -174,12 +178,14 @@ func (c *statementDisallowMixDMLChecker) EnterUpdateStatement(ctx *mysql.UpdateSfor _, tableRefCtx := range ctx.TableReferenceList().AllTableReference() {tables, err := extractTableReference(tableRefCtx)if err != nil {- c.adviceList = append(c.adviceList, advisor.Advice{+ c.adviceList = append(c.adviceList, &storepb.Advice{Status: c.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: c.title,Content: fmt.Sprintf("Failed to extract table reference: %v", err),- Line: tableRefCtx.GetStart().GetLine() + c.baseLine,+ StartPosition: &storepb.Position{+ Line: int32(tableRefCtx.GetStart().GetLine() + c.baseLine),+ },})continue}@@ -201,12 +207,14 @@ func (c *statementDisallowMixDMLChecker) EnterDeleteStatement(ctx *mysql.DeleteSif ctx.TableRef() != nil {tables, err := extractTableRef(ctx.TableRef())if err != nil {- c.adviceList = append(c.adviceList, advisor.Advice{+ c.adviceList = append(c.adviceList, &storepb.Advice{Status: c.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: c.title,Content: fmt.Sprintf("Failed to extract table reference: %v", err),- Line: ctx.GetStart().GetLine() + c.baseLine,+ StartPosition: &storepb.Position{+ Line: int32(c.baseLine + ctx.GetStart().GetLine()),+ },})} else {allTables = append(allTables, tables...)@@ -215,12 +223,14 @@ func (c *statementDisallowMixDMLChecker) EnterDeleteStatement(ctx *mysql.DeleteSif ctx.TableReferenceList() != nil {tables, err := extractTableReferenceList(ctx.TableReferenceList())if err != nil {- c.adviceList = append(c.adviceList, advisor.Advice{+ c.adviceList = append(c.adviceList, &storepb.Advice{Status: c.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: c.title,Content: fmt.Sprintf("Failed to extract table reference: %v", err),- Line: ctx.GetStart().GetLine() + c.baseLine,+ StartPosition: &storepb.Position{+ Line: int32(c.baseLine + ctx.GetStart().GetLine()),+ },})} else {allTables = append(allTables, tables...)diff --git a/backend/plugin/advisor/mysql/advisor_statement_query_minumum_plan_level.go b/backend/plugin/advisor/mysql/advisor_statement_query_minumum_plan_level.goindex e4f8a6c66f..6ff3bf74fa 100644--- a/backend/plugin/advisor/mysql/advisor_statement_query_minumum_plan_level.go+++ b/backend/plugin/advisor/mysql/advisor_statement_query_minumum_plan_level.go@@ -27,7 +27,7 @@ func init() {type StatementQueryMinumumPlanLevelAdvisor struct {}-func (*StatementQueryMinumumPlanLevelAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementQueryMinumumPlanLevelAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -58,9 +58,9 @@ func (*StatementQueryMinumumPlanLevelAdvisor) Check(ctx advisor.Context, _ strin}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -72,8 +72,8 @@ type statementQueryMinumumPlanLevelChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringdriver *sql.DB@@ -146,22 +146,26 @@ func (checker *statementQueryMinumumPlanLevelChecker) EnterSelectStatement(ctx *query := ctx.GetParser().GetTokenStream().GetTextFromRuleContext(ctx)res, err := advisor.Query(checker.ctx, checker.driver, fmt.Sprintf("EXPLAIN %s", query))if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementExplainQueryFailed,+ Code: advisor.StatementExplainQueryFailed.Int32(),Title: checker.title,Content: fmt.Sprintf("Failed to explain query: %s, with error: %s", query, err),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})} else {explainTypes, err := getQueryExplainTypes(res)if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: checker.title,Content: fmt.Sprintf("Failed to check explain type column: %s, with error: %s", query, err),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})} else if len(explainTypes) > 0 {overused, overusedType := false, ExplainTypeAll@@ -173,12 +177,14 @@ func (checker *statementQueryMinumumPlanLevelChecker) EnterSelectStatement(ctx *}}if overused {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementUnwantedQueryPlanLevel,+ Code: advisor.StatementUnwantedQueryPlanLevel.Int32(),Title: checker.title,Content: fmt.Sprintf("Overused query plan level detected %s, minimum plan level: %s", overusedType.String(), checker.explainType.String()),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_statement_select_full_table_scan.go b/backend/plugin/advisor/mysql/advisor_statement_select_full_table_scan.goindex 160bce4c96..cbdc2e181f 100644--- a/backend/plugin/advisor/mysql/advisor_statement_select_full_table_scan.go+++ b/backend/plugin/advisor/mysql/advisor_statement_select_full_table_scan.go@@ -29,7 +29,7 @@ func init() {type StatementSelectFullTableScanAdvisor struct {}-func (*StatementSelectFullTableScanAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementSelectFullTableScanAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -60,8 +60,8 @@ type statementSelectFullTableScanChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringdriver *sql.DBctx context.Context@@ -78,30 +78,36 @@ func (checker *statementSelectFullTableScanChecker) EnterSelectStatement(ctx *myquery := ctx.GetParser().GetTokenStream().GetTextFromRuleContext(ctx)res, err := advisor.Query(checker.ctx, checker.driver, fmt.Sprintf("EXPLAIN %s", query))if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementCheckSelectFullTableScanFailed,+ Code: advisor.StatementCheckSelectFullTableScanFailed.Int32(),Title: checker.title,Content: fmt.Sprintf("Failed to check full table scan: %s, with error: %s", query, err),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})} else {hasFullScan, tables, err := hasTableFullScan(res)if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: checker.title,Content: fmt.Sprintf("Failed to check full table scan: %s, with error: %s", query, err),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})} else if hasFullScan {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementHasTableFullScan,+ Code: advisor.StatementHasTableFullScan.Int32(),Title: checker.title,Content: fmt.Sprintf("Full table scan detected on table(s): %s", tables),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_statement_where_disallow_using_function.go b/backend/plugin/advisor/mysql/advisor_statement_where_disallow_using_function.goindex fbdb087638..d0fac9f4e6 100644--- a/backend/plugin/advisor/mysql/advisor_statement_where_disallow_using_function.go+++ b/backend/plugin/advisor/mysql/advisor_statement_where_disallow_using_function.go@@ -24,7 +24,7 @@ func init() {type StatementWhereDisallowUsingFunctionAdvisor struct {}-func (*StatementWhereDisallowUsingFunctionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementWhereDisallowUsingFunctionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -45,9 +45,9 @@ func (*StatementWhereDisallowUsingFunctionAdvisor) Check(ctx advisor.Context, _}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -59,8 +59,8 @@ type statementWhereDisallowUsingFunctionChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringisSelect bool@@ -94,12 +94,14 @@ func (checker *statementWhereDisallowUsingFunctionChecker) EnterFunctionCall(ctxpi := ctx.PureIdentifier()if pi != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DisabledFunction,+ Code: advisor.DisabledFunction.Int32(),Title: checker.title,Content: fmt.Sprintf("Function is disallowed in where clause, but \"%s\" uses", checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_statement_where_maximum_logical_operator_count.go b/backend/plugin/advisor/mysql/advisor_statement_where_maximum_logical_operator_count.goindex 8ebef63a61..db2bc66666 100644--- a/backend/plugin/advisor/mysql/advisor_statement_where_maximum_logical_operator_count.go+++ b/backend/plugin/advisor/mysql/advisor_statement_where_maximum_logical_operator_count.go@@ -24,7 +24,7 @@ func init() {type StatementWhereMaximumLogicalOperatorCountAdvisor struct {}-func (*StatementWhereMaximumLogicalOperatorCountAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementWhereMaximumLogicalOperatorCountAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -49,20 +49,22 @@ func (*StatementWhereMaximumLogicalOperatorCountAdvisor) Check(ctx advisor.Contechecker.reported = falseantlr.ParseTreeWalkerDefault.Walk(checker, stmt.Tree)if checker.maxOrCount > checker.maximum {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementWhereMaximumLogicalOperatorCount,+ Code: advisor.StatementWhereMaximumLogicalOperatorCount.Int32(),Title: checker.title,Content: fmt.Sprintf("Number of tokens (%d) in the OR predicate operation exceeds limit (%d) in statement %q.", checker.maxOrCount, checker.maximum, checker.text),- Line: checker.maxOrCountLine,+ StartPosition: &storepb.Position{+ Line: int32(checker.maxOrCountLine),+ },})}}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -74,8 +76,8 @@ type statementWhereMaximumLogicalOperatorCountChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringmaximum int@@ -108,12 +110,14 @@ func (checker *statementWhereMaximumLogicalOperatorCountChecker) EnterExprList(ccount := len(ctx.AllExpr())if count > checker.maximum {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementWhereMaximumLogicalOperatorCount,+ Code: advisor.StatementWhereMaximumLogicalOperatorCount.Int32(),Title: checker.title,Content: fmt.Sprintf("Number of tokens (%d) in IN predicate operation exceeds limit (%d) in statement %q.", count, checker.maximum, checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_statement_where_no_equal_null.go b/backend/plugin/advisor/mysql/advisor_statement_where_no_equal_null.goindex b5ca7aab36..c695856b60 100644--- a/backend/plugin/advisor/mysql/advisor_statement_where_no_equal_null.go+++ b/backend/plugin/advisor/mysql/advisor_statement_where_no_equal_null.go@@ -24,7 +24,7 @@ func init() {type StatementWhereNoEqualNullAdvisor struct {}-func (*StatementWhereNoEqualNullAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementWhereNoEqualNullAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -45,9 +45,9 @@ func (*StatementWhereNoEqualNullAdvisor) Check(ctx advisor.Context, _ string) ([}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -59,8 +59,8 @@ type statementWhereNoEqualNullChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringisSelect bool@@ -89,12 +89,14 @@ func (checker *statementWhereNoEqualNullChecker) EnterPrimaryExprCompare(ctx *myreturn}if ctx.Predicate() != nil && ctx.Predicate().GetText() == "NULL" {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementWhereNoEqualNull,+ Code: advisor.StatementWhereNoEqualNull.Int32(),Title: checker.title,Content: fmt.Sprintf("WHERE clause contains equal null: %s", checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_stmt_disallow_commit.go b/backend/plugin/advisor/mysql/advisor_stmt_disallow_commit.goindex 6c43def121..5380bd882f 100644--- a/backend/plugin/advisor/mysql/advisor_stmt_disallow_commit.go+++ b/backend/plugin/advisor/mysql/advisor_stmt_disallow_commit.go@@ -29,7 +29,7 @@ type StatementDisallowCommitAdvisor struct {}// Check checks for index type no blob.-func (*StatementDisallowCommitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementDisallowCommitAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -50,9 +50,9 @@ func (*StatementDisallowCommitAdvisor) Check(ctx advisor.Context, _ string) ([]a}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -64,8 +64,8 @@ type statementDisallowCommitChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext string}@@ -83,11 +83,13 @@ func (checker *statementDisallowCommitChecker) EnterTransactionStatement(ctx *myreturn}- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementDisallowCommit,+ Code: advisor.StatementDisallowCommit.Int32(),Title: checker.title,Content: fmt.Sprintf("Commit is not allowed, related statement: \"%s\"", checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}diff --git a/backend/plugin/advisor/mysql/advisor_stmt_disallow_limit.go b/backend/plugin/advisor/mysql/advisor_stmt_disallow_limit.goindex 0b432d83d4..31b7d15abc 100644--- a/backend/plugin/advisor/mysql/advisor_stmt_disallow_limit.go+++ b/backend/plugin/advisor/mysql/advisor_stmt_disallow_limit.go@@ -29,7 +29,7 @@ type StatementDisallowLimitAdvisor struct {}// Check checks for no LIMIT clause in INSERT/UPDATE statement.-func (*StatementDisallowLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementDisallowLimitAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -50,9 +50,9 @@ func (*StatementDisallowLimitAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,8 +65,8 @@ type statementDisallowLimitChecker struct {baseLine intisInsertStmt bool- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -111,11 +111,13 @@ func (checker *statementDisallowLimitChecker) EnterQueryExpression(ctx *mysql.Qu}func (checker *statementDisallowLimitChecker) handleLimitClause(code advisor.Code, lineNumber int) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but \"%s\" uses", checker.text),- Line: checker.line + lineNumber,+ StartPosition: &storepb.Position{+ Line: int32(checker.line + lineNumber),+ },})}diff --git a/backend/plugin/advisor/mysql/advisor_stmt_disallow_order_by.go b/backend/plugin/advisor/mysql/advisor_stmt_disallow_order_by.goindex 3397aa8573..7de3b80f43 100644--- a/backend/plugin/advisor/mysql/advisor_stmt_disallow_order_by.go+++ b/backend/plugin/advisor/mysql/advisor_stmt_disallow_order_by.go@@ -30,7 +30,7 @@ type DisallowOrderByAdvisor struct {}// Check checks for no ORDER BY clause in DELETE/UPDATE statements.-func (*DisallowOrderByAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*DisallowOrderByAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -51,9 +51,9 @@ func (*DisallowOrderByAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.A}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,8 +65,8 @@ type disallowOrderByChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -91,11 +91,13 @@ func (checker *disallowOrderByChecker) EnterUpdateStatement(ctx *mysql.UpdateSta}func (checker *disallowOrderByChecker) handleOrderByClause(code advisor.Code, lineNumber int) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("ORDER BY clause is forbidden in DELETE and UPDATE statements, but \"%s\" uses", checker.text),- Line: checker.line + lineNumber,+ StartPosition: &storepb.Position{+ Line: int32(checker.line + lineNumber),+ },})}diff --git a/backend/plugin/advisor/mysql/advisor_stmt_no_leading_wildcard_like.go b/backend/plugin/advisor/mysql/advisor_stmt_no_leading_wildcard_like.goindex e8c3bbe4d0..681967a7c8 100644--- a/backend/plugin/advisor/mysql/advisor_stmt_no_leading_wildcard_like.go+++ b/backend/plugin/advisor/mysql/advisor_stmt_no_leading_wildcard_like.go@@ -29,7 +29,7 @@ type NoLeadingWildcardLikeAdvisor struct {}// Check checks for no leading wildcard LIKE.-func (*NoLeadingWildcardLikeAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NoLeadingWildcardLikeAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -50,9 +50,9 @@ func (*NoLeadingWildcardLikeAdvisor) Check(ctx advisor.Context, _ string) ([]adv}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,8 +65,8 @@ type noLeadingWildcardLikeChecker struct {baseLine inttitle string- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustext string}@@ -83,12 +83,14 @@ func (checker *noLeadingWildcardLikeChecker) EnterPredicateExprLike(ctx *mysql.Pfor _, expr := range ctx.AllSimpleExpr() {pattern := expr.GetText()if (strings.HasPrefix(pattern, "'%") && strings.HasSuffix(pattern, "'")) || (strings.HasPrefix(pattern, "\"%") && strings.HasSuffix(pattern, "\"")) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementLeadingWildcardLike,+ Code: advisor.StatementLeadingWildcardLike.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" uses leading wildcard LIKE", checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_stmt_no_select_all.go b/backend/plugin/advisor/mysql/advisor_stmt_no_select_all.goindex 9383746fea..8a3fe546a7 100644--- a/backend/plugin/advisor/mysql/advisor_stmt_no_select_all.go+++ b/backend/plugin/advisor/mysql/advisor_stmt_no_select_all.go@@ -27,7 +27,7 @@ type NoSelectAllAdvisor struct {}// Check checks for no "select *".-func (*NoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -47,9 +47,9 @@ func (*NoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advic}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -61,8 +61,8 @@ type noSelectAllChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext string}@@ -73,12 +73,14 @@ func (checker *noSelectAllChecker) EnterQuery(ctx *mysql.QueryContext) {func (checker *noSelectAllChecker) EnterSelectItemList(ctx *mysql.SelectItemListContext) {if ctx.MULT_OPERATOR() != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementSelectAll,+ Code: advisor.StatementSelectAll.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" uses SELECT all", checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_stmt_where_required.go b/backend/plugin/advisor/mysql/advisor_stmt_where_required.goindex 073a578ab3..b57356ec9d 100644--- a/backend/plugin/advisor/mysql/advisor_stmt_where_required.go+++ b/backend/plugin/advisor/mysql/advisor_stmt_where_required.go@@ -27,7 +27,7 @@ type WhereRequirementAdvisor struct {}// Check checks for the WHERE clause requirement.-func (*WhereRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*WhereRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -47,9 +47,9 @@ func (*WhereRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -61,8 +61,8 @@ type whereRequirementChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext string}@@ -102,11 +102,13 @@ func (checker *whereRequirementChecker) EnterQuerySpecification(ctx *mysql.Query}func (checker *whereRequirementChecker) handleWhereClause(lineNumber int) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementNoWhere,+ Code: advisor.StatementNoWhere.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" requires WHERE clause", checker.text),- Line: checker.baseLine + lineNumber,+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + lineNumber),+ },})}diff --git a/backend/plugin/advisor/mysql/advisor_table_comment_convention.go b/backend/plugin/advisor/mysql/advisor_table_comment_convention.goindex 77a35f5860..a8e5a0bdf9 100644--- a/backend/plugin/advisor/mysql/advisor_table_comment_convention.go+++ b/backend/plugin/advisor/mysql/advisor_table_comment_convention.go@@ -27,7 +27,7 @@ type TableCommentConventionAdvisor struct {}// Check checks for table comment convention.-func (*TableCommentConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableCommentConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {list, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -55,9 +55,9 @@ func (*TableCommentConventionAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -69,8 +69,8 @@ type tableCommentConventionChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringrequired boolmaxLength int@@ -90,21 +90,25 @@ func (checker *tableCommentConventionChecker) EnterCreateTable(ctx *mysql.Createcomment, exists := checker.handleCreateTableOptions(ctx.CreateTableOptions())if checker.required && !exists {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NoTableComment,+ Code: advisor.NoTableComment.Int32(),Title: checker.title,Content: fmt.Sprintf("Table `%s` requires comments", tableName),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}if checker.maxLength >= 0 && len(comment) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.TableCommentTooLong,+ Code: advisor.TableCommentTooLong.Int32(),Title: checker.title,Content: fmt.Sprintf("The length of table `%s` comment should be within %d characters", tableName, checker.maxLength),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_table_disallow_partition.go b/backend/plugin/advisor/mysql/advisor_table_disallow_partition.goindex ce4a0c3c5c..e46ae59a39 100644--- a/backend/plugin/advisor/mysql/advisor_table_disallow_partition.go+++ b/backend/plugin/advisor/mysql/advisor_table_disallow_partition.go@@ -28,7 +28,7 @@ type TableDisallowPartitionAdvisor struct {}// Check checks for disallow table partition.-func (*TableDisallowPartitionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableDisallowPartitionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -49,9 +49,9 @@ func (*TableDisallowPartitionAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -63,8 +63,8 @@ type tableDisallowPartitionChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext string}@@ -84,12 +84,14 @@ func (checker *tableDisallowPartitionChecker) EnterCreateTable(ctx *mysql.Create}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("Table partition is forbidden, but \"%s\" creates", checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}@@ -104,12 +106,14 @@ func (checker *tableDisallowPartitionChecker) EnterAlterTable(ctx *mysql.AlterTacode = advisor.CreateTablePartition}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("Table partition is forbidden, but \"%s\" creates", checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_table_disallow_set_charset.go b/backend/plugin/advisor/mysql/advisor_table_disallow_set_charset.goindex 176b17598e..198ac8b435 100644--- a/backend/plugin/advisor/mysql/advisor_table_disallow_set_charset.go+++ b/backend/plugin/advisor/mysql/advisor_table_disallow_set_charset.go@@ -24,7 +24,7 @@ func init() {type TableDisallowSetCharsetAdvisor struct {}-func (*TableDisallowSetCharsetAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableDisallowSetCharsetAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -45,9 +45,9 @@ func (*TableDisallowSetCharsetAdvisor) Check(ctx advisor.Context, _ string) ([]a}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -59,8 +59,8 @@ type tableDisallowSetCharsetChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext string}@@ -76,12 +76,14 @@ func (checker *tableDisallowSetCharsetChecker) EnterCreateTable(ctx *mysql.Creatif ctx.CreateTableOptions() != nil {for _, option := range ctx.CreateTableOptions().AllCreateTableOption() {if option.DefaultCharset() != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DisallowSetCharset,+ Code: advisor.DisallowSetCharset.Int32(),Title: checker.title,Content: fmt.Sprintf("Set charset on tables is disallowed, but \"%s\" uses", checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}@@ -106,12 +108,14 @@ func (checker *tableDisallowSetCharsetChecker) EnterAlterTable(ctx *mysql.AlterT}if alterListItem.Charset() != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DisallowSetCharset,+ Code: advisor.DisallowSetCharset.Int32(),Title: checker.title,Content: fmt.Sprintf("Set charset on tables is disallowed, but \"%s\" uses", checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_table_disallow_trigger.go b/backend/plugin/advisor/mysql/advisor_table_disallow_trigger.goindex c549152024..bc3d5b6878 100644--- a/backend/plugin/advisor/mysql/advisor_table_disallow_trigger.go+++ b/backend/plugin/advisor/mysql/advisor_table_disallow_trigger.go@@ -26,7 +26,7 @@ type TableDisallowTriggerAdvisor struct {}// Check checks for disallow table trigger.-func (*TableDisallowTriggerAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableDisallowTriggerAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -47,9 +47,9 @@ func (*TableDisallowTriggerAdvisor) Check(ctx advisor.Context, _ string) ([]advi}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -61,8 +61,8 @@ type tableDisallowTriggerChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext string}@@ -82,12 +82,14 @@ func (checker *tableDisallowTriggerChecker) EnterCreateTrigger(ctx *mysql.Create}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("Trigger is forbidden, but \"%s\" creates", checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_table_drop_naming_convention.go b/backend/plugin/advisor/mysql/advisor_table_drop_naming_convention.goindex 9b92c99cb4..84224ee07b 100644--- a/backend/plugin/advisor/mysql/advisor_table_drop_naming_convention.go+++ b/backend/plugin/advisor/mysql/advisor_table_drop_naming_convention.go@@ -28,7 +28,7 @@ type TableDropNamingConventionAdvisor struct {}// Check checks for drop table naming convention.-func (*TableDropNamingConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableDropNamingConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {list, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -54,9 +54,9 @@ func (*TableDropNamingConventionAdvisor) Check(ctx advisor.Context, _ string) ([}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -68,8 +68,8 @@ type namingDropTableConventionChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat *regexp.Regexp}@@ -86,12 +86,14 @@ func (checker *namingDropTableConventionChecker) EnterDropTable(ctx *mysql.DropTfor _, tableRef := range ctx.TableRefList().AllTableRef() {_, tableName := mysqlparser.NormalizeMySQLTableRef(tableRef)if !checker.format.MatchString(tableName) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.TableDropNamingConventionMismatch,+ Code: advisor.TableDropNamingConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("`%s` mismatches drop table naming convention, naming format should be %q", tableName, checker.format),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_table_limit_size.go b/backend/plugin/advisor/mysql/advisor_table_limit_size.goindex 1338acafad..d8beb21bf3 100644--- a/backend/plugin/advisor/mysql/advisor_table_limit_size.go+++ b/backend/plugin/advisor/mysql/advisor_table_limit_size.go@@ -9,13 +9,13 @@ import (mysql "github.com/bytebase/mysql-parser"mysqlparser "github.com/bytebase/bytebase/backend/plugin/parser/mysql"- "github.com/bytebase/bytebase/proto/generated-go/store"+ storepb "github.com/bytebase/bytebase/proto/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor")func init() {- advisor.Register(store.Engine_MYSQL, advisor.MySQLTableLimitSize, &MaximumTableSizeAdvisor{})+ advisor.Register(storepb.Engine_MYSQL, advisor.MySQLTableLimitSize, &MaximumTableSizeAdvisor{})}type MaximumTableSizeAdvisor struct {@@ -32,13 +32,13 @@ var ()// If table size > xx bytes, then warning/error.-func (*MaximumTableSizeAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {- var adviceList []advisor.Advice+func (*MaximumTableSizeAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {+ var adviceList []*storepb.Advice- if ctx.ChangeType != store.PlanCheckRunConfig_DDL && ctx.ChangeType != store.PlanCheckRunConfig_CHANGE_DATABASE_TYPE_UNSPECIFIED {- return []advisor.Advice{{- Status: advisor.Success,- Code: advisor.Ok,+ if ctx.ChangeType != storepb.PlanCheckRunConfig_DDL && ctx.ChangeType != storepb.PlanCheckRunConfig_CHANGE_DATABASE_TYPE_UNSPECIFIED {+ return []*storepb.Advice{{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",}}, nil@@ -74,12 +74,14 @@ func (*MaximumTableSizeAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.for _, tabName := range tableSizeChecker.affectedTabNames {tableRows := getTabRowsByName(tabName, ctx.DBSchema.Schemas[0].Tables)if tableRows >= int64(payload.Number) {- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: status,- Code: advisor.TableExceedLimitSize,+ Code: advisor.TableExceedLimitSize.Int32(),Title: ctx.Rule.Type,Content: fmt.Sprintf("Apply DDL on large table '%s' ( %d rows ) will lock table for a long time", tabName, tableRows),- Line: statementBaseLine + tableSizeChecker.baseLine,+ StartPosition: &storepb.Position{+ Line: int32(statementBaseLine + tableSizeChecker.baseLine),+ },})}}@@ -88,9 +90,9 @@ func (*MaximumTableSizeAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.}if len(adviceList) == 0 {- return []advisor.Advice{{- Status: advisor.Success,- Code: advisor.Ok,+ return []*storepb.Advice{{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",}}, nil@@ -118,7 +120,7 @@ func (checker *MaximumTableSizeChecker) EnterDropTable(ctx *mysql.DropTableConte}}-func getTabRowsByName(targetTabName string, tables []*store.TableMetadata) int64 {+func getTabRowsByName(targetTabName string, tables []*storepb.TableMetadata) int64 {for _, table := range tables {if table.Name == targetTabName {return table.RowCountdiff --git a/backend/plugin/advisor/mysql/advisor_table_no_duplicate_index.go b/backend/plugin/advisor/mysql/advisor_table_no_duplicate_index.goindex 1104a29fb2..ea4f08d378 100644--- a/backend/plugin/advisor/mysql/advisor_table_no_duplicate_index.go+++ b/backend/plugin/advisor/mysql/advisor_table_no_duplicate_index.go@@ -29,7 +29,7 @@ type TableNoDuplicateIndexAdvisor struct {}// Check checks for no duplicate index in table.-func (*TableNoDuplicateIndexAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableNoDuplicateIndexAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -51,9 +51,9 @@ func (*TableNoDuplicateIndexAdvisor) Check(ctx advisor.Context, _ string) ([]adv}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,8 +65,8 @@ type tableNoDuplicateIndexChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringindexList []duplicateIndex}@@ -105,12 +105,14 @@ func (checker *tableNoDuplicateIndexChecker) EnterCreateTable(ctx *mysql.CreateT}// Check for duplicate index.if index := hasDuplicateIndexes(checker.indexList); index != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DuplicateIndexInTable,+ Code: advisor.DuplicateIndexInTable.Int32(),Title: checker.title,Content: fmt.Sprintf("`%s` has duplicate index `%s`", tableName, index.indexName),- Line: index.line,+ StartPosition: &storepb.Position{+ Line: int32(index.line),+ },})}}@@ -136,12 +138,14 @@ func (checker *tableNoDuplicateIndexChecker) EnterAlterTable(ctx *mysql.AlterTab}}if index := hasDuplicateIndexes(checker.indexList); index != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DuplicateIndexInTable,+ Code: advisor.DuplicateIndexInTable.Int32(),Title: checker.title,Content: fmt.Sprintf("`%s` has duplicate index `%s`", tableName, index.indexName),- Line: index.line,+ StartPosition: &storepb.Position{+ Line: int32(index.line),+ },})}}@@ -218,12 +222,14 @@ func (checker *tableNoDuplicateIndexChecker) EnterCreateIndex(ctx *mysql.CreateIindex.columns = mysqlparser.NormalizeKeyListVariants(ctx.CreateIndexTarget().KeyListVariants())checker.indexList = append(checker.indexList, index)if index := hasDuplicateIndexes(checker.indexList); index != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DuplicateIndexInTable,+ Code: advisor.DuplicateIndexInTable.Int32(),Title: checker.title,Content: fmt.Sprintf("`%s` has duplicate index `%s`", tableName, index.indexName),- Line: index.line,+ StartPosition: &storepb.Position{+ Line: int32(index.line),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_table_no_fk.go b/backend/plugin/advisor/mysql/advisor_table_no_fk.goindex c43b5af557..cdefb671a5 100644--- a/backend/plugin/advisor/mysql/advisor_table_no_fk.go+++ b/backend/plugin/advisor/mysql/advisor_table_no_fk.go@@ -29,7 +29,7 @@ type TableNoFKAdvisor struct {}// Check checks table disallow foreign key.-func (*TableNoFKAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableNoFKAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -49,9 +49,9 @@ func (*TableNoFKAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice,}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -64,8 +64,8 @@ type tableNoFKChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle string}@@ -118,12 +118,14 @@ func (checker *tableNoFKChecker) handleTableConstraintDef(tableName string, ctxif ctx.GetType_() != nil {switch strings.ToUpper(ctx.GetType_().GetText()) {case "FOREIGN":- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.TableHasFK,+ Code: advisor.TableHasFK.Int32(),Title: checker.title,Content: fmt.Sprintf("Foreign key is not allowed in the table `%s`", tableName),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})default:}diff --git a/backend/plugin/advisor/mysql/advisor_table_require_pk.go b/backend/plugin/advisor/mysql/advisor_table_require_pk.goindex 9688b5c812..74afd3e7b4 100644--- a/backend/plugin/advisor/mysql/advisor_table_require_pk.go+++ b/backend/plugin/advisor/mysql/advisor_table_require_pk.go@@ -34,7 +34,7 @@ type TableRequirePKAdvisor struct {}// Check checks table requires PK.-func (*TableRequirePKAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableRequirePKAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -64,8 +64,8 @@ type tableRequirePKChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtables tablePKline map[string]int@@ -196,24 +196,26 @@ func (checker *tableRequirePKChecker) EnterAlterTable(ctx *mysql.AlterTableConte}}-func (checker *tableRequirePKChecker) generateAdviceList() []advisor.Advice {+func (checker *tableRequirePKChecker) generateAdviceList() []*storepb.Advice {tableList := checker.tables.tableList()for _, tableName := range tableList {if len(checker.tables[tableName]) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.TableNoPK,+ Code: advisor.TableNoPK.Int32(),Title: checker.title,Content: fmt.Sprintf("Table `%s` requires PRIMARY KEY", tableName),- Line: checker.line[tableName],+ StartPosition: &storepb.Position{+ Line: int32(checker.line[tableName]),+ },})}}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/mysql/advisor_table_text_fields_total_length.go b/backend/plugin/advisor/mysql/advisor_table_text_fields_total_length.goindex ef73d0bc73..07131ee452 100644--- a/backend/plugin/advisor/mysql/advisor_table_text_fields_total_length.go+++ b/backend/plugin/advisor/mysql/advisor_table_text_fields_total_length.go@@ -28,7 +28,7 @@ func init() {type TableMaximumVarcharLengthAdvisor struct {}-func (*TableMaximumVarcharLengthAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableMaximumVarcharLengthAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parse result")@@ -55,9 +55,9 @@ func (*TableMaximumVarcharLengthAdvisor) Check(ctx advisor.Context, _ string) ([}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -69,8 +69,8 @@ type tableFieldsMaximumVarcharLengthChecker struct {*mysql.BaseMySQLParserListenercatalog *catalog.Finder- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringbaseLine intmaximum int@@ -94,12 +94,14 @@ func (checker *tableFieldsMaximumVarcharLengthChecker) EnterCreateTable(ctx *mys}total := getTotalTextLength(tableInfo)if total > int64(checker.maximum) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.IndexCountExceedsLimit,+ Code: advisor.IndexCountExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("Table %q total text column length (%d) exceeds the limit (%d).", tableName, total, checker.maximum),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}@@ -128,12 +130,14 @@ func (checker *tableFieldsMaximumVarcharLengthChecker) EnterAlterTable(ctx *mysq}total := getTotalTextLength(tableInfo)if total > int64(checker.maximum) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.TotalTextLengthExceedsLimit,+ Code: advisor.TotalTextLengthExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("Table %q total text column length (%d) exceeds the limit (%d).", tableName, total, checker.maximum),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/advisor_use_innodb.go b/backend/plugin/advisor/mysql/advisor_use_innodb.goindex b8d6d3c9e0..286e579336 100644--- a/backend/plugin/advisor/mysql/advisor_use_innodb.go+++ b/backend/plugin/advisor/mysql/advisor_use_innodb.go@@ -31,7 +31,7 @@ type UseInnoDBAdvisor struct {}// Check checks for using InnoDB engine.-func (*UseInnoDBAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*UseInnoDBAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {list, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -53,9 +53,9 @@ func (*UseInnoDBAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice,}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -67,8 +67,8 @@ type useInnoDBChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle string}@@ -168,11 +168,13 @@ func (c *useInnoDBChecker) EnterSetStatement(ctx *mysql.SetStatementContext) {func (c *useInnoDBChecker) addAdvice(content string, lineNumber int) {lineNumber += c.baseLine- c.adviceList = append(c.adviceList, advisor.Advice{+ c.adviceList = append(c.adviceList, &storepb.Advice{Status: c.level,- Code: advisor.NotInnoDBEngine,+ Code: advisor.NotInnoDBEngine.Int32(),Title: c.title,Content: fmt.Sprintf("\"%s;\" doesn't use InnoDB engine", content),- Line: lineNumber,+ StartPosition: &storepb.Position{+ Line: int32(lineNumber),+ },})}diff --git a/backend/plugin/advisor/mysql/advisor_view_disallow_create.go b/backend/plugin/advisor/mysql/advisor_view_disallow_create.goindex d72fd11343..94885d31ca 100644--- a/backend/plugin/advisor/mysql/advisor_view_disallow_create.go+++ b/backend/plugin/advisor/mysql/advisor_view_disallow_create.go@@ -26,7 +26,7 @@ type ViewDisallowCreateAdvisor struct {}// Check checks for disallow creating view.-func (*ViewDisallowCreateAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ViewDisallowCreateAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -47,9 +47,9 @@ func (*ViewDisallowCreateAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -61,8 +61,8 @@ type viewDisallowCreateChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext string}@@ -81,12 +81,14 @@ func (checker *viewDisallowCreateChecker) EnterCreateView(ctx *mysql.CreateViewC}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("View is forbidden, but \"%s\" creates", checker.text),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/mysql/test/column_auto_increment_initial_value.yaml b/backend/plugin/advisor/mysql/test/column_auto_increment_initial_value.yamlindex 670c9c38f6..12b583acd6 100644--- a/backend/plugin/advisor/mysql/test/column_auto_increment_initial_value.yaml+++ b/backend/plugin/advisor/mysql/test/column_auto_increment_initial_value.yaml@@ -1,38 +1,42 @@- statement: CREATE TABLE t(a int);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a int auto_increment) auto_increment = 20;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t1(a int auto_increment) auto_increment = 20;CREATE TABLE t2(a int auto_increment) auto_increment = 2;want:- - status: WARN+ - status: 2code: 416title: column.auto-increment-initial-valuecontent: The initial auto-increment value in table `t2` is 2, which doesn't equal 20- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int auto_increment) auto_increment = 20;ALTER TABLE t COMMENT 'table t';ALTER TABLE t AUTO_INCREMENT = 20;ALTER TABLE t AUTO_INCREMENT = 100;want:- - status: WARN+ - status: 2code: 416title: column.auto-increment-initial-valuecontent: The initial auto-increment value in table `t` is 100, which doesn't equal 20- line: 4- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0diff --git a/backend/plugin/advisor/mysql/test/column_auto_increment_must_integer.yaml b/backend/plugin/advisor/mysql/test/column_auto_increment_must_integer.yamlindex a69ec37dc5..f1d093da8a 100644--- a/backend/plugin/advisor/mysql/test/column_auto_increment_must_integer.yaml+++ b/backend/plugin/advisor/mysql/test/column_auto_increment_must_integer.yaml@@ -10,70 +10,82 @@CREATE TABLE t9(a bigint AUTO_INCREMENT);CREATE TABLE t10(a BIGINT AUTO_INCREMENT);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t1(a INT AUTO_INCREMENT);CREATE TABLE t2(a varchar(255) AUTO_INCREMENT);want:- - status: WARN+ - status: 2code: 410title: column.auto-increment-must-integercontent: Auto-increment column `t2`.`a` requires integer type- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(b int);ALTER TABLE t ADD COLUMN a varchar(255) AUTO_INCREMENT;want:- - status: WARN+ - status: 2code: 410title: column.auto-increment-must-integercontent: Auto-increment column `t`.`a` requires integer type- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(b int);ALTER TABLE t ADD COLUMN a varchar(255) AUTO_INCREMENT, ADD COLUMN c INT;want:- - status: WARN+ - status: 2code: 410title: column.auto-increment-must-integercontent: Auto-increment column `t`.`a` requires integer type- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(b int);ALTER TABLE t ADD COLUMN (a varchar(255) AUTO_INCREMENT, c INT);want:- - status: WARN+ - status: 2code: 410title: column.auto-increment-must-integercontent: Auto-increment column `t`.`a` requires integer type- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int, b int);ALTER TABLE t MODIFY COLUMN a varchar(255) AUTO_INCREMENT;ALTER TABLE t MODIFY COLUMN b varchar(255);want:- - status: WARN+ - status: 2code: 410title: column.auto-increment-must-integercontent: Auto-increment column `t`.`a` requires integer type- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(b int);ALTER TABLE t CHANGE COLUMN b a varchar(255) AUTO_INCREMENT;want:- - status: WARN+ - status: 2code: 410title: column.auto-increment-must-integercontent: Auto-increment column `t`.`a` requires integer type- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mysql/test/column_auto_increment_must_unsigned.yaml b/backend/plugin/advisor/mysql/test/column_auto_increment_must_unsigned.yamlindex 7902405aff..49286f54bc 100644--- a/backend/plugin/advisor/mysql/test/column_auto_increment_must_unsigned.yaml+++ b/backend/plugin/advisor/mysql/test/column_auto_increment_must_unsigned.yaml@@ -1,64 +1,74 @@- statement: CREATE TABLE t(a INT UNSIGNED AUTO_INCREMENT);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a INT AUTO_INCREMENT);want:- - status: WARN+ - status: 2code: 417title: column.auto-increment-must-unsignedcontent: Auto-increment column `t`.`a` is not UNSIGNED type- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(a INT SIGNED AUTO_INCREMENT);want:- - status: WARN+ - status: 2code: 417title: column.auto-increment-must-unsignedcontent: Auto-increment column `t`.`a` is not UNSIGNED type- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(a INT ZEROFILL AUTO_INCREMENT);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(b int);ALTER TABLE t ADD COLUMN a INT AUTO_INCREMENT, ADD COLUMN c INT ZEROFILL AUTO_INCREMENT, ADD COLUMN d INT UNSIGNED AUTO_INCREMENT;want:- - status: WARN+ - status: 2code: 417title: column.auto-increment-must-unsignedcontent: Auto-increment column `t`.`a` is not UNSIGNED type- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int, b int);ALTER TABLE t MODIFY COLUMN a INT AUTO_INCREMENT;ALTER TABLE t MODIFY COLUMN a INT UNSIGNED AUTO_INCREMENT;want:- - status: WARN+ - status: 2code: 417title: column.auto-increment-must-unsignedcontent: Auto-increment column `t`.`a` is not UNSIGNED type- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(b int);ALTER TABLE t CHANGE COLUMN b a INT AUTO_INCREMENT;ALTER TABLE t CHANGE COLUMN a c INT UNSIGNED AUTO_INCREMENT;want:- - status: WARN+ - status: 2code: 417title: column.auto-increment-must-unsignedcontent: Auto-increment column `t`.`a` is not UNSIGNED type- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mysql/test/column_comment.yaml b/backend/plugin/advisor/mysql/test/column_comment.yamlindex 3c59a0aa38..6a582f03cd 100644--- a/backend/plugin/advisor/mysql/test/column_comment.yaml+++ b/backend/plugin/advisor/mysql/test/column_comment.yaml@@ -12,24 +12,30 @@FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin;want:- - status: WARN+ - status: 2code: 408title: column.commentcontent: Column `userTable`.`id` requires comments- line: 2- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 408title: column.commentcontent: Column `userTable`.`name` requires comments- line: 3- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 408title: column.commentcontent: Column `userTable`.`roomId` requires comments- line: 4- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0- statement: |CREATE TABLE user(id INT PRIMARY KEY COMMENT 'comment',@@ -43,20 +49,20 @@UNIQUE KEY uk_user_id_name(id, name)) ENGINE = INNODB COMMENT 'comment';want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a int COMMENT 'comments');want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int COMMENT 'some comments',@@ -64,95 +70,119 @@c int);want:- - status: WARN+ - status: 2code: 409title: column.commentcontent: The length of column `t`.`a` comment should be within 10 characters- line: 2- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 408title: column.commentcontent: Column `t`.`b` requires comments- line: 3- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 408title: column.commentcontent: Column `t`.`c` requires comments- line: 4- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0- statement: |-CREATE TABLE t(a int COMMENT 'comment');ALTER TABLE t ADD COLUMN b int;want:- - status: WARN+ - status: 2code: 408title: column.commentcontent: Column `t`.`b` requires comments- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int COMMENT 'comment');ALTER TABLE t ADD COLUMN (b int, c int);want:- - status: WARN+ - status: 2code: 408title: column.commentcontent: Column `t`.`b` requires comments- line: 2- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 408title: column.commentcontent: Column `t`.`c` requires comments- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int COMMENT 'this is comment');ALTER TABLE t CHANGE COLUMN a b int;want:- - status: WARN+ - status: 2code: 409title: column.commentcontent: The length of column `t`.`a` comment should be within 10 characters- line: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 408title: column.commentcontent: Column `t`.`b` requires comments- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(b int COMMENT 'It is comment');ALTER TABLE t MODIFY COLUMN b int;want:- - status: WARN+ - status: 2code: 409title: column.commentcontent: The length of column `t`.`b` comment should be within 10 characters- line: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 408title: column.commentcontent: Column `t`.`b` requires comments- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(b int COMMENT 'It is COMMENT');ALTER TABLE t MODIFY COLUMN b int COMMENT 'abcdefghiakljhakljdsfalugelkhnabsdguelkadf';want:- - status: WARN+ - status: 2code: 409title: column.commentcontent: The length of column `t`.`b` comment should be within 10 characters- line: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 409title: column.commentcontent: The length of column `t`.`b` comment should be within 10 characters- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mysql/test/column_current_time_count_limit.yaml b/backend/plugin/advisor/mysql/test/column_current_time_count_limit.yamlindex 964007036d..4e23a85da9 100644--- a/backend/plugin/advisor/mysql/test/column_current_time_count_limit.yaml+++ b/backend/plugin/advisor/mysql/test/column_current_time_count_limit.yaml@@ -12,12 +12,14 @@FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin;want:- - status: WARN+ - status: 2code: 419title: column.current-time-count-limitcontent: Table `userTable` has 2 ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than 1.- line: 6- details: ""+ detail: ""+ startposition:+ line: 6+ column: 0- statement: |CREATE TABLE user(id INT PRIMARY KEY COMMENT 'comment',@@ -31,20 +33,20 @@UNIQUE KEY uk_user_id_name(id, name)) ENGINE = INNODB COMMENT 'comment';want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a timestamp, b timestamp)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a timestamp default now(),@@ -52,31 +54,37 @@c timestamp default localtime);want:- - status: WARN+ - status: 2code: 418title: column.current-time-count-limitcontent: Table `t` has 3 DEFAULT CURRENT_TIMESTAMP() columns. The count greater than 2.- line: 4- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0- statement: |-CREATE TABLE t(a timestamp default now() on update localtime,b timestamp default current_timestamp() on update localtimestamp());want:- - status: WARN+ - status: 2code: 419title: column.current-time-count-limitcontent: Table `t` has 2 ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than 1.- line: 3- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-ALTER TABLE tech_book ADD COLUMN a timestamp default now() on update localtime;ALTER TABLE tech_book ADD COLUMN b timestamp default current_timestamp() on update localtimestamp();want:- - status: WARN+ - status: 2code: 419title: column.current-time-count-limitcontent: Table `tech_book` has 2 ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than 1.- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mysql/test/column_disallow_change.yaml b/backend/plugin/advisor/mysql/test/column_disallow_change.yamlindex ae6e3b9cd4..2a19e3b299 100644--- a/backend/plugin/advisor/mysql/test/column_disallow_change.yaml+++ b/backend/plugin/advisor/mysql/test/column_disallow_change.yaml@@ -2,20 +2,21 @@CREATE TABLE t(b int);ALTER TABLE t ADD COLUMN a int;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(b int);ALTER TABLE t CHANGE COLUMN b a int;want:- - status: WARN+ - status: 2code: 406title: column.disallow-change- content: |-- "ALTER TABLE t CHANGE COLUMN b a int;" contains CHANGE COLUMN statement- line: 2- details: ""+ content: '"ALTER TABLE t CHANGE COLUMN b a int;" contains CHANGE COLUMN statement'+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mysql/test/column_disallow_change_type.yaml b/backend/plugin/advisor/mysql/test/column_disallow_change_type.yamlindex e3fa0bd32b..bde0c6079c 100644--- a/backend/plugin/advisor/mysql/test/column_disallow_change_type.yaml+++ b/backend/plugin/advisor/mysql/test/column_disallow_change_type.yaml@@ -4,55 +4,61 @@ALTER TABLE tech_book MODIFY id INTEGER;ALTER TABLE tech_book MODIFY id INTEGER UNSIGNED;want:- - status: WARN+ - status: 2code: 403title: column.disallow-change-type- content: |-- "ALTER TABLE tech_book MODIFY id INTEGER;" changes column type- line: 3- details: ""- - status: WARN+ content: '"ALTER TABLE tech_book MODIFY id INTEGER;" changes column type'+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 403title: column.disallow-change-type- content: |-- "ALTER TABLE tech_book MODIFY id INTEGER UNSIGNED;" changes column type- line: 4- details: ""+ content: '"ALTER TABLE tech_book MODIFY id INTEGER UNSIGNED;" changes column type'+ detail: ""+ startposition:+ line: 4+ column: 0- statement: |-ALTER TABLE tech_book MODIFY id int;ALTER TABLE tech_book MODIFY id int(4);want:- - status: WARN+ - status: 2code: 403title: column.disallow-change-type- content: |-- "ALTER TABLE tech_book MODIFY id int(4);" changes column type- line: 2- details: ""+ content: '"ALTER TABLE tech_book MODIFY id int(4);" changes column type'+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-ALTER TABLE tech_book MODIFY id bigint;ALTER TABLE tech_book MODIFY id smallint;want:- - status: WARN+ - status: 2code: 403title: column.disallow-change-type- content: |-- "ALTER TABLE tech_book MODIFY id bigint;" changes column type- line: 1- details: ""- - status: WARN+ content: '"ALTER TABLE tech_book MODIFY id bigint;" changes column type'+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 403title: column.disallow-change-type- content: |-- "ALTER TABLE tech_book MODIFY id smallint;" changes column type- line: 2- details: ""+ content: '"ALTER TABLE tech_book MODIFY id smallint;" changes column type'+ detail: ""+ startposition:+ line: 2+ column: 0- statement: ALTER TABLE tech_book CHANGE name uname varchar(20);want:- - status: WARN+ - status: 2code: 403title: column.disallow-change-type- content: |-- "ALTER TABLE tech_book CHANGE name uname varchar(20);" changes column type- line: 1- details: ""+ content: '"ALTER TABLE tech_book CHANGE name uname varchar(20);" changes column type'+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mysql/test/column_disallow_changing_order.yaml b/backend/plugin/advisor/mysql/test/column_disallow_changing_order.yamlindex 3ee6b1bc42..381febe053 100644--- a/backend/plugin/advisor/mysql/test/column_disallow_changing_order.yaml+++ b/backend/plugin/advisor/mysql/test/column_disallow_changing_order.yaml@@ -2,53 +2,57 @@CREATE TABLE t(a int);ALTER TABLE t MODIFY COLUMN a int;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int);ALTER TABLE t MODIFY COLUMN a int FIRST;want:- - status: WARN+ - status: 2code: 407title: column.disallow-changing-order- content: |-- "ALTER TABLE t MODIFY COLUMN a int FIRST;" changes column order- line: 2- details: ""+ content: '"ALTER TABLE t MODIFY COLUMN a int FIRST;" changes column order'+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(b int, a1 int);ALTER TABLE t CHANGE COLUMN a1 a int FIRST;want:- - status: WARN+ - status: 2code: 407title: column.disallow-changing-order- content: |-- "ALTER TABLE t CHANGE COLUMN a1 a int FIRST;" changes column order- line: 2- details: ""+ content: '"ALTER TABLE t CHANGE COLUMN a1 a int FIRST;" changes column order'+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int, b int);ALTER TABLE t MODIFY COLUMN a int AFTER b;want:- - status: WARN+ - status: 2code: 407title: column.disallow-changing-order- content: |-- "ALTER TABLE t MODIFY COLUMN a int AFTER b;" changes column order- line: 2- details: ""+ content: '"ALTER TABLE t MODIFY COLUMN a int AFTER b;" changes column order'+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a1 int, b int);ALTER TABLE t CHANGE COLUMN a1 a int AFTER b;want:- - status: WARN+ - status: 2code: 407title: column.disallow-changing-order- content: |-- "ALTER TABLE t CHANGE COLUMN a1 a int AFTER b;" changes column order- line: 2- details: ""+ content: '"ALTER TABLE t CHANGE COLUMN a1 a int AFTER b;" changes column order'+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mysql/test/column_disallow_drop_in_index.yaml b/backend/plugin/advisor/mysql/test/column_disallow_drop_in_index.yamlindex 5e89bfc084..e53ec71d60 100644--- a/backend/plugin/advisor/mysql/test/column_disallow_drop_in_index.yaml+++ b/backend/plugin/advisor/mysql/test/column_disallow_drop_in_index.yaml@@ -12,12 +12,12 @@FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE user(id INT PRIMARY KEY COMMENT 'comment',@@ -31,67 +31,75 @@UNIQUE KEY uk_user_id_name(id, name)) ENGINE = INNODB COMMENT 'comment';want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int, b int, INDEX idx_a(a));ALTER TABLE t DROP COLUMN b;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int, b int, INDEX idx_b(b));ALTER TABLE t DROP COLUMN b;want:- - status: WARN+ - status: 2code: 424- title: "column.disallow-drop-in-index"- content: "`t`.`b` cannot drop index column"- line: 2- details: ""+ title: column.disallow-drop-in-index+ content: '`t`.`b` cannot drop index column'+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int, c int, INDEX idx_ac(a,c));ALTER TABLE t DROP COLUMN c;want:- - status: WARN+ - status: 2code: 424- title: "column.disallow-drop-in-index"- content: "`t`.`c` cannot drop index column"- line: 2- details: ""+ title: column.disallow-drop-in-index+ content: '`t`.`c` cannot drop index column'+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int, b int, INDEX idx_a(a));CREATE TABLE y(a int, b int);ALTER TABLE y DROP COLUMN a;want:- - status: SUCCESS+ - status: 1code: 0- title: "OK"+ title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int,b int, c int, INDEX idx_ac(a,c));ALTER TABLE t DROP COLUMN a;ALTER TABLE t DROP COLUMN c;want:- - status: WARN+ - status: 2code: 424- title: "column.disallow-drop-in-index"- content: "`t`.`a` cannot drop index column"- line: 2- details: ""- - status: WARN+ title: column.disallow-drop-in-index+ content: '`t`.`a` cannot drop index column'+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 424- title: "column.disallow-drop-in-index"- content: "`t`.`c` cannot drop index column"- line: 3- details: ""+ title: column.disallow-drop-in-index+ content: '`t`.`c` cannot drop index column'+ detail: ""+ startposition:+ line: 3+ column: 0diff --git a/backend/plugin/advisor/mysql/test/column_disallow_set_charset.yaml b/backend/plugin/advisor/mysql/test/column_disallow_set_charset.yamlindex d8f89c0308..6996eb338a 100644--- a/backend/plugin/advisor/mysql/test/column_disallow_set_charset.yaml+++ b/backend/plugin/advisor/mysql/test/column_disallow_set_charset.yaml@@ -2,94 +2,102 @@CREATE TABLE dt_relation_temp(objto int);ALTER TABLE dt_relation_temp ADD COLUMN infos json null comment'关系信息点'AFTER`objto`;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a varchar(20));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t1(a varchar(20) CHARSET ascii);CREATE TABLE t2(a varchar(20) CHARSET ascii);want:- - status: WARN+ - status: 2code: 414title: column.disallow-set-charset- content: |-- Disallow set column charset but "CREATE TABLE t1(a varchar(20) CHARSET ascii);" does- line: 1- details: ""- - status: WARN+ content: Disallow set column charset but "CREATE TABLE t1(a varchar(20) CHARSET ascii);" does+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 414title: column.disallow-set-charset- content: |-- Disallow set column charset but "CREATE TABLE t2(a varchar(20) CHARSET ascii);" does- line: 2- details: ""+ content: Disallow set column charset but "CREATE TABLE t2(a varchar(20) CHARSET ascii);" does+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-ALTER TABLE tech_book ADD COLUMN a varchar(20);ALTER TABLE tech_book ADD COLUMN b varchar(20) CHARSET ascii;want:- - status: WARN+ - status: 2code: 414title: column.disallow-set-charset- content: |-- Disallow set column charset but "ALTER TABLE tech_book ADD COLUMN b varchar(20) CHARSET ascii;" does- line: 2- details: ""+ content: Disallow set column charset but "ALTER TABLE tech_book ADD COLUMN b varchar(20) CHARSET ascii;" does+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-ALTER TABLE tech_book ADD COLUMN a varchar(20), ADD COLUMN b varchar(20);ALTER TABLE tech_book ADD COLUMN (c varchar(20) CHARSET ascii, d varchar(20) CHARSET ascii);ALTER TABLE tech_book ADD COLUMN e varchar(20) CHARSET ascii;want:- - status: WARN+ - status: 2code: 414title: column.disallow-set-charset- content: |-- Disallow set column charset but "ALTER TABLE tech_book ADD COLUMN (c varchar(20) CHARSET ascii, d varchar(20) CHARSET ascii);" does- line: 2- details: ""- - status: WARN+ content: Disallow set column charset but "ALTER TABLE tech_book ADD COLUMN (c varchar(20) CHARSET ascii, d varchar(20) CHARSET ascii);" does+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 414title: column.disallow-set-charset- content: |-- Disallow set column charset but "ALTER TABLE tech_book ADD COLUMN (c varchar(20) CHARSET ascii, d varchar(20) CHARSET ascii);" does- line: 2- details: ""- - status: WARN+ content: Disallow set column charset but "ALTER TABLE tech_book ADD COLUMN (c varchar(20) CHARSET ascii, d varchar(20) CHARSET ascii);" does+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 414title: column.disallow-set-charset- content: |-- Disallow set column charset but "ALTER TABLE tech_book ADD COLUMN e varchar(20) CHARSET ascii;" does- line: 3- details: ""+ content: Disallow set column charset but "ALTER TABLE tech_book ADD COLUMN e varchar(20) CHARSET ascii;" does+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-ALTER TABLE tech_book MODIFY COLUMN id int;ALTER TABLE tech_book MODIFY COLUMN id varchar(20) CHARSET ascii;want:- - status: WARN+ - status: 2code: 414title: column.disallow-set-charset- content: |-- Disallow set column charset but "ALTER TABLE tech_book MODIFY COLUMN id varchar(20) CHARSET ascii;" does- line: 2- details: ""+ content: Disallow set column charset but "ALTER TABLE tech_book MODIFY COLUMN id varchar(20) CHARSET ascii;" does+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-ALTER TABLE tech_book CHANGE COLUMN name name int;ALTER TABLE tech_book CHANGE COLUMN name name varchar(20) CHARSET ascii;want:- - status: WARN+ - status: 2code: 414title: column.disallow-set-charset- content: |-- Disallow set column charset but "ALTER TABLE tech_book CHANGE COLUMN name name varchar(20) CHARSET ascii;" does- line: 2- details: ""+ content: Disallow set column charset but "ALTER TABLE tech_book CHANGE COLUMN name name varchar(20) CHARSET ascii;" does+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mysql/test/column_maximum_character_length.yaml b/backend/plugin/advisor/mysql/test/column_maximum_character_length.yamlindex 0ecf1c3bc0..236c28bab3 100644--- a/backend/plugin/advisor/mysql/test/column_maximum_character_length.yaml+++ b/backend/plugin/advisor/mysql/test/column_maximum_character_length.yaml@@ -1,64 +1,72 @@- statement: CREATE TABLE t1(name char);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(name char(20));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(name varchar(225));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t1(name char(20));CREATE TABLE t2(name char(225));want:- - status: WARN+ - status: 2code: 415title: column.maximum-character-lengthcontent: The length of the CHAR column `t2.name` is bigger than 20, please use VARCHAR instead- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-ALTER TABLE tech_book ADD COLUMN name_1 char(20);ALTER TABLE tech_book ADD COLUMN name_2 char(225);want:- - status: WARN+ - status: 2code: 415title: column.maximum-character-lengthcontent: The length of the CHAR column `tech_book.name_2` is bigger than 20, please use VARCHAR instead- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-ALTER TABLE tech_book CHANGE COLUMN name name char(20);ALTER TABLE tech_book CHANGE COLUMN name name char(225);want:- - status: WARN+ - status: 2code: 415title: column.maximum-character-lengthcontent: The length of the CHAR column `tech_book.name` is bigger than 20, please use VARCHAR instead- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-ALTER TABLE tech_book MODIFY COLUMN name char(20);ALTER TABLE tech_book MODIFY COLUMN name char(225);want:- - status: WARN+ - status: 2code: 415title: column.maximum-character-lengthcontent: The length of the CHAR column `tech_book.name` is bigger than 20, please use VARCHAR instead- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mysql/test/column_maximum_varchar_length.yaml b/backend/plugin/advisor/mysql/test/column_maximum_varchar_length.yamlindex 4bc09a2b1f..7a3611356d 100644--- a/backend/plugin/advisor/mysql/test/column_maximum_varchar_length.yaml+++ b/backend/plugin/advisor/mysql/test/column_maximum_varchar_length.yaml@@ -1,27 +1,30 @@- statement: CREATE TABLE t(name varchar(225));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""-- statement: |-- CREATE TABLE t1(name varchar(3000));+ detail: ""+ startposition: null+- statement: CREATE TABLE t1(name varchar(3000));want:- - status: WARN+ - status: 2code: 422title: column.maximum-varchar-lengthcontent: The length of the VARCHAR column `t1.name` is bigger than 2560- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-ALTER TABLE tech_book ADD COLUMN name_1 char(20);ALTER TABLE tech_book ADD COLUMN name_2 varchar(3000);want:- - status: WARN+ - status: 2code: 422title: column.maximum-varchar-lengthcontent: The length of the VARCHAR column `tech_book.name_2` is bigger than 2560- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mysql/test/column_no_null.yaml b/backend/plugin/advisor/mysql/test/column_no_null.yamlindex 7285b839eb..f202213cad 100644--- a/backend/plugin/advisor/mysql/test/column_no_null.yaml+++ b/backend/plugin/advisor/mysql/test/column_no_null.yaml@@ -4,99 +4,113 @@name varchar(255));want:- - status: WARN+ - status: 2code: 402title: column.no-null- content: "`book`.`id` cannot have NULL value"- line: 2- details: ""- - status: WARN+ content: '`book`.`id` cannot have NULL value'+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 402title: column.no-null- content: "`book`.`name` cannot have NULL value"- line: 3- details: ""+ content: '`book`.`name` cannot have NULL value'+ detail: ""+ startposition:+ line: 3+ column: 0- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255));want:- - status: WARN+ - status: 2code: 402title: column.no-null- content: "`book`.`name` cannot have NULL value"- line: 1- details: ""+ content: '`book`.`name` cannot have NULL value'+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id int NOT NULL, name varchar(255));want:- - status: WARN+ - status: 2code: 402title: column.no-null- content: "`book`.`name` cannot have NULL value"- line: 1- details: ""+ content: '`book`.`name` cannot have NULL value'+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255) NOT NULL);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(a int NOT NULL);ALTER TABLE book ADD COLUMN (id int, name varchar(255) NOT NULL);want:- - status: WARN+ - status: 2code: 402title: column.no-null- content: "`book`.`id` cannot have NULL value"- line: 2- details: ""+ content: '`book`.`id` cannot have NULL value'+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE book(a int NOT NULL);ALTER TABLE book ADD COLUMN id int, ADD COLUMN name varchar(255) NOT NULL;want:- - status: WARN+ - status: 2code: 402title: column.no-null- content: "`book`.`id` cannot have NULL value"- line: 2- details: ""+ content: '`book`.`id` cannot have NULL value'+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE book(a int NOT NULL);ALTER TABLE book ADD COLUMN (id int PRIMARY KEY, name varchar(255) NOT NULL);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(a int NOT NULL);ALTER TABLE book ADD COLUMN id int PRIMARY KEY, ADD COLUMN name varchar(255) NOT NULL;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int NOT NULL);ALTER TABLE book CHANGE COLUMN id name varchar(255);want:- - status: WARN+ - status: 2code: 402title: column.no-null- content: "`book`.`name` cannot have NULL value"- line: 2- details: ""+ content: '`book`.`name` cannot have NULL value'+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE book(id int NOT NULL);ALTER TABLE book CHANGE COLUMN id name varchar(255) NOT NULL;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/test/column_require_default.yaml b/backend/plugin/advisor/mysql/test/column_require_default.yamlindex 25a90de542..3a7b72c43f 100644--- a/backend/plugin/advisor/mysql/test/column_require_default.yaml+++ b/backend/plugin/advisor/mysql/test/column_require_default.yaml@@ -8,12 +8,12 @@f geometry);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a geometry,@@ -26,12 +26,12 @@h geometrycollection);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t1(a int primary key@@ -40,71 +40,79 @@a int auto_increment primary key);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int,b int default 1)want:- - status: WARN+ - status: 2code: 420title: column.require-defaultcontent: Column `t`.`a` doesn't have DEFAULT.- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-ALTER TABLE tech_book ADD COLUMN a BLOB;ALTER TABLE tech_book ADD COLUMN b timestamp;ALTER TABLE tech_book MODIFY COLUMN a varchar(220);want:- - status: WARN+ - status: 2code: 420title: column.require-defaultcontent: Column `tech_book`.`b` doesn't have DEFAULT.- line: 2- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 420title: column.require-defaultcontent: Column `tech_book`.`a` doesn't have DEFAULT.- line: 3- details: ""-- statement: |-- ALTER TABLE tech_book ADD COLUMN (a BLOB, b timestamp);+ detail: ""+ startposition:+ line: 3+ column: 0+- statement: ALTER TABLE tech_book ADD COLUMN (a BLOB, b timestamp);want:- - status: WARN+ - status: 2code: 420title: column.require-defaultcontent: Column `tech_book`.`b` doesn't have DEFAULT.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-ALTER TABLE tech_book ADD COLUMN a VARCHAR(255) DEFAULT 'default value';ALTER TABLE tech_book MODIFY COLUMN a char(25) DEFAULT 'default';ALTER TABLE tech_book CHANGE COLUMN a b int;want:- - status: WARN+ - status: 2code: 420title: column.require-defaultcontent: Column `tech_book`.`b` doesn't have DEFAULT.- line: 3- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-CREATE TABLE t(id int,PRIMARY KEY (id))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""\ No newline at end of file+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/test/column_required.yaml b/backend/plugin/advisor/mysql/test/column_required.yamlindex 9b7e4dfcc7..b0531150f6 100644--- a/backend/plugin/advisor/mysql/test/column_required.yaml+++ b/backend/plugin/advisor/mysql/test/column_required.yaml@@ -6,36 +6,46 @@CREATE TABLE t4(id INT, creator_id INT, created_ts timestamp, updater_id INT);CREATE TABLE t5(id INT, creator_id INT, created_ts timestamp, updater_id INT, updated_ts timestamp);want:- - status: WARN+ - status: 2code: 401title: column.required- content: "Table `t1` requires columns: created_ts, creator_id, id, updated_ts, updater_id"- line: 1- details: ""- - status: WARN+ content: 'Table `t1` requires columns: created_ts, creator_id, id, updated_ts, updater_id'+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 401title: column.required- content: "Table `book` requires columns: created_ts, creator_id, updated_ts, updater_id"- line: 2- details: ""- - status: WARN+ content: 'Table `book` requires columns: created_ts, creator_id, updated_ts, updater_id'+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 401title: column.required- content: "Table `t2` requires columns: created_ts, updated_ts, updater_id"- line: 3- details: ""- - status: WARN+ content: 'Table `t2` requires columns: created_ts, updated_ts, updater_id'+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 401title: column.required- content: "Table `t3` requires columns: updated_ts, updater_id"- line: 4- details: ""- - status: WARN+ content: 'Table `t3` requires columns: updated_ts, updater_id'+ detail: ""+ startposition:+ line: 4+ column: 0+ - status: 2code: 401title: column.required- content: "Table `t4` requires columns: updated_ts"- line: 5- details: ""+ content: 'Table `t4` requires columns: updated_ts'+ detail: ""+ startposition:+ line: 5+ column: 0- statement: |-CREATE TABLE book(id int,@@ -45,12 +55,12 @@updated_ts timestamp);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int,@@ -61,12 +71,14 @@);ALTER TABLE book RENAME COLUMN creator_id TO creator;want:- - status: WARN+ - status: 2code: 401title: column.required- content: "Table `book` requires columns: creator_id"- line: 8- details: ""+ content: 'Table `book` requires columns: creator_id'+ detail: ""+ startposition:+ line: 8+ column: 0- statement: |-CREATE TABLE book(id int,@@ -77,12 +89,12 @@);ALTER TABLE book RENAME COLUMN creator TO creator_id;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int,@@ -93,12 +105,14 @@);ALTER TABLE book CHANGE COLUMN creator_id creator int;want:- - status: WARN+ - status: 2code: 401title: column.required- content: "Table `book` requires columns: creator_id"- line: 8- details: ""+ content: 'Table `book` requires columns: creator_id'+ detail: ""+ startposition:+ line: 8+ column: 0- statement: |-CREATE TABLE book(id int,@@ -109,12 +123,12 @@);ALTER TABLE book CHANGE COLUMN creator creator_id int;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int,@@ -125,12 +139,14 @@);ALTER TABLE book DROP COLUMN creator_id;want:- - status: WARN+ - status: 2code: 401title: column.required- content: "Table `book` requires columns: creator_id"- line: 8- details: ""+ content: 'Table `book` requires columns: creator_id'+ detail: ""+ startposition:+ line: 8+ column: 0- statement: |-CREATE TABLE book(id int,@@ -142,12 +158,12 @@);ALTER TABLE book DROP COLUMN content;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int,@@ -157,12 +173,14 @@);ALTER TABLE book ADD COLUMN content varchar(255);want:- - status: WARN+ - status: 2code: 401title: column.required- content: "Table `book` requires columns: updater_id"- line: 1- details: ""+ content: 'Table `book` requires columns: updater_id'+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE book(id int,@@ -173,12 +191,12 @@);ALTER TABLE book ADD COLUMN creator_id int;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int,@@ -192,18 +210,22 @@updated_ts timestamp);want:- - status: WARN+ - status: 2code: 401title: column.required- content: "Table `book` requires columns: creator_id"- line: 1- details: ""- - status: WARN+ content: 'Table `book` requires columns: creator_id'+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 401title: column.required- content: "Table `student` requires columns: creator_id, updater_id"- line: 7- details: ""+ content: 'Table `student` requires columns: creator_id, updater_id'+ detail: ""+ startposition:+ line: 7+ column: 0- statement: |-CREATE TABLE book(id int,@@ -214,12 +236,12 @@);DROP TABLE book;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int@@ -231,9 +253,9 @@updated_ts timestamp);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/test/column_set_default_for_not_null.yaml b/backend/plugin/advisor/mysql/test/column_set_default_for_not_null.yamlindex ad1dee9222..c54ece6f35 100644--- a/backend/plugin/advisor/mysql/test/column_set_default_for_not_null.yaml+++ b/backend/plugin/advisor/mysql/test/column_set_default_for_not_null.yaml@@ -3,129 +3,141 @@id int PRIMARY KEY DEFAULT 0);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int PRIMARY KEY);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int NOT NULL);want:- - status: WARN+ - status: 2code: 404title: column.set-default-for-not-nullcontent: Column `book`.`id` is NOT NULL but doesn't have DEFAULT- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE book(id int,PRIMARY KEY (id));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(a int);ALTER TABLE book ADD COLUMN id int PRIMARY KEY;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(a int);ALTER TABLE book ADD COLUMN id int NOT NULL;want:- - status: WARN+ - status: 2code: 404title: column.set-default-for-not-nullcontent: Column `book`.`id` is NOT NULL but doesn't have DEFAULT- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE book(a int);ALTER TABLE book ADD COLUMN (b int NOT NULL, c int NOT NULL);want:- - status: WARN+ - status: 2code: 404title: column.set-default-for-not-nullcontent: Column `book`.`b` is NOT NULL but doesn't have DEFAULT- line: 2- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 404title: column.set-default-for-not-nullcontent: Column `book`.`c` is NOT NULL but doesn't have DEFAULT- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE book(id int);ALTER TABLE book MODIFY COLUMN id int NOT NULL;want:- - status: WARN+ - status: 2code: 404title: column.set-default-for-not-nullcontent: Column `book`.`id` is NOT NULL but doesn't have DEFAULT- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE book(id int);ALTER TABLE book MODIFY COLUMN id int PRIMARY KEY;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(uid int);ALTER TABLE book CHANGE COLUMN uid id int PRIMARY KEY;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(uid int);ALTER TABLE book CHANGE COLUMN uid id int NOT NULL;want:- - status: WARN+ - status: 2code: 404title: column.set-default-for-not-nullcontent: Column `book`.`id` is NOT NULL but doesn't have DEFAULT- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE book(uid int, id int);ALTER TABLE book CHANGE COLUMN uid uid int NOT NULL DEFAULT 0, MODIFY COLUMN id int PRIMARY KEY DEFAULT 0, ADD COLUMN name varchar(20) NOT NULL DEFAULT '';want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/test/column_type_disallow_list.yaml b/backend/plugin/advisor/mysql/test/column_type_disallow_list.yamlindex e290d67130..bc6384e69e 100644--- a/backend/plugin/advisor/mysql/test/column_type_disallow_list.yaml+++ b/backend/plugin/advisor/mysql/test/column_type_disallow_list.yaml@@ -1,62 +1,74 @@- statement: CREATE TABLE t(a int);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a JSON, b BLOB, c TEXT);want:- - status: WARN+ - status: 2code: 411title: column.type-disallow-listcontent: Disallow column type JSON but column `t`.`a` is- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t(d int);ALTER TABLE t add COLUMN (a JSON, b BLOB, c TEXT);want:- - status: WARN+ - status: 2code: 411title: column.type-disallow-listcontent: Disallow column type JSON but column `t`.`a` is- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(d int);ALTER TABLE t ADD COLUMN (a JSON, b JSON);want:- - status: WARN+ - status: 2code: 411title: column.type-disallow-listcontent: Disallow column type JSON but column `t`.`a` is- line: 2- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 411title: column.type-disallow-listcontent: Disallow column type JSON but column `t`.`b` is- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(c int, b int);ALTER TABLE t CHANGE COLUMN c a JSON, MODIFY b BLOB;want:- - status: WARN+ - status: 2code: 411title: column.type-disallow-listcontent: Disallow column type JSON but column `t`.`a` is- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(c int, b int);ALTER TABLE t MODIFY COLUMN c JSON;want:- - status: WARN+ - status: 2code: 411title: column.type-disallow-listcontent: Disallow column type JSON but column `t`.`c` is- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mysql/test/database_drop_empty_database.yaml b/backend/plugin/advisor/mysql/test/database_drop_empty_database.yamlindex 1202469b93..fb773f2b28 100644--- a/backend/plugin/advisor/mysql/test/database_drop_empty_database.yaml+++ b/backend/plugin/advisor/mysql/test/database_drop_empty_database.yaml@@ -1,8 +1,10 @@- statement: DROP DATABASE IF EXISTS test;want:- - status: WARN+ - status: 2code: 701title: database.drop-empty-databasecontent: Database `test` is not allowed to drop if not empty- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mysql/test/engine_mysql_use_innodb.yaml b/backend/plugin/advisor/mysql/test/engine_mysql_use_innodb.yamlindex 0affbdc302..90c0f31119 100644--- a/backend/plugin/advisor/mysql/test/engine_mysql_use_innodb.yaml+++ b/backend/plugin/advisor/mysql/test/engine_mysql_use_innodb.yaml@@ -12,7 +12,7 @@FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin;want:- - status: WARN+ - status: 2code: 501title: engine.mysql.use-innodbcontent: |-@@ -28,9 +28,10 @@UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin;" doesn't use InnoDB engine- line: 12- column: 0- details: ""+ detail: ""+ startposition:+ line: 12+ column: 0- statement: |CREATE TABLE user(id INT PRIMARY KEY COMMENT 'comment',@@ -44,38 +45,35 @@UNIQUE KEY uk_user_id_name(id, name)) ENGINE = INNODB COMMENT 'comment';want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE book(id int) ENGINE = INNODB;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE book(id int);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE book(id INT,price INT) ENGINE = CSV;want:- - status: WARN+ - status: 2code: 501title: engine.mysql.use-innodbcontent: |-@@ -83,9 +81,10 @@id INT,price INT) ENGINE = CSV;" doesn't use InnoDB engine- line: 4- column: 0- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0- statement: |CREATE TABLE teck_book(a INT);CREATE TABLE book(@@ -93,7 +92,7 @@price INT) ENGINE = CSV;want:- - status: WARN+ - status: 2code: 501title: engine.mysql.use-innodbcontent: |-@@ -101,57 +100,57 @@id INT,price INT) ENGINE = CSV;" doesn't use InnoDB engine- line: 5- column: 0- details: ""+ detail: ""+ startposition:+ line: 5+ column: 0- statement: ALTER TABLE tech_book ENGINE = INNODB;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE teck_book(a INT);CREATE TABLE book(a INT);ALTER TABLE tech_book ENGINE = CSV;want:- - status: WARN+ - status: 2code: 501title: engine.mysql.use-innodbcontent: '"ALTER TABLE tech_book ENGINE = CSV;" doesn''t use InnoDB engine'- line: 3- column: 0- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: SET default_storage_engine=INNODB;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE book(a INT);SET default_storage_engine=CSV;want:- - status: WARN+ - status: 2code: 501title: engine.mysql.use-innodbcontent: '"SET default_storage_engine=CSV;" doesn''t use InnoDB engine'- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |SET foreign_key_checks=0;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/test/index_key_number_limit.yaml b/backend/plugin/advisor/mysql/test/index_key_number_limit.yamlindex 1799a25b4a..48d0488c69 100644--- a/backend/plugin/advisor/mysql/test/index_key_number_limit.yaml+++ b/backend/plugin/advisor/mysql/test/index_key_number_limit.yaml@@ -1,11 +1,11 @@- statement: CREATE TABLE t(a int, b int, primary key (a, b));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int,@@ -15,74 +15,91 @@foreign key fk (a, b, b, b, b, b) references t1(a, b, b, b, b, b));want:- - status: WARN+ - status: 2code: 802title: index.key-number-limitcontent: The number of index `pk` in table `t` should be not greater than 5- line: 4- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 4+ column: 0+ - status: 2code: 802title: index.key-number-limitcontent: The number of index `uk` in table `t` should be not greater than 5- line: 5- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 5+ column: 0+ - status: 2code: 802title: index.key-number-limitcontent: The number of index `fk` in table `t` should be not greater than 5- line: 6- details: ""+ detail: ""+ startposition:+ line: 6+ column: 0- statement: |-CREATE TABLE t(a int, b int, c int, d int, e int, f int, g int);CREATE INDEX idx ON t(a, b, c, d, e, f, g);CREATE UNIQUE INDEX uk ON t(a, b, c, d, e, f, g);want:- - status: WARN+ - status: 2code: 802title: index.key-number-limitcontent: The number of index `idx` in table `t` should be not greater than 5- line: 2- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 802title: index.key-number-limitcontent: The number of index `uk` in table `t` should be not greater than 5- line: 3- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-CREATE TABLE t(a int, b int, c int, d int, e int, f int, g int);ALTER TABLE t ADD PRIMARY KEY pk (a, b, c, d, e, f, g);ALTER TABLE t ADD UNIQUE KEY uk (a, b, c, d, e, f, g);want:- - status: WARN+ - status: 2code: 802title: index.key-number-limitcontent: The number of index `pk` in table `t` should be not greater than 5- line: 2- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 802title: index.key-number-limitcontent: The number of index `uk` in table `t` should be not greater than 5- line: 3- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-CREATE TABLE t(a int, b int, c int, d int, e int, f int, g int);ALTER TABLE t ADD FOREIGN KEY uk (a, b, c, d, e, f, g) REFERENCES t1(a, b, c, d, e, f, g)want:- - status: WARN+ - status: 2code: 802title: index.key-number-limitcontent: The number of index `uk` in table `t` should be not greater than 5- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int, b varchar(255));CREATE FULLTEXT INDEX idx ON t(b, b, b, b, b, b);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/test/index_no_duplicate_column.yaml b/backend/plugin/advisor/mysql/test/index_no_duplicate_column.yamlindex 0c5f76d55e..6b45e08aea 100644--- a/backend/plugin/advisor/mysql/test/index_no_duplicate_column.yaml+++ b/backend/plugin/advisor/mysql/test/index_no_duplicate_column.yaml@@ -1,23 +1,25 @@- statement: CREATE TABLE t (a int, PRIMARY KEY (a));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t (a int,PRIMARY KEY (a, a));want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: PRIMARY KEY `` has duplicate column `t`.`a`- line: 3- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-CREATE TABLE t1 (a int,@@ -32,96 +34,112 @@FOREIGN KEY fk1 (a, a) REFERENCES t1(a, a));want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: FOREIGN KEY `fk1` has duplicate column `t3`.`a`- line: 11- details: ""+ detail: ""+ startposition:+ line: 11+ column: 0- statement: |-CREATE TABLE t (a int,INDEX idx_a (a, a));want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: INDEX `idx_a` has duplicate column `t`.`a`- line: 3- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-CREATE TABLE t(a int);CREATE INDEX idx ON t(a);CREATE INDEX idx_a ON t(a, a);want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: INDEX `idx_a` has duplicate column `t`.`a`- line: 3- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-CREATE TABLE t(a int);CREATE UNIQUE INDEX idx ON t(a);CREATE UNIQUE INDEX idx_a ON t(a, a);want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: UNIQUE INDEX `idx_a` has duplicate column `t`.`a`- line: 3- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD INDEX idx (a);ALTER TABLE t ADD INDEX idx_a (a, a);want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: INDEX `idx_a` has duplicate column `t`.`a`- line: 3- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD PRIMARY KEY pk_a (a, a);want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: PRIMARY KEY `pk_a` has duplicate column `t`.`a`- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD PRIMARY KEY pk_a (a);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD UNIQUE KEY uk (a);ALTER TABLE t ADD UNIQUE KEY uk_a (a, a);want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: UNIQUE KEY `uk_a` has duplicate column `t`.`a`- line: 3- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD FOREIGN KEY fk (a) REFERENCES t1(a);ALTER TABLE t ADD FOREIGN KEY fk_a (a, a) REFERENCES t1(a, b);want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: FOREIGN KEY `fk_a` has duplicate column `t`.`a`- line: 3- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0diff --git a/backend/plugin/advisor/mysql/test/index_pk_type_limit.yaml b/backend/plugin/advisor/mysql/test/index_pk_type_limit.yamlindex c64c2b1665..7e0ea39ff1 100644--- a/backend/plugin/advisor/mysql/test/index_pk_type_limit.yaml+++ b/backend/plugin/advisor/mysql/test/index_pk_type_limit.yaml@@ -1,206 +1,232 @@- statement: CREATE TABLE t(id VARCHAR(5) PRIMARY KEY);want:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(id INT PRIMARY KEY);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(id VARCHAR(5), PRIMARY KEY(id));want:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(id INT, id2 VARCHAR(5), id3 VARCHAR(5), PRIMARY KEY(id, id2, id3));want:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)- line: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id3` is varchar(5)- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(id INT, id2 BIGINT, PRIMARY KEY(id, id2));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(id INT, PRIMARY KEY(id));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id VARCHAR(5) PRIMARY KEY;want:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id INT PRIMARY KEY;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id VARCHAR(5), ADD PRIMARY KEY (id);want:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id INT, ADD COLUMN id2 VARCHAR(5), ADD COLUMN id3 VARCHAR(5), ADD PRIMARY KEY (id, id2, id3);want:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)- line: 2- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id3` is varchar(5)- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id INT, ADD COLUMN id2 BIGINT, ADD PRIMARY KEY (id, id2);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id BIGINT, ADD PRIMARY KEY (id);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id VARCHAR(5));ALTER TABLE t ADD PRIMARY KEY(id);want:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id INT, id2 VARCHAR(5), id3 VARCHAR(5));ALTER TABLE t ADD PRIMARY KEY(id, id2, id3);want:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)- line: 2- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id3` is varchar(5)- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id INT, id2 BIGINT);ALTER TABLE t ADD PRIMARY KEY(id, id2);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id BIGINT);ALTER TABLE t ADD PRIMARY KEY(id);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id int);ALTER TABLE t MODIFY COLUMN id VARCHAR(5) PRIMARY KEY;want:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id int);ALTER TABLE t MODIFY COLUMN id INT(5) PRIMARY KEY;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id int);ALTER TABLE t CHANGE COLUMN id id2 VARCHAR(5) PRIMARY KEY;want:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id int);ALTER TABLE t CHANGE COLUMN id id2 INT(5) PRIMARY KEY;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/test/index_primary_key_type_allowlist.yaml b/backend/plugin/advisor/mysql/test/index_primary_key_type_allowlist.yamlindex bb7078ce83..1350ccc071 100644--- a/backend/plugin/advisor/mysql/test/index_primary_key_type_allowlist.yaml+++ b/backend/plugin/advisor/mysql/test/index_primary_key_type_allowlist.yaml@@ -1,206 +1,232 @@- statement: CREATE TABLE t(id VARCHAR(5) PRIMARY KEY);want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(id INT PRIMARY KEY);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(id VARCHAR(5), PRIMARY KEY(id));want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(id INT, id2 VARCHAR(5), id3 VARCHAR(5), PRIMARY KEY(id, id2, id3));want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id2` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id3` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(id INT, id2 BIGINT, PRIMARY KEY(id, id2));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(id INT, PRIMARY KEY(id));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id VARCHAR(5) PRIMARY KEY;want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id INT PRIMARY KEY;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id VARCHAR(5), ADD PRIMARY KEY (id);want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id INT, ADD COLUMN id2 VARCHAR(5), ADD COLUMN id3 VARCHAR(5), ADD PRIMARY KEY (id, id2, id3);want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id2` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 2- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id3` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id INT, ADD COLUMN id2 BIGINT, ADD PRIMARY KEY (id, id2);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id BIGINT, ADD PRIMARY KEY (id);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id VARCHAR(5));ALTER TABLE t ADD PRIMARY KEY(id);want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id INT, id2 VARCHAR(5), id3 VARCHAR(5));ALTER TABLE t ADD PRIMARY KEY(id, id2, id3);want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id2` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 2- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id3` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id INT, id2 BIGINT);ALTER TABLE t ADD PRIMARY KEY(id, id2);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id BIGINT);ALTER TABLE t ADD PRIMARY KEY(id);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id int);ALTER TABLE t MODIFY COLUMN id VARCHAR(5) PRIMARY KEY;want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id int);ALTER TABLE t MODIFY COLUMN id INT(5) PRIMARY KEY;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id int);ALTER TABLE t CHANGE COLUMN id id2 VARCHAR(5) PRIMARY KEY;want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id2` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id int);ALTER TABLE t CHANGE COLUMN id id2 INT(5) PRIMARY KEY;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/test/index_total_number_limit.yaml b/backend/plugin/advisor/mysql/test/index_total_number_limit.yamlindex 775a5a4f23..6090d19451 100644--- a/backend/plugin/advisor/mysql/test/index_total_number_limit.yaml+++ b/backend/plugin/advisor/mysql/test/index_total_number_limit.yaml@@ -1,19 +1,19 @@- statement: CREATE TABLE t(a int, b int, c int, unique key(a, b, c));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE INDEX idx_id_name on tech_book(id, name);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE INDEX idx_id_name_1 on tech_book(id, name);CREATE INDEX idx_id_name_2 on tech_book(id, name);@@ -21,12 +21,14 @@CREATE INDEX idx_id_name_4 on tech_book(id, name);CREATE INDEX idx_id_name_5 on tech_book(id, name);want:- - status: WARN+ - status: 2code: 813title: index.total-number-limitcontent: The count of index in table `tech_book` should be no more than 5, but found 8- line: 5- details: ""+ detail: ""+ startposition:+ line: 5+ column: 0- statement: |-CREATE TABLE t(a int PRIMARY KEY, b int, c int);CREATE INDEX idx_a_b_1 on t(a, b);@@ -35,12 +37,14 @@CREATE INDEX idx_a_b_4 on t(a, b);CREATE INDEX idx_a_b_5 on t(a, b);want:- - status: WARN+ - status: 2code: 813title: index.total-number-limitcontent: The count of index in table `t` should be no more than 5, but found 6- line: 6- details: ""+ detail: ""+ startposition:+ line: 6+ column: 0- statement: |-CREATE TABLE t(a int PRIMARY KEY,@@ -52,12 +56,14 @@INDEX idx_a_b_4 (a, b),INDEX idx_a_b_5 (a, b));want:- - status: WARN+ - status: 2code: 813title: index.total-number-limitcontent: The count of index in table `t` should be no more than 5, but found 6- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t (a int PRIMARY KEY,@@ -70,9 +76,11 @@ALTER TABLE t ADD INDEX idx_a_b_4 (a, b);ALTER TABLE t ADD INDEX idx_a_b_5 (a, b);want:- - status: WARN+ - status: 2code: 813title: index.total-number-limitcontent: The count of index in table `t` should be no more than 5, but found 6- line: 10- details: ""+ detail: ""+ startposition:+ line: 10+ column: 0diff --git a/backend/plugin/advisor/mysql/test/index_type_allow_list.yaml b/backend/plugin/advisor/mysql/test/index_type_allow_list.yamlindex d0bd2f56b0..9b57159bb2 100644--- a/backend/plugin/advisor/mysql/test/index_type_allow_list.yaml+++ b/backend/plugin/advisor/mysql/test/index_type_allow_list.yaml@@ -5,8 +5,12 @@INDEX idx_email (email));want:- - status: SUCCESS+ - status: 1+ code: 0title: OK+ content: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE orders (id INT PRIMARY KEY,@@ -16,8 +20,12 @@CREATE INDEX idx_customer ON orders (customer, (order_number * 2));CREATE INDEX idx_customer_duplicate ON orders (customer, (order_number * 2));want:- - status: SUCCESS+ - status: 1+ code: 0title: OK+ content: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE locations (id INT AUTO_INCREMENT PRIMARY KEY,@@ -25,12 +33,14 @@);CREATE SPATIAL INDEX spatial_index_name ON locations(geom);want:- - status: WARN+ - status: 2code: 816title: index.type-allow-list- content: "Index type `SPATIAL` is not allowed"- line: 5- details: ""+ content: Index type `SPATIAL` is not allowed+ detail: ""+ startposition:+ line: 5+ column: 0- statement: |-CREATE TABLE locations (id INT AUTO_INCREMENT PRIMARY KEY,@@ -38,9 +48,11 @@);CREATE FULLTEXT INDEX fulltext_index_name ON locations(description);want:- - status: WARN+ - status: 2code: 816title: index.type-allow-list- content: "Index type `FULLTEXT` is not allowed"- line: 5- details: ""+ content: Index type `FULLTEXT` is not allowed+ detail: ""+ startposition:+ line: 5+ column: 0diff --git a/backend/plugin/advisor/mysql/test/index_type_no_blob.yaml b/backend/plugin/advisor/mysql/test/index_type_no_blob.yamlindex 8e79cadb1f..7e0b1bec84 100644--- a/backend/plugin/advisor/mysql/test/index_type_no_blob.yaml+++ b/backend/plugin/advisor/mysql/test/index_type_no_blob.yaml@@ -12,12 +12,14 @@FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin;want:- - status: WARN+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `userTable`.`content` is blob- line: 12- details: ""+ detail: ""+ startposition:+ line: 12+ column: 0- statement: |CREATE TABLE user(id INT PRIMARY KEY COMMENT 'comment',@@ -31,152 +33,186 @@UNIQUE KEY uk_user_id_name(id, name)) ENGINE = INNODB COMMENT 'comment';want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(b BLOB, PRIMARY KEY(b(10)));want:- - status: WARN+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`b` is blob- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(b BLOB, mb MEDIUMBLOB, lb LONGBLOB, id INT, PRIMARY KEY(b(1), mb(2), lb(3), id));want:- - status: WARN+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`b` is blob- line: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`lb` is longblob- line: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`mb` is mediumblob- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(b BLOB, mb MEDIUMBLOB, lb LONGBLOB, id INT, UNIQUE INDEX(b(1), mb(2), lb(3), id))want:- - status: WARN+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`b` is blob- line: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`lb` is longblob- line: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`mb` is mediumblob- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(b BLOB, mb MEDIUMBLOB, lb LONGBLOB, id iNT, INDEX(b(1), mb(2), lb(3), id))want:- - status: WARN+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`b` is blob- line: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`lb` is longblob- line: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`mb` is mediumblob- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(id INT, PRIMARY KEY(id))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN b BLOB, ADD COLUMN id INT, ADD PRIMARY KEY(b(1), id);want:- - status: WARN+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`b` is blob- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN b BLOB, ADD COLUMN mb MEDIUMBLOB, ADD COLUMN lb LONGBLOB, ADD COLUMN id INT, ADD UNIQUE INDEX(b(1), mb(2), lb(3), id)want:- - status: WARN+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`b` is blob- line: 2- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`lb` is longblob- line: 2- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`mb` is mediumblob- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN b BLOB, ADD COLUMN mb MEDIUMBLOB, ADD COLUMN lb LONGBLOB, ADD COLUMN id INT, ADD INDEX(b(1), mb(2), lb(3), id)want:- - status: WARN+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`b` is blob- line: 2- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`lb` is longblob- line: 2- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`mb` is mediumblob- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN b BLOB, ADD COLUMN mb MEDIUMBLOB, ADD COLUMN lb LONGBLOB, ADD COLUMN id INT, ADD INDEX(id);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(b blob, mb mediumblob, lb longblob, id int);CREATE INDEX idx_b ON t(b(5));@@ -184,53 +220,63 @@CREATE INDEX idx_lb ON t(lb(5));CREATE INDEX idx_id ON t(id);want:- - status: WARN+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`b` is blob- line: 2- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`mb` is mediumblob- line: 3- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`lb` is longblob- line: 4- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0- statement: |-CREATE TABLE t(b blob, mb mediumblob, lb longblob, id int);CREATE INDEX idx_id ON t(id);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(b int, mb mediumblob, lb longblob, id int);ALTER TABLE t MODIFY COLUMN b blob;ALTER TABLE t ADD PRIMARY KEY(b);want:- - status: WARN+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`b` is blob- line: 3- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-CREATE TABLE t(b int, mb mediumblob, lb longblob, id int);ALTER TABLE t CHANGE COLUMN b d blob;ALTER TABLE t ADD PRIMARY KEY(d);want:- - status: WARN+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`d` is blob- line: 3- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0diff --git a/backend/plugin/advisor/mysql/test/naming_column.yaml b/backend/plugin/advisor/mysql/test/naming_column.yamlindex a4ced7e3a1..f5f2723e00 100644--- a/backend/plugin/advisor/mysql/test/naming_column.yaml+++ b/backend/plugin/advisor/mysql/test/naming_column.yaml@@ -1,54 +1,64 @@- statement: CREATE TABLE book(id int, creatorId int);want:- - status: WARN+ - status: 2code: 302title: naming.columncontent: '`book`.`creatorId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id int, gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx int);want:- - status: WARN+ - status: 2code: 302title: naming.column- content: "`book`.`gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx` mismatches column naming convention, its length should be within 64 characters"- line: 1- details: ""+ content: '`book`.`gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx` mismatches column naming convention, its length should be within 64 characters'+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id int, creator_id int);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int, creator_id int);ALTER TABLE book RENAME COLUMN creator_id TO creatorId;ALTER TABLE book CHANGE COLUMN creatorId gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx int;want:- - status: WARN+ - status: 2code: 302title: naming.columncontent: '`book`.`creatorId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 2- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 302title: naming.column- content: "`book`.`gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx` mismatches column naming convention, its length should be within 64 characters"- line: 3- details: ""+ content: '`book`.`gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx` mismatches column naming convention, its length should be within 64 characters'+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |ALTER TABLE tech_book RENAME COLUMN id TO creator_id;ALTER TABLE tech_book RENAME COLUMN creator_id TO gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx;want:- - status: WARN+ - status: 2code: 302title: naming.column- content: "`tech_book`.`gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx` mismatches column naming convention, its length should be within 64 characters"- line: 2- details: ""+ content: '`tech_book`.`gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx` mismatches column naming convention, its length should be within 64 characters'+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE book(id int,@@ -58,30 +68,32 @@updated_ts timestamp);ALTER TABLE book CHANGE COLUMN creator_id creatorId int;want:- - status: WARN+ - status: 2code: 302title: naming.columncontent: '`book`.`creatorId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 7- details: ""+ detail: ""+ startposition:+ line: 7+ column: 0- statement: |-CREATE TABLE book (id INT);ALTER TABLE book CHANGE COLUMN id creator_id int;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book DROP COLUMN id;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int,@@ -90,12 +102,14 @@updated_ts timestamp);ALTER TABLE book ADD COLUMN contentString varchar(255);want:- - status: WARN+ - status: 2code: 302title: naming.columncontent: '`book`.`contentString` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 6- details: ""+ detail: ""+ startposition:+ line: 6+ column: 0- statement: |-CREATE TABLE book(id int,@@ -104,18 +118,22 @@updated_ts timestamp);ALTER TABLE book ADD COLUMN (personAge INT, contentString varchar(255));want:- - status: WARN+ - status: 2code: 302title: naming.columncontent: '`book`.`contentString` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 6- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 6+ column: 0+ - status: 2code: 302title: naming.columncontent: '`book`.`personAge` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 6- details: ""+ detail: ""+ startposition:+ line: 6+ column: 0- statement: |-CREATE TABLE book(id int,@@ -127,27 +145,35 @@createdTs timestamp,updatedTs timestamp);want:- - status: WARN+ - status: 2code: 302title: naming.columncontent: '`book`.`createdTs` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 3- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 302title: naming.columncontent: '`book`.`updaterId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 4- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 4+ column: 0+ - status: 2code: 302title: naming.columncontent: '`student`.`createdTs` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 8- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 8+ column: 0+ - status: 2code: 302title: naming.columncontent: '`student`.`updatedTs` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 9- details: ""+ detail: ""+ startposition:+ line: 9+ column: 0diff --git a/backend/plugin/advisor/mysql/test/naming_column_auto_increment.yaml b/backend/plugin/advisor/mysql/test/naming_column_auto_increment.yamlindex b16c193b09..16558fdcb3 100644--- a/backend/plugin/advisor/mysql/test/naming_column_auto_increment.yaml+++ b/backend/plugin/advisor/mysql/test/naming_column_auto_increment.yaml@@ -1,80 +1,88 @@- statement: CREATE TABLE book(id int AUTO_INCREMENT);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE book(a int AUTO_INCREMENT);want:- - status: WARN+ - status: 2code: 307title: naming.column.auto-incrementcontent: '`book`.`a` mismatches auto_increment column naming convention, naming format should be "^id$"'- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ADD COLUMN a int AUTO_INCREMENT;want:- - status: WARN+ - status: 2code: 307title: naming.column.auto-incrementcontent: '`tech_book`.`a` mismatches auto_increment column naming convention, naming format should be "^id$"'- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book CHANGE COLUMN id a int AUTO_INCREMENT;want:- - status: WARN+ - status: 2code: 307title: naming.column.auto-incrementcontent: '`tech_book`.`a` mismatches auto_increment column naming convention, naming format should be "^id$"'- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book MODIFY COLUMN name int AUTO_INCREMENT;want:- - status: WARN+ - status: 2code: 307title: naming.column.auto-incrementcontent: '`tech_book`.`name` mismatches auto_increment column naming convention, naming format should be "^id$"'- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |CREATE TABLE book(id int);ALTER TABLE tech_book MODIFY COLUMN id int AUTO_INCREMENT;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE book(name VARCHAR(255));ALTER TABLE book ADD COLUMN id int AUTO_INCREMENT;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE book(a INT, name VARCHAR(255));ALTER TABLE book CHANGE COLUMN a id int AUTO_INCREMENT;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE book(name VARCHAR(255));ALTER TABLE book ADD COLUMN (id int AUTO_INCREMENT, a int, b int, c int, d int);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/test/naming_identifier_no_keyword.yaml b/backend/plugin/advisor/mysql/test/naming_identifier_no_keyword.yamlindex 04dd176e22..721c0d00d0 100644--- a/backend/plugin/advisor/mysql/test/naming_identifier_no_keyword.yaml+++ b/backend/plugin/advisor/mysql/test/naming_identifier_no_keyword.yaml@@ -1,61 +1,68 @@- statement: CREATE TABLE `t`(a int);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE interval(id int);want:- - status: ERROR+ - status: 3code: 201title: Syntax errorcontent: "Syntax error at line 1:13 \nrelated text: CREATE TABLE interval"- line: 1- column: 13- details: ""+ detail: ""+ startposition:+ line: 1+ column: 13- statement: CREATE TABLE execute(id int)want:- - status: WARN+ - status: 2code: 308title: naming.identifier.no-keyword- content: 'Identifier "execute" is a keyword and should be avoided'- line: 1- details: ""+ content: Identifier "execute" is a keyword and should be avoided+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE `execute`(id int)want:- - status: WARN+ - status: 2code: 308title: naming.identifier.no-keyword- content: 'Identifier "execute" is a keyword and should be avoided'- line: 1- details: ""+ content: Identifier "execute" is a keyword and should be avoided+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE `interval`(id int);want:- - status: WARN+ - status: 2code: 308title: naming.identifier.no-keyword- content: 'Identifier "interval" is a keyword and should be avoided'- line: 1- details: ""-- statement: |- CREATE TABLE t(- id int,- `current_timestamp` int- );+ content: Identifier "interval" is a keyword and should be avoided+ detail: ""+ startposition:+ line: 1+ column: 0+- statement: "CREATE TABLE t(\n id int, \n `current_timestamp` int\n);\n"want:- - status: WARN+ - status: 2code: 308title: naming.identifier.no-keyword- content: 'Identifier "current_timestamp" is a keyword and should be avoided'- line: 3- details: ""+ content: Identifier "current_timestamp" is a keyword and should be avoided+ detail: ""+ startposition:+ line: 3+ column: 0- statement: CREATE TABLE `test`.`interval`(id int);want:- - status: WARN+ - status: 2code: 308title: naming.identifier.no-keyword- content: 'Identifier "interval" is a keyword and should be avoided'- line: 1- details: ""+ content: Identifier "interval" is a keyword and should be avoided+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mysql/test/naming_index_fk.yaml b/backend/plugin/advisor/mysql/test/naming_index_fk.yamlindex f5bba48227..e5be9b4026 100644--- a/backend/plugin/advisor/mysql/test/naming_index_fk.yaml+++ b/backend/plugin/advisor/mysql/test/naming_index_fk.yaml@@ -1,41 +1,49 @@- statement: CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin;want:- - status: WARN+ - status: 2code: 305title: naming.index.fkcontent: Foreign key in table `userTable` mismatches the naming convention, expect "^$|^fk_userTable_roomId_room_id$" but found `fk1`- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ADD CONSTRAINT fk_tech_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book ADD CONSTRAINT fk_author_id FOREIGN KEY (author_id) REFERENCES author (id);want:- - status: WARN+ - status: 2code: 305title: naming.index.fkcontent: Foreign key in table `tech_book` mismatches the naming convention, expect "^$|^fk_tech_book_author_id_author_id$" but found `fk_author_id`- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ADD CONSTRAINT rvemempmcmmhutaskvcidmwaldtfjdgmcpkhmibtadfydtkexpuzczrrneucthfwk FOREIGN KEY (author_id) REFERENCES author (id);want:- - status: WARN+ - status: 2code: 305title: naming.index.fkcontent: Foreign key `rvemempmcmmhutaskvcidmwaldtfjdgmcpkhmibtadfydtkexpuzczrrneucthfwk` in table `tech_book` mismatches the naming convention, its length should be within 64 characters- line: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 305title: naming.index.fkcontent: Foreign key in table `tech_book` mismatches the naming convention, expect "^$|^fk_tech_book_author_id_author_id$" but found `rvemempmcmmhutaskvcidmwaldtfjdgmcpkhmibtadfydtkexpuzczrrneucthfwk`- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |CREATE TABLE book(id INT,@@ -43,12 +51,12 @@FOREIGN KEY fk_book_author_id_author_id (author_id) REFERENCES author (id));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE book(id INT,@@ -56,12 +64,12 @@FOREIGN KEY (author_id) REFERENCES author (id));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE book(id INT,@@ -69,9 +77,11 @@FOREIGN KEY fk_book_author_id (author_id) REFERENCES author (id));want:- - status: WARN+ - status: 2code: 305title: naming.index.fkcontent: Foreign key in table `book` mismatches the naming convention, expect "^$|^fk_book_author_id_author_id$" but found `fk_book_author_id`- line: 4- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0diff --git a/backend/plugin/advisor/mysql/test/naming_index_idx.yaml b/backend/plugin/advisor/mysql/test/naming_index_idx.yamlindex c320c41d51..e3cdf22ee3 100644--- a/backend/plugin/advisor/mysql/test/naming_index_idx.yaml+++ b/backend/plugin/advisor/mysql/test/naming_index_idx.yaml@@ -1,102 +1,112 @@- statement: CREATE INDEX idx_tech_book_id_name ON tech_book(id, name);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE INDEX tech_book_id_name ON tech_book(id, name);want:- - status: WARN+ - status: 2code: 303title: naming.index.idxcontent: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `tech_book_id_name`- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE INDEX afvjwsgrbgqzjfrkmbcoxzstznuypasijbbcdykoboredqovetzfcmmqliaelyavw ON tech_book(id, name);want:- - status: WARN+ - status: 2code: 303title: naming.index.idxcontent: Index `afvjwsgrbgqzjfrkmbcoxzstznuypasijbbcdykoboredqovetzfcmmqliaelyavw` in table `tech_book` mismatches the naming convention, its length should be within 64 characters- line: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 303title: naming.index.idxcontent: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `afvjwsgrbgqzjfrkmbcoxzstznuypasijbbcdykoboredqovetzfcmmqliaelyavw`- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book RENAME INDEX old_index TO idx_tech_book_id_name;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book RENAME INDEX old_index TO idx_tech_book;want:- - status: WARN+ - status: 2code: 303title: naming.index.idxcontent: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `idx_tech_book`- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ADD INDEX idx_tech_book_id_name (id, name);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book ADD INDEX tech_book_id_name (id, name);want:- - status: WARN+ - status: 2code: 303title: naming.index.idxcontent: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `tech_book_id_name`- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE tech_book_copy(id INT PRIMARY KEY, name VARCHAR(20), INDEX idx_tech_book_copy_name (name));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE tech_book_copy(id INT PRIMARY KEY, name VARCHAR(20), INDEX (name));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE tech_book_copy(id INT PRIMARY KEY, name VARCHAR(20), UNIQUE INDEX (name));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE tech_book_copy(id INT PRIMARY KEY, name VARCHAR(20), FULLTEXT INDEX (name));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE tech_book_copy(id INT PRIMARY KEY, name VARCHAR(20), SPATIAL INDEX (name));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/test/naming_index_uk.yaml b/backend/plugin/advisor/mysql/test/naming_index_uk.yamlindex e5748a7375..a07c7a55b1 100644--- a/backend/plugin/advisor/mysql/test/naming_index_uk.yaml+++ b/backend/plugin/advisor/mysql/test/naming_index_uk.yaml@@ -1,90 +1,91 @@- statement: CREATE UNIQUE INDEX uk_tech_book_id_name ON tech_book(id, name);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE UNIQUE INDEX uk_tech_book_id_name ON tech_book(id, name);CREATE UNIQUE INDEX tech_book_id_name ON tech_book(id, name);want:- - status: WARN+ - status: 2code: 304title: naming.index.ukcontent: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `tech_book_id_name`- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |CREATE UNIQUE INDEX uk_tech_book_id_name ON tech_book(id, name);CREATE UNIQUE INDEX qtzmquwvlnttctfluoouxelxeliltcfzzstrtyocogwwyiyrflmrkbhbfasynlacy ON tech_book(id, name)want:- - status: WARN+ - status: 2code: 304title: naming.index.ukcontent: Unique key `qtzmquwvlnttctfluoouxelxeliltcfzzstrtyocogwwyiyrflmrkbhbfasynlacy` in table `tech_book` mismatches the naming convention, its length should be within 64 characters- line: 2- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 304title: naming.index.ukcontent: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `qtzmquwvlnttctfluoouxelxeliltcfzzstrtyocogwwyiyrflmrkbhbfasynlacy`- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: ALTER TABLE tech_book ADD UNIQUE uk_tech_book_id_name (id, name);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE t1(a INT);ALTER TABLE tech_book ADD UNIQUE tech_book_id_name (id, name);want:- - status: WARN+ - status: 2code: 304title: naming.index.ukcontent: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `tech_book_id_name`- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: ALTER TABLE tech_book RENAME INDEX old_uk TO uk_tech_book_id_name;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE t1(a INT);ALTER TABLE tech_book RENAME INDEX old_uk TO uk_tech_book;want:- - status: WARN+ - status: 2code: 304title: naming.index.ukcontent: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `uk_tech_book`- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: CREATE TABLE book(id INT PRIMARY KEY, name VARCHAR(20), UNIQUE INDEX uk_book_name (name));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE book(id INT PRIMARY KEY,@@ -92,13 +93,12 @@UNIQUE KEY (name));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE book(id INT PRIMARY KEY,@@ -106,10 +106,9 @@UNIQUE INDEX (name));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/test/naming_table.yaml b/backend/plugin/advisor/mysql/test/naming_table.yamlindex 7529feef28..d82f259735 100644--- a/backend/plugin/advisor/mysql/test/naming_table.yaml+++ b/backend/plugin/advisor/mysql/test/naming_table.yaml@@ -1,82 +1,94 @@- statement: CREATE TABLE techBook(id int, name varchar(255));want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '`techBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE tech_book_copy(id int, name varchar(255));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE cjnubexocfhqoogdmihudyahmmghviqkzvpixnwvxtxumvuannpwdcbtsgwrvzpde(id int, name varchar(255));want:- - status: WARN+ - status: 2code: 301title: naming.table- content: "`cjnubexocfhqoogdmihudyahmmghviqkzvpixnwvxtxumvuannpwdcbtsgwrvzpde` mismatches table naming convention, its length should be within 64 characters"- line: 1- details: ""+ content: '`cjnubexocfhqoogdmihudyahmmghviqkzvpixnwvxtxumvuannpwdcbtsgwrvzpde` mismatches table naming convention, its length should be within 64 characters'+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |CREATE TABLE book(a INT);ALTER TABLE book RENAME TO TechBook;want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '`TechBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |CREATE TABLE book(a INT);ALTER TABLE book RENAME TO tech_book_copy;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE book (a INT);RENAME TABLE book TO tech_book_copy, tech_book_copy TO LiteraryBook;want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '`LiteraryBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |CREATE TABLE literary_book(a int);CREATE TABLE book(a int);RENAME TABLE book TO TechBook, literary_book TO LiteraryBook;want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '`LiteraryBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 3- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 301title: naming.tablecontent: '`TechBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 3- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |CREATE TABLE literary_book(a int);CREATE TABLE book(a int);RENAME TABLE book TO tech_book_copy, literary_book TO literary_book_copy;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/test/schema_backward_compatibility.yaml b/backend/plugin/advisor/mysql/test/schema_backward_compatibility.yamlindex 804414eacc..dcdc7a3ffe 100644--- a/backend/plugin/advisor/mysql/test/schema_backward_compatibility.yaml+++ b/backend/plugin/advisor/mysql/test/schema_backward_compatibility.yaml@@ -1,45 +1,50 @@- statement: ALTER TABLE tech_book CHANGE name f2 TEXT;want:- - status: WARN+ - status: 2code: 111title: schema.backward-compatibility- content: |-- "ALTER TABLE tech_book CHANGE name f2 TEXT;" may cause incompatibility with the existing data and code- line: 1- details: ""+ content: '"ALTER TABLE tech_book CHANGE name f2 TEXT;" may cause incompatibility with the existing data and code'+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book MODIFY name TEXT;want:- - status: WARN+ - status: 2code: 111title: schema.backward-compatibility- content: |-- "ALTER TABLE tech_book MODIFY name TEXT;" may cause incompatibility with the existing data and code- line: 1- details: ""+ content: '"ALTER TABLE tech_book MODIFY name TEXT;" may cause incompatibility with the existing data and code'+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book MODIFY name TEXT NULL;want:- - status: WARN+ - status: 2code: 111title: schema.backward-compatibility- content: |-- "ALTER TABLE tech_book MODIFY name TEXT NULL;" may cause incompatibility with the existing data and code- line: 1- details: ""+ content: '"ALTER TABLE tech_book MODIFY name TEXT NULL;" may cause incompatibility with the existing data and code'+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book MODIFY name TEXT NOT NULL;want:- - status: WARN+ - status: 2code: 111title: schema.backward-compatibility- content: |-- "ALTER TABLE tech_book MODIFY name TEXT NOT NULL;" may cause incompatibility with the existing data and code- line: 1- details: ""+ content: '"ALTER TABLE tech_book MODIFY name TEXT NOT NULL;" may cause incompatibility with the existing data and code'+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book MODIFY name TEXT COMMENT 'bla';want:- - status: WARN+ - status: 2code: 111title: schema.backward-compatibility- content: |-- "ALTER TABLE tech_book MODIFY name TEXT COMMENT 'bla';" may cause incompatibility with the existing data and code- line: 1- details: ""+ content: '"ALTER TABLE tech_book MODIFY name TEXT COMMENT ''bla'';" may cause incompatibility with the existing data and code'+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mysql/test/statement_affected_row_limit.yaml b/backend/plugin/advisor/mysql/test/statement_affected_row_limit.yamlindex 2b5a418f16..72034d69d6 100644--- a/backend/plugin/advisor/mysql/test/statement_affected_row_limit.yaml+++ b/backend/plugin/advisor/mysql/test/statement_affected_row_limit.yaml@@ -1,16 +1,16 @@- statement: DELETE FROM tech_book WHERE a > 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: UPDATE tech_book SET id = 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/test/statement_disallow_commit.yaml b/backend/plugin/advisor/mysql/test/statement_disallow_commit.yamlindex f5682ce4ca..00970f21b7 100644--- a/backend/plugin/advisor/mysql/test/statement_disallow_commit.yaml+++ b/backend/plugin/advisor/mysql/test/statement_disallow_commit.yaml@@ -3,13 +3,14 @@CREATE TABLE techBook(id int, name varchar(255));COMMIT;want:- - status: WARN+ - status: 2code: 206title: statement.disallow-commit- content: |-- Commit is not allowed, related statement: "COMMIT;"- line: 3- details: ""+ content: 'Commit is not allowed, related statement: "COMMIT;"'+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-START TRANSACTION;CREATE TABLE techBook(id int, name varchar(255));@@ -19,17 +20,19 @@INSERT INTO techBook(id, name) VALUES(1, "book");COMMIT;want:- - status: WARN+ - status: 2code: 206title: statement.disallow-commit- content: |-- Commit is not allowed, related statement: "COMMIT;"- line: 3- details: ""- - status: WARN+ content: 'Commit is not allowed, related statement: "COMMIT;"'+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 206title: statement.disallow-commit- content: |-- Commit is not allowed, related statement: "COMMIT;"- line: 7- details: ""+ content: 'Commit is not allowed, related statement: "COMMIT;"'+ detail: ""+ startposition:+ line: 7+ column: 0diff --git a/backend/plugin/advisor/mysql/test/statement_disallow_limit.yaml b/backend/plugin/advisor/mysql/test/statement_disallow_limit.yamlindex 682b41e850..f8cdc0d720 100644--- a/backend/plugin/advisor/mysql/test/statement_disallow_limit.yaml+++ b/backend/plugin/advisor/mysql/test/statement_disallow_limit.yaml@@ -1,63 +1,68 @@-- statement: "INSERT INTO tech_book SELECT * FROM tech_book;"+- statement: INSERT INTO tech_book SELECT * FROM tech_book;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |INSERT INTO tech_book SELECT * FROM tech_book;INSERT INTO tech_book SELECT * FROM tech_book LIMIT 1;want:- - status: WARN+ - status: 2code: 1103title: statement.disallow-limit- content: |-- LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO tech_book SELECT * FROM tech_book LIMIT 1;" uses- line: 2- details: ""+ content: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO tech_book SELECT * FROM tech_book LIMIT 1;" uses+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |INSERT INTO tech_book SELECT * FROM tech_book;INSERT INTO tech_book SELECT * FROM tech_book UNION SELECT * FROM tech_book LIMIT 1;want:- - status: WARN+ - status: 2code: 1103title: statement.disallow-limit- content: |-- LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO tech_book SELECT * FROM tech_book UNION SELECT * FROM tech_book LIMIT 1;" uses- line: 2- details: ""+ content: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO tech_book SELECT * FROM tech_book UNION SELECT * FROM tech_book LIMIT 1;" uses+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |INSERT INTO tech_book SELECT * FROM tech_book;INSERT INTO tech_book SELECT * FROM tech_book UNION SELECT * FROM tech_book LIMIT 1;want:- - status: WARN+ - status: 2code: 1103title: statement.disallow-limit- content: |-- LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO tech_book SELECT * FROM tech_book UNION SELECT * FROM tech_book LIMIT 1;" uses- line: 2- details: ""+ content: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO tech_book SELECT * FROM tech_book UNION SELECT * FROM tech_book LIMIT 1;" uses+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |UPDATE tech_book SET name = 'my name';UPDATE tech_book SET name = 'my name' LIMIT 10;want:- - status: WARN+ - status: 2code: 1102title: statement.disallow-limit- content: |-- LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "UPDATE tech_book SET name = 'my name' LIMIT 10;" uses- line: 2- details: ""+ content: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "UPDATE tech_book SET name = 'my name' LIMIT 10;" uses+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |DELETE FROM tech_book;DELETE FROM tech_book LIMIT 10;want:- - status: WARN+ - status: 2code: 1106title: statement.disallow-limit- content: |-- LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "DELETE FROM tech_book LIMIT 10;" uses- line: 2- details: ""+ content: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "DELETE FROM tech_book LIMIT 10;" uses+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mysql/test/statement_disallow_mix_ddl_dml.yaml b/backend/plugin/advisor/mysql/test/statement_disallow_mix_ddl_dml.yamlindex 62469211b4..581f21d722 100644--- a/backend/plugin/advisor/mysql/test/statement_disallow_mix_ddl_dml.yaml+++ b/backend/plugin/advisor/mysql/test/statement_disallow_mix_ddl_dml.yaml@@ -1,27 +1,24 @@- statement: DELETE FROM tech_book WHERE a > 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: UPDATE tech_book SET id = 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book ADD COLUMN author TEXT; UPDATE tech_book SET id = 1;DELETE FROM tech_book WHERE a > 1;want:- - status: WARN+ - status: 2code: 227title: statement.disallow-mix-ddl-dmlcontent: Mixing DDL with DML is not allowed- line: 0- column: 0- details: ""\ No newline at end of file+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/test/statement_disallow_order_by.yaml b/backend/plugin/advisor/mysql/test/statement_disallow_order_by.yamlindex 88f6f31789..6493907c8a 100644--- a/backend/plugin/advisor/mysql/test/statement_disallow_order_by.yaml+++ b/backend/plugin/advisor/mysql/test/statement_disallow_order_by.yaml@@ -1,30 +1,32 @@- statement: INSERT INTO tech_book values(1, 'a');want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-UPDATE tech_book SET name = 'my name';UPDATE tech_book SET name = 'my name' ORDER BY id;want:- - status: WARN+ - status: 2code: 1104title: statement.disallow-order-by- content: |-- ORDER BY clause is forbidden in DELETE and UPDATE statements, but "UPDATE tech_book SET name = 'my name' ORDER BY id;" uses- line: 2- details: ""+ content: ORDER BY clause is forbidden in DELETE and UPDATE statements, but "UPDATE tech_book SET name = 'my name' ORDER BY id;" uses+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-DELETE FROM tech_book;DELETE FROM tech_book ORDER BY id;want:- - status: WARN+ - status: 2code: 1105title: statement.disallow-order-by- content: |-- ORDER BY clause is forbidden in DELETE and UPDATE statements, but "DELETE FROM tech_book ORDER BY id;" uses- line: 2- details: ""+ content: ORDER BY clause is forbidden in DELETE and UPDATE statements, but "DELETE FROM tech_book ORDER BY id;" uses+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mysql/test/statement_dml_dry_run.yaml b/backend/plugin/advisor/mysql/test/statement_dml_dry_run.yamlindex d44c44e224..b7f60bc458 100644--- a/backend/plugin/advisor/mysql/test/statement_dml_dry_run.yaml+++ b/backend/plugin/advisor/mysql/test/statement_dml_dry_run.yaml@@ -1,24 +1,24 @@- statement: INSERT INTO tech_book values(1, 'zp');want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: DELETE FROM tech_book;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: UPDATE tech_book SET name = 'xz' WHERE id = 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/test/statement_insert_disallow_order_by_rand.yaml b/backend/plugin/advisor/mysql/test/statement_insert_disallow_order_by_rand.yamlindex 7a39100a60..86eaf5869a 100644--- a/backend/plugin/advisor/mysql/test/statement_insert_disallow_order_by_rand.yaml+++ b/backend/plugin/advisor/mysql/test/statement_insert_disallow_order_by_rand.yaml@@ -1,30 +1,32 @@- statement: INSERT INTO tech_book VALUES(1, "a");want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-INSERT INTO tech_book VALUES(1, "a");INSERT INTO tech_book SELECT * FROM tech_book ORDER BY rand();want:- - status: WARN+ - status: 2code: 1108title: statement.insert.disallow-order-by-rand- content: |-- "INSERT INTO tech_book SELECT * FROM tech_book ORDER BY rand();" uses ORDER BY RAND in the INSERT statement- line: 2- details: ""+ content: '"INSERT INTO tech_book SELECT * FROM tech_book ORDER BY rand();" uses ORDER BY RAND in the INSERT statement'+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-INSERT INTO tech_book VALUES(1, "a");INSERT INTO tech_book SELECT * FROM tech_book ORDER BY RAND() LIMIT 1;want:- - status: WARN+ - status: 2code: 1108title: statement.insert.disallow-order-by-rand- content: |-- "INSERT INTO tech_book SELECT * FROM tech_book ORDER BY RAND() LIMIT 1;" uses ORDER BY RAND in the INSERT statement- line: 2- details: ""+ content: '"INSERT INTO tech_book SELECT * FROM tech_book ORDER BY RAND() LIMIT 1;" uses ORDER BY RAND in the INSERT statement'+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mysql/test/statement_insert_must_specify_column.yaml b/backend/plugin/advisor/mysql/test/statement_insert_must_specify_column.yamlindex 24a695f9d5..9da2ba77ff 100644--- a/backend/plugin/advisor/mysql/test/statement_insert_must_specify_column.yaml+++ b/backend/plugin/advisor/mysql/test/statement_insert_must_specify_column.yaml@@ -1,28 +1,28 @@- statement: INSERT INTO t_copy SELECT * FROM t;want:- - status: WARN+ - status: 2code: 1107title: statement.insert.must-specify-column- content: |-- The INSERT statement must specify columns but "INSERT INTO t_copy SELECT * FROM t;" does not- line: 1- details: ""+ content: The INSERT statement must specify columns but "INSERT INTO t_copy SELECT * FROM t;" does not+ detail: ""+ startposition:+ line: 1+ column: 0- statement: INSERT INTO tech_book(id, name) VALUES (1, '1');want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""-- statement: |-- INSERT INTO tech_book(id, name) VALUES (1, '1');- INSERT INTO tech_book VALUES (1, '1');+ detail: ""+ startposition: null+- statement: "INSERT INTO tech_book(id, name) VALUES (1, '1'); \nINSERT INTO tech_book VALUES (1, '1');"want:- - status: WARN+ - status: 2code: 1107title: statement.insert.must-specify-column- content: |-- The INSERT statement must specify columns but "INSERT INTO tech_book VALUES (1, '1');" does not- line: 2- details: ""+ content: The INSERT statement must specify columns but "INSERT INTO tech_book VALUES (1, '1');" does not+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mysql/test/statement_insert_row_limit.yaml b/backend/plugin/advisor/mysql/test/statement_insert_row_limit.yamlindex 25e3a3b143..8937b92ce1 100644--- a/backend/plugin/advisor/mysql/test/statement_insert_row_limit.yaml+++ b/backend/plugin/advisor/mysql/test/statement_insert_row_limit.yaml@@ -1,27 +1,28 @@- statement: INSERT INTO tech_book values(1, 'a');want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |INSERT INTO tech_book values(1, 'a');INSERT INTO tech_book values(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f');want:- - status: WARN+ - status: 2code: 1101title: statement.insert.row-limit- content: |-- "INSERT INTO tech_book values(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f');" inserts 6 rows. The count exceeds 5.- line: 2- details: ""+ content: '"INSERT INTO tech_book values(1, ''a''), (2, ''b''), (3, ''c''), (4, ''d''), (5, ''e''), (6, ''f'');" inserts 6 rows. The count exceeds 5.'+ detail: ""+ startposition:+ line: 2+ column: 0- statement: INSERT INTO tech_book SELECT * FROM tech_book;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/test/statement_maximum_join_table_count.yaml b/backend/plugin/advisor/mysql/test/statement_maximum_join_table_count.yamlindex c69948c1c9..468538309d 100644--- a/backend/plugin/advisor/mysql/test/statement_maximum_join_table_count.yaml+++ b/backend/plugin/advisor/mysql/test/statement_maximum_join_table_count.yaml@@ -1,18 +1,18 @@- statement: SELECT * FROM t;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""-- statement: |-- select name from hello join world on hello.id = world.id join baby on world.id = baby.id;+ detail: ""+ startposition: null+- statement: select name from hello join world on hello.id = world.id join baby on world.id = baby.id;want:- - status: WARN+ - status: 2code: 223title: statement.maximum-join-table-count- content: |-- "select name from hello join world on hello.id = world.id join baby on world.id = baby.id;" exceeds the maximum number of joins 2.- line: 1- details: ""+ content: '"select name from hello join world on hello.id = world.id join baby on world.id = baby.id;" exceeds the maximum number of joins 2.'+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mysql/test/statement_maximum_limit_value.yaml b/backend/plugin/advisor/mysql/test/statement_maximum_limit_value.yamlindex 3929343eaf..92506c1406 100644--- a/backend/plugin/advisor/mysql/test/statement_maximum_limit_value.yaml+++ b/backend/plugin/advisor/mysql/test/statement_maximum_limit_value.yaml@@ -1,9 +1,11 @@- statement: |SELECT * FROM employee LIMIT 1000000;want:- - status: WARN+ - status: 2code: 222title: statement.maximum-limit-value- content: |-- The limit value 1000000 exceeds the maximum allowed value 1000- line: 1+ content: The limit value 1000000 exceeds the maximum allowed value 1000+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mysql/test/statement_merge_alter_table.yaml b/backend/plugin/advisor/mysql/test/statement_merge_alter_table.yamlindex af1ba35f4c..b42968d1ab 100644--- a/backend/plugin/advisor/mysql/test/statement_merge_alter_table.yaml+++ b/backend/plugin/advisor/mysql/test/statement_merge_alter_table.yaml@@ -1,54 +1,64 @@- statement: ALTER TABLE tech_book ADD COLUMN a int;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-ALTER TABLE tech_book ADD COLUMN a int;ALTER TABLE tech_book CHANGE COLUMN a c int;want:- - status: WARN+ - status: 2code: 207title: statement.merge-alter-tablecontent: There are 2 statements to modify table `tech_book`- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE tech_book ADD COLUMN b int;ALTER TABLE t ADD COLUMN b int;ALTER TABLE tech_book MODIFY COLUMN b varchar(255);want:- - status: WARN+ - status: 2code: 207title: statement.merge-alter-tablecontent: There are 2 statements to modify table `t`- line: 3- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 207title: statement.merge-alter-tablecontent: There are 2 statements to modify table `tech_book`- line: 4- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE tech_book ADD COLUMN a int;ALTER TABLE tech_book ADD COLUMN b int;ALTER TABLE t ADD COLUMN b int;want:- - status: WARN+ - status: 2code: 207title: statement.merge-alter-tablecontent: There are 2 statements to modify table `tech_book`- line: 3- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 207title: statement.merge-alter-tablecontent: There are 2 statements to modify table `t`- line: 4- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0diff --git a/backend/plugin/advisor/mysql/test/statement_prior_backup_check.yaml b/backend/plugin/advisor/mysql/test/statement_prior_backup_check.yamlindex 328b03fe13..dcd8f3bf18 100644--- a/backend/plugin/advisor/mysql/test/statement_prior_backup_check.yaml+++ b/backend/plugin/advisor/mysql/test/statement_prior_backup_check.yaml@@ -1,6 +1,6 @@- statement: DELETE FROM tech_book WHERE a > 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""@@ -9,7 +9,7 @@details: ""- statement: UPDATE tech_book SET id = 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""@@ -18,7 +18,7 @@details: ""- statement: UPDATE tech_book SET id = 1;DELETE FROM tech_book WHERE a > 1;want:- - status: WARN+ - status: 2code: 227title: statement.prior-backup-checkcontent: Found 1 DELETE, 1 UPDATE on table ``.`tech_book`, disallow mixing different types of DML statementsdiff --git a/backend/plugin/advisor/mysql/test/statement_select_no_select_all.yaml b/backend/plugin/advisor/mysql/test/statement_select_no_select_all.yamlindex 558acacbce..22e7e2965e 100644--- a/backend/plugin/advisor/mysql/test/statement_select_no_select_all.yaml+++ b/backend/plugin/advisor/mysql/test/statement_select_no_select_all.yaml@@ -1,99 +1,112 @@- statement: SELECT * FROM t;want:- - status: WARN+ - status: 2code: 203title: statement.select.no-select-all- content: |-- "SELECT * FROM t;" uses SELECT all- line: 1- details: ""+ content: '"SELECT * FROM t;" uses SELECT all'+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT a, b FROM t;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |SELECT a, b FROM t;SELECT * FROM t;SELECT a, b FROM (SELECT * from t1 JOIN t2) t;want:- - status: WARN+ - status: 2code: 203title: statement.select.no-select-all- content: |-- "SELECT * FROM t;" uses SELECT all- line: 2- details: ""- - status: WARN+ content: '"SELECT * FROM t;" uses SELECT all'+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 203title: statement.select.no-select-all- content: |-- "SELECT a, b FROM (SELECT * from t1 JOIN t2) t;" uses SELECT all- line: 3- details: ""+ content: '"SELECT a, b FROM (SELECT * from t1 JOIN t2) t;" uses SELECT all'+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-SELECT a, b FROM t;SELECT * FROM t1UNIONSELECT * FROM t2;want:- - status: WARN+ - status: 2code: 203title: statement.select.no-select-allcontent: |-"SELECT * FROM t1UNIONSELECT * FROM t2;" uses SELECT all- line: 2- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 203title: statement.select.no-select-allcontent: |-"SELECT * FROM t1UNIONSELECT * FROM t2;" uses SELECT all- line: 4- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0- statement: |-SELECT a, b FROM t;WITH cte AS (SELECT * FROM a) SELECT * FROM cte;want:- - status: WARN+ - status: 2code: 203title: statement.select.no-select-allcontent: |-"WITH cte AS (SELECT * FROM a) SELECT * FROM cte;" uses SELECT all- line: 3- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 203title: statement.select.no-select-allcontent: |-"WITH cte AS (SELECT * FROM a) SELECT * FROM cte;" uses SELECT all- line: 4- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0- statement: |-SELECT a, b FROM t;SELECT *FROM aINNER JOIN b USING(id);want:- - status: WARN+ - status: 2code: 203title: statement.select.no-select-allcontent: |-"SELECT *FROM aINNER JOIN b USING(id);" uses SELECT all- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mysql/test/statement_where_disallow_functions_and_calculations.yaml b/backend/plugin/advisor/mysql/test/statement_where_disallow_functions_and_calculations.yamlindex 0270425f2f..a81724727b 100644--- a/backend/plugin/advisor/mysql/test/statement_where_disallow_functions_and_calculations.yaml+++ b/backend/plugin/advisor/mysql/test/statement_where_disallow_functions_and_calculations.yaml@@ -1,9 +1,10 @@- statement: SELECT * FROM employee WHERE id = RAND();want:- - status: WARN+ - status: 2code: 1702title: statement.where.disallow-functions-and-calculations- content: |-- Function is disallowed in where clause, but "SELECT * FROM employee WHERE id = RAND();" uses- line: 1- details: ""+ content: Function is disallowed in where clause, but "SELECT * FROM employee WHERE id = RAND();" uses+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mysql/test/statement_where_maximum_logical_operator_count.yaml b/backend/plugin/advisor/mysql/test/statement_where_maximum_logical_operator_count.yamlindex 8971fc80c2..6c6b819b00 100644--- a/backend/plugin/advisor/mysql/test/statement_where_maximum_logical_operator_count.yaml+++ b/backend/plugin/advisor/mysql/test/statement_where_maximum_logical_operator_count.yaml@@ -1,18 +1,20 @@- statement: SELECT * FROM employee WHERE id IN (1, 2, 3, 4, 5);want:- - status: WARN+ - status: 2code: 225title: statement.where.maximum-logical-operator-count- content: |-- Number of tokens (5) in IN predicate operation exceeds limit (2) in statement "SELECT * FROM employee WHERE id IN (1, 2, 3, 4, 5);".- line: 1- details: ""+ content: Number of tokens (5) in IN predicate operation exceeds limit (2) in statement "SELECT * FROM employee WHERE id IN (1, 2, 3, 4, 5);".+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT * FROM employee WHERE id = 1 OR id = 2 OR id = 3 OR id = 4 OR id = 5;want:- - status: WARN+ - status: 2code: 225title: statement.where.maximum-logical-operator-count- content: |-- Number of tokens (5) in the OR predicate operation exceeds limit (2) in statement "SELECT * FROM employee WHERE id = 1 OR id = 2 OR id = 3 OR id = 4 OR id = 5;".- line: 1- details: ""+ content: Number of tokens (5) in the OR predicate operation exceeds limit (2) in statement "SELECT * FROM employee WHERE id = 1 OR id = 2 OR id = 3 OR id = 4 OR id = 5;".+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mysql/test/statement_where_no_equal_null.yaml b/backend/plugin/advisor/mysql/test/statement_where_no_equal_null.yamlindex c77a57726d..6bfb9c87f2 100644--- a/backend/plugin/advisor/mysql/test/statement_where_no_equal_null.yaml+++ b/backend/plugin/advisor/mysql/test/statement_where_no_equal_null.yaml@@ -1,19 +1,29 @@- statement: |SELECT * FROM employee WHERE name = 'Jack' AND id IS NULL;want:- - status: SUCCESS+ - status: 1+ code: 0title: OK+ content: ""+ detail: ""+ startposition: null- statement: |UPDATE employee SET name = NULL;want:- - status: SUCCESS+ - status: 1+ code: 0title: OK+ content: ""+ detail: ""+ startposition: null- statement: |SELECT * FROM t WHERE name = 'test' AND id = NULL;want:- - status: WARN+ - status: 2code: 221title: statement.where.no-equal-null- content: |-- WHERE clause contains equal null: SELECT * FROM t WHERE name = 'test' AND id = NULL;- line: 1+ content: 'WHERE clause contains equal null: SELECT * FROM t WHERE name = ''test'' AND id = NULL;'+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mysql/test/statement_where_no_leading_wildcard_like.yaml b/backend/plugin/advisor/mysql/test/statement_where_no_leading_wildcard_like.yamlindex 14d8fb2504..235903a1d3 100644--- a/backend/plugin/advisor/mysql/test/statement_where_no_leading_wildcard_like.yaml+++ b/backend/plugin/advisor/mysql/test/statement_where_no_leading_wildcard_like.yaml@@ -1,46 +1,48 @@- statement: |DELETE FROM tech_book WHERE name like "%abc";want:- - status: WARN+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: '"DELETE FROM tech_book WHERE name like "%abc";" uses leading wildcard LIKE'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |CREATE TABLE t (id INT);SELECT * FROM t WHERE a LIKE 'abc%';want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE t (id INT);SELECT * FROM t WHERE a LIKE '%abc';want:- - status: WARN+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: '"SELECT * FROM t WHERE a LIKE ''%abc'';" uses leading wildcard LIKE'- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |CREATE TABLE t (id INT);SELECT * FROM t WHERE a LIKE 'abc' OR a LIKE '%abc';want:- - status: WARN+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: '"SELECT * FROM t WHERE a LIKE ''abc'' OR a LIKE ''%abc'';" uses leading wildcard LIKE'- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |CREATE TABLE t (id INT, a VARCHAR(255));SELECT *@@ -48,7 +50,7 @@WHERE a LIKE '%acc'OR a LIKE '%abc';want:- - status: WARN+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: |-@@ -56,10 +58,11 @@FROM tWHERE a LIKE '%acc'OR a LIKE '%abc';" uses leading wildcard LIKE- line: 4- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 4+ column: 0+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: |-@@ -67,9 +70,10 @@FROM tWHERE a LIKE '%acc'OR a LIKE '%abc';" uses leading wildcard LIKE- line: 5- column: 0- details: ""+ detail: ""+ startposition:+ line: 5+ column: 0- statement: |CREATE TABLE t (id INT, a VARCHAR(255));SELECT * FROM@@ -79,7 +83,7 @@OR a LIKE '%abc') t1;want:- - status: WARN+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: |-@@ -89,10 +93,11 @@WHERE a LIKE '%acc'OR a LIKE '%abc') t1;" uses leading wildcard LIKE- line: 5- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 5+ column: 0+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: |-@@ -102,6 +107,7 @@WHERE a LIKE '%acc'OR a LIKE '%abc') t1;" uses leading wildcard LIKE- line: 6- column: 0- details: ""+ detail: ""+ startposition:+ line: 6+ column: 0diff --git a/backend/plugin/advisor/mysql/test/statement_where_require.yaml b/backend/plugin/advisor/mysql/test/statement_where_require.yamlindex 274defe053..0a671e3c3d 100644--- a/backend/plugin/advisor/mysql/test/statement_where_require.yaml+++ b/backend/plugin/advisor/mysql/test/statement_where_require.yaml@@ -2,75 +2,78 @@CREATE TABLE book(id INT);INSERT INTO book(id) values (1);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE book(id INT);DELETE FROM book;want:- - status: WARN+ - status: 2code: 202title: statement.where.require- content: |-- "DELETE FROM book;" requires WHERE clause- line: 2- details: ""+ content: '"DELETE FROM book;" requires WHERE clause'+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |CREATE TABLE book(id INT);UPDATE book SET id = 1;want:- - status: WARN+ - status: 2code: 202title: statement.where.require- content: |-- "UPDATE book SET id = 1;" requires WHERE clause- line: 2- details: ""+ content: '"UPDATE book SET id = 1;" requires WHERE clause'+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |CREATE TABLE book(id INT);DELETE FROM book WHERE id > 0;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE book(id INT);UPDATE book SET id = 1 WHERE id > 10;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE book(id INT);SELECT id FROM book;want:- - status: WARN+ - status: 2code: 202title: statement.where.require- content: |-- "SELECT id FROM book;" requires WHERE clause- line: 2- details: ""+ content: '"SELECT id FROM book;" requires WHERE clause'+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |CREATE TABLE book(id INT);SELECT id FROM book WHERE id > 0;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE book(id INT);SELECT id@@ -80,7 +83,7 @@FROM book);want:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: |-@@ -90,14 +93,16 @@SELECT max(id)FROM book);" requires WHERE clause- line: 5- details: ""+ detail: ""+ startposition:+ line: 5+ column: 0- statement: |SELECT CURDATE();want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/test/system_charset_allowlist.yaml b/backend/plugin/advisor/mysql/test/system_charset_allowlist.yamlindex d091beb73e..2ba9c3d098 100644--- a/backend/plugin/advisor/mysql/test/system_charset_allowlist.yaml+++ b/backend/plugin/advisor/mysql/test/system_charset_allowlist.yaml@@ -1,95 +1,102 @@- statement: CREATE TABLE t(a int) CHARSET utf8mb4;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a varchar(255));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a int) CHARSET ascii;want:- - status: WARN+ - status: 2code: 1001title: system.charset.allowlist- content: |-- "CREATE TABLE t(a int) CHARSET ascii;" used disabled charset 'ascii'- line: 1- details: ""+ content: '"CREATE TABLE t(a int) CHARSET ascii;" used disabled charset ''ascii'''+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t CHARSET ascii;want:- - status: WARN+ - status: 2code: 1001title: system.charset.allowlist- content: |-- "ALTER TABLE t CHARSET ascii;" used disabled charset 'ascii'- line: 2- details: ""+ content: '"ALTER TABLE t CHARSET ascii;" used disabled charset ''ascii'''+ detail: ""+ startposition:+ line: 2+ column: 0- statement: ALTER DATABASE test CHARSET ascii;want:- - status: WARN+ - status: 2code: 1001title: system.charset.allowlist- content: |-- "ALTER DATABASE test CHARSET ascii;" used disabled charset 'ascii'- line: 1- details: ""+ content: '"ALTER DATABASE test CHARSET ascii;" used disabled charset ''ascii'''+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(a varchar(255) CHARSET ascii);want:- - status: WARN+ - status: 2code: 1001title: system.charset.allowlist- content: |-- "CREATE TABLE t(a varchar(255) CHARSET ascii);" used disabled charset 'ascii'- line: 1- details: ""+ content: '"CREATE TABLE t(a varchar(255) CHARSET ascii);" used disabled charset ''ascii'''+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t(b int);ALTER TABLE t ADD COLUMN a varchar(255) CHARSET ascii;want:- - status: WARN+ - status: 2code: 1001title: system.charset.allowlist- content: |-- "ALTER TABLE t ADD COLUMN a varchar(255) CHARSET ascii;" used disabled charset 'ascii'- line: 2- details: ""+ content: '"ALTER TABLE t ADD COLUMN a varchar(255) CHARSET ascii;" used disabled charset ''ascii'''+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t MODIFY COLUMN a varchar(255) CHARSET ascii;want:- - status: WARN+ - status: 2code: 1001title: system.charset.allowlist- content: |-- "ALTER TABLE t MODIFY COLUMN a varchar(255) CHARSET ascii;" used disabled charset 'ascii'- line: 2- details: ""+ content: '"ALTER TABLE t MODIFY COLUMN a varchar(255) CHARSET ascii;" used disabled charset ''ascii'''+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARSET ascii;want:- - status: WARN+ - status: 2code: 1001title: system.charset.allowlist- content: |-- "ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARSET ascii;" used disabled charset 'ascii'- line: 2- details: ""+ content: '"ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARSET ascii;" used disabled charset ''ascii'''+ detail: ""+ startposition:+ line: 2+ column: 0- statement: /* this is a comment */want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/test/system_collation_allowlist.yaml b/backend/plugin/advisor/mysql/test/system_collation_allowlist.yamlindex 093a39fa5e..2699e2094d 100644--- a/backend/plugin/advisor/mysql/test/system_collation_allowlist.yaml+++ b/backend/plugin/advisor/mysql/test/system_collation_allowlist.yaml@@ -1,12 +1,11 @@-- statement: |-- CREATE TABLE test(id INT PRIMARY KEY COMMENT 'comment',name VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'comment',room_id INT NOT NULL DEFAULT 0 COMMENT 'comment',creator_id INT NOT NULL DEFAULT 0 COMMENT 'comment',created_ts TIMESTAMP NOT NULL DEFAULT NOW() COMMENT 'comment',updater_id INT NOT NULL DEFAULT 0 COMMENT 'comment',updated_ts TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',INDEX idx_test_name(name),UNIQUE KEY uk_test_id_name(id, name)) ENGINE = INNODB COMMENT 'comment'+- statement: CREATE TABLE test(id INT PRIMARY KEY COMMENT 'comment',name VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'comment',room_id INT NOT NULL DEFAULT 0 COMMENT 'comment',creator_id INT NOT NULL DEFAULT 0 COMMENT 'comment',created_ts TIMESTAMP NOT NULL DEFAULT NOW() COMMENT 'comment',updater_id INT NOT NULL DEFAULT 0 COMMENT 'comment',updated_ts TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',INDEX idx_test_name(name),UNIQUE KEY uk_test_id_name(id, name)) ENGINE = INNODB COMMENT 'comment'want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE userTable(id INT NOT NULL,@@ -21,7 +20,7 @@FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin;want:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlistcontent: |-@@ -37,8 +36,10 @@UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin;" used disabled collation 'latin1_bin'- line: 12- details: ""+ detail: ""+ startposition:+ line: 12+ column: 0- statement: |CREATE TABLE user(id INT PRIMARY KEY COMMENT 'comment',@@ -52,97 +53,105 @@UNIQUE KEY uk_user_id_name(id, name)) ENGINE = INNODB COMMENT 'comment';want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a int) COLLATE utf8mb4_polish_ci;want:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlist- content: |-- "CREATE TABLE t(a int) COLLATE utf8mb4_polish_ci;" used disabled collation 'utf8mb4_polish_ci'- line: 1- details: ""+ content: '"CREATE TABLE t(a int) COLLATE utf8mb4_polish_ci;" used disabled collation ''utf8mb4_polish_ci'''+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(a varchar(255));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a int) COLLATE latin1_bin;want:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlist- content: |-- "CREATE TABLE t(a int) COLLATE latin1_bin;" used disabled collation 'latin1_bin'- line: 1- details: ""+ content: '"CREATE TABLE t(a int) COLLATE latin1_bin;" used disabled collation ''latin1_bin'''+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t COLLATE latin1_bin;want:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlist- content: |-- "ALTER TABLE t COLLATE latin1_bin;" used disabled collation 'latin1_bin'- line: 2- details: ""+ content: '"ALTER TABLE t COLLATE latin1_bin;" used disabled collation ''latin1_bin'''+ detail: ""+ startposition:+ line: 2+ column: 0- statement: ALTER DATABASE test COLLATE latin1_bin;want:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlist- content: |-- "ALTER DATABASE test COLLATE latin1_bin;" used disabled collation 'latin1_bin'- line: 1- details: ""+ content: '"ALTER DATABASE test COLLATE latin1_bin;" used disabled collation ''latin1_bin'''+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin);want:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlist- content: |-- "CREATE TABLE t(a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin);" used disabled collation 'latin1_bin'- line: 1- details: ""+ content: '"CREATE TABLE t(a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin);" used disabled collation ''latin1_bin'''+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t(b int);ALTER TABLE t ADD COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin;want:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlist- content: |-- "ALTER TABLE t ADD COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin;" used disabled collation 'latin1_bin'- line: 2- details: ""+ content: '"ALTER TABLE t ADD COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin;" used disabled collation ''latin1_bin'''+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t MODIFY COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin;want:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlist- content: |-- "ALTER TABLE t MODIFY COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin;" used disabled collation 'latin1_bin'- line: 2- details: ""+ content: '"ALTER TABLE t MODIFY COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin;" used disabled collation ''latin1_bin'''+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin;want:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlist- content: |-- "ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin;" used disabled collation 'latin1_bin'- line: 2- details: ""+ content: '"ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin;" used disabled collation ''latin1_bin'''+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mysql/test/system_event_disallow_create.yaml b/backend/plugin/advisor/mysql/test/system_event_disallow_create.yamlindex c34bcb2c1f..6b0133f9d9 100644--- a/backend/plugin/advisor/mysql/test/system_event_disallow_create.yaml+++ b/backend/plugin/advisor/mysql/test/system_event_disallow_create.yaml@@ -1,11 +1,11 @@- statement: CREATE TABLE t(a int);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE EVENT daily_backupON SCHEDULE@@ -16,7 +16,7 @@SELECT NOW(), dataFROM main_table;want:- - status: WARN+ - status: 2code: 1501title: system.event.disallow-createcontent: |-@@ -28,5 +28,7 @@INSERT INTO backup_table (backup_date, data)SELECT NOW(), dataFROM main_table;" creates- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mysql/test/system_function_disallow_create.yaml b/backend/plugin/advisor/mysql/test/system_function_disallow_create.yamlindex f95f29926a..5efd3ea708 100644--- a/backend/plugin/advisor/mysql/test/system_function_disallow_create.yaml+++ b/backend/plugin/advisor/mysql/test/system_function_disallow_create.yaml@@ -1,11 +1,11 @@- statement: CREATE TABLE t(a int);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE FUNCTION add_two_numbers(a INT, b INT)RETURNS INT@@ -15,7 +15,7 @@RETURN result;END;want:- - status: WARN+ - status: 2code: 1701title: system.function.disallow-createcontent: |-@@ -26,5 +26,7 @@SET result = a + b;RETURN result;END;" creates- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mysql/test/system_function_disallowed_list.yaml b/backend/plugin/advisor/mysql/test/system_function_disallowed_list.yamlindex 8c2fffaedc..3e1522bf57 100644--- a/backend/plugin/advisor/mysql/test/system_function_disallowed_list.yaml+++ b/backend/plugin/advisor/mysql/test/system_function_disallowed_list.yaml@@ -1,20 +1,21 @@- statement: CREATE TABLE t(a int);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: SELECT RAND();want:- - status: WARN+ - status: 2code: 1702title: system.function.disallowed-list- content: |-- Function "RAND" is disallowed, but "SELECT RAND();" uses- line: 1- details: ""+ content: Function "RAND" is disallowed, but "SELECT RAND();" uses+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE employee (id VARCHAR(36) DEFAULT (UUID()) PRIMARY KEY,@@ -22,7 +23,7 @@age INT);want:- - status: WARN+ - status: 2code: 1702title: system.function.disallowed-listcontent: |-@@ -31,14 +32,17 @@name VARCHAR(255),age INT);" uses- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: SELECT SLEEP(5);want:- - status: WARN+ - status: 2code: 1702title: system.function.disallowed-list- content: |-- Function "SLEEP" is disallowed, but "SELECT SLEEP(5);" uses- line: 1- details: ""+ content: Function "SLEEP" is disallowed, but "SELECT SLEEP(5);" uses+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mysql/test/system_procedure_disallow_create.yaml b/backend/plugin/advisor/mysql/test/system_procedure_disallow_create.yamlindex 4e2b7c32be..55b1cf7810 100644--- a/backend/plugin/advisor/mysql/test/system_procedure_disallow_create.yaml+++ b/backend/plugin/advisor/mysql/test/system_procedure_disallow_create.yaml@@ -1,18 +1,18 @@- statement: CREATE TABLE t(a int);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE PROCEDURE simpleProcedure()BEGINSELECT 'Hello, World!' AS Message;END;want:- - status: WARN+ - status: 2code: 1401title: system.procedure.disallow-createcontent: |-@@ -20,5 +20,7 @@BEGINSELECT 'Hello, World!' AS Message;END;" creates- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mysql/test/system_view_disallow_create.yaml b/backend/plugin/advisor/mysql/test/system_view_disallow_create.yamlindex 3c3ab1beaa..5e47781c10 100644--- a/backend/plugin/advisor/mysql/test/system_view_disallow_create.yaml+++ b/backend/plugin/advisor/mysql/test/system_view_disallow_create.yaml@@ -1,18 +1,18 @@- statement: CREATE TABLE t(a int);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""-- statement: |-- CREATE VIEW get_one AS SELECT 1;+ detail: ""+ startposition: null+- statement: CREATE VIEW get_one AS SELECT 1;want:- - status: WARN+ - status: 2code: 1601title: system.view.disallow-create- content: |-- View is forbidden, but "CREATE VIEW get_one AS SELECT 1;" creates- line: 1- details: ""+ content: View is forbidden, but "CREATE VIEW get_one AS SELECT 1;" creates+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/mysql/test/table_comment.yaml b/backend/plugin/advisor/mysql/test/table_comment.yamlindex edd577b38a..930792b251 100644--- a/backend/plugin/advisor/mysql/test/table_comment.yaml+++ b/backend/plugin/advisor/mysql/test/table_comment.yaml@@ -2,29 +2,35 @@CREATE TABLE a(b INT) COMMENT 'table';CREATE TABLE t(a int) COMMENT 'some comments';want:- - status: WARN+ - status: 2code: 606title: table.commentcontent: The length of table `t` comment should be within 10 characters- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE a(b INT) COMMENT 'table';CREATE TABLE t(a int);want:- - status: WARN+ - status: 2code: 605title: table.commentcontent: Table `t` requires comments- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE a(b INT) COMMENT 'table';CREATE TABLE t(a int) COMMENT 'sdlfkjalkseblkjduafelbnlsdfkljayue';want:- - status: WARN+ - status: 2code: 606title: table.commentcontent: The length of table `t` comment should be within 10 characters- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mysql/test/table_disallow_partition.yaml b/backend/plugin/advisor/mysql/test/table_disallow_partition.yamlindex aec1fbeaa4..790dee3e67 100644--- a/backend/plugin/advisor/mysql/test/table_disallow_partition.yaml+++ b/backend/plugin/advisor/mysql/test/table_disallow_partition.yaml@@ -1,11 +1,11 @@- statement: CREATE TABLE t(a int);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE b(a INT);CREATE TABLE t(a int) PARTITION BY RANGE (a) (@@ -13,7 +13,7 @@PARTITION p1 VALUES LESS THAN (11));want:- - status: WARN+ - status: 2code: 608title: table.disallow-partitioncontent: |-@@ -21,15 +21,17 @@PARTITION p0 VALUES LESS THAN (6),PARTITION p1 VALUES LESS THAN (11));" creates- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-ALTER TABLE tech_book PARTITION BY RANGE (a) (PARTITION p0 VALUES LESS THAN (6),PARTITION p1 VALUES LESS THAN (11));want:- - status: WARN+ - status: 2code: 608title: table.disallow-partitioncontent: |-@@ -37,8 +39,10 @@PARTITION p0 VALUES LESS THAN (6),PARTITION p1 VALUES LESS THAN (11));" creates- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t(a int) PARTITION BY RANGE (a) (PARTITION p0 VALUES LESS THAN (6),@@ -49,7 +53,7 @@PARTITION p1 VALUES LESS THAN (11));want:- - status: WARN+ - status: 2code: 608title: table.disallow-partitioncontent: |-@@ -57,9 +61,11 @@PARTITION p0 VALUES LESS THAN (6),PARTITION p1 VALUES LESS THAN (11));" creates- line: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 608title: table.disallow-partitioncontent: |-@@ -67,5 +73,7 @@PARTITION p0 VALUES LESS THAN (6),PARTITION p1 VALUES LESS THAN (11));" creates- line: 5- details: ""+ detail: ""+ startposition:+ line: 5+ column: 0diff --git a/backend/plugin/advisor/mysql/test/table_disallow_set_charset.yaml b/backend/plugin/advisor/mysql/test/table_disallow_set_charset.yamlindex cc53ad78be..056d6dd4b1 100644--- a/backend/plugin/advisor/mysql/test/table_disallow_set_charset.yaml+++ b/backend/plugin/advisor/mysql/test/table_disallow_set_charset.yaml@@ -4,7 +4,7 @@name VARCHAR(50)) CHARSET=utf8;want:- - status: WARN+ - status: 2code: 612title: table.disallow-set-charsetcontent: |-@@ -12,8 +12,10 @@id INT PRIMARY KEY,name VARCHAR(50)) CHARSET=utf8;" uses- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE employee (id INT PRIMARY KEY,@@ -21,10 +23,11 @@);ALTER TABLE employee CONVERT TO CHARACTER SET utf8;want:- - status: WARN+ - status: 2code: 612title: table.disallow-set-charset- content: |-- Set charset on tables is disallowed, but "ALTER TABLE employee CONVERT TO CHARACTER SET utf8;" uses- line: 5- details: ""+ content: Set charset on tables is disallowed, but "ALTER TABLE employee CONVERT TO CHARACTER SET utf8;" uses+ detail: ""+ startposition:+ line: 5+ column: 0diff --git a/backend/plugin/advisor/mysql/test/table_disallow_trigger.yaml b/backend/plugin/advisor/mysql/test/table_disallow_trigger.yamlindex d956a97f49..de3c896144 100644--- a/backend/plugin/advisor/mysql/test/table_disallow_trigger.yaml+++ b/backend/plugin/advisor/mysql/test/table_disallow_trigger.yaml@@ -1,21 +1,23 @@- statement: CREATE TABLE t(a int);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE account (acct_num INT, amount DECIMAL(10,2));CREATE TRIGGER ins_sum BEFORE INSERT ON accountFOR EACH ROW SET @sum = @sum + NEW.amount;want:- - status: WARN+ - status: 2code: 610title: table.disallow-triggercontent: |-Trigger is forbidden, but "CREATE TRIGGER ins_sum BEFORE INSERT ON accountFOR EACH ROW SET @sum = @sum + NEW.amount;" creates- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mysql/test/table_drop_naming_convention.yaml b/backend/plugin/advisor/mysql/test/table_drop_naming_convention.yamlindex 10117b5f89..55cfd7a66c 100644--- a/backend/plugin/advisor/mysql/test/table_drop_naming_convention.yaml+++ b/backend/plugin/advisor/mysql/test/table_drop_naming_convention.yaml@@ -3,31 +3,35 @@RENAME TABLE foo to foo_delete;DROP TABLE IF EXISTS foo_delete;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE foo(a INT);DROP TABLE IF EXISTS foo;want:- - status: WARN+ - status: 2code: 603title: table.drop-naming-conventioncontent: '`foo` mismatches drop table naming convention, naming format should be "_delete$"'- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE foo(a INT);RENAME TABLE foo to foo_delete;CREATE TABLE bar(a INT);DROP TABLE IF EXISTS foo_delete, bar;want:- - status: WARN+ - status: 2code: 603title: table.drop-naming-conventioncontent: '`bar` mismatches drop table naming convention, naming format should be "_delete$"'- line: 4- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0diff --git a/backend/plugin/advisor/mysql/test/table_no_duplicate_index.yaml b/backend/plugin/advisor/mysql/test/table_no_duplicate_index.yamlindex f482f64c7b..b88eb07889 100644--- a/backend/plugin/advisor/mysql/test/table_no_duplicate_index.yaml+++ b/backend/plugin/advisor/mysql/test/table_no_duplicate_index.yaml@@ -8,8 +8,12 @@INDEX idx_name (last_name, first_name));want:- - status: SUCCESS+ - status: 1+ code: 0title: OK+ content: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE orders (id INT PRIMARY KEY,@@ -20,8 +24,12 @@UNIQUE (customer_id));want:- - status: SUCCESS+ - status: 1+ code: 0title: OK+ content: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE users (id INT PRIMARY KEY,@@ -32,12 +40,14 @@INDEX idx_username_duplicate (username));want:- - status: WARN+ - status: 2code: 815title: table.no-duplicate-index- content: "`users` has duplicate index `idx_username_duplicate`"- line: 7- details: ""+ content: '`users` has duplicate index `idx_username_duplicate`'+ detail: ""+ startposition:+ line: 7+ column: 0- statement: |-CREATE TABLE orders (id INT PRIMARY KEY,@@ -48,12 +58,14 @@INDEX (customer_id));want:- - status: WARN+ - status: 2code: 815title: table.no-duplicate-index- content: "`orders` has duplicate index ``"- line: 7- details: ""+ content: '`orders` has duplicate index ``'+ detail: ""+ startposition:+ line: 7+ column: 0- statement: |-CREATE TABLE orders (id INT PRIMARY KEY,@@ -65,12 +77,14 @@);ALTER TABLE orders ADD INDEX idx_duplicate (customer_id);want:- - status: WARN+ - status: 2code: 815title: table.no-duplicate-index- content: "`orders` has duplicate index `idx_duplicate`"- line: 9- details: ""+ content: '`orders` has duplicate index `idx_duplicate`'+ detail: ""+ startposition:+ line: 9+ column: 0- statement: |-CREATE TABLE orders (id INT PRIMARY KEY,@@ -80,12 +94,14 @@CREATE INDEX idx_customer_id ON orders (customer_id);CREATE INDEX idx_customer_id_duplicate ON orders (customer_id);want:- - status: WARN+ - status: 2code: 815title: table.no-duplicate-index- content: "`orders` has duplicate index `idx_customer_id_duplicate`"- line: 7- details: ""+ content: '`orders` has duplicate index `idx_customer_id_duplicate`'+ detail: ""+ startposition:+ line: 7+ column: 0- statement: |-CREATE TABLE orders (id INT PRIMARY KEY,@@ -95,12 +111,14 @@CREATE INDEX idx_customer ON orders (customer, (order_number * 2));CREATE INDEX idx_customer_duplicate ON orders (customer, (order_number * 2));want:- - status: WARN+ - status: 2code: 815title: table.no-duplicate-index- content: "`orders` has duplicate index `idx_customer_duplicate`"- line: 7- details: ""+ content: '`orders` has duplicate index `idx_customer_duplicate`'+ detail: ""+ startposition:+ line: 7+ column: 0- statement: |-CREATE TABLE orders (id INT PRIMARY KEY,@@ -110,8 +128,12 @@CREATE INDEX idx_customer_btree USING BTREE ON orders (customer);CREATE INDEX idx_customer_hash USING HASH ON orders (customer);want:- - status: SUCCESS+ - status: 1+ code: 0title: OK+ content: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE orders_sh (id INT PRIMARY KEY,@@ -126,5 +148,9 @@);CREATE INDEX idx_customer_bj ON orders_bj (customer);want:- - status: SUCCESS+ - status: 1+ code: 0title: OK+ content: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/mysql/test/table_no_foreign_key.yaml b/backend/plugin/advisor/mysql/test/table_no_foreign_key.yamlindex 2656854ba7..dcf0fbc8c3 100644--- a/backend/plugin/advisor/mysql/test/table_no_foreign_key.yaml+++ b/backend/plugin/advisor/mysql/test/table_no_foreign_key.yaml@@ -2,19 +2,23 @@CREATE TABLE book(id INT);ALTER TABLE tech_book ADD CONSTRAINT fk_tech_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id);want:- - status: WARN+ - status: 2code: 602title: table.no-foreign-keycontent: Foreign key is not allowed in the table `tech_book`- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t1 (id INT);CREATE TABLE book(id INT, author_id INT, FOREIGN KEY fk_book_author_id_author_id (author_id) REFERENCES author (id));want:- - status: WARN+ - status: 2code: 602title: table.no-foreign-keycontent: Foreign key is not allowed in the table `book`- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/mysql/test/table_require_pk.yaml b/backend/plugin/advisor/mysql/test/table_require_pk.yamlindex ad02277d03..7260ff5255 100644--- a/backend/plugin/advisor/mysql/test/table_require_pk.yaml+++ b/backend/plugin/advisor/mysql/test/table_require_pk.yaml@@ -12,12 +12,14 @@FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin;want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table `userTable` requires PRIMARY KEY- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |CREATE TABLE user(id INT PRIMARY KEY COMMENT 'comment',@@ -31,199 +33,217 @@UNIQUE KEY uk_user_id_name(id, name)) ENGINE = INNODB COMMENT 'comment';want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |CREATE TABLE t1(id INT PRIMARY KEY);CREATE TABLE t2(id INT);ALTER TABLE t2 ADD UNIQUE INDEX uk (id);want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table `t2` requires PRIMARY KEY- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t1(id INT, PRIMARY KEY (id));CREATE TABLE t2(id INT);ALTER TABLE t2 ADD COLUMN uid INT UNIQUE KEY;want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table `t2` requires PRIMARY KEY- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t1(id INT PRIMARY KEY);CREATE TABLE t2(id INT, PRIMARY KEY (id));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t1(id INT PRIMARY KEY);CREATE TABLE t2(id INT);DROP TABLE t1;want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table `t2` requires PRIMARY KEY- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t1(id INT PRIMARY KEY);CREATE TABLE t2(id INT);DROP TABLE t1;DROP TABLE t2;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id INT);ALTER TABLE t ADD CONSTRAINT PRIMARY KEY (id);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id INT PRIMARY KEY);ALTER TABLE t DROP PRIMARY KEY;want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table `t` requires PRIMARY KEY- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id INT PRIMARY KEY);ALTER TABLE t DROP INDEX `PRIMARY`;want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table `t` requires PRIMARY KEY- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id INT);ALTER TABLE t ADD COLUMN name varchar(30) PRIMARY KEY;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id INT);ALTER TABLE t CHANGE COLUMN id id INT PRIMARY KEY;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book CHANGE COLUMN id uid INT;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id INT);ALTER TABLE t MODIFY COLUMN id INT PRIMARY KEY;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book MODIFY COLUMN id INT;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id INT, name varchar(30), PRIMARY KEY(id, name));ALTER TABLE t DROP COLUMN id;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id INT, name varchar(30), comment varchar(255), PRIMARY KEY(id, name));ALTER TABLE t ADD COLUMN age INT;ALTER TABLE t DROP COLUMN id, DROP COLUMN name;want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table `t` requires PRIMARY KEY- line: 3- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-ALTER TABLE tech_book ADD COLUMN c INT;ALTER TABLE tech_book ADD COLUMN a int, DROP COLUMN id, DROP COLUMN name;want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table `tech_book` requires PRIMARY KEY- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: ALTER TABLE tech_book DROP COLUMN name;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-ALTER TABLE tech_book ADD COLUMN c INT;ALTER TABLE tech_book DROP COLUMN name, DROP COLUMN id;want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table `tech_book` requires PRIMARY KEY- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-ALTER TABLE tech_book CHANGE COLUMN id uid int;ALTER TABLE tech_book ADD COLUMN a int, DROP COLUMN uid, DROP COLUMN name;want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table `tech_book` requires PRIMARY KEY- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/oceanbase/advisor_disallow_offline_ddl.go b/backend/plugin/advisor/oceanbase/advisor_disallow_offline_ddl.goindex 2df8161b14..b443b2e1f9 100644--- a/backend/plugin/advisor/oceanbase/advisor_disallow_offline_ddl.go+++ b/backend/plugin/advisor/oceanbase/advisor_disallow_offline_ddl.go@@ -31,7 +31,7 @@ type DisallowOfflineDdlAdvisor struct {}// Check checks for disallow Offline DDL.-func (*DisallowOfflineDdlAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*DisallowOfflineDdlAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)if !ok {return nil, errors.Errorf("failed to convert to mysql parser result")@@ -55,9 +55,9 @@ func (*DisallowOfflineDdlAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -69,8 +69,8 @@ type disallowOfflineDdlChecker struct {*mysql.BaseMySQLParserListenerbaseLine int- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringdriver *sql.DBcurrentDb string@@ -249,11 +249,13 @@ func (*disallowOfflineDdlChecker) isPrimaryKeyColumn(ctx mysql.IFieldDefinitionC}func (checker *disallowOfflineDdlChecker) advice(ctx antlr.ParserRuleContext, operation string) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementOfflineDDL,+ Code: advisor.StatementOfflineDDL.Int32(),Title: checker.title,Content: fmt.Sprintf("%s is an offline DDL operation.", operation),- Line: checker.baseLine + ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ },})}diff --git a/backend/plugin/advisor/oracle/advisor_column_add_not_null_column_require_default.go b/backend/plugin/advisor/oracle/advisor_column_add_not_null_column_require_default.goindex 5f508c6581..937e02d237 100644--- a/backend/plugin/advisor/oracle/advisor_column_add_not_null_column_require_default.go+++ b/backend/plugin/advisor/oracle/advisor_column_add_not_null_column_require_default.go@@ -27,7 +27,7 @@ type ColumnAddNotNullColumnRequireDefaultAdvisor struct {}// Check checks for adding not null column requires default.-func (*ColumnAddNotNullColumnRequireDefaultAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnAddNotNullColumnRequireDefaultAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -53,19 +53,19 @@ func (*ColumnAddNotNullColumnRequireDefaultAdvisor) Check(ctx advisor.Context, _type columnAddNotNullColumnRequireDefaultListener struct {*parser.BasePlSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcurrentDatabase stringtableName stringisNotNull bool- adviceList []advisor.Advice+ adviceList []*storepb.Advice}-func (l *columnAddNotNullColumnRequireDefaultListener) generateAdvice() ([]advisor.Advice, error) {+func (l *columnAddNotNullColumnRequireDefaultListener) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -102,12 +102,14 @@ func (l *columnAddNotNullColumnRequireDefaultListener) ExitColumn_definition(ctx}if ctx.DEFAULT() == nil {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NotNullColumnWithNoDefault,+ Code: advisor.NotNullColumnWithNoDefault.Int32(),Title: l.title,Content: fmt.Sprintf("Adding not null column %q requires default.", normalizeIdentifier(ctx.Column_name(), l.currentDatabase)),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/oracle/advisor_column_maximum_character_length.go b/backend/plugin/advisor/oracle/advisor_column_maximum_character_length.goindex 7718328056..30b24e872f 100644--- a/backend/plugin/advisor/oracle/advisor_column_maximum_character_length.go+++ b/backend/plugin/advisor/oracle/advisor_column_maximum_character_length.go@@ -28,7 +28,7 @@ type ColumnMaximumCharacterLengthAdvisor struct {}// Check checks for maximum character length.-func (*ColumnMaximumCharacterLengthAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnMaximumCharacterLengthAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -60,17 +60,17 @@ func (*ColumnMaximumCharacterLengthAdvisor) Check(ctx advisor.Context, _ string)type columnMaximumCharacterLengthListener struct {*parser.BasePlSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringmaximum int- adviceList []advisor.Advice+ adviceList []*storepb.Advice}-func (l *columnMaximumCharacterLengthListener) generateAdvice() ([]advisor.Advice, error) {+func (l *columnMaximumCharacterLengthListener) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -100,11 +100,13 @@ func (l *columnMaximumCharacterLengthListener) EnterDatatype(ctx *parser.Datatyp}}- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.CharLengthExceedsLimit,+ Code: advisor.CharLengthExceedsLimit.Int32(),Title: l.title,Content: fmt.Sprintf("The maximum character length is %d.", l.maximum),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}diff --git a/backend/plugin/advisor/oracle/advisor_column_maximum_varchar_length.go b/backend/plugin/advisor/oracle/advisor_column_maximum_varchar_length.goindex 8acf7ce9f8..274f89bee2 100644--- a/backend/plugin/advisor/oracle/advisor_column_maximum_varchar_length.go+++ b/backend/plugin/advisor/oracle/advisor_column_maximum_varchar_length.go@@ -28,7 +28,7 @@ type ColumnMaximumVarcharLengthAdvisor struct {}// Check checks for maximum varchar length.-func (*ColumnMaximumVarcharLengthAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnMaximumVarcharLengthAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -60,17 +60,17 @@ func (*ColumnMaximumVarcharLengthAdvisor) Check(ctx advisor.Context, _ string) (type columnMaximumVarcharLengthListener struct {*parser.BasePlSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringmaximum int- adviceList []advisor.Advice+ adviceList []*storepb.Advice}-func (l *columnMaximumVarcharLengthListener) generateAdvice() ([]advisor.Advice, error) {+func (l *columnMaximumVarcharLengthListener) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -100,11 +100,13 @@ func (l *columnMaximumVarcharLengthListener) EnterDatatype(ctx *parser.DatatypeC}}- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.VarcharLengthExceedsLimit,+ Code: advisor.VarcharLengthExceedsLimit.Int32(),Title: l.title,Content: fmt.Sprintf("The maximum varchar length is %d.", l.maximum),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}diff --git a/backend/plugin/advisor/oracle/advisor_column_no_null.go b/backend/plugin/advisor/oracle/advisor_column_no_null.goindex 2fd82be71a..a5556cb857 100644--- a/backend/plugin/advisor/oracle/advisor_column_no_null.go+++ b/backend/plugin/advisor/oracle/advisor_column_no_null.go@@ -30,7 +30,7 @@ type ColumnNoNullAdvisor struct {}// Check checks for column no NULL value.-func (*ColumnNoNullAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnNoNullAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -57,7 +57,7 @@ func (*ColumnNoNullAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advitype columnNoNullListener struct {*parser.BasePlSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcurrentDatabase stringnullableColumns columnMap@@ -65,8 +65,8 @@ type columnNoNullListener struct {columnID string}-func (l *columnNoNullListener) generateAdvice() ([]advisor.Advice, error) {- advice := []advisor.Advice{}+func (l *columnNoNullListener) generateAdvice() ([]*storepb.Advice, error) {+ advice := []*storepb.Advice{}var columnIDs []stringfor columnID := range l.nullableColumns {@@ -75,19 +75,21 @@ func (l *columnNoNullListener) generateAdvice() ([]advisor.Advice, error) {sort.Strings(columnIDs)for _, columnID := range columnIDs {line := l.nullableColumns[columnID]- advice = append(advice, advisor.Advice{+ advice = append(advice, &storepb.Advice{Status: l.level,- Code: advisor.ColumnCannotNull,+ Code: advisor.ColumnCannotNull.Int32(),Title: l.title,Content: fmt.Sprintf("Column %q is nullable, which is not allowed.", lastIdentifier(columnID)),- Line: line,+ StartPosition: &storepb.Position{+ Line: int32(line),+ },})}if len(advice) == 0 {- advice = append(advice, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ advice = append(advice, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/oracle/advisor_column_require.go b/backend/plugin/advisor/oracle/advisor_column_require.goindex c2cbe837bb..773d5c5b88 100644--- a/backend/plugin/advisor/oracle/advisor_column_require.go+++ b/backend/plugin/advisor/oracle/advisor_column_require.go@@ -29,7 +29,7 @@ type ColumnRequireAdvisor struct {}// Check checks for column requirement.-func (*ColumnRequireAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnRequireAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -66,19 +66,19 @@ type columnSet map[string]booltype columnRequireListener struct {*parser.BasePlSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcurrentDatabase stringrequiredColumns columnSetmissingColumns columnSet- adviceList []advisor.Advice+ adviceList []*storepb.Advice}-func (l *columnRequireListener) generateAdvice() ([]advisor.Advice, error) {+func (l *columnRequireListener) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -108,12 +108,14 @@ func (l *columnRequireListener) ExitCreate_table(ctx *parser.Create_tableContextsort.Strings(missingColumns)tableName := normalizeIdentifier(ctx.Table_name(), l.currentDatabase)- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NoRequiredColumn,+ Code: advisor.NoRequiredColumn.Int32(),Title: l.title,Content: fmt.Sprintf("Table %q requires columns: %s", tableName, strings.Join(missingColumns, ", ")),- Line: ctx.GetStop().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStop().GetLine()),+ },})}@@ -145,12 +147,14 @@ func (l *columnRequireListener) ExitAlter_table(ctx *parser.Alter_tableContext)sort.Strings(missingColumns)tableName := lastIdentifier(normalizeIdentifier(ctx.Tableview_name(), l.currentDatabase))- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NoRequiredColumn,+ Code: advisor.NoRequiredColumn.Int32(),Title: l.title,Content: fmt.Sprintf("Table %q requires columns: %s", tableName, strings.Join(missingColumns, ", ")),- Line: ctx.GetStop().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStop().GetLine()),+ },})}diff --git a/backend/plugin/advisor/oracle/advisor_column_require_default.go b/backend/plugin/advisor/oracle/advisor_column_require_default.goindex 346ec03547..ff0b298bec 100644--- a/backend/plugin/advisor/oracle/advisor_column_require_default.go+++ b/backend/plugin/advisor/oracle/advisor_column_require_default.go@@ -28,7 +28,7 @@ type ColumnRequireDefaultAdvisor struct {}// Check checks for column default requirement.-func (*ColumnRequireDefaultAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnRequireDefaultAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -55,15 +55,15 @@ func (*ColumnRequireDefaultAdvisor) Check(ctx advisor.Context, _ string) ([]advitype columnRequireDefaultListener struct {*parser.BasePlSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcurrentDatabase stringnoDefaultColumns columnMaptableName string}-func (l *columnRequireDefaultListener) generateAdvice() ([]advisor.Advice, error) {- advice := []advisor.Advice{}+func (l *columnRequireDefaultListener) generateAdvice() ([]*storepb.Advice, error) {+ advice := []*storepb.Advice{}var columnIDs []stringfor columnID := range l.noDefaultColumns {@@ -72,19 +72,21 @@ func (l *columnRequireDefaultListener) generateAdvice() ([]advisor.Advice, errorsort.Strings(columnIDs)for _, columnID := range columnIDs {line := l.noDefaultColumns[columnID]- advice = append(advice, advisor.Advice{+ advice = append(advice, &storepb.Advice{Status: l.level,- Code: advisor.NoDefault,+ Code: advisor.NoDefault.Int32(),Title: l.title,Content: fmt.Sprintf("Column %q doesn't have default value", lastIdentifier(columnID)),- Line: line,+ StartPosition: &storepb.Position{+ Line: int32(line),+ },})}if len(advice) == 0 {- advice = append(advice, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ advice = append(advice, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/oracle/advisor_column_type_disallow_list.go b/backend/plugin/advisor/oracle/advisor_column_type_disallow_list.goindex 096aeb33f1..d5376304e4 100644--- a/backend/plugin/advisor/oracle/advisor_column_type_disallow_list.go+++ b/backend/plugin/advisor/oracle/advisor_column_type_disallow_list.go@@ -28,7 +28,7 @@ type ColumnTypeDisallowListAdvisor struct {}// Check checks for column type disallow list.-func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -59,18 +59,18 @@ func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]adtype columnTypeDisallowListListener struct {*parser.BasePlSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcurrentDatabase stringdisallowList []string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}-func (l *columnTypeDisallowListListener) generateAdvice() ([]advisor.Advice, error) {+func (l *columnTypeDisallowListListener) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -93,23 +93,27 @@ func (l *columnTypeDisallowListListener) isDisallowType(tp parser.IDatatypeConte// EnterColumn_definition is called when production column_definition is entered.func (l *columnTypeDisallowListListener) EnterColumn_definition(ctx *parser.Column_definitionContext) {if l.isDisallowType(ctx.Datatype()) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.DisabledColumnType,+ Code: advisor.DisabledColumnType.Int32(),Title: l.title,Content: fmt.Sprintf("Disallow column type %s but column \"%s\" is", ctx.Datatype().GetText(), normalizeIdentifier(ctx.Column_name(), l.currentDatabase)),- Line: ctx.Datatype().GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.Datatype().GetStart().GetLine()),+ },})}if ctx.Regular_id() != nil {for _, tp := range l.disallowList {if ctx.Regular_id().GetText() == tp {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.DisabledColumnType,+ Code: advisor.DisabledColumnType.Int32(),Title: l.title,Content: fmt.Sprintf("Disallow column type %s but column \"%s\" is", ctx.Regular_id().GetText(), normalizeIdentifier(ctx.Column_name(), l.currentDatabase)),- Line: ctx.Regular_id().GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.Regular_id().GetStart().GetLine()),+ },})break}@@ -120,12 +124,14 @@ func (l *columnTypeDisallowListListener) EnterColumn_definition(ctx *parser.Colu// EnterModify_col_properties is called when production modify_col_properties is entered.func (l *columnTypeDisallowListListener) EnterModify_col_properties(ctx *parser.Modify_col_propertiesContext) {if l.isDisallowType(ctx.Datatype()) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.DisabledColumnType,+ Code: advisor.DisabledColumnType.Int32(),Title: l.title,Content: fmt.Sprintf("Disallow column type %s but column \"%s\" is", ctx.Datatype().GetText(), normalizeIdentifier(ctx.Column_name(), l.currentDatabase)),- Line: ctx.Datatype().GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.Datatype().GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/oracle/advisor_index_key_number_limit.go b/backend/plugin/advisor/oracle/advisor_index_key_number_limit.goindex 2c1882a356..5d6a844316 100644--- a/backend/plugin/advisor/oracle/advisor_index_key_number_limit.go+++ b/backend/plugin/advisor/oracle/advisor_index_key_number_limit.go@@ -27,7 +27,7 @@ type IndexKeyNumberLimitAdvisor struct {}// Check checks for index key number limit.-func (*IndexKeyNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*IndexKeyNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -60,18 +60,18 @@ func (*IndexKeyNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advistype indexKeyNumberLimitListener struct {*parser.BasePlSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcurrentDatabase stringmax int- adviceList []advisor.Advice+ adviceList []*storepb.Advice}-func (l *indexKeyNumberLimitListener) generateAdvice() ([]advisor.Advice, error) {+func (l *indexKeyNumberLimitListener) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -83,12 +83,14 @@ func (l *indexKeyNumberLimitListener) generateAdvice() ([]advisor.Advice, error)func (l *indexKeyNumberLimitListener) EnterTable_index_clause(ctx *parser.Table_index_clauseContext) {keys := len(ctx.AllIndex_expr_option())if keys > l.max {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.IndexKeyNumberExceedsLimit,+ Code: advisor.IndexKeyNumberExceedsLimit.Int32(),Title: l.title,Content: fmt.Sprintf("Index key number should be less than or equal to %d", l.max),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}@@ -97,12 +99,14 @@ func (l *indexKeyNumberLimitListener) EnterTable_index_clause(ctx *parser.Table_func (l *indexKeyNumberLimitListener) EnterOut_of_line_constraint(ctx *parser.Out_of_line_constraintContext) {keys := len(ctx.AllColumn_name())if keys > l.max {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.IndexKeyNumberExceedsLimit,+ Code: advisor.IndexKeyNumberExceedsLimit.Int32(),Title: l.title,Content: fmt.Sprintf("Index key number should be less than or equal to %d", l.max),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/oracle/advisor_insert_must_specify_column.go b/backend/plugin/advisor/oracle/advisor_insert_must_specify_column.goindex bf95e22369..9ddb6a02e6 100644--- a/backend/plugin/advisor/oracle/advisor_insert_must_specify_column.go+++ b/backend/plugin/advisor/oracle/advisor_insert_must_specify_column.go@@ -25,7 +25,7 @@ type InsertMustSpecifyColumnAdvisor struct {}// Check checks for to enforce column specified.-func (*InsertMustSpecifyColumnAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*InsertMustSpecifyColumnAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -51,17 +51,17 @@ func (*InsertMustSpecifyColumnAdvisor) Check(ctx advisor.Context, _ string) ([]atype insertMustSpecifyColumnListener struct {*parser.BasePlSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcurrentDatabase string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}-func (l *insertMustSpecifyColumnListener) generateAdvice() ([]advisor.Advice, error) {+func (l *insertMustSpecifyColumnListener) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -72,12 +72,14 @@ func (l *insertMustSpecifyColumnListener) generateAdvice() ([]advisor.Advice, er// EnterInsert_into_clause is called when production insert_into_clause is entered.func (l *insertMustSpecifyColumnListener) EnterInsert_into_clause(ctx *parser.Insert_into_clauseContext) {if ctx.Paren_column_list() == nil {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.InsertNotSpecifyColumn,+ Code: advisor.InsertNotSpecifyColumn.Int32(),Title: l.title,Content: "INSERT statement should specify column name.",- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/oracle/advisor_naming_identifier_case.go b/backend/plugin/advisor/oracle/advisor_naming_identifier_case.goindex 527631be5d..891486809f 100644--- a/backend/plugin/advisor/oracle/advisor_naming_identifier_case.go+++ b/backend/plugin/advisor/oracle/advisor_naming_identifier_case.go@@ -28,7 +28,7 @@ type NamingIdentifierCaseAdvisor struct {}// Check checks for identifier case.-func (*NamingIdentifierCaseAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingIdentifierCaseAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -59,18 +59,18 @@ func (*NamingIdentifierCaseAdvisor) Check(ctx advisor.Context, _ string) ([]advitype namingIdentifierCaseListener struct {*parser.BasePlSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcurrentDatabase string- adviceList []advisor.Advice+ adviceList []*storepb.Adviceupper bool}-func (l *namingIdentifierCaseListener) generateAdvice() ([]advisor.Advice, error) {+func (l *namingIdentifierCaseListener) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -83,22 +83,26 @@ func (l *namingIdentifierCaseListener) EnterId_expression(ctx *parser.Id_expressidentifier := normalizeIDExpression(ctx)if l.upper {if identifier != strings.ToUpper(identifier) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NamingCaseMismatch,+ Code: advisor.NamingCaseMismatch.Int32(),Title: l.title,Content: fmt.Sprintf("Identifier %q should be upper case", identifier),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}} else {if identifier != strings.ToLower(identifier) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NamingCaseMismatch,+ Code: advisor.NamingCaseMismatch.Int32(),Title: l.title,Content: fmt.Sprintf("Identifier %q should be lower case", identifier),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/oracle/advisor_naming_identifier_no_keyword.go b/backend/plugin/advisor/oracle/advisor_naming_identifier_no_keyword.goindex d2f74e37a1..e60fc33665 100644--- a/backend/plugin/advisor/oracle/advisor_naming_identifier_no_keyword.go+++ b/backend/plugin/advisor/oracle/advisor_naming_identifier_no_keyword.go@@ -28,7 +28,7 @@ type NamingIdentifierNoKeywordAdvisor struct {}// Check checks for identifier naming convention without keyword.-func (*NamingIdentifierNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingIdentifierNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -54,17 +54,17 @@ func (*NamingIdentifierNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([type namingIdentifierNoKeywordListener struct {*parser.BasePlSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcurrentDatabase string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}-func (l *namingIdentifierNoKeywordListener) generateAdvice() ([]advisor.Advice, error) {+func (l *namingIdentifierNoKeywordListener) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -76,12 +76,14 @@ func (l *namingIdentifierNoKeywordListener) generateAdvice() ([]advisor.Advice,func (l *namingIdentifierNoKeywordListener) EnterId_expression(ctx *parser.Id_expressionContext) {identifier := normalizeIDExpression(ctx)if plsqlparser.IsOracleKeyword(identifier) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NameIsKeywordIdentifier,+ Code: advisor.NameIsKeywordIdentifier.Int32(),Title: l.title,Content: fmt.Sprintf("Identifier %q is a keyword and should be avoided", identifier),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/oracle/advisor_naming_table.go b/backend/plugin/advisor/oracle/advisor_naming_table.goindex 6ca302f61b..237bb8d7f8 100644--- a/backend/plugin/advisor/oracle/advisor_naming_table.go+++ b/backend/plugin/advisor/oracle/advisor_naming_table.go@@ -28,7 +28,7 @@ type NamingTableAdvisor struct {}// Check checks for table naming convention.-func (*NamingTableAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingTableAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -60,20 +60,20 @@ func (*NamingTableAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advictype namingTableListener struct {*parser.BasePlSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcurrentDatabase stringformat *regexp.RegexpmaxLength int- adviceList []advisor.Advice+ adviceList []*storepb.Advice}-func (l *namingTableListener) generateAdvice() ([]advisor.Advice, error) {+func (l *namingTableListener) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -85,21 +85,25 @@ func (l *namingTableListener) generateAdvice() ([]advisor.Advice, error) {func (l *namingTableListener) EnterCreate_table(ctx *parser.Create_tableContext) {tableName := normalizeIdentifier(ctx.Table_name(), l.currentDatabase)if !l.format.MatchString(tableName) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NamingTableConventionMismatch,+ Code: advisor.NamingTableConventionMismatch.Int32(),Title: l.title,Content: fmt.Sprintf(`"%s" mismatches table naming convention, naming format should be %q`, tableName, l.format),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}if l.maxLength > 0 && len(tableName) > l.maxLength {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NamingTableConventionMismatch,+ Code: advisor.NamingTableConventionMismatch.Int32(),Title: l.title,Content: fmt.Sprintf("\"%s\" mismatches table naming convention, its length should be within %d characters", tableName, l.maxLength),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}@@ -114,21 +118,25 @@ func (l *namingTableListener) EnterAlter_table_properties(ctx *parser.Alter_tablreturn}if !l.format.MatchString(tableName) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NamingTableConventionMismatch,+ Code: advisor.NamingTableConventionMismatch.Int32(),Title: l.title,Content: fmt.Sprintf(`"%s" mismatches table naming convention, naming format should be %q`, tableName, l.format),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}if l.maxLength > 0 && len(tableName) > l.maxLength {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NamingTableConventionMismatch,+ Code: advisor.NamingTableConventionMismatch.Int32(),Title: l.title,Content: fmt.Sprintf("\"%s\" mismatches table naming convention, its length should be within %d characters", tableName, l.maxLength),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/oracle/advisor_naming_table_no_keyword.go b/backend/plugin/advisor/oracle/advisor_naming_table_no_keyword.goindex 9bb819f867..de9928bb6f 100644--- a/backend/plugin/advisor/oracle/advisor_naming_table_no_keyword.go+++ b/backend/plugin/advisor/oracle/advisor_naming_table_no_keyword.go@@ -28,7 +28,7 @@ type NamingTableNoKeywordAdvisor struct {}// Check checks for table naming convention without keyword.-func (*NamingTableNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingTableNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -54,17 +54,17 @@ func (*NamingTableNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([]advitype namingTableNoKeywordListener struct {*parser.BasePlSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcurrentDatabase string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}-func (l *namingTableNoKeywordListener) generateAdvice() ([]advisor.Advice, error) {+func (l *namingTableNoKeywordListener) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -76,12 +76,14 @@ func (l *namingTableNoKeywordListener) generateAdvice() ([]advisor.Advice, errorfunc (l *namingTableNoKeywordListener) EnterCreate_table(ctx *parser.Create_tableContext) {tableName := normalizeIdentifier(ctx.Table_name(), l.currentDatabase)if plsqlparser.IsOracleKeyword(tableName) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NameIsKeywordIdentifier,+ Code: advisor.NameIsKeywordIdentifier.Int32(),Title: l.title,Content: fmt.Sprintf("Table name %q is a keyword identifier and should be avoided.", tableName),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}@@ -93,12 +95,14 @@ func (l *namingTableNoKeywordListener) EnterAlter_table_properties(ctx *parser.A}tableName := lastIdentifier(normalizeIdentifier(ctx.Tableview_name(), l.currentDatabase))if plsqlparser.IsOracleKeyword(tableName) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NameIsKeywordIdentifier,+ Code: advisor.NameIsKeywordIdentifier.Int32(),Title: l.title,Content: fmt.Sprintf("Table name %q is a keyword identifier and should be avoided.", tableName),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/oracle/advisor_select_no_select_all.go b/backend/plugin/advisor/oracle/advisor_select_no_select_all.goindex aa7fcd3fdb..4e54bdd499 100644--- a/backend/plugin/advisor/oracle/advisor_select_no_select_all.go+++ b/backend/plugin/advisor/oracle/advisor_select_no_select_all.go@@ -25,7 +25,7 @@ type SelectNoSelectAllAdvisor struct {}// Check checks for no select all.-func (*SelectNoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*SelectNoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -51,17 +51,17 @@ func (*SelectNoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]advisortype selectNoSelectAllListener struct {*parser.BasePlSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcurrentDatabase string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}-func (l *selectNoSelectAllListener) generateAdvice() ([]advisor.Advice, error) {+func (l *selectNoSelectAllListener) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -72,12 +72,14 @@ func (l *selectNoSelectAllListener) generateAdvice() ([]advisor.Advice, error) {// EnterSelected_list is called when production selected_list is entered.func (l *selectNoSelectAllListener) EnterSelected_list(ctx *parser.Selected_listContext) {if ctx.ASTERISK() != nil {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.StatementSelectAll,+ Code: advisor.StatementSelectAll.Int32(),Title: l.title,Content: "Avoid using SELECT *.",- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/oracle/advisor_table_no_foreign_key.go b/backend/plugin/advisor/oracle/advisor_table_no_foreign_key.goindex 52438a9ca4..bd9a798da9 100644--- a/backend/plugin/advisor/oracle/advisor_table_no_foreign_key.go+++ b/backend/plugin/advisor/oracle/advisor_table_no_foreign_key.go@@ -27,7 +27,7 @@ type TableNoForeignKeyAdvisor struct {}// Check checks for table disallow foreign key.-func (*TableNoForeignKeyAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableNoForeignKeyAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -55,7 +55,7 @@ func (*TableNoForeignKeyAdvisor) Check(ctx advisor.Context, _ string) ([]advisortype tableNoForeignKeyListener struct {*parser.BasePlSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcurrentDatabase stringtableName string@@ -63,24 +63,26 @@ type tableNoForeignKeyListener struct {tableLine map[string]int}-func (l *tableNoForeignKeyListener) generateAdvice() ([]advisor.Advice, error) {- advice := []advisor.Advice{}+func (l *tableNoForeignKeyListener) generateAdvice() ([]*storepb.Advice, error) {+ advice := []*storepb.Advice{}for tableName, hasFK := range l.tableWithFK {if hasFK {- advice = append(advice, advisor.Advice{+ advice = append(advice, &storepb.Advice{Status: l.level,- Code: advisor.TableHasFK,+ Code: advisor.TableHasFK.Int32(),Title: l.title,Content: fmt.Sprintf("Foreign key is not allowed in the table %s.", normalizeTableName(tableName)),- Line: l.tableLine[tableName],+ StartPosition: &storepb.Position{+ Line: int32(l.tableLine[tableName]),+ },})}}if len(advice) == 0 {- advice = append(advice, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ advice = append(advice, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/oracle/advisor_table_require_pk.go b/backend/plugin/advisor/oracle/advisor_table_require_pk.goindex 4227e891a1..69e1146203 100644--- a/backend/plugin/advisor/oracle/advisor_table_require_pk.go+++ b/backend/plugin/advisor/oracle/advisor_table_require_pk.go@@ -27,7 +27,7 @@ type TableRequirePKAdvisor struct {}// Check checks table requires PK.-func (*TableRequirePKAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableRequirePKAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -55,7 +55,7 @@ func (*TableRequirePKAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Adtype TableRequirePKListener struct {*parser.BasePlSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcurrentDatabase stringtableName string@@ -63,24 +63,26 @@ type TableRequirePKListener struct {tableLine map[string]int}-func (l *TableRequirePKListener) generateAdvice() ([]advisor.Advice, error) {- advice := []advisor.Advice{}+func (l *TableRequirePKListener) generateAdvice() ([]*storepb.Advice, error) {+ advice := []*storepb.Advice{}for tableName, hasPK := range l.tableWitPK {if !hasPK {- advice = append(advice, advisor.Advice{+ advice = append(advice, &storepb.Advice{Status: l.level,- Code: advisor.TableNoPK,+ Code: advisor.TableNoPK.Int32(),Title: l.title,Content: fmt.Sprintf("Table %s requires PRIMARY KEY.", normalizeTableName(tableName)),- Line: l.tableLine[tableName],+ StartPosition: &storepb.Position{+ Line: int32(l.tableLine[tableName]),+ },})}}if len(advice) == 0 {- advice = append(advice, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ advice = append(advice, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/oracle/advisor_where_no_leading_wildcard_like.go b/backend/plugin/advisor/oracle/advisor_where_no_leading_wildcard_like.goindex 40dd9b3d57..0a2f2d0df2 100644--- a/backend/plugin/advisor/oracle/advisor_where_no_leading_wildcard_like.go+++ b/backend/plugin/advisor/oracle/advisor_where_no_leading_wildcard_like.go@@ -27,7 +27,7 @@ type WhereNoLeadingWildcardLikeAdvisor struct {}// Check checks for no leading wildcard LIKE.-func (*WhereNoLeadingWildcardLikeAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*WhereNoLeadingWildcardLikeAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -53,17 +53,17 @@ func (*WhereNoLeadingWildcardLikeAdvisor) Check(ctx advisor.Context, _ string) (type whereNoLeadingWildcardLikeListener struct {*parser.BasePlSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcurrentDatabase string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}-func (l *whereNoLeadingWildcardLikeListener) generateAdvice() ([]advisor.Advice, error) {+func (l *whereNoLeadingWildcardLikeListener) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -83,12 +83,14 @@ func (l *whereNoLeadingWildcardLikeListener) EnterCompound_expression(ctx *parsetext := ctx.Concatenation(1).GetText()if strings.HasPrefix(text, "'%") && strings.HasSuffix(text, "'") {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.StatementLeadingWildcardLike,+ Code: advisor.StatementLeadingWildcardLike.Int32(),Title: l.title,Content: "Avoid using leading wildcard LIKE.",- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/oracle/advisor_where_require.go b/backend/plugin/advisor/oracle/advisor_where_require.goindex 81b210a21e..6e9bf9e749 100644--- a/backend/plugin/advisor/oracle/advisor_where_require.go+++ b/backend/plugin/advisor/oracle/advisor_where_require.go@@ -27,7 +27,7 @@ type WhereRequireAdvisor struct {}// Check checks for WHERE clause requirement.-func (*WhereRequireAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*WhereRequireAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -53,17 +53,17 @@ func (*WhereRequireAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advitype whereRequireListener struct {*parser.BasePlSqlParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringcurrentDatabase string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}-func (l *whereRequireListener) generateAdvice() ([]advisor.Advice, error) {+func (l *whereRequireListener) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -74,12 +74,14 @@ func (l *whereRequireListener) generateAdvice() ([]advisor.Advice, error) {// EnterUpdate_statement is called when production update_statement is entered.func (l *whereRequireListener) EnterUpdate_statement(ctx *parser.Update_statementContext) {if ctx.Where_clause() == nil {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.StatementNoWhere,+ Code: advisor.StatementNoWhere.Int32(),Title: l.title,Content: "WHERE clause is required for UPDATE statement.",- Line: ctx.GetStop().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStop().GetLine()),+ },})}}@@ -87,12 +89,14 @@ func (l *whereRequireListener) EnterUpdate_statement(ctx *parser.Update_statemen// EnterDelete_statement is called when production delete_statement is entered.func (l *whereRequireListener) EnterDelete_statement(ctx *parser.Delete_statementContext) {if ctx.Where_clause() == nil {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.StatementNoWhere,+ Code: advisor.StatementNoWhere.Int32(),Title: l.title,Content: "WHERE clause is required for DELETE statement.",- Line: ctx.GetStop().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStop().GetLine()),+ },})}}@@ -107,12 +111,14 @@ func (l *whereRequireListener) EnterQuery_block(ctx *parser.Query_blockContext)return}if ctx.Where_clause() == nil {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.StatementNoWhere,+ Code: advisor.StatementNoWhere.Int32(),Title: l.title,Content: "WHERE clause is required for SELECT statement.",- Line: ctx.GetStop().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStop().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/oracle/test/column_add_not_null_require_default.yaml b/backend/plugin/advisor/oracle/test/column_add_not_null_require_default.yamlindex 130f5563c5..58adeaa201 100644--- a/backend/plugin/advisor/oracle/test/column_add_not_null_require_default.yaml+++ b/backend/plugin/advisor/oracle/test/column_add_not_null_require_default.yaml@@ -1,16 +1,18 @@- statement: ALTER TABLE tech_book ADD reader int NOT NULLwant:- - status: WARN+ - status: 2code: 404title: column.add-not-null-require-defaultcontent: Adding not null column "READER" requires default.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ADD reader int DEFAULT 0 NOT NULLwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/oracle/test/column_maximum_character_length.yaml b/backend/plugin/advisor/oracle/test/column_maximum_character_length.yamlindex d2ed238dd8..16b3de3b39 100644--- a/backend/plugin/advisor/oracle/test/column_maximum_character_length.yaml+++ b/backend/plugin/advisor/oracle/test/column_maximum_character_length.yaml@@ -1,40 +1,46 @@- statement: CREATE TABLE t(name char(20));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(name varchar(225));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(name char(225));want:- - status: WARN+ - status: 2code: 415title: column.maximum-character-lengthcontent: The maximum character length is 20.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE public.tech_book ADD name_2 char(225)want:- - status: WARN+ - status: 2code: 415title: column.maximum-character-lengthcontent: The maximum character length is 20.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book MODIFY name char(225)want:- - status: WARN+ - status: 2code: 415title: column.maximum-character-lengthcontent: The maximum character length is 20.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/oracle/test/column_maximum_varchar_length.yaml b/backend/plugin/advisor/oracle/test/column_maximum_varchar_length.yamlindex 3ce965b10b..ac34840709 100644--- a/backend/plugin/advisor/oracle/test/column_maximum_varchar_length.yaml+++ b/backend/plugin/advisor/oracle/test/column_maximum_varchar_length.yaml@@ -1,40 +1,46 @@- statement: CREATE TABLE t(name varchar(20));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(name varchar(3000));want:- - status: WARN+ - status: 2code: 422title: column.maximum-varchar-lengthcontent: The maximum varchar length is 2560.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(name varchar(225));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE public.tech_book ADD name_2 varchar(22225)want:- - status: WARN+ - status: 2code: 422title: column.maximum-varchar-lengthcontent: The maximum varchar length is 2560.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book MODIFY name varchar(22225)want:- - status: WARN+ - status: 2code: 422title: column.maximum-varchar-lengthcontent: The maximum varchar length is 2560.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/oracle/test/column_no_null.yaml b/backend/plugin/advisor/oracle/test/column_no_null.yamlindex dee048773e..7d6b295e6a 100644--- a/backend/plugin/advisor/oracle/test/column_no_null.yaml+++ b/backend/plugin/advisor/oracle/test/column_no_null.yaml@@ -4,91 +4,105 @@name varchar(255))want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column "ID" is nullable, which is not allowed.- line: 2- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 402title: column.no-nullcontent: Column "NAME" is nullable, which is not allowed.- line: 3- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: CREATE TABLE book(id int, name varchar(255), PRIMARY KEY (id))want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column "NAME" is nullable, which is not allowed.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255))want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column "NAME" is nullable, which is not allowed.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id int NOT NULL, name varchar(255))want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column "NAME" is nullable, which is not allowed.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255) NOT NULL)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book ADD reader intwant:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column "READER" is nullable, which is not allowed.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-ALTER TABLE tech_book DROP COLUMN id;ALTER TABLE tech_book DROP COLUMN name;ALTER TABLE tech_book ADD id int PRIMARY KEY;ALTER TABLE tech_book ADD name varchar(255) NOT NULL;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book MODIFY id NOT NULLwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book MODIFY name NULLwant:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column "NAME" is nullable, which is not allowed.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: -- this is a commentwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/oracle/test/column_require_default.yaml b/backend/plugin/advisor/oracle/test/column_require_default.yamlindex f87e3cb5f5..9b0b5c8bc1 100644--- a/backend/plugin/advisor/oracle/test/column_require_default.yaml+++ b/backend/plugin/advisor/oracle/test/column_require_default.yaml@@ -1,20 +1,24 @@- statement: CREATE TABLE t(a int primary key, b int default 1)want:- - status: WARN+ - status: 2code: 420title: column.require-defaultcontent: Column "A" doesn't have default value- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t(a int,b int default 1)want:- - status: WARN+ - status: 2code: 420title: column.require-defaultcontent: Column "A" doesn't have default value- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/oracle/test/column_required.yaml b/backend/plugin/advisor/oracle/test/column_required.yamlindex d1570ab96b..ed34f7b1cc 100644--- a/backend/plugin/advisor/oracle/test/column_required.yaml+++ b/backend/plugin/advisor/oracle/test/column_required.yaml@@ -1,11 +1,13 @@- statement: CREATE TABLE book("id" int)want:- - status: WARN+ - status: 2code: 401title: column.requiredcontent: 'Table "BOOK" requires columns: "created_ts", "creator_id", "updated_ts", "updater_id"'- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE book("id" int,@@ -14,29 +16,33 @@"updater_id" int,"updated_ts" timestamp)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-ALTER TABLE tech_book ADD "creator_id" int;ALTER TABLE tech_book RENAME COLUMN "creator_id" TO creator;want:- - status: WARN+ - status: 2code: 401title: column.requiredcontent: 'Table "TECH_BOOK" requires columns: "creator_id"'- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-ALTER TABLE tech_book ADD "creator_id" int;ALTER TABLE tech_book DROP COLUMN "creator_id";want:- - status: WARN+ - status: 2code: 401title: column.requiredcontent: 'Table "TECH_BOOK" requires columns: "creator_id"'- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/oracle/test/column_type_disallow_list.yaml b/backend/plugin/advisor/oracle/test/column_type_disallow_list.yamlindex cdff2d6167..604ad3db13 100644--- a/backend/plugin/advisor/oracle/test/column_type_disallow_list.yaml+++ b/backend/plugin/advisor/oracle/test/column_type_disallow_list.yaml@@ -1,54 +1,64 @@- statement: CREATE TABLE t(a char(5));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a int, b JSON);want:- - status: WARN+ - status: 2code: 411title: column.type-disallow-listcontent: Disallow column type JSON but column "B" is- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t(d char(5));ALTER TABLE t add a JSON;want:- - status: WARN+ - status: 2code: 411title: column.type-disallow-listcontent: Disallow column type JSON but column "A" is- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(d char(5));ALTER TABLE t MODIFY d BINARY_FLOAT;want:- - status: WARN+ - status: 2code: 411title: column.type-disallow-listcontent: Disallow column type BINARY_FLOAT but column "D" is- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: CREATE TABLE t(a int, b BINARY_FLOAT);want:- - status: WARN+ - status: 2code: 411title: column.type-disallow-listcontent: Disallow column type BINARY_FLOAT but column "B" is- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t(d char(5));ALTER TABLE t add a BINARY_FLOAT;want:- - status: WARN+ - status: 2code: 411title: column.type-disallow-listcontent: Disallow column type BINARY_FLOAT but column "A" is- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/oracle/test/index_key_number_limit.yaml b/backend/plugin/advisor/oracle/test/index_key_number_limit.yamlindex 41a9586ddb..1ed6160eb5 100644--- a/backend/plugin/advisor/oracle/test/index_key_number_limit.yaml+++ b/backend/plugin/advisor/oracle/test/index_key_number_limit.yaml@@ -1,70 +1,80 @@- statement: CREATE TABLE t(name char(20));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(name varchar(225));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(name char(225), PRIMARY KEY (name));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(id int, name char(225), c1 int, c2 int, c3 int, c4 int, CONSTRAINT t_id_name PRIMARY KEY (id, name, c1, c2, c3, c4));want:- - status: WARN+ - status: 2code: 802title: index.key-number-limitcontent: Index key number should be less than or equal to 5- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(id int, name char(225), c1 int, c2 int, c3 int, c4 int, CONSTRAINT t_id_name UNIQUE (id, name, c1, c2, c3, c4));want:- - status: WARN+ - status: 2code: 802title: index.key-number-limitcontent: Index key number should be less than or equal to 5- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE address(id int, phone varchar(225), c1 int, c2 int, c3 int, c4 int);CREATE INDEX idx_address_phone ON address(id, phone, c1, c2, c3, c4);want:- - status: WARN+ - status: 2code: 802title: index.key-number-limitcontent: Index key number should be less than or equal to 5- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE address(id int, phone varchar(225), c1 int, c2 int, c3 int, c4 int);CREATE UNIQUE INDEX idx_address_phone ON address(id, phone, c2, c1, c3, c4);want:- - status: WARN+ - status: 2code: 802title: index.key-number-limitcontent: Index key number should be less than or equal to 5- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE address(id int, phone varchar(225), c1 int, c2 int, c3 int, c4 int);ALTER TABLE address ADD CONSTRAINT address_id_name UNIQUE (id, phone, c1, c2, c3, c4);want:- - status: WARN+ - status: 2code: 802title: index.key-number-limitcontent: Index key number should be less than or equal to 5- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/oracle/test/naming_identifier_case.yaml b/backend/plugin/advisor/oracle/test/naming_identifier_case.yamlindex 7cd20f8ad8..9e4f58688b 100644--- a/backend/plugin/advisor/oracle/test/naming_identifier_case.yaml+++ b/backend/plugin/advisor/oracle/test/naming_identifier_case.yaml@@ -1,42 +1,46 @@- statement: CREATE TABLE "table"(id int, name varchar(255))want:- - status: WARN+ - status: 2code: 309title: naming.identifier.casecontent: Identifier "table" should be upper case- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE tt(id int, name varchar(255))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE "Tt"(id int, name varchar(255))want:- - status: WARN+ - status: 2code: 309title: naming.identifier.casecontent: Identifier "Tt" should be upper case- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book RENAME TO analyzewant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-create table techBook(id int);ALTER TABLE techBook RENAME TO tech_book_tmp;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/oracle/test/naming_identifier_no_keyword.yaml b/backend/plugin/advisor/oracle/test/naming_identifier_no_keyword.yamlindex 4738505d42..ac6a5e7f0d 100644--- a/backend/plugin/advisor/oracle/test/naming_identifier_no_keyword.yaml+++ b/backend/plugin/advisor/oracle/test/naming_identifier_no_keyword.yaml@@ -1,48 +1,56 @@- statement: CREATE TABLE "table"(id int, name varchar(255))want:- - status: WARN+ - status: 2code: 308title: naming.identifier.no-keywordcontent: Identifier "NAME" is a keyword and should be avoided- line: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 308title: naming.identifier.no-keywordcontent: Identifier "table" is a keyword and should be avoided- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE "rlcmidzlevbivwvcntihenpoibtsdfasdfasdfiutqeb"(id int, name varchar(255))want:- - status: WARN+ - status: 2code: 308title: naming.identifier.no-keywordcontent: Identifier "NAME" is a keyword and should be avoided- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE analyze(id int, name varchar(255))want:- - status: WARN+ - status: 2code: 308title: naming.identifier.no-keywordcontent: Identifier "NAME" is a keyword and should be avoided- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book RENAME TO analyzewant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-create table techBook(id int);ALTER TABLE techBook RENAME TO tech_book_tmp;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/oracle/test/naming_table.yaml b/backend/plugin/advisor/oracle/test/naming_table.yamlindex 16880dba19..80db49292f 100644--- a/backend/plugin/advisor/oracle/test/naming_table.yaml+++ b/backend/plugin/advisor/oracle/test/naming_table.yaml@@ -1,74 +1,90 @@- statement: CREATE TABLE "techBook"(id int, name varchar(255))want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '"techBook" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE "rlcmidzlevbivwvcntihenpoibtsdfasdfasdfiutqeb"(id int, name varchar(255))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE tech_Book(id int, name varchar(255))want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '"TECH_BOOK" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE techBook(id int, name varchar(255))want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '"TECHBOOK" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id int, name varchar(255))want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '"BOOK" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book RENAME TO "TechBook"want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '"TechBook" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-create table techBook(id int);ALTER TABLE techBook RENAME TO tech_book_tmp;want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '"TECHBOOK" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 301title: naming.tablecontent: '"TECH_BOOK_TMP" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE tech_Book(id int, name varchar(255));ALTER TABLE tech_book RENAME TO "tech_book";want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '"TECH_BOOK" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/oracle/test/naming_table_no_keyword.yaml b/backend/plugin/advisor/oracle/test/naming_table_no_keyword.yamlindex 5390f22500..f9aab2cec4 100644--- a/backend/plugin/advisor/oracle/test/naming_table_no_keyword.yaml+++ b/backend/plugin/advisor/oracle/test/naming_table_no_keyword.yaml@@ -1,42 +1,48 @@- statement: CREATE TABLE "table"(id int, name varchar(255))want:- - status: WARN+ - status: 2code: 308title: naming.table.no-keywordcontent: Table name "table" is a keyword identifier and should be avoided.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE "rlcmidzlevbivwvcntihenpoibtsdfasdfasdfiutqeb"(id int, name varchar(255))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE avg(id int, name varchar(255))want:- - status: WARN+ - status: 2code: 308title: naming.table.no-keywordcontent: Table name "AVG" is a keyword identifier and should be avoided.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book RENAME TO avgwant:- - status: WARN+ - status: 2code: 308title: naming.table.no-keywordcontent: Table name "AVG" is a keyword identifier and should be avoided.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-create table techBook(id int);ALTER TABLE techBook RENAME TO tech_book_tmp;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/oracle/test/statement_insert_must_specify_column.yaml b/backend/plugin/advisor/oracle/test/statement_insert_must_specify_column.yamlindex bba142fd49..2ea68aec16 100644--- a/backend/plugin/advisor/oracle/test/statement_insert_must_specify_column.yaml+++ b/backend/plugin/advisor/oracle/test/statement_insert_must_specify_column.yaml@@ -1,16 +1,18 @@- statement: INSERT INTO tech_book(id, name) VALUES (1, '1')want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: INSERT INTO tech_book VALUES (1, '1')want:- - status: WARN+ - status: 2code: 1107title: statement.insert.must-specify-columncontent: INSERT statement should specify column name.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/oracle/test/statement_select_no_select_all.yaml b/backend/plugin/advisor/oracle/test/statement_select_no_select_all.yamlindex e0c5ddbd9c..da283d21ee 100644--- a/backend/plugin/advisor/oracle/test/statement_select_no_select_all.yaml+++ b/backend/plugin/advisor/oracle/test/statement_select_no_select_all.yaml@@ -1,32 +1,38 @@- statement: SELECT * FROM twant:- - status: WARN+ - status: 2code: 203title: statement.select.no-select-allcontent: Avoid using SELECT *.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT a, b FROM twant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: SELECT a, b FROM (SELECT * from t1, t2) twant:- - status: WARN+ - status: 2code: 203title: statement.select.no-select-allcontent: Avoid using SELECT *.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: INSERT INTO t SELECT * FROM t1want:- - status: WARN+ - status: 2code: 203title: statement.select.no-select-allcontent: Avoid using SELECT *.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/oracle/test/statement_where_no_leading_wildcard_like.yaml b/backend/plugin/advisor/oracle/test/statement_where_no_leading_wildcard_like.yamlindex f26f069c27..f6d02b7b43 100644--- a/backend/plugin/advisor/oracle/test/statement_where_no_leading_wildcard_like.yaml+++ b/backend/plugin/advisor/oracle/test/statement_where_no_leading_wildcard_like.yaml@@ -1,52 +1,64 @@- statement: SELECT * FROM t WHERE a LIKE 'abc%'want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: SELECT * FROM t WHERE a LIKE '%abc'want:- - status: WARN+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: Avoid using leading wildcard LIKE.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT * FROM t WHERE a LIKE 'abc' OR a LIKE '%abc'want:- - status: WARN+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: Avoid using leading wildcard LIKE.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc'want:- - status: WARN+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: Avoid using leading wildcard LIKE.- line: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: Avoid using leading wildcard LIKE.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT * FROM (SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc') t1want:- - status: WARN+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: Avoid using leading wildcard LIKE.- line: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: Avoid using leading wildcard LIKE.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/oracle/test/statement_where_require.yaml b/backend/plugin/advisor/oracle/test/statement_where_require.yamlindex cd8a6f1b78..8c6bd8755d 100644--- a/backend/plugin/advisor/oracle/test/statement_where_require.yaml+++ b/backend/plugin/advisor/oracle/test/statement_where_require.yaml@@ -1,72 +1,80 @@- statement: INSERT INTO t VALUES(1)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: DELETE FROM t1want:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: WHERE clause is required for DELETE statement.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: UPDATE t1 SET a = 1want:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: WHERE clause is required for UPDATE statement.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: DELETE FROM t1 WHERE a > 0want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: UPDATE t1 SET a = 1 WHERE a > 10want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: SELECT a FROM twant:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: WHERE clause is required for SELECT statement.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT a FROM t WHERE a > 0want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: SELECT a FROM t WHERE a > (SELECT max(id) FROM user)want:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: WHERE clause is required for SELECT statement.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT 1 FROM dualwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/oracle/test/table_no_foreign_key.yaml b/backend/plugin/advisor/oracle/test/table_no_foreign_key.yamlindex 2329a267e5..0ea787295b 100644--- a/backend/plugin/advisor/oracle/test/table_no_foreign_key.yaml+++ b/backend/plugin/advisor/oracle/test/table_no_foreign_key.yaml@@ -1,16 +1,20 @@- statement: ALTER TABLE tech_book ADD CONSTRAINT fk_tech_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id)want:- - status: WARN+ - status: 2code: 602title: table.no-foreign-keycontent: Foreign key is not allowed in the table "TEST_DB"."TECH_BOOK".- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id INT, author_id INT, CONSTRAINT fk_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id))want:- - status: WARN+ - status: 2code: 602title: table.no-foreign-keycontent: Foreign key is not allowed in the table "TEST_DB"."BOOK".- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/oracle/test/table_require_pk.yaml b/backend/plugin/advisor/oracle/test/table_require_pk.yamlindex 38f51f4aef..73786d0ada 100644--- a/backend/plugin/advisor/oracle/test/table_require_pk.yaml+++ b/backend/plugin/advisor/oracle/test/table_require_pk.yaml@@ -1,54 +1,58 @@- statement: CREATE TABLE abc.t(id INT PRIMARY KEY);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(id INT, PRIMARY KEY (id))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE "TEST_DB".t(id INT)want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table "TEST_DB"."T" requires PRIMARY KEY.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t(id INT);DROP TABLE twant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id INT);ALTER TABLE t ADD CONSTRAINT tpk PRIMARY KEY (id)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id INT PRIMARY KEY);ALTER TABLE t DROP PRIMARY KEYwant:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table "TEST_DB"."T" requires PRIMARY KEY.- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/pg/advisor_collation_allowlist.go b/backend/plugin/advisor/pg/advisor_collation_allowlist.goindex 0399cc8115..e7fde67274 100644--- a/backend/plugin/advisor/pg/advisor_collation_allowlist.go+++ b/backend/plugin/advisor/pg/advisor_collation_allowlist.go@@ -26,7 +26,7 @@ type CollationAllowlistAdvisor struct {}// Check checks for collation allowlist.-func (*CollationAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*CollationAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -55,9 +55,9 @@ func (*CollationAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -66,8 +66,8 @@ func (*CollationAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}type collationAllowlistChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringallowlist map[string]bool@@ -122,12 +122,14 @@ func (checker *collationAllowlistChecker) Visit(in ast.Node) ast.Visitor {}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("Use disabled collation \"%s\", related statement \"%s\"", disabledCollation, checker.text),- Line: line,+ StartPosition: &storepb.Position{+ Line: int32(line),+ },})}diff --git a/backend/plugin/advisor/pg/advisor_column_disallow_changing_type.go b/backend/plugin/advisor/pg/advisor_column_disallow_changing_type.goindex e8d097a62e..dcd4d922cf 100644--- a/backend/plugin/advisor/pg/advisor_column_disallow_changing_type.go+++ b/backend/plugin/advisor/pg/advisor_column_disallow_changing_type.go@@ -26,7 +26,7 @@ type ColumnDisallowChangingTypeAdvisor struct {}// Check checks for disallow changing column type.-func (*ColumnDisallowChangingTypeAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnDisallowChangingTypeAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -48,9 +48,9 @@ func (*ColumnDisallowChangingTypeAdvisor) Check(ctx advisor.Context, _ string) (}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -59,8 +59,8 @@ func (*ColumnDisallowChangingTypeAdvisor) Check(ctx advisor.Context, _ string) (}type columnDisallowChangingTypeChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustext stringline inttitle string@@ -74,12 +74,14 @@ func (checker *columnDisallowChangingTypeChecker) Visit(in ast.Node) ast.Visitor}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("The statement \"%s\" changes column type", checker.text),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}diff --git a/backend/plugin/advisor/pg/advisor_column_maximum_character_length.go b/backend/plugin/advisor/pg/advisor_column_maximum_character_length.goindex 8bae3384f7..2af1add036 100644--- a/backend/plugin/advisor/pg/advisor_column_maximum_character_length.go+++ b/backend/plugin/advisor/pg/advisor_column_maximum_character_length.go@@ -26,7 +26,7 @@ type ColumnMaximumCharacterLengthAdvisor struct {}// Check checks for maximum character length.-func (*ColumnMaximumCharacterLengthAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnMaximumCharacterLengthAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -53,9 +53,9 @@ func (*ColumnMaximumCharacterLengthAdvisor) Check(ctx advisor.Context, _ string)}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -64,8 +64,8 @@ func (*ColumnMaximumCharacterLengthAdvisor) Check(ctx advisor.Context, _ string)}type columnMaximumCharacterLengthChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringmaximum int}@@ -113,12 +113,14 @@ func (checker *columnMaximumCharacterLengthChecker) Visit(in ast.Node) ast.Visit}if tableName != "" {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.CharLengthExceedsLimit,+ Code: advisor.CharLengthExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf(`The length of the CHAR column %q in table %s is bigger than %d, please use VARCHAR instead`, columnName, tableName, checker.maximum),- Line: line,+ StartPosition: &storepb.Position{+ Line: int32(line),+ },})}diff --git a/backend/plugin/advisor/pg/advisor_column_no_null.go b/backend/plugin/advisor/pg/advisor_column_no_null.goindex f484832b2f..10098a5ebb 100644--- a/backend/plugin/advisor/pg/advisor_column_no_null.go+++ b/backend/plugin/advisor/pg/advisor_column_no_null.go@@ -26,7 +26,7 @@ type ColumnNoNullAdvisor struct {}// Check checks for column no NULL value.-func (*ColumnNoNullAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnNoNullAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmts, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -52,14 +52,14 @@ func (*ColumnNoNullAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advi}type columnNoNullChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringcatalog *catalog.FindernullableColumns columnMap}-func (checker *columnNoNullChecker) generateAdviceList() []advisor.Advice {+func (checker *columnNoNullChecker) generateAdviceList() []*storepb.Advice {var columnList []columnNamefor column := range checker.nullableColumns {columnList = append(columnList, column)@@ -77,19 +77,21 @@ func (checker *columnNoNullChecker) generateAdviceList() []advisor.Advice {})}for _, column := range columnList {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.ColumnCannotNull,+ Code: advisor.ColumnCannotNull.Int32(),Title: checker.title,Content: fmt.Sprintf(`Column "%s" in %s cannot have NULL value`, column.column, column.normalizeTableName()),- Line: checker.nullableColumns[column],+ StartPosition: &storepb.Position{+ Line: int32(checker.nullableColumns[column]),+ },})}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/pg/advisor_column_require_default.go b/backend/plugin/advisor/pg/advisor_column_require_default.goindex 8b53284e8a..d59230d9fc 100644--- a/backend/plugin/advisor/pg/advisor_column_require_default.go+++ b/backend/plugin/advisor/pg/advisor_column_require_default.go@@ -28,7 +28,7 @@ type ColumnRequireDefaultAdvisor struct {}// Check checks for column default requirement.-func (*ColumnRequireDefaultAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnRequireDefaultAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -55,8 +55,8 @@ func (*ColumnRequireDefaultAdvisor) Check(ctx advisor.Context, _ string) ([]advi}type columnRequireDefaultChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringcolumnSet map[string]columnDatacatalog *catalog.Finder@@ -69,7 +69,7 @@ type columnData struct {line int}-func (checker *columnRequireDefaultChecker) generateAdvice() []advisor.Advice {+func (checker *columnRequireDefaultChecker) generateAdvice() []*storepb.Advice {var columnList []columnDatafor _, column := range checker.columnSet {columnList = append(columnList, column)@@ -85,20 +85,22 @@ func (checker *columnRequireDefaultChecker) generateAdvice() []advisor.Advice {ColumnName: column.name,})if columnInfo != nil && !columnInfo.HasDefault() {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NoDefault,+ Code: advisor.NoDefault.Int32(),Title: checker.title,Content: fmt.Sprintf("Column %q.%q in schema %q doesn't have DEFAULT", column.table, column.name, column.schema),- Line: column.line,+ StartPosition: &storepb.Position{+ Line: int32(column.line),+ },})}}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/pg/advisor_column_required.go b/backend/plugin/advisor/pg/advisor_column_required.goindex ad994af32b..57d5b5e148 100644--- a/backend/plugin/advisor/pg/advisor_column_required.go+++ b/backend/plugin/advisor/pg/advisor_column_required.go@@ -28,7 +28,7 @@ type ColumnRequirementAdvisor struct {}// Check checks for the column requirement.-func (*ColumnRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmts, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -58,9 +58,9 @@ func (*ColumnRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]advisor}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -69,8 +69,8 @@ func (*ColumnRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]advisor}type columnRequirementChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringrequiredColumns columnSet}@@ -108,12 +108,14 @@ func (checker *columnRequirementChecker) Visit(node ast.Node) ast.Visitor {if len(missingColumns) > 0 {// Order it cause the random iteration order in Go, see https://go.dev/blog/mapssort.Strings(missingColumns)- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NoRequiredColumn,+ Code: advisor.NoRequiredColumn.Int32(),Title: checker.title,Content: fmt.Sprintf("Table %q requires columns: %s", table.Name, strings.Join(missingColumns, ", ")),- Line: node.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(node.LastLine()),+ },})}diff --git a/backend/plugin/advisor/pg/advisor_column_type_disallow_list.go b/backend/plugin/advisor/pg/advisor_column_type_disallow_list.goindex bf0a68c1a0..f550c45735 100644--- a/backend/plugin/advisor/pg/advisor_column_type_disallow_list.go+++ b/backend/plugin/advisor/pg/advisor_column_type_disallow_list.go@@ -20,7 +20,7 @@ type ColumnTypeDisallowListAdvisor struct {}// Check checks for column type restriction.-func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -51,9 +51,9 @@ func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -62,8 +62,8 @@ func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]ad}type columnTypeDisallowListChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -143,12 +143,14 @@ func (checker *columnTypeDisallowListChecker) Visit(in ast.Node) ast.Visitor {}for _, column := range columnList {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DisabledColumnType,+ Code: advisor.DisabledColumnType.Int32(),Title: checker.title,Content: fmt.Sprintf("Disallow column type %s but column \"%s\".\"%s\" is", column.tp, column.table, column.column),- Line: column.line,+ StartPosition: &storepb.Position{+ Line: int32(column.line),+ },})}return checkerdiff --git a/backend/plugin/advisor/pg/advisor_comment_convention.go b/backend/plugin/advisor/pg/advisor_comment_convention.goindex dd53435065..a7ed310fac 100644--- a/backend/plugin/advisor/pg/advisor_comment_convention.go+++ b/backend/plugin/advisor/pg/advisor_comment_convention.go@@ -26,7 +26,7 @@ type CommentConventionAdvisor struct {}// Check checks for comment convention.-func (*CommentConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*CommentConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -51,9 +51,9 @@ func (*CommentConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -62,8 +62,8 @@ func (*CommentConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor}type commentConventionChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringmaxLength int}@@ -84,12 +84,14 @@ func (checker *commentConventionChecker) Visit(node ast.Node) ast.Visitor {}if checker.maxLength > 0 && len(comment.comment) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.CommentTooLong,+ Code: advisor.CommentTooLong.Int32(),Title: checker.title,Content: fmt.Sprintf("The length of comment should be within %d characters", checker.maxLength),- Line: comment.line,+ StartPosition: &storepb.Position{+ Line: int32(comment.line),+ },})}diff --git a/backend/plugin/advisor/pg/advisor_encoding_allowlist.go b/backend/plugin/advisor/pg/advisor_encoding_allowlist.goindex 987369cef1..a3e8f96a85 100644--- a/backend/plugin/advisor/pg/advisor_encoding_allowlist.go+++ b/backend/plugin/advisor/pg/advisor_encoding_allowlist.go@@ -25,7 +25,7 @@ type EncodingAllowlistAdvisor struct {}// Check checks for encoding allowlist.-func (*EncodingAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*EncodingAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -56,9 +56,9 @@ func (*EncodingAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]advisor}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -67,8 +67,8 @@ func (*EncodingAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]advisor}type encodingAllowlistChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -91,12 +91,14 @@ func (checker *encodingAllowlistChecker) Visit(in ast.Node) ast.Visitor {}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" used disabled encoding '%s'", checker.text, disabledEncoding),- Line: line,+ StartPosition: &storepb.Position{+ Line: int32(line),+ },})}diff --git a/backend/plugin/advisor/pg/advisor_index_create_concurrently.go b/backend/plugin/advisor/pg/advisor_index_create_concurrently.goindex a16f9c6ced..ab76f1b0a9 100644--- a/backend/plugin/advisor/pg/advisor_index_create_concurrently.go+++ b/backend/plugin/advisor/pg/advisor_index_create_concurrently.go@@ -24,7 +24,7 @@ type IndexCreateConcurrentlyAdvisor struct {}// Check checks for to create index concurrently.-func (*IndexCreateConcurrentlyAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*IndexCreateConcurrentlyAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -44,9 +44,9 @@ func (*IndexCreateConcurrentlyAdvisor) Check(ctx advisor.Context, _ string) ([]a}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -55,8 +55,8 @@ func (*IndexCreateConcurrentlyAdvisor) Check(ctx advisor.Context, _ string) ([]a}type indexCreateConcurrentlyChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle string}@@ -64,12 +64,14 @@ type indexCreateConcurrentlyChecker struct {func (checker *indexCreateConcurrentlyChecker) Visit(in ast.Node) ast.Visitor {if node, ok := in.(*ast.CreateIndexStmt); ok {if !node.Concurrently {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.CreateIndexUnconcurrently,+ Code: advisor.CreateIndexUnconcurrently.Int32(),Title: checker.title,Content: "Creating indexes will block writes on the table, unless use CONCURRENTLY",- Line: in.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(in.LastLine()),+ },})}}diff --git a/backend/plugin/advisor/pg/advisor_index_key_number_limit.go b/backend/plugin/advisor/pg/advisor_index_key_number_limit.goindex 026b68a5f2..83f267e53e 100644--- a/backend/plugin/advisor/pg/advisor_index_key_number_limit.go+++ b/backend/plugin/advisor/pg/advisor_index_key_number_limit.go@@ -24,7 +24,7 @@ type IndexKeyNumberLimitAdvisor struct {}// Check checks for index key number limit.-func (*IndexKeyNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*IndexKeyNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmts, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -50,9 +50,9 @@ func (*IndexKeyNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advis}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -61,8 +61,8 @@ func (*IndexKeyNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advis}type indexKeyNumberLimitChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringmax int}@@ -106,12 +106,14 @@ func (checker *indexKeyNumberLimitChecker) Visit(node ast.Node) ast.Visitor {indexDataList := checker.getMetaDataList(node)for _, index := range indexDataList {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.IndexKeyNumberExceedsLimit,+ Code: advisor.IndexKeyNumberExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("The number of keys of index %q in table %q should be not greater than %d", index.indexName, index.tableName, checker.max),- Line: index.line,+ StartPosition: &storepb.Position{+ Line: int32(index.line),+ },})}return checkerdiff --git a/backend/plugin/advisor/pg/advisor_index_no_duplicate_column.go b/backend/plugin/advisor/pg/advisor_index_no_duplicate_column.goindex c4d24a72ac..fc71850e8f 100644--- a/backend/plugin/advisor/pg/advisor_index_no_duplicate_column.go+++ b/backend/plugin/advisor/pg/advisor_index_no_duplicate_column.go@@ -19,7 +19,7 @@ type IndexNoDuplicateColumnAdvisor struct {}// Check checks for no duplicate columns in index.-func (*IndexNoDuplicateColumnAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*IndexNoDuplicateColumnAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -41,9 +41,9 @@ func (*IndexNoDuplicateColumnAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -53,8 +53,8 @@ func (*IndexNoDuplicateColumnAdvisor) Check(ctx advisor.Context, _ string) ([]ad}type indexNoDuplicateColumnChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -127,12 +127,14 @@ func (checker *indexNoDuplicateColumnChecker) Visit(node ast.Node) ast.Visitor {}for _, column := range columnList {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DuplicateColumnInIndex,+ Code: advisor.DuplicateColumnInIndex.Int32(),Title: checker.title,Content: fmt.Sprintf("%s \"%s\" has duplicate column \"%s\".\"%s\"", column.constraintType, column.index, column.table, column.column),- Line: column.line,+ StartPosition: &storepb.Position{+ Line: int32(column.line),+ },})}diff --git a/backend/plugin/advisor/pg/advisor_index_primary_key_type_allowlist.go b/backend/plugin/advisor/pg/advisor_index_primary_key_type_allowlist.goindex 4875e66200..c6ebacda19 100644--- a/backend/plugin/advisor/pg/advisor_index_primary_key_type_allowlist.go+++ b/backend/plugin/advisor/pg/advisor_index_primary_key_type_allowlist.go@@ -28,7 +28,7 @@ type IndexPrimaryKeyTypeAllowlistAdvisor struct {}// Check checks for primary key type allowlist.-func (*IndexPrimaryKeyTypeAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*IndexPrimaryKeyTypeAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -53,9 +53,9 @@ func (*IndexPrimaryKeyTypeAllowlistAdvisor) Check(ctx advisor.Context, _ string)}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -64,8 +64,8 @@ func (*IndexPrimaryKeyTypeAllowlistAdvisor) Check(ctx advisor.Context, _ string)}type indexPrimaryKeyTypeAllowlistChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringallowlist []string}@@ -101,12 +101,14 @@ func (checker *indexPrimaryKeyTypeAllowlistChecker) Visit(in ast.Node) ast.Visitslog.String("originalSQL", in.Text()))typeText = ""}- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.IndexPKType,+ Code: advisor.IndexPKType.Int32(),Title: checker.title,Content: fmt.Sprintf(`The column "%s" is one of the primary key, but its type "%s" is not in allowlist`, column.ColumnName, typeText),- Line: column.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(column.LastLine()),+ },})}}diff --git a/backend/plugin/advisor/pg/advisor_index_total_number_limit.go b/backend/plugin/advisor/pg/advisor_index_total_number_limit.goindex 654589a91b..e3a6a03e51 100644--- a/backend/plugin/advisor/pg/advisor_index_total_number_limit.go+++ b/backend/plugin/advisor/pg/advisor_index_total_number_limit.go@@ -28,7 +28,7 @@ type IndexTotalNumberLimitAdvisor struct {}// Check checks for index total number limit.-func (*IndexTotalNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*IndexTotalNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -79,15 +79,15 @@ func (m tableLineMap) set(schema string, table string, line int) {}type indexTotalNumberLimitChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringmax intcatalog *catalog.FindertableLine tableLineMap}-func (checker *indexTotalNumberLimitChecker) generateAdvice() []advisor.Advice {+func (checker *indexTotalNumberLimitChecker) generateAdvice() []*storepb.Advice {var tableList []tableLinefor _, table := range checker.tableLine {tableList = append(tableList, table)@@ -102,20 +102,22 @@ func (checker *indexTotalNumberLimitChecker) generateAdvice() []advisor.Advice {TableName: table.table,})if tableInfo != nil && tableInfo.CountIndex() > checker.max {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.IndexCountExceedsLimit,+ Code: advisor.IndexCountExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("The count of index in table %q.%q should be no more than %d, but found %d", table.schema, table.table, checker.max, tableInfo.CountIndex()),- Line: table.line,+ StartPosition: &storepb.Position{+ Line: int32(table.line),+ },})}}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/pg/advisor_insert_disallow_order_by_rand.go b/backend/plugin/advisor/pg/advisor_insert_disallow_order_by_rand.goindex 9f8f18d2e5..d65a86c027 100644--- a/backend/plugin/advisor/pg/advisor_insert_disallow_order_by_rand.go+++ b/backend/plugin/advisor/pg/advisor_insert_disallow_order_by_rand.go@@ -27,7 +27,7 @@ type InsertDisallowOrderByRandAdvisor struct {}// Check checks for to disallow order by rand in INSERT statements.-func (*InsertDisallowOrderByRandAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*InsertDisallowOrderByRandAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -48,9 +48,9 @@ func (*InsertDisallowOrderByRandAdvisor) Check(ctx advisor.Context, _ string) ([}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -59,8 +59,8 @@ func (*InsertDisallowOrderByRandAdvisor) Check(ctx advisor.Context, _ string) ([}type insertDisallowOrderByRandChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext string}@@ -79,12 +79,14 @@ func (checker *insertDisallowOrderByRandChecker) Visit(in ast.Node) ast.Visitor}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("The INSERT statement uses ORDER BY random() or random_between(), related statement \"%s\"", checker.text),- Line: in.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(in.LastLine()),+ },})}diff --git a/backend/plugin/advisor/pg/advisor_insert_must_specify_column.go b/backend/plugin/advisor/pg/advisor_insert_must_specify_column.goindex c01bd2f22c..b6a89b6004 100644--- a/backend/plugin/advisor/pg/advisor_insert_must_specify_column.go+++ b/backend/plugin/advisor/pg/advisor_insert_must_specify_column.go@@ -26,7 +26,7 @@ type InsertMustSpecifyColumnAdvisor struct {}// Check checks for to enforce column specified.-func (*InsertMustSpecifyColumnAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*InsertMustSpecifyColumnAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -47,9 +47,9 @@ func (*InsertMustSpecifyColumnAdvisor) Check(ctx advisor.Context, _ string) ([]a}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -58,8 +58,8 @@ func (*InsertMustSpecifyColumnAdvisor) Check(ctx advisor.Context, _ string) ([]a}type insertMustSpecifyColumnChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext string}@@ -67,12 +67,14 @@ type insertMustSpecifyColumnChecker struct {// Visit implements ast.Visitor interface.func (checker *insertMustSpecifyColumnChecker) Visit(in ast.Node) ast.Visitor {if node, ok := in.(*ast.InsertStmt); ok && len(node.ColumnList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.InsertNotSpecifyColumn,+ Code: advisor.InsertNotSpecifyColumn.Int32(),Title: checker.title,Content: fmt.Sprintf("The INSERT statement must specify columns but \"%s\" does not", checker.text),- Line: node.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(node.LastLine()),+ },})}diff --git a/backend/plugin/advisor/pg/advisor_insert_row_limit.go b/backend/plugin/advisor/pg/advisor_insert_row_limit.goindex 9397427373..36b787f94d 100644--- a/backend/plugin/advisor/pg/advisor_insert_row_limit.go+++ b/backend/plugin/advisor/pg/advisor_insert_row_limit.go@@ -28,7 +28,7 @@ type InsertRowLimitAdvisor struct {}// Check checks for the WHERE clause requirement.-func (*InsertRowLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*InsertRowLimitAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmts, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -59,9 +59,9 @@ func (*InsertRowLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -70,8 +70,8 @@ func (*InsertRowLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Ad}type insertRowLimitChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -97,22 +97,26 @@ func (checker *insertRowLimitChecker) Visit(node ast.Node) ast.Visitor {// For INSERT INTO ... SELECT statements, use EXPLAIN.res, err := advisor.Query(checker.ctx, checker.driver, fmt.Sprintf("EXPLAIN %s", node.Text()))if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.InsertTooManyRows,+ Code: advisor.InsertTooManyRows.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" dry runs failed: %s", checker.text, err.Error()),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})} else {rowCount, err := getAffectedRows(res)if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: checker.title,Content: fmt.Sprintf("failed to get row count for \"%s\": %s", checker.text, err.Error()),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})} else if rowCount > int64(checker.maxRow) {code = advisor.InsertTooManyRows@@ -123,12 +127,14 @@ func (checker *insertRowLimitChecker) Visit(node ast.Node) ast.Visitor {}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("The statement \"%s\" inserts %d rows. The count exceeds %d.", checker.text, rows, checker.maxRow),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}return checkerdiff --git a/backend/plugin/advisor/pg/advisor_migration_compatibility.go b/backend/plugin/advisor/pg/advisor_migration_compatibility.goindex 97a7eef478..843568a6d9 100644--- a/backend/plugin/advisor/pg/advisor_migration_compatibility.go+++ b/backend/plugin/advisor/pg/advisor_migration_compatibility.go@@ -24,7 +24,7 @@ type CompatibilityAdvisor struct {}// Check checks schema backward compatibility.-func (*CompatibilityAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*CompatibilityAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmts, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -45,9 +45,9 @@ func (*CompatibilityAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Adv}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -56,8 +56,8 @@ func (*CompatibilityAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Adv}type compatibilityChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringlastCreateTable string@@ -123,12 +123,14 @@ func (checker *compatibilityChecker) Visit(node ast.Node) ast.Visitor {}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" may cause incompatibility with the existing data and code", checker.text),- Line: node.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(node.LastLine()),+ },})}return checkerdiff --git a/backend/plugin/advisor/pg/advisor_naming_column.go b/backend/plugin/advisor/pg/advisor_naming_column.goindex 566c6f12d5..c878889624 100644--- a/backend/plugin/advisor/pg/advisor_naming_column.go+++ b/backend/plugin/advisor/pg/advisor_naming_column.go@@ -25,7 +25,7 @@ type NamingColumnConventionAdvisor struct {}// Check checks for column naming convention.-func (*NamingColumnConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingColumnConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmts, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -52,9 +52,9 @@ func (*NamingColumnConventionAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -63,8 +63,8 @@ func (*NamingColumnConventionAdvisor) Check(ctx advisor.Context, _ string) ([]ad}type namingColumnConventionChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat *regexp.RegexpmaxLength int@@ -109,22 +109,26 @@ func (checker *namingColumnConventionChecker) Visit(node ast.Node) ast.Visitor {for _, column := range columnList {if !checker.format.MatchString(column.name) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingColumnConventionMismatch,+ Code: advisor.NamingColumnConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\".\"%s\" mismatches column naming convention, naming format should be %q", tableName, column.name, checker.format),- Line: column.line,+ StartPosition: &storepb.Position{+ Line: int32(column.line),+ },})}if checker.maxLength > 0 && len(column.name) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingColumnConventionMismatch,+ Code: advisor.NamingColumnConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\".\"%s\" mismatches column naming convention, its length should be within %d characters", tableName, column.name, checker.maxLength),- Line: column.line,+ StartPosition: &storepb.Position{+ Line: int32(column.line),+ },})}}diff --git a/backend/plugin/advisor/pg/advisor_naming_foreign_key_convention.go b/backend/plugin/advisor/pg/advisor_naming_foreign_key_convention.goindex 2a69f52655..997695faaf 100644--- a/backend/plugin/advisor/pg/advisor_naming_foreign_key_convention.go+++ b/backend/plugin/advisor/pg/advisor_naming_foreign_key_convention.go@@ -26,7 +26,7 @@ type NamingFKConventionAdvisor struct {}// Check checks for foreign key naming convention.-func (*NamingFKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingFKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -55,9 +55,9 @@ func (*NamingFKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -67,8 +67,8 @@ func (*NamingFKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}type namingFKConventionChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat stringmaxLength int@@ -89,30 +89,34 @@ func (checker *namingFKConventionChecker) Visit(in ast.Node) ast.Visitor {for _, indexData := range indexDataList {regex, err := getTemplateRegexp(checker.format, checker.templateList, indexData.metaData)if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: "Internal error for foreign key naming convention rule",Content: fmt.Sprintf("%q meet internal error %q", in.Text(), err.Error()),})continue}if !regex.MatchString(indexData.indexName) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingFKConventionMismatch,+ Code: advisor.NamingFKConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf(`Foreign key in table "%s" mismatches the naming convention, expect %q but found "%s"`, indexData.tableName, regex, indexData.indexName),- Line: indexData.line,+ StartPosition: &storepb.Position{+ Line: int32(indexData.line),+ },})}if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingFKConventionMismatch,+ Code: advisor.NamingFKConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf(`Foreign key "%s" in table "%s" mismatches the naming convention, its length should be within %d characters`, indexData.indexName, indexData.tableName, checker.maxLength),- Line: indexData.line,+ StartPosition: &storepb.Position{+ Line: int32(indexData.line),+ },})}}diff --git a/backend/plugin/advisor/pg/advisor_naming_fully_qualified.go b/backend/plugin/advisor/pg/advisor_naming_fully_qualified.goindex 2874ef3c17..f7f08a20aa 100644--- a/backend/plugin/advisor/pg/advisor_naming_fully_qualified.go+++ b/backend/plugin/advisor/pg/advisor_naming_fully_qualified.go@@ -12,18 +12,18 @@ import ("github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/plugin/parser/sql/ast"- "github.com/bytebase/bytebase/proto/generated-go/store"+ storepb "github.com/bytebase/bytebase/proto/generated-go/store")func init() {- advisor.Register(store.Engine_POSTGRES, advisor.PostgreSQLNamingFullyQualifiedObjectName, &FullyQualifiedObjectNameAdvisor{})+ advisor.Register(storepb.Engine_POSTGRES, advisor.PostgreSQLNamingFullyQualifiedObjectName, &FullyQualifiedObjectNameAdvisor{})}type FullyQualifiedObjectNameAdvisor struct{}type FullyQualifiedObjectNameChecker struct {- adviceList []advisor.Advice- status advisor.Status+ adviceList []*storepb.Advice+ status storepb.Advice_Statustitle stringline intisSelectStmt bool@@ -126,7 +126,7 @@ var (_ ast.Visitor = (*FullyQualifiedObjectNameChecker)(nil))-func (*FullyQualifiedObjectNameAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*FullyQualifiedObjectNameAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {checker := &FullyQualifiedObjectNameChecker{}status, err := advisor.NewStatusBySQLReviewRuleLevel(ctx.Rule.Level)if err != nil {@@ -155,9 +155,9 @@ func (*FullyQualifiedObjectNameAdvisor) Check(ctx advisor.Context, _ string) ([]}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -172,12 +172,14 @@ func (checker *FullyQualifiedObjectNameChecker) appendAdviceByObjName(objName st}re := regexp.MustCompile(`.+\..+`)if !re.MatchString(objName) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.status,Code: advisor.NamingNotFullyQualifiedName,Title: checker.title,Content: fmt.Sprintf("unqualified object name: '%s'", objName),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}}@@ -249,7 +251,7 @@ func getFullyQualiufiedObjectName(nodeDef ast.Node) string {}// Used for select statement.-func findAllTables(statement string, schemaMetadata *store.DatabaseSchemaMetadata) []base.ColumnResource {+func findAllTables(statement string, schemaMetadata *storepb.DatabaseSchemaMetadata) []base.ColumnResource {jsonText, err := pgquery.ParseToJSON(statement)if err != nil {return nil@@ -273,7 +275,7 @@ func findAllTables(statement string, schemaMetadata *store.DatabaseSchemaMetadatreturn resourceArray}-func getSchemaNameMapFromPublic(schemaMetadata *store.DatabaseSchemaMetadata) map[string]bool {+func getSchemaNameMapFromPublic(schemaMetadata *storepb.DatabaseSchemaMetadata) map[string]bool {if schemaMetadata.Schemas == nil {return nil}diff --git a/backend/plugin/advisor/pg/advisor_naming_index_convention.go b/backend/plugin/advisor/pg/advisor_naming_index_convention.goindex 621250bb96..388c3eacd7 100644--- a/backend/plugin/advisor/pg/advisor_naming_index_convention.go+++ b/backend/plugin/advisor/pg/advisor_naming_index_convention.go@@ -26,7 +26,7 @@ type NamingIndexConventionAdvisor struct {}// Check checks for index naming convention.-func (*NamingIndexConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingIndexConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmts, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -55,9 +55,9 @@ func (*NamingIndexConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adv}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -67,8 +67,8 @@ func (*NamingIndexConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adv}type namingIndexConventionChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat stringmaxLength int@@ -83,30 +83,34 @@ func (checker *namingIndexConventionChecker) Visit(node ast.Node) ast.Visitor {for _, indexData := range indexDataList {regex, err := getTemplateRegexp(checker.format, checker.templateList, indexData.metaData)if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: "Internal error for index naming convention rule",Content: fmt.Sprintf("%q meet internal error %q", node.Text(), err.Error()),})continue}if !regex.MatchString(indexData.indexName) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingIndexConventionMismatch,+ Code: advisor.NamingIndexConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("Index in table %q mismatches the naming convention, expect %q but found %q", indexData.tableName, regex, indexData.indexName),- Line: node.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(node.LastLine()),+ },})}if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingIndexConventionMismatch,+ Code: advisor.NamingIndexConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("Index %q in table %q mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),- Line: node.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(node.LastLine()),+ },})}}diff --git a/backend/plugin/advisor/pg/advisor_naming_primary_key_convention.go b/backend/plugin/advisor/pg/advisor_naming_primary_key_convention.goindex d9ef8ebbe5..d5efdec840 100644--- a/backend/plugin/advisor/pg/advisor_naming_primary_key_convention.go+++ b/backend/plugin/advisor/pg/advisor_naming_primary_key_convention.go@@ -26,7 +26,7 @@ type NamingPKConventionAdvisor struct {}// Check checks for index naming convention.-func (*NamingPKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingPKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmts, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -56,9 +56,9 @@ func (*NamingPKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -68,8 +68,8 @@ func (*NamingPKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}type namingPKConventionChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat stringmaxLength int@@ -84,30 +84,34 @@ func (checker *namingPKConventionChecker) Visit(in ast.Node) ast.Visitor {for _, indexData := range indexDataList {regex, err := getTemplateRegexp(checker.format, checker.templateList, indexData.metaData)if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: "Internal error for primary key naming convention rule",Content: fmt.Sprintf("%q meet internal error %q", in.Text(), err.Error()),})continue}if !regex.MatchString(indexData.indexName) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingPKConventionMismatch,+ Code: advisor.NamingPKConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf(`Primary key in table "%s" mismatches the naming convention, expect %q but found "%s"`, indexData.tableName, regex, indexData.indexName),- Line: indexData.line,+ StartPosition: &storepb.Position{+ Line: int32(indexData.line),+ },})}if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingPKConventionMismatch,+ Code: advisor.NamingPKConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf(`Primary key "%s" in table "%s" mismatches the naming convention, its length should be within %d characters`, indexData.indexName, indexData.tableName, checker.maxLength),- Line: indexData.line,+ StartPosition: &storepb.Position{+ Line: int32(indexData.line),+ },})}}diff --git a/backend/plugin/advisor/pg/advisor_naming_table.go b/backend/plugin/advisor/pg/advisor_naming_table.goindex 8cf657cdc2..4087988931 100644--- a/backend/plugin/advisor/pg/advisor_naming_table.go+++ b/backend/plugin/advisor/pg/advisor_naming_table.go@@ -25,7 +25,7 @@ type NamingTableConventionAdvisor struct {}// Check checks for table naming convention.-func (*NamingTableConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingTableConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmts, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -52,9 +52,9 @@ func (*NamingTableConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adv}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -63,8 +63,8 @@ func (*NamingTableConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adv}type namingTableConventionChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat *regexp.RegexpmaxLength int@@ -85,21 +85,25 @@ func (checker *namingTableConventionChecker) Visit(node ast.Node) ast.Visitor {for _, tableName := range tableNames {if !checker.format.MatchString(tableName) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingTableConventionMismatch,+ Code: advisor.NamingTableConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf(`"%s" mismatches table naming convention, naming format should be %q`, tableName, checker.format),- Line: node.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(node.LastLine()),+ },})}if checker.maxLength > 0 && len(tableName) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingTableConventionMismatch,+ Code: advisor.NamingTableConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" mismatches table naming convention, its length should be within %d characters", tableName, checker.maxLength),- Line: node.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(node.LastLine()),+ },})}}diff --git a/backend/plugin/advisor/pg/advisor_naming_unique_key_convention.go b/backend/plugin/advisor/pg/advisor_naming_unique_key_convention.goindex c12df94e07..caecfd8b94 100644--- a/backend/plugin/advisor/pg/advisor_naming_unique_key_convention.go+++ b/backend/plugin/advisor/pg/advisor_naming_unique_key_convention.go@@ -26,7 +26,7 @@ type NamingUKConventionAdvisor struct {}// Check checks for unique key naming convention.-func (*NamingUKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingUKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -56,9 +56,9 @@ func (*NamingUKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -68,8 +68,8 @@ func (*NamingUKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}type namingUKConventionChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat stringmaxLength int@@ -84,30 +84,34 @@ func (checker *namingUKConventionChecker) Visit(in ast.Node) ast.Visitor {for _, indexData := range indexDataList {regex, err := getTemplateRegexp(checker.format, checker.templateList, indexData.metaData)if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: "Internal error for unique key naming convention rule",Content: fmt.Sprintf("%q meet internal error %q", in.Text(), err.Error()),})continue}if !regex.MatchString(indexData.indexName) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingUKConventionMismatch,+ Code: advisor.NamingUKConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf(`Unique key in table "%s" mismatches the naming convention, expect %q but found "%s"`, indexData.tableName, regex, indexData.indexName),- Line: indexData.line,+ StartPosition: &storepb.Position{+ Line: int32(indexData.line),+ },})}if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingUKConventionMismatch,+ Code: advisor.NamingUKConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf(`Unique key "%s" in table "%s" mismatches the naming convention, its length should be within %d characters`, indexData.indexName, indexData.tableName, checker.maxLength),- Line: indexData.line,+ StartPosition: &storepb.Position{+ Line: int32(indexData.line),+ },})}}diff --git a/backend/plugin/advisor/pg/advisor_statement_add_check_not_valid.go b/backend/plugin/advisor/pg/advisor_statement_add_check_not_valid.goindex 54000c46e6..a24bbff7ee 100644--- a/backend/plugin/advisor/pg/advisor_statement_add_check_not_valid.go+++ b/backend/plugin/advisor/pg/advisor_statement_add_check_not_valid.go@@ -24,7 +24,7 @@ type StatementAddCheckNotValidAdvisor struct {}// Check checks for to add check not valid.-func (*StatementAddCheckNotValidAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementAddCheckNotValidAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -45,9 +45,9 @@ func (*StatementAddCheckNotValidAdvisor) Check(ctx advisor.Context, _ string) ([}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -56,8 +56,8 @@ func (*StatementAddCheckNotValidAdvisor) Check(ctx advisor.Context, _ string) ([}type statementAddCheckNotValidChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringline int}@@ -66,12 +66,14 @@ type statementAddCheckNotValidChecker struct {func (checker *statementAddCheckNotValidChecker) Visit(in ast.Node) ast.Visitor {if node, ok := in.(*ast.AddConstraintStmt); ok {if node.Constraint.Type == ast.ConstraintTypeCheck && !node.Constraint.SkipValidation {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementAddCheckWithValidation,+ Code: advisor.StatementAddCheckWithValidation.Int32(),Title: checker.title,Content: "Adding check constraints with validation will block reads and writes. You can add check constraints not valid and then validate separately",- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}}diff --git a/backend/plugin/advisor/pg/advisor_statement_add_fk_not_valid.go b/backend/plugin/advisor/pg/advisor_statement_add_fk_not_valid.goindex 7136be1478..d51ecf6139 100644--- a/backend/plugin/advisor/pg/advisor_statement_add_fk_not_valid.go+++ b/backend/plugin/advisor/pg/advisor_statement_add_fk_not_valid.go@@ -24,7 +24,7 @@ type StatementAddFKNotValidAdvisor struct {}// Check checks for to add check not valid.-func (*StatementAddFKNotValidAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementAddFKNotValidAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -45,9 +45,9 @@ func (*StatementAddFKNotValidAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -56,8 +56,8 @@ func (*StatementAddFKNotValidAdvisor) Check(ctx advisor.Context, _ string) ([]ad}type statementAddFKNotValidChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringline int}@@ -66,12 +66,14 @@ type statementAddFKNotValidChecker struct {func (checker *statementAddFKNotValidChecker) Visit(in ast.Node) ast.Visitor {if node, ok := in.(*ast.AddConstraintStmt); ok {if node.Constraint.Type == ast.ConstraintTypeForeign && !node.Constraint.SkipValidation {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementAddFKWithValidation,+ Code: advisor.StatementAddFKWithValidation.Int32(),Title: checker.title,Content: "Adding foreign keys with validation will block reads and writes. You can add check foreign keys not valid and then validate separately",- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}}diff --git a/backend/plugin/advisor/pg/advisor_statement_affected_row_limit.go b/backend/plugin/advisor/pg/advisor_statement_affected_row_limit.goindex 88ae3c7ca8..b7cb167e58 100644--- a/backend/plugin/advisor/pg/advisor_statement_affected_row_limit.go+++ b/backend/plugin/advisor/pg/advisor_statement_affected_row_limit.go@@ -28,7 +28,7 @@ type StatementAffectedRowLimitAdvisor struct {}// Check checks for UPDATE/DELETE affected row limit.-func (*StatementAffectedRowLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementAffectedRowLimitAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -58,9 +58,9 @@ func (*StatementAffectedRowLimitAdvisor) Check(ctx advisor.Context, _ string) ([}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -69,8 +69,8 @@ func (*StatementAffectedRowLimitAdvisor) Check(ctx advisor.Context, _ string) ([}type statementAffectedRowLimitChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustext stringtitle stringmaxRow int@@ -86,22 +86,26 @@ func (checker *statementAffectedRowLimitChecker) Visit(in ast.Node) ast.Visitorcase *ast.UpdateStmt, *ast.DeleteStmt:res, err := advisor.Query(checker.ctx, checker.driver, fmt.Sprintf("EXPLAIN %s", node.Text()))if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.InsertTooManyRows,+ Code: advisor.InsertTooManyRows.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" dry runs failed: %s", checker.text, err.Error()),- Line: node.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(node.LastLine()),+ },})} else {rowCount, err := getAffectedRows(res)if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: checker.title,Content: fmt.Sprintf("failed to get row count for \"%s\": %s", checker.text, err.Error()),- Line: node.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(node.LastLine()),+ },})} else if rowCount > int64(checker.maxRow) {code = advisor.StatementAffectedRowExceedsLimit@@ -111,12 +115,14 @@ func (checker *statementAffectedRowLimitChecker) Visit(in ast.Node) ast.Visitor}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("The statement \"%s\" affected %d rows (estimated). The count exceeds %d.", checker.text, rows, checker.maxRow),- Line: in.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(in.LastLine()),+ },})}return checkerdiff --git a/backend/plugin/advisor/pg/advisor_statement_check_set_role_variable.go b/backend/plugin/advisor/pg/advisor_statement_check_set_role_variable.goindex c2ccbc9840..d85c492ff4 100644--- a/backend/plugin/advisor/pg/advisor_statement_check_set_role_variable.go+++ b/backend/plugin/advisor/pg/advisor_statement_check_set_role_variable.go@@ -19,7 +19,7 @@ func init() {type StatementCheckSetRoleVariable struct {}-func (*StatementCheckSetRoleVariable) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementCheckSetRoleVariable) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmts, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -46,18 +46,20 @@ func (*StatementCheckSetRoleVariable) Check(ctx advisor.Context, _ string) ([]ad}if !hasSetRole {- return []advisor.Advice{{+ return []*storepb.Advice{{Status: level,- Code: advisor.StatementCheckSetRoleVariable,+ Code: advisor.StatementCheckSetRoleVariable.Int32(),Title: string(ctx.Rule.Type),Content: "No SET ROLE statement found.",- Line: 1,+ StartPosition: &storepb.Position{+ Line: 1,+ },}}, nil}- return []advisor.Advice{{- Status: advisor.Success,- Code: advisor.Ok,+ return []*storepb.Advice{{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",}}, nildiff --git a/backend/plugin/advisor/pg/advisor_statement_create_specify_schema.go b/backend/plugin/advisor/pg/advisor_statement_create_specify_schema.goindex 1dbe6320f0..3ccc5cba9a 100644--- a/backend/plugin/advisor/pg/advisor_statement_create_specify_schema.go+++ b/backend/plugin/advisor/pg/advisor_statement_create_specify_schema.go@@ -20,7 +20,7 @@ func init() {type StatementCreateSpecifySchema struct {}-func (*StatementCreateSpecifySchema) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementCreateSpecifySchema) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmts, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -40,9 +40,9 @@ func (*StatementCreateSpecifySchema) Check(ctx advisor.Context, _ string) ([]adv}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -51,8 +51,8 @@ func (*StatementCreateSpecifySchema) Check(ctx advisor.Context, _ string) ([]adv}type statementCreateSpecifySchemaChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle string}@@ -60,62 +60,74 @@ func (c *statementCreateSpecifySchemaChecker) Visit(node ast.Node) ast.Visitor {switch n := node.(type) {case *ast.CreateTableStmt:if n.Name.Schema == "" {- c.adviceList = append(c.adviceList, advisor.Advice{+ c.adviceList = append(c.adviceList, &storepb.Advice{Status: c.level,- Code: advisor.StatementCreateWithoutSchemaName,+ Code: advisor.StatementCreateWithoutSchemaName.Int32(),Title: c.title,Content: "Table schema should be specified.",- Line: node.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(node.LastLine()),+ },})}case *ast.CreateExtensionStmt:if n.Schema == "" {- c.adviceList = append(c.adviceList, advisor.Advice{+ c.adviceList = append(c.adviceList, &storepb.Advice{Status: c.level,- Code: advisor.StatementCreateWithoutSchemaName,+ Code: advisor.StatementCreateWithoutSchemaName.Int32(),Title: c.title,Content: "Extension schema should be specified.",- Line: node.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(node.LastLine()),+ },})}case *ast.CreateFunctionStmt:if n.Function.Schema == "" {- c.adviceList = append(c.adviceList, advisor.Advice{+ c.adviceList = append(c.adviceList, &storepb.Advice{Status: c.level,- Code: advisor.StatementCreateWithoutSchemaName,+ Code: advisor.StatementCreateWithoutSchemaName.Int32(),Title: c.title,Content: "Function schema should be specified.",- Line: node.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(node.LastLine()),+ },})}case *ast.CreateIndexStmt:if n.Index.Table.Schema == "" {- c.adviceList = append(c.adviceList, advisor.Advice{+ c.adviceList = append(c.adviceList, &storepb.Advice{Status: c.level,- Code: advisor.StatementCreateWithoutSchemaName,+ Code: advisor.StatementCreateWithoutSchemaName.Int32(),Title: c.title,Content: "Table schema for index should be specified.",- Line: node.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(node.LastLine()),+ },})}case *ast.CreateSequenceStmt:if n.SequenceDef.SequenceName.Schema == "" {- c.adviceList = append(c.adviceList, advisor.Advice{+ c.adviceList = append(c.adviceList, &storepb.Advice{Status: c.level,- Code: advisor.StatementCreateWithoutSchemaName,+ Code: advisor.StatementCreateWithoutSchemaName.Int32(),Title: c.title,Content: "Sequence schema should be specified.",- Line: node.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(node.LastLine()),+ },})}case *ast.CreateTriggerStmt:if n.Trigger.Table.Schema == "" {- c.adviceList = append(c.adviceList, advisor.Advice{+ c.adviceList = append(c.adviceList, &storepb.Advice{Status: c.level,- Code: advisor.StatementCreateWithoutSchemaName,+ Code: advisor.StatementCreateWithoutSchemaName.Int32(),Title: c.title,Content: "Table schema for trigger should be specified.",- Line: node.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(node.LastLine()),+ },})}}diff --git a/backend/plugin/advisor/pg/advisor_statement_disallow_add_column_with_default.go b/backend/plugin/advisor/pg/advisor_statement_disallow_add_column_with_default.goindex 32f1e42d34..c9e3a646c1 100644--- a/backend/plugin/advisor/pg/advisor_statement_disallow_add_column_with_default.go+++ b/backend/plugin/advisor/pg/advisor_statement_disallow_add_column_with_default.go@@ -24,7 +24,7 @@ type StatementDisallowAddColumnWithDefaultAdvisor struct {}// Check checks for to disallow add column with default.-func (*StatementDisallowAddColumnWithDefaultAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementDisallowAddColumnWithDefaultAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -45,9 +45,9 @@ func (*StatementDisallowAddColumnWithDefaultAdvisor) Check(ctx advisor.Context,}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -56,8 +56,8 @@ func (*StatementDisallowAddColumnWithDefaultAdvisor) Check(ctx advisor.Context,}type statementDisallowAddColumnWithDefaultChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringline int}@@ -67,12 +67,14 @@ func (checker *statementDisallowAddColumnWithDefaultChecker) Visit(in ast.Node)if node, ok := in.(*ast.AddColumnListStmt); ok {for _, column := range node.ColumnList {if setDefault(column) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementAddColumnWithDefault,+ Code: advisor.StatementAddColumnWithDefault.Int32(),Title: checker.title,Content: "Adding column with DEFAULT will locked the whole table and rewriting each rows",- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}}diff --git a/backend/plugin/advisor/pg/advisor_statement_disallow_add_not_null.go b/backend/plugin/advisor/pg/advisor_statement_disallow_add_not_null.goindex 1970bc291b..dcd259ec32 100644--- a/backend/plugin/advisor/pg/advisor_statement_disallow_add_not_null.go+++ b/backend/plugin/advisor/pg/advisor_statement_disallow_add_not_null.go@@ -26,7 +26,7 @@ type StatementDisallowAddNotNullAdvisor struct {}// Check checks for to disallow add not null.-func (*StatementDisallowAddNotNullAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementDisallowAddNotNullAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -47,9 +47,9 @@ func (*StatementDisallowAddNotNullAdvisor) Check(ctx advisor.Context, _ string)}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -58,8 +58,8 @@ func (*StatementDisallowAddNotNullAdvisor) Check(ctx advisor.Context, _ string)}type statementDisallowAddNotNullChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringline int}@@ -67,12 +67,14 @@ type statementDisallowAddNotNullChecker struct {// Visit implements ast.Visitor interface.func (checker *statementDisallowAddNotNullChecker) Visit(in ast.Node) ast.Visitor {if node, ok := in.(*ast.SetNotNullStmt); ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementAddNotNull,+ Code: advisor.StatementAddNotNull.Int32(),Title: checker.title,Content: fmt.Sprintf("Setting NOT NULL will block reads and writes. You can use CHECK (%q IS NOT NULL) instead", node.ColumnName),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}diff --git a/backend/plugin/advisor/pg/advisor_statement_disallow_commit.go b/backend/plugin/advisor/pg/advisor_statement_disallow_commit.goindex aa97337fd6..d5f54fe936 100644--- a/backend/plugin/advisor/pg/advisor_statement_disallow_commit.go+++ b/backend/plugin/advisor/pg/advisor_statement_disallow_commit.go@@ -26,7 +26,7 @@ type StatementDisallowCommitAdvisor struct {}// Check checks for to disallow commit.-func (*StatementDisallowCommitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementDisallowCommitAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -46,9 +46,9 @@ func (*StatementDisallowCommitAdvisor) Check(ctx advisor.Context, _ string) ([]a}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -57,20 +57,22 @@ func (*StatementDisallowCommitAdvisor) Check(ctx advisor.Context, _ string) ([]a}type statementDisallowCommitChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle string}// Visit implements ast.Visitor interface.func (checker *statementDisallowCommitChecker) Visit(in ast.Node) ast.Visitor {if _, ok := in.(*ast.CommitStmt); ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementDisallowCommit,+ Code: advisor.StatementDisallowCommit.Int32(),Title: checker.title,Content: fmt.Sprintf("Commit is not allowed, related statement: \"%s\"", in.Text()),- Line: in.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(in.LastLine()),+ },})}diff --git a/backend/plugin/advisor/pg/advisor_statement_disallow_mix_ddl_dml.go b/backend/plugin/advisor/pg/advisor_statement_disallow_mix_ddl_dml.goindex b4acd3dfc6..4e6a688f2c 100644--- a/backend/plugin/advisor/pg/advisor_statement_disallow_mix_ddl_dml.go+++ b/backend/plugin/advisor/pg/advisor_statement_disallow_mix_ddl_dml.go@@ -25,7 +25,7 @@ type StatementDisallowMixDdlDmlAdvisor struct {}// Check checks for disallow mix DDL and DML.-func (*StatementDisallowMixDdlDmlAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementDisallowMixDdlDmlAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -37,7 +37,7 @@ func (*StatementDisallowMixDdlDmlAdvisor) Check(ctx advisor.Context, _ string) (}title := string(ctx.Rule.Type)- var adviceList []advisor.Advice+ var adviceList []*storepb.Advicevar hasDDL, hasDML boolfor _, stmt := range stmtList {var isDDL, isDML bool@@ -50,22 +50,26 @@ func (*StatementDisallowMixDdlDmlAdvisor) Check(ctx advisor.Context, _ string) (switch ctx.ChangeType {case storepb.PlanCheckRunConfig_DDL, storepb.PlanCheckRunConfig_SDL, storepb.PlanCheckRunConfig_DDL_GHOST:if isDML {- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: level,Title: title,Content: fmt.Sprintf("Alter schema can only run DDL, \"%s\" is not DDL", stmt.Text()),- Code: advisor.StatementDisallowMixDDLDML,- Line: stmt.LastLine(),+ Code: advisor.StatementDisallowMixDDLDML.Int32(),+ StartPosition: &storepb.Position{+ Line: int32(stmt.LastLine()),+ },})}case storepb.PlanCheckRunConfig_DML:if isDDL {- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: level,Title: title,Content: fmt.Sprintf("Data change can only run DML, \"%s\" is not DML", stmt.Text()),- Code: advisor.StatementDisallowMixDDLDML,- Line: stmt.LastLine(),+ Code: advisor.StatementDisallowMixDDLDML.Int32(),+ StartPosition: &storepb.Position{+ Line: int32(stmt.LastLine()),+ },})}}@@ -81,18 +85,18 @@ func (*StatementDisallowMixDdlDmlAdvisor) Check(ctx advisor.Context, _ string) (}if hasDDL && hasDML {- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: level,Title: title,Content: "Mixing DDL with DML is not allowed",- Code: advisor.StatementDisallowMixDDLDML,+ Code: advisor.StatementDisallowMixDDLDML.Int32(),})}if len(adviceList) == 0 {- adviceList = append(adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ adviceList = append(adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/pg/advisor_statement_disallow_on_del_cascade.go b/backend/plugin/advisor/pg/advisor_statement_disallow_on_del_cascade.goindex 23f029037c..1bf3a6057b 100644--- a/backend/plugin/advisor/pg/advisor_statement_disallow_on_del_cascade.go+++ b/backend/plugin/advisor/pg/advisor_statement_disallow_on_del_cascade.go@@ -25,13 +25,13 @@ type StatementDisallowOnDelCascadeAdvisor struct {}// Check checks for DML dry run.-func (*StatementDisallowOnDelCascadeAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementDisallowOnDelCascadeAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmt := ctx.Statementsif stmt == "" {- return []advisor.Advice{+ return []*storepb.Advice{{- Status: advisor.Success,- Code: advisor.Ok,+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",},@@ -56,21 +56,23 @@ func (*StatementDisallowOnDelCascadeAdvisor) Check(ctx advisor.Context, _ stringcascadeLocations := cascadeNumRecursive(jsonData, 0, isOnDelCascade)cascadePositions := convertLocationsToPositions(stmt, cascadeLocations)- var adviceList []advisor.Advice+ var adviceList []*storepb.Advicefor _, p := range cascadePositions {- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: level,Title: string(ctx.Rule.Type),Content: "The CASCADE option is not permitted for ON DELETE clauses",- Code: advisor.StatementDisallowCascade,- Line: p.line + 1,- Column: p.column + 1,+ Code: advisor.StatementDisallowCascade.Int32(),+ StartPosition: &storepb.Position{+ Line: int32(p.line + 1),+ Column: int32(p.column + 1),+ },})}if len(adviceList) == 0 {- adviceList = append(adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ adviceList = append(adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/pg/advisor_statement_disallow_rm_tbl_cascade.go b/backend/plugin/advisor/pg/advisor_statement_disallow_rm_tbl_cascade.goindex e92949a674..e089f53125 100644--- a/backend/plugin/advisor/pg/advisor_statement_disallow_rm_tbl_cascade.go+++ b/backend/plugin/advisor/pg/advisor_statement_disallow_rm_tbl_cascade.go@@ -25,13 +25,13 @@ type StatementDisallowRemoveTblCascadeAdvisor struct {}// Check checks for DML dry run.-func (*StatementDisallowRemoveTblCascadeAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementDisallowRemoveTblCascadeAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmt := ctx.Statementsif stmt == "" {- return []advisor.Advice{+ return []*storepb.Advice{{- Status: advisor.Success,- Code: advisor.Ok,+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",},@@ -56,21 +56,23 @@ func (*StatementDisallowRemoveTblCascadeAdvisor) Check(ctx advisor.Context, _ stcascadeLocations := cascadeNumRecursive(jsonData, 0, isDropCascade)cascadePositions := convertLocationsToPositions(stmt, cascadeLocations)- var adviceList []advisor.Advice+ var adviceList []*storepb.Advicefor _, p := range cascadePositions {- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: level,Title: string(ctx.Rule.Type),Content: "The use of CASCADE is not permitted when removing a table",- Code: advisor.StatementDisallowCascade,- Line: p.line + 1,- Column: p.column + 1,+ Code: advisor.StatementDisallowCascade.Int32(),+ StartPosition: &storepb.Position{+ Line: int32(p.line + 1),+ Column: int32(p.column + 1),+ },})}if len(adviceList) == 0 {- adviceList = append(adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ adviceList = append(adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/pg/advisor_statement_dml_dry_run.go b/backend/plugin/advisor/pg/advisor_statement_dml_dry_run.goindex d7e558f81f..d8051de0fb 100644--- a/backend/plugin/advisor/pg/advisor_statement_dml_dry_run.go+++ b/backend/plugin/advisor/pg/advisor_statement_dml_dry_run.go@@ -28,7 +28,7 @@ type StatementDmlDryRunAdvisor struct {}// Check checks for DML dry run.-func (*StatementDmlDryRunAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementDmlDryRunAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -52,9 +52,9 @@ func (*StatementDmlDryRunAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -63,8 +63,8 @@ func (*StatementDmlDryRunAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}type statementDmlDryRunChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringdriver *sql.DBctx context.Context@@ -75,12 +75,14 @@ func (checker *statementDmlDryRunChecker) Visit(in ast.Node) ast.Visitor {switch node := in.(type) {case *ast.InsertStmt, *ast.UpdateStmt, *ast.DeleteStmt:if _, err := advisor.Query(checker.ctx, checker.driver, fmt.Sprintf("EXPLAIN %s", node.Text())); err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementDMLDryRunFailed,+ Code: advisor.StatementDMLDryRunFailed.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" dry runs failed: %s", node.Text(), err.Error()),- Line: node.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(node.LastLine()),+ },})}}diff --git a/backend/plugin/advisor/pg/advisor_statement_maximum_limit_value.go b/backend/plugin/advisor/pg/advisor_statement_maximum_limit_value.goindex baa7afbd29..4a8783c01b 100644--- a/backend/plugin/advisor/pg/advisor_statement_maximum_limit_value.go+++ b/backend/plugin/advisor/pg/advisor_statement_maximum_limit_value.go@@ -26,7 +26,7 @@ type StatementMaximumLimitValueAdvisor struct {}// Check checks for to add check not valid.-func (*StatementMaximumLimitValueAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementMaximumLimitValueAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -52,9 +52,9 @@ func (*StatementMaximumLimitValueAdvisor) Check(ctx advisor.Context, _ string) (}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -63,8 +63,8 @@ func (*StatementMaximumLimitValueAdvisor) Check(ctx advisor.Context, _ string) (}type statementMaximumLimitValueChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringline intlimitMaxValue int@@ -74,12 +74,14 @@ type statementMaximumLimitValueChecker struct {func (checker *statementMaximumLimitValueChecker) Visit(in ast.Node) ast.Visitor {if node, ok := in.(*ast.SelectStmt); ok {if node.Limit != nil && int(*node.Limit) > checker.limitMaxValue {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementExceedMaximumLimitValue,+ Code: advisor.StatementExceedMaximumLimitValue.Int32(),Title: checker.title,Content: fmt.Sprintf("The limit value %d exceeds the maximum allowed value %d", *node.Limit, checker.limitMaxValue),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}}diff --git a/backend/plugin/advisor/pg/advisor_statement_merge_alter_table.go b/backend/plugin/advisor/pg/advisor_statement_merge_alter_table.goindex 41906b968b..14aabc0cb5 100644--- a/backend/plugin/advisor/pg/advisor_statement_merge_alter_table.go+++ b/backend/plugin/advisor/pg/advisor_statement_merge_alter_table.go@@ -27,7 +27,7 @@ type StatementMergeAlterTableAdvisor struct {}// Check checks for no redundant ALTER TABLE statements.-func (*StatementMergeAlterTableAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementMergeAlterTableAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -50,7 +50,7 @@ func (*StatementMergeAlterTableAdvisor) Check(ctx advisor.Context, _ string) ([]return checker.generateAdvice(), nil}-func (checker *statementMergeAlterTableChecker) generateAdvice() []advisor.Advice {+func (checker *statementMergeAlterTableChecker) generateAdvice() []*storepb.Advice {var tableList []tableStatementfor _, table := range checker.tableMap {tableList = append(tableList, table)@@ -60,20 +60,22 @@ func (checker *statementMergeAlterTableChecker) generateAdvice() []advisor.Advic})for _, table := range tableList {if table.count > 1 {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementRedundantAlterTable,+ Code: advisor.StatementRedundantAlterTable.Int32(),Title: checker.title,Content: fmt.Sprintf("There are %d statements to modify table `%s`", table.count, table.name),- Line: table.line,+ StartPosition: &storepb.Position{+ Line: int32(table.line),+ },})}}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -82,8 +84,8 @@ func (checker *statementMergeAlterTableChecker) generateAdvice() []advisor.Advic}type statementMergeAlterTableChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtableMap tableMap}diff --git a/backend/plugin/advisor/pg/advisor_statement_non_transactional.go b/backend/plugin/advisor/pg/advisor_statement_non_transactional.goindex 60629587a6..60a523a782 100644--- a/backend/plugin/advisor/pg/advisor_statement_non_transactional.go+++ b/backend/plugin/advisor/pg/advisor_statement_non_transactional.go@@ -20,7 +20,7 @@ func init() {type NonTransactionalAdvisor struct {}-func (*NonTransactionalAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NonTransactionalAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmts, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -39,20 +39,22 @@ func (*NonTransactionalAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.checker.text = stmt.Text()checker.line = stmt.LastLine()if pg.IsNonTransactionStatement(checker.text) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementNonTransactional,+ Code: advisor.StatementNonTransactional.Int32(),Title: checker.title,Content: "This statement is non-transactional",- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -61,8 +63,8 @@ func (*NonTransactionalAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.}type NonTransactionalChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline intdiff --git a/backend/plugin/advisor/pg/advisor_statement_prior_backup_check.go b/backend/plugin/advisor/pg/advisor_statement_prior_backup_check.goindex b56e578485..68925dda7e 100644--- a/backend/plugin/advisor/pg/advisor_statement_prior_backup_check.go+++ b/backend/plugin/advisor/pg/advisor_statement_prior_backup_check.go@@ -28,12 +28,12 @@ type StatementPriorBackupCheckAdvisor struct {}// Check checks for disallow mix DDL and DML.-func (*StatementPriorBackupCheckAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {- var adviceList []advisor.Advice+func (*StatementPriorBackupCheckAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {+ var adviceList []*storepb.Adviceif ctx.PreUpdateBackupDetail == nil || ctx.ChangeType != storepb.PlanCheckRunConfig_DML {- adviceList = append(adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ adviceList = append(adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -56,30 +56,34 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx advisor.Context, _ string) ([isDDL = true}if isDDL {- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: level,Title: title,Content: fmt.Sprintf("Data change can only run DML, \"%s\" is not DML", stmt.Text()),- Code: advisor.StatementPriorBackupCheck,- Line: stmt.LastLine(),+ Code: advisor.StatementPriorBackupCheck.Int32(),+ StartPosition: &storepb.Position{+ Line: int32(stmt.LastLine()),+ },})}}if !databaseExists(ctx.Context, ctx.Driver, extractDatabaseName(ctx.PreUpdateBackupDetail.Database)) {- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: level,Title: title,Content: fmt.Sprintf("Need database %q to do prior backup but it does not exist", ctx.PreUpdateBackupDetail.Database),- Code: advisor.DatabaseNotExists,- Line: 0,+ Code: advisor.DatabaseNotExists.Int32(),+ StartPosition: &storepb.Position{+ Line: 0,+ },})}if len(adviceList) == 0 {- adviceList = append(adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ adviceList = append(adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/pg/advisor_stmt_no_leading_wildcard_like.go b/backend/plugin/advisor/pg/advisor_stmt_no_leading_wildcard_like.goindex 21c19bbc0f..09b582472a 100644--- a/backend/plugin/advisor/pg/advisor_stmt_no_leading_wildcard_like.go+++ b/backend/plugin/advisor/pg/advisor_stmt_no_leading_wildcard_like.go@@ -28,7 +28,7 @@ type NoLeadingWildcardLikeAdvisor struct {}// Check checks for no leading wildcard LIKE.-func (*NoLeadingWildcardLikeAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NoLeadingWildcardLikeAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmts, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -50,20 +50,22 @@ func (*NoLeadingWildcardLikeAdvisor) Check(ctx advisor.Context, _ string) ([]advast.Walk(checker, stmt)if checker.leadingWildcardLike {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementLeadingWildcardLike,+ Code: advisor.StatementLeadingWildcardLike.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" uses leading wildcard LIKE", checker.text),- Line: stmt.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(stmt.LastLine()),+ },})}}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -72,8 +74,8 @@ func (*NoLeadingWildcardLikeAdvisor) Check(ctx advisor.Context, _ string) ([]adv}type noLeadingWildcardLikeChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringleadingWildcardLike booldiff --git a/backend/plugin/advisor/pg/advisor_stmt_no_select_all.go b/backend/plugin/advisor/pg/advisor_stmt_no_select_all.goindex 653e8493d8..ad123c6b2e 100644--- a/backend/plugin/advisor/pg/advisor_stmt_no_select_all.go+++ b/backend/plugin/advisor/pg/advisor_stmt_no_select_all.go@@ -24,7 +24,7 @@ type NoSelectAllAdvisor struct {}// Check checks for no "select *".-func (*NoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmts, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -46,9 +46,9 @@ func (*NoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advic}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -57,8 +57,8 @@ func (*NoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advic}type noSelectAllChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -69,12 +69,14 @@ func (checker *noSelectAllChecker) Visit(node ast.Node) ast.Visitor {if n, ok := node.(*ast.SelectStmt); ok {for _, field := range n.FieldList {if column, ok := field.(*ast.ColumnNameDef); ok && column.ColumnName == "*" {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementSelectAll,+ Code: advisor.StatementSelectAll.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" uses SELECT all", checker.text),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})break}diff --git a/backend/plugin/advisor/pg/advisor_stmt_where_required.go b/backend/plugin/advisor/pg/advisor_stmt_where_required.goindex fda6d14d98..d7b0b13a20 100644--- a/backend/plugin/advisor/pg/advisor_stmt_where_required.go+++ b/backend/plugin/advisor/pg/advisor_stmt_where_required.go@@ -24,7 +24,7 @@ type WhereRequirementAdvisor struct {}// Check checks for the WHERE clause requirement.-func (*WhereRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*WhereRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmts, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -46,9 +46,9 @@ func (*WhereRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -57,8 +57,8 @@ func (*WhereRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.}type whereRequirementChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -87,12 +87,14 @@ func (checker *whereRequirementChecker) Visit(node ast.Node) ast.Visitor {}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" requires WHERE clause", checker.text),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}return checkerdiff --git a/backend/plugin/advisor/pg/advisor_table_disallow_partition.go b/backend/plugin/advisor/pg/advisor_table_disallow_partition.goindex 731e75be43..d1d7b0c52b 100644--- a/backend/plugin/advisor/pg/advisor_table_disallow_partition.go+++ b/backend/plugin/advisor/pg/advisor_table_disallow_partition.go@@ -26,7 +26,7 @@ type TableDisallowPartitionAdvisor struct {}// Check checks for disallow table partition.-func (*TableDisallowPartitionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableDisallowPartitionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -48,9 +48,9 @@ func (*TableDisallowPartitionAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -59,8 +59,8 @@ func (*TableDisallowPartitionAdvisor) Check(ctx advisor.Context, _ string) ([]ad}type tableDisallowPartitionChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -80,12 +80,14 @@ func (checker *tableDisallowPartitionChecker) Visit(in ast.Node) ast.Visitor {}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("Table partition is forbidden, but \"%s\" creates", checker.text),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}diff --git a/backend/plugin/advisor/pg/advisor_table_drop_naming_convention.go b/backend/plugin/advisor/pg/advisor_table_drop_naming_convention.goindex 97c984e97e..a6bbd617a5 100644--- a/backend/plugin/advisor/pg/advisor_table_drop_naming_convention.go+++ b/backend/plugin/advisor/pg/advisor_table_drop_naming_convention.go@@ -27,7 +27,7 @@ type TableDropNamingConventionAdvisor struct {}// Check checks for table drop with naming convention.-func (*TableDropNamingConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableDropNamingConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -53,9 +53,9 @@ func (*TableDropNamingConventionAdvisor) Check(ctx advisor.Context, _ string) ([}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -64,8 +64,8 @@ func (*TableDropNamingConventionAdvisor) Check(ctx advisor.Context, _ string) ([}type tableDropNamingConventionChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat *regexp.Regexp}@@ -75,12 +75,14 @@ func (checker *tableDropNamingConventionChecker) Visit(in ast.Node) ast.Visitorif node, ok := in.(*ast.DropTableStmt); ok {for _, table := range node.TableList {if !checker.format.MatchString(table.Name) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.TableDropNamingConventionMismatch,+ Code: advisor.TableDropNamingConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("`%s` mismatches drop table naming convention, naming format should be %q", table.Name, checker.format),- Line: node.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(node.LastLine()),+ },})}}diff --git a/backend/plugin/advisor/pg/advisor_table_no_fk.go b/backend/plugin/advisor/pg/advisor_table_no_fk.goindex c3d7a21f77..0a12853949 100644--- a/backend/plugin/advisor/pg/advisor_table_no_fk.go+++ b/backend/plugin/advisor/pg/advisor_table_no_fk.go@@ -24,7 +24,7 @@ type TableNoFKAdvisor struct {}// Check checks table disallow foreign key.-func (*TableNoFKAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableNoFKAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmts, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -46,9 +46,9 @@ func (*TableNoFKAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice,}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -57,8 +57,8 @@ func (*TableNoFKAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice,}type tableNoFKChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext string}@@ -86,16 +86,18 @@ func (checker *tableNoFKChecker) Visit(node ast.Node) ast.Visitor {}if tableHasFK != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.TableHasFK,+ Code: advisor.TableHasFK.Int32(),Title: checker.title,Content: fmt.Sprintf("Foreign key is not allowed in the table %q.%q, related statement: \"%s\"",normalizeSchemaName(tableHasFK.Schema),tableHasFK.Name,checker.text,),- Line: node.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(node.LastLine()),+ },})}diff --git a/backend/plugin/advisor/pg/advisor_table_require_pk.go b/backend/plugin/advisor/pg/advisor_table_require_pk.goindex 77c2fd9eeb..f3366318cd 100644--- a/backend/plugin/advisor/pg/advisor_table_require_pk.go+++ b/backend/plugin/advisor/pg/advisor_table_require_pk.go@@ -25,7 +25,7 @@ type TableRequirePKAdvisor struct {}// Check parses the given statement and checks for errors.-func (*TableRequirePKAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableRequirePKAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmts, ok := ctx.AST.([]ast.Node)if !ok {return nil, errors.Errorf("failed to convert to Node")@@ -48,9 +48,9 @@ func (*TableRequirePKAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -59,8 +59,8 @@ func (*TableRequirePKAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Ad}type tableRequirePKChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringcatalog *catalog.Findertext string@@ -110,16 +110,18 @@ func (checker *tableRequirePKChecker) Visit(node ast.Node) ast.Visitor {}if missingPK != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.TableNoPK,+ Code: advisor.TableNoPK.Int32(),Title: checker.title,Content: fmt.Sprintf("Table %q.%q requires PRIMARY KEY, related statement: %q",normalizeSchemaName(missingPK.Schema),missingPK.Name,checker.text,),- Line: node.LastLine(),+ StartPosition: &storepb.Position{+ Line: int32(node.LastLine()),+ },})}diff --git a/backend/plugin/advisor/pg/test/column_disallow_change_type.yaml b/backend/plugin/advisor/pg/test/column_disallow_change_type.yamlindex aa0c219357..048a57c2b5 100644--- a/backend/plugin/advisor/pg/test/column_disallow_change_type.yaml+++ b/backend/plugin/advisor/pg/test/column_disallow_change_type.yaml@@ -1,18 +1,18 @@- statement: ALTER TABLE tech_book ALTER COLUMN id SET DATA TYPE INTEGERwant:- - status: WARN+ - status: 2code: 403title: column.disallow-change-typecontent: The statement "ALTER TABLE tech_book ALTER COLUMN id SET DATA TYPE INTEGER" changes column type- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ADD COLUMN c1 intwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/pg/test/column_maximum_character_length.yaml b/backend/plugin/advisor/pg/test/column_maximum_character_length.yamlindex 75703aa81f..95cb21a46c 100644--- a/backend/plugin/advisor/pg/test/column_maximum_character_length.yaml+++ b/backend/plugin/advisor/pg/test/column_maximum_character_length.yaml@@ -1,45 +1,46 @@- statement: CREATE TABLE t(name char(20));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(name varchar(225));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(name char(225));want:- - status: WARN+ - status: 2code: 415title: column.maximum-character-lengthcontent: The length of the CHAR column "name" in table "t" is bigger than 20, please use VARCHAR instead- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE public.tech_book ADD COLUMN name_2 char(225)want:- - status: WARN+ - status: 2code: 415title: column.maximum-character-lengthcontent: The length of the CHAR column "name_2" in table "public"."tech_book" is bigger than 20, please use VARCHAR instead- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ALTER COLUMN name SET DATA TYPE char(225)want:- - status: WARN+ - status: 2code: 415title: column.maximum-character-lengthcontent: The length of the CHAR column "name" in table "tech_book" is bigger than 20, please use VARCHAR instead- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/pg/test/column_no_null.yaml b/backend/plugin/advisor/pg/test/column_no_null.yamlindex 631499db15..92e454bfdb 100644--- a/backend/plugin/advisor/pg/test/column_no_null.yaml+++ b/backend/plugin/advisor/pg/test/column_no_null.yaml@@ -4,101 +4,104 @@name varchar(255))want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column "id" in "public"."book" cannot have NULL value- line: 2- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 402title: column.no-nullcontent: Column "name" in "public"."book" cannot have NULL value- line: 3- column: 0- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: CREATE TABLE book(id int, name varchar(255), PRIMARY KEY (id))want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column "name" in "public"."book" cannot have NULL value- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255))want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column "name" in "public"."book" cannot have NULL value- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id int NOT NULL, name varchar(255))want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column "name" in "public"."book" cannot have NULL value- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255) NOT NULL)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book ADD COLUMN reader intwant:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column "reader" in "public"."tech_book" cannot have NULL value- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-ALTER TABLE tech_book DROP COLUMN id;ALTER TABLE tech_book DROP COLUMN name;ALTER TABLE tech_book ADD COLUMN id int PRIMARY KEY, ADD COLUMN name varchar(255) NOT NULL;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book ALTER COLUMN id SET NOT NULLwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book ALTER COLUMN name DROP NOT NULLwant:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column "name" in "public"."tech_book" cannot have NULL value- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: /* this is a comment */want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/pg/test/column_require_default.yaml b/backend/plugin/advisor/pg/test/column_require_default.yamlindex 4038d0a07e..bddb48fced 100644--- a/backend/plugin/advisor/pg/test/column_require_default.yaml+++ b/backend/plugin/advisor/pg/test/column_require_default.yaml@@ -1,40 +1,42 @@- statement: CREATE TABLE t(a serial primary key, b int default 1)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int,b int default 1)want:- - status: WARN+ - status: 2code: 420title: column.require-defaultcontent: Column "t"."a" in schema "public" doesn't have DEFAULT- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-ALTER TABLE tech_book ADD COLUMN a BLOB;ALTER TABLE tech_book ADD COLUMN b timestamp;want:- - status: WARN+ - status: 2code: 420title: column.require-defaultcontent: Column "tech_book"."a" in schema "public" doesn't have DEFAULT- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 420title: column.require-defaultcontent: Column "tech_book"."b" in schema "public" doesn't have DEFAULT- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/pg/test/column_required.yaml b/backend/plugin/advisor/pg/test/column_required.yamlindex e3bd7b25ae..da257bc107 100644--- a/backend/plugin/advisor/pg/test/column_required.yaml+++ b/backend/plugin/advisor/pg/test/column_required.yaml@@ -1,12 +1,13 @@- statement: CREATE TABLE book(id int)want:- - status: WARN+ - status: 2code: 401title: column.requiredcontent: 'Table "book" requires columns: created_ts, creator_id, updated_ts, updater_id'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE book(id int,@@ -15,32 +16,33 @@updater_id int,updated_ts timestamp)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-ALTER TABLE tech_book ADD COLUMN creator_id int;ALTER TABLE tech_book RENAME COLUMN creator_id TO creator;want:- - status: WARN+ - status: 2code: 401title: column.requiredcontent: 'Table "tech_book" requires columns: creator_id'- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-ALTER TABLE tech_book ADD COLUMN creator_id int;ALTER TABLE tech_book DROP COLUMN creator_id;want:- - status: WARN+ - status: 2code: 401title: column.requiredcontent: 'Table "tech_book" requires columns: creator_id'- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/pg/test/column_type_disallow_list.yaml b/backend/plugin/advisor/pg/test/column_type_disallow_list.yamlindex 276c6b9d3b..c98a508a80 100644--- a/backend/plugin/advisor/pg/test/column_type_disallow_list.yaml+++ b/backend/plugin/advisor/pg/test/column_type_disallow_list.yaml@@ -1,29 +1,30 @@- statement: CREATE TABLE t(a char(5));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a int, b JSON);want:- - status: WARN+ - status: 2code: 411title: column.type-disallow-listcontent: Disallow column type JSON but column "t"."b" is- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t(d char(5));ALTER TABLE t add COLUMN a JSON;want:- - status: WARN+ - status: 2code: 411title: column.type-disallow-listcontent: Disallow column type JSON but column "t"."a" is- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/pg/test/index_create_concurrently.yaml b/backend/plugin/advisor/pg/test/index_create_concurrently.yamlindex a3aef4aaf1..985528bc5b 100644--- a/backend/plugin/advisor/pg/test/index_create_concurrently.yaml+++ b/backend/plugin/advisor/pg/test/index_create_concurrently.yaml@@ -1,18 +1,18 @@- statement: create index on tech_book(id);want:- - status: WARN+ - status: 2code: 814title: index.create-concurrentlycontent: Creating indexes will block writes on the table, unless use CONCURRENTLY- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: create index concurrently on tech_book(id);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/pg/test/index_key_number_limit.yaml b/backend/plugin/advisor/pg/test/index_key_number_limit.yamlindex e724baa8e5..8f4ca9b911 100644--- a/backend/plugin/advisor/pg/test/index_key_number_limit.yaml+++ b/backend/plugin/advisor/pg/test/index_key_number_limit.yaml@@ -1,78 +1,80 @@- statement: CREATE TABLE t(name char(20));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(name varchar(225));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(name char(225), PRIMARY KEY (name));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(id int, name char(225), c1 int, c2 int, c3 int, c4 int, CONSTRAINT t_id_name PRIMARY KEY (id, name, c1, c2, c3, c4));want:- - status: WARN+ - status: 2code: 802title: index.key-number-limitcontent: The number of keys of index "t_id_name" in table "t" should be not greater than 5- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(id int, name char(225), c1 int, c2 int, c3 int, c4 int, CONSTRAINT t_id_name UNIQUE (id, name, c1, c2, c3, c4));want:- - status: WARN+ - status: 2code: 802title: index.key-number-limitcontent: The number of keys of index "t_id_name" in table "t" should be not greater than 5- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE address(id int, phone varchar(225), c1 int, c2 int, c3 int, c4 int);CREATE INDEX idx_address_phone ON address(id, phone, c1, c2, c3, c4);want:- - status: WARN+ - status: 2code: 802title: index.key-number-limitcontent: The number of keys of index "idx_address_phone" in table "address" should be not greater than 5- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE address(id int, phone varchar(225), c1 int, c2 int, c3 int, c4 int);CREATE UNIQUE INDEX idx_address_phone ON address(id, phone, c2, c1, c3, c4);want:- - status: WARN+ - status: 2code: 802title: index.key-number-limitcontent: The number of keys of index "idx_address_phone" in table "address" should be not greater than 5- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE address(id int, phone varchar(225), c1 int, c2 int, c3 int, c4 int);ALTER TABLE address ADD CONSTRAINT address_id_name UNIQUE (id, phone, c1, c2, c3, c4);want:- - status: WARN+ - status: 2code: 802title: index.key-number-limitcontent: The number of keys of index "address_id_name" in table "address" should be not greater than 5- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/pg/test/index_no_duplicate_column.yaml b/backend/plugin/advisor/pg/test/index_no_duplicate_column.yamlindex 1ca3a3dac9..88a0179717 100644--- a/backend/plugin/advisor/pg/test/index_no_duplicate_column.yaml+++ b/backend/plugin/advisor/pg/test/index_no_duplicate_column.yaml@@ -1,65 +1,69 @@- statement: CREATE TABLE t (a INT, PRIMARY KEY (a));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t (a int,PRIMARY KEY (a, a));want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: PRIMARY KEY "" has duplicate column "t"."a"- line: 3- column: 0- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-CREATE TABLE t(a int);CREATE INDEX idx_a on t(a, a);want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: INDEX "idx_a" has duplicate column "t"."a"- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD CONSTRAINT uk_a UNIQUE (a, a);want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: UNIQUE KEY "uk_a" has duplicate column "t"."a"- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD CONSTRAINT pk_a PRIMARY KEY (a, a);want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: PRIMARY KEY "pk_a" has duplicate column "t"."a"- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD CONSTRAINT fk_a FOREIGN KEY (a, a) REFERENCES t1(a, b);want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: FOREIGN KEY "fk_a" has duplicate column "t"."a"- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/pg/test/index_primary_key_type_allowlist.yaml b/backend/plugin/advisor/pg/test/index_primary_key_type_allowlist.yamlindex 28949541da..305e750fd7 100644--- a/backend/plugin/advisor/pg/test/index_primary_key_type_allowlist.yaml+++ b/backend/plugin/advisor/pg/test/index_primary_key_type_allowlist.yaml@@ -1,43 +1,43 @@- statement: CREATE TABLE t(a SERIAL PRIMARY KEY);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a BIGSERIAL, PRIMARY KEY(a));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a varchar(20) PRIMARY KEY);want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column "a" is one of the primary key, but its type "character varying(20)" is not in allowlist- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a varchar(20),PRIMARY KEY(a));want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column "a" is one of the primary key, but its type "character varying(20)" is not in allowlist- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/pg/test/index_total_number_limit.yaml b/backend/plugin/advisor/pg/test/index_total_number_limit.yamlindex 32d6497f3d..ff98430ffe 100644--- a/backend/plugin/advisor/pg/test/index_total_number_limit.yaml+++ b/backend/plugin/advisor/pg/test/index_total_number_limit.yaml@@ -1,21 +1,19 @@- statement: CREATE TABLE t(a int, b int, c int, unique (a, b, c))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE INDEX idx_id_name on tech_book(id, name)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE INDEX idx_id_name_1 on tech_book(id, name);CREATE INDEX idx_id_name_2 on tech_book(id, name);@@ -23,13 +21,14 @@CREATE INDEX idx_id_name_4 on tech_book(id, name);CREATE INDEX idx_id_name_5 on tech_book(id, name);want:- - status: WARN+ - status: 2code: 813title: index.total-number-limitcontent: The count of index in table "public"."tech_book" should be no more than 5, but found 8- line: 5- column: 0- details: ""+ detail: ""+ startposition:+ line: 5+ column: 0- statement: |-CREATE TABLE t(a int PRIMARY KEY, b int, c int);CREATE INDEX idx_a_b_1 on t(a, b);@@ -38,13 +37,14 @@CREATE INDEX idx_a_b_4 on t(a, b);CREATE INDEX idx_a_b_5 on t(a, b);want:- - status: WARN+ - status: 2code: 813title: index.total-number-limitcontent: The count of index in table "public"."t" should be no more than 5, but found 6- line: 6- column: 0- details: ""+ detail: ""+ startposition:+ line: 6+ column: 0- statement: |-CREATE TABLE t(a int PRIMARY KEY,@@ -56,10 +56,11 @@CONSTRAINT idx_a_b_4 UNIQUE (a, b),CONSTRAINT idx_a_b_5 UNIQUE (a, b));want:- - status: WARN+ - status: 2code: 813title: index.total-number-limitcontent: The count of index in table "public"."t" should be no more than 5, but found 6- line: 9- column: 0- details: ""+ detail: ""+ startposition:+ line: 9+ column: 0diff --git a/backend/plugin/advisor/pg/test/naming_column.yaml b/backend/plugin/advisor/pg/test/naming_column.yamlindex 5df9efe826..d4c3a2e21c 100644--- a/backend/plugin/advisor/pg/test/naming_column.yaml+++ b/backend/plugin/advisor/pg/test/naming_column.yaml@@ -1,80 +1,78 @@- statement: CREATE TABLE book(id int, "creatorId" int)want:- - status: WARN+ - status: 2code: 302title: naming.columncontent: '"book"."creatorId" mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id int, qavszgslczmsacubtvyymzhojfytkcmon int)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE book(id int, creator_Id int)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE book(id int, creator_id int)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int, creator_id int);ALTER TABLE book ADD COLUMN "creatorId" intwant:- - status: WARN+ - status: 2code: 302title: naming.columncontent: '"book"."creatorId" mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE book(id int, creator_id int);ALTER TABLE book ADD COLUMN "creator" intwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int, creator_id int);ALTER TABLE book RENAME COLUMN creator_id TO "creatorId"want:- - status: WARN+ - status: 2code: 302title: naming.columncontent: '"book"."creatorId" mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE book(id int, creator_id int);ALTER TABLE book RENAME COLUMN creator_id TO "creator"want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/pg/test/naming_fully_qualified.yaml b/backend/plugin/advisor/pg/test/naming_fully_qualified.yamlindex deeb60a5e9..457b3b0e88 100644--- a/backend/plugin/advisor/pg/test/naming_fully_qualified.yaml+++ b/backend/plugin/advisor/pg/test/naming_fully_qualified.yaml@@ -4,23 +4,27 @@CREATE TABLE public.pokes (foo int);CREATE TABLE pokesv2 (foo int, bar varchar);want:- - status: WARN+ - status: 2code: 310title: naming.fully-qualified- content: "unqualified object name: 'pokesv2'"- line: 4-+ content: 'unqualified object name: ''pokesv2'''+ detail: ""+ startposition:+ line: 4+ column: 0- statement: |-CREATE SEQUENCE public.seq;CREATE SEQUENCE seq;DROP SEQUENCE public.seqwant:- - status: WARN+ - status: 2code: 310title: naming.fully-qualified- content: "unqualified object name: 'seq'"- line: 2-+ content: 'unqualified object name: ''seq'''+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TRIGGER test_triggerAFTER INSERT ON pokesv1@@ -28,39 +32,47 @@EXECUTE PROCEDURE trigger_function();INSERT INTO bbdev.public.pokesv1 VALUES (1, '1');want:- - status: WARN+ - status: 2code: 310title: naming.fully-qualified- content: "unqualified object name: 'pokesv1'"- line: 4-+ content: 'unqualified object name: ''pokesv1'''+ detail: ""+ startposition:+ line: 4+ column: 0- statement: DROP TRIGGER test_trigger ON public.pokes;want:- - status: SUCCESS+ - status: 1code: 0- title: "OK"-+ title: OK+ content: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE public.pokesv1 (foo int, bar varchar);ALTER TABLE pokesv1 RENAME TO pokesv2;want:- - status: WARN+ - status: 2code: 310title: naming.fully-qualified- content: "unqualified object name: 'pokesv1'"- line: 2-+ content: 'unqualified object name: ''pokesv1'''+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE public.pokesv1 (foo int);INSERT INTO pokesv1(foo) VALUES (1);INSERT INTO public.pokesv1 VALUES (2);want:- - status: WARN+ - status: 2code: 310title: naming.fully-qualified- content: "unqualified object name: 'pokesv1'"- line: 2-+ content: 'unqualified object name: ''pokesv1'''+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE public.pokesv1 (foo int);UPDATE public.pokesv1 SET foo = 1 WHERE 1=1;@@ -68,27 +80,29 @@UPDATE pokesv1 SET foo = 1 WHERE 1=1;UPDATE public.pokesv1 SET foo = 1 WHERE 1 > 1;want:- - status: WARN+ - status: 2code: 310title: naming.fully-qualified- content: "unqualified object name: 'pokesv1'"- line: 4--- statement: |-- CREATE TABLE public.pokes (foo int);- SELECT * FROM (SELECT (id) FROM tech_book) AS foo;+ content: 'unqualified object name: ''pokesv1'''+ detail: ""+ startposition:+ line: 4+ column: 0+- statement: "CREATE TABLE public.pokes (foo int); \nSELECT * FROM (SELECT (id) FROM tech_book) AS foo;"want:- - status: WARN+ - status: 2code: 310title: naming.fully-qualified- content: "unqualified object name: 'tech_book'"- line: 2--- statement: |-- CREATE TABLE public.pokes (foo int);- WITH foo1 AS (SELECT * FROM public.tech_book)- SELECT * FROM foo1;+ content: 'unqualified object name: ''tech_book'''+ detail: ""+ startposition:+ line: 2+ column: 0+- statement: "CREATE TABLE public.pokes (foo int);\nWITH foo1 AS (SELECT * FROM public.tech_book) \nSELECT * FROM foo1;"want:- - status: SUCCESS+ - status: 1code: 0title: OK+ content: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/pg/test/naming_index_fk.yaml b/backend/plugin/advisor/pg/test/naming_index_fk.yamlindex eeaa164bac..befb2d9b69 100644--- a/backend/plugin/advisor/pg/test/naming_index_fk.yaml+++ b/backend/plugin/advisor/pg/test/naming_index_fk.yaml@@ -1,75 +1,75 @@- statement: ALTER TABLE tech_book ADD CONSTRAINT fk_tech_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book ADD CONSTRAINT fk_author_id FOREIGN KEY (author_id) REFERENCES author (id)want:- - status: WARN+ - status: 2code: 305title: naming.index.fkcontent: Foreign key in table "tech_book" mismatches the naming convention, expect "^$|^fk_tech_book_author_id_author_id$" but found "fk_author_id"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ADD CONSTRAINT wlwflloczhmazamdotbibvqrrzyhmvkslvyzpmlmxt FOREIGN KEY (author_id) REFERENCES author (id)want:- - status: WARN+ - status: 2code: 305title: naming.index.fkcontent: Foreign key in table "tech_book" mismatches the naming convention, expect "^$|^fk_tech_book_author_id_author_id$" but found "wlwflloczhmazamdotbibvqrrzyhmvkslvyzpmlmxt"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ADD COLUMN author_id INT CONSTRAINT fk_tech_book_author_id_author_id REFERENCES author (id)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book ADD COLUMN author_id INT CONSTRAINT fk_author_id REFERENCES author (id)want:- - status: WARN+ - status: 2code: 305title: naming.index.fkcontent: Foreign key in table "tech_book" mismatches the naming convention, expect "^$|^fk_tech_book_author_id_author_id$" but found "fk_author_id"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id INT, author_id INT, CONSTRAINT fk_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE book(id INT, author_id INT, CONSTRAINT fk_book_author_id FOREIGN KEY (author_id) REFERENCES author (id))want:- - status: WARN+ - status: 2code: 305title: naming.index.fkcontent: Foreign key in table "book" mismatches the naming convention, expect "^$|^fk_book_author_id_author_id$" but found "fk_book_author_id"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id INT, author_id INT CONSTRAINT fk_book_author_id_author_id REFERENCES author (id))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |--- this is the first line.CREATE TABLE book(@@ -77,10 +77,11 @@author_id INT CONSTRAINT fk_book_author_id REFERENCES author (id))want:- - status: WARN+ - status: 2code: 305title: naming.index.fkcontent: Foreign key in table "book" mismatches the naming convention, expect "^$|^fk_book_author_id_author_id$" but found "fk_book_author_id"- line: 4- column: 0- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0diff --git a/backend/plugin/advisor/pg/test/naming_index_idx.yaml b/backend/plugin/advisor/pg/test/naming_index_idx.yamlindex 2f48cd1cb0..3faa419a44 100644--- a/backend/plugin/advisor/pg/test/naming_index_idx.yaml+++ b/backend/plugin/advisor/pg/test/naming_index_idx.yaml@@ -1,45 +1,46 @@- statement: CREATE INDEX idx_tech_book_id_name ON tech_book(id, name)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE INDEX tech_book_id_name ON tech_book(id, name)want:- - status: WARN+ - status: 2code: 303title: naming.index.idxcontent: Index in table "tech_book" mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found "tech_book_id_name"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE INDEX wfdtqyetsyoovcvikjlyfukxyjxxxhifl ON tech_book(id, name)want:- - status: WARN+ - status: 2code: 303title: naming.index.idxcontent: Index in table "tech_book" mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found "wfdtqyetsyoovcvikjlyfukxyjxxxhifl"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER INDEX old_index RENAME TO idx_tech_book_id_namewant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER INDEX old_index RENAME TO idx_tech_bookwant:- - status: WARN+ - status: 2code: 303title: naming.index.idxcontent: Index in table "tech_book" mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found "idx_tech_book"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/pg/test/naming_index_pk.yaml b/backend/plugin/advisor/pg/test/naming_index_pk.yamlindex f5b2a56531..8adaed08d4 100644--- a/backend/plugin/advisor/pg/test/naming_index_pk.yaml+++ b/backend/plugin/advisor/pg/test/naming_index_pk.yaml@@ -1,39 +1,39 @@- statement: ALTER TABLE tech_book ADD CONSTRAINT pk_tech_book_id_name PRIMARY KEY (id, name)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book ADD CONSTRAINT tech_book_id_name PRIMARY KEY (id, name)want:- - status: WARN+ - status: 2code: 306title: naming.index.pkcontent: Primary key in table "tech_book" mismatches the naming convention, expect "^$|^pk_tech_book_id_name$" but found "tech_book_id_name"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ADD CONSTRAINT udmhjtnsaablcmjhqcznfiwtnevcehcvw PRIMARY KEY (id, name)want:- - status: WARN+ - status: 2code: 306title: naming.index.pkcontent: Primary key in table "tech_book" mismatches the naming convention, expect "^$|^pk_tech_book_id_name$" but found "udmhjtnsaablcmjhqcznfiwtnevcehcvw"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id INT, name VARCHAR(20), CONSTRAINT pk_book_name PRIMARY KEY (name))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |--- this is the first line.CREATE TABLE book(@@ -42,82 +42,81 @@CONSTRAINT tech_book_name PRIMARY KEY (name))want:- - status: WARN+ - status: 2code: 306title: naming.index.pkcontent: Primary key in table "book" mismatches the naming convention, expect "^$|^pk_book_name$" but found "tech_book_name"- line: 5- column: 0- details: ""+ detail: ""+ startposition:+ line: 5+ column: 0- statement: CREATE TABLE book(id INT, name VARCHAR(20), PRIMARY KEY (name))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE book(id INT, name VARCHAR(20) PRIMARY KEY)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book ADD CONSTRAINT pk_tech_book_id_name PRIMARY KEY USING INDEX old_indexwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book ADD CONSTRAINT pk_tech_book PRIMARY KEY USING INDEX old_indexwant:- - status: WARN+ - status: 2code: 306title: naming.index.pkcontent: Primary key in table "tech_book" mismatches the naming convention, expect "^$|^pk_tech_book_id_name$" but found "pk_tech_book"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book RENAME CONSTRAINT old_pk TO pk_tech_book_id_namewant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book RENAME CONSTRAINT old_pk TO pk_tech_bookwant:- - status: WARN+ - status: 2code: 306title: naming.index.pkcontent: Primary key in table "tech_book" mismatches the naming convention, expect "^$|^pk_tech_book_id_name$" but found "pk_tech_book"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER INDEX old_pk RENAME TO pk_tech_book_id_namewant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER INDEX old_pk RENAME TO pk_tech_bookwant:- - status: WARN+ - status: 2code: 306title: naming.index.pkcontent: Primary key in table "tech_book" mismatches the naming convention, expect "^$|^pk_tech_book_id_name$" but found "pk_tech_book"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/pg/test/naming_index_uk.yaml b/backend/plugin/advisor/pg/test/naming_index_uk.yamlindex e36729bbf8..692edf7439 100644--- a/backend/plugin/advisor/pg/test/naming_index_uk.yaml+++ b/backend/plugin/advisor/pg/test/naming_index_uk.yaml@@ -1,57 +1,57 @@- statement: CREATE UNIQUE INDEX uk_tech_book_id_name ON tech_book(id, name)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE UNIQUE INDEX tech_book_id_name ON tech_book(id, name)want:- - status: WARN+ - status: 2code: 304title: naming.index.ukcontent: Unique key in table "tech_book" mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found "tech_book_id_name"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE UNIQUE INDEX dzfzqbhnkiiegdhvqjeqoevesfuwcmokrehxlapoqj ON tech_book(id, name)want:- - status: WARN+ - status: 2code: 304title: naming.index.ukcontent: Unique key in table "tech_book" mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found "dzfzqbhnkiiegdhvqjeqoevesfuwcmokrehxlapoqj"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ADD CONSTRAINT uk_tech_book_id_name UNIQUE (id, name)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book ADD CONSTRAINT tech_book_id_name UNIQUE (id, name)want:- - status: WARN+ - status: 2code: 304title: naming.index.ukcontent: Unique key in table "tech_book" mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found "tech_book_id_name"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id INT PRIMARY KEY, name VARCHAR(20), CONSTRAINT uk_book_name UNIQUE (name))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |--- this is the first line.CREATE TABLE book(@@ -60,82 +60,81 @@CONSTRAINT book_name UNIQUE (name))want:- - status: WARN+ - status: 2code: 304title: naming.index.ukcontent: Unique key in table "book" mismatches the naming convention, expect "^$|^uk_book_name$" but found "book_name"- line: 5- column: 0- details: ""+ detail: ""+ startposition:+ line: 5+ column: 0- statement: CREATE TABLE book(id INT PRIMARY KEY, name VARCHAR(20), UNIQUE (name))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE book(id INT PRIMARY KEY, name VARCHAR(20) UNIQUE)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book ADD CONSTRAINT uk_tech_book_id_name UNIQUE USING INDEX old_indexwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book ADD CONSTRAINT uk_tech_book UNIQUE USING INDEX old_indexwant:- - status: WARN+ - status: 2code: 304title: naming.index.ukcontent: Unique key in table "tech_book" mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found "uk_tech_book"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book RENAME CONSTRAINT old_uk TO uk_tech_book_id_namewant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book RENAME CONSTRAINT old_uk TO uk_tech_bookwant:- - status: WARN+ - status: 2code: 304title: naming.index.ukcontent: Unique key in table "tech_book" mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found "uk_tech_book"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER INDEX old_uk RENAME TO uk_tech_book_id_namewant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER INDEX old_uk RENAME TO uk_tech_bookwant:- - status: WARN+ - status: 2code: 304title: naming.index.ukcontent: Unique key in table "tech_book" mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found "uk_tech_book"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/pg/test/naming_table.yaml b/backend/plugin/advisor/pg/test/naming_table.yamlindex 0a91d56648..679cf26e2a 100644--- a/backend/plugin/advisor/pg/test/naming_table.yaml+++ b/backend/plugin/advisor/pg/test/naming_table.yaml@@ -1,83 +1,84 @@- statement: CREATE TABLE "techBook"(id int, name varchar(255))want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '"techBook" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE "rlcmidzlevbivwvcntihenpoibtiutqeb"(id int, name varchar(255))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE _techBook(id int, name varchar(255))want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '"_techbook" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE techBook(id int, name varchar(255))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE book(id int, name varchar(255))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book RENAME TO "TechBook"want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '"TechBook" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-create table techBook(id int);ALTER TABLE techBook RENAME TO tech_book_tmp;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE _techBook(id int, name varchar(255));ALTER TABLE tech_book RENAME TO "TechBook";want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '"_techbook" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 301title: naming.tablecontent: '"TechBook" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/pg/test/schema_backward_compatibility.yaml b/backend/plugin/advisor/pg/test/schema_backward_compatibility.yamlindex 369d9594ab..b78dd4e62f 100644--- a/backend/plugin/advisor/pg/test/schema_backward_compatibility.yaml+++ b/backend/plugin/advisor/pg/test/schema_backward_compatibility.yaml@@ -1,9 +1,10 @@- statement: ALTER TABLE tech_book ALTER COLUMN name TYPE TEXTwant:- - status: WARN+ - status: 2code: 111title: schema.backward-compatibilitycontent: '"ALTER TABLE tech_book ALTER COLUMN name TYPE TEXT" may cause incompatibility with the existing data and code'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/pg/test/statement_add_check_not_valid.yaml b/backend/plugin/advisor/pg/test/statement_add_check_not_valid.yamlindex 393d534b24..c9956aad60 100644--- a/backend/plugin/advisor/pg/test/statement_add_check_not_valid.yaml+++ b/backend/plugin/advisor/pg/test/statement_add_check_not_valid.yaml@@ -1,18 +1,18 @@- statement: alter table tech_book add constraint check_id check(id > 0);want:- - status: WARN+ - status: 2code: 211title: statement.add-check-not-validcontent: Adding check constraints with validation will block reads and writes. You can add check constraints not valid and then validate separately- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: alter table tech_book add constraint check_id check(id > 0) NOT VALID;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/pg/test/statement_add_foreign_key_not_valid.yaml b/backend/plugin/advisor/pg/test/statement_add_foreign_key_not_valid.yamlindex ce7f611e8f..2432f7f153 100644--- a/backend/plugin/advisor/pg/test/statement_add_foreign_key_not_valid.yaml+++ b/backend/plugin/advisor/pg/test/statement_add_foreign_key_not_valid.yaml@@ -12,13 +12,14 @@);ALTER TABLE task_run ADD CONSTRAINT task_run_task_id_fk_task_id FOREIGN KEY (task_id) REFERENCES task (id);want:- - status: WARN+ - status: 2code: 229title: statement.add-foreign-key-not-validcontent: Adding foreign keys with validation will block reads and writes. You can add check foreign keys not valid and then validate separately- line: 12- column: 0- details: ""+ detail: ""+ startposition:+ line: 12+ column: 0- statement: |-CREATE TABLE task (id SERIAL PRIMARY KEY,@@ -33,10 +34,9 @@);ALTER TABLE task_run ADD CONSTRAINT task_run_task_id_fk_task_id FOREIGN KEY (task_id) REFERENCES task (id) NOT VALID;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/pg/test/statement_affected_row_limit.yaml b/backend/plugin/advisor/pg/test/statement_affected_row_limit.yamlindex 71cbed1869..4c53b25ff2 100644--- a/backend/plugin/advisor/pg/test/statement_affected_row_limit.yaml+++ b/backend/plugin/advisor/pg/test/statement_affected_row_limit.yaml@@ -1,18 +1,16 @@- statement: DELETE FROM tech_book WHERE a > 1want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: UPDATE tech_book SET id = 1want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/pg/test/statement_check_set_role_variable.yaml b/backend/plugin/advisor/pg/test/statement_check_set_role_variable.yamlindex ca8c955f8e..2ffc4c4619 100644--- a/backend/plugin/advisor/pg/test/statement_check_set_role_variable.yaml+++ b/backend/plugin/advisor/pg/test/statement_check_set_role_variable.yaml@@ -1,18 +1,18 @@- statement: SET SESSION ROLE joe; SELECT * FROM twant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: SELECT * FROM twant:- - status: WARN+ - status: 2code: 217title: statement.check-set-role-variablecontent: No SET ROLE statement found.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/pg/test/statement_create_specify_schema.yaml b/backend/plugin/advisor/pg/test/statement_create_specify_schema.yamlindex 9e4026c8f2..6f3e340aab 100644--- a/backend/plugin/advisor/pg/test/statement_create_specify_schema.yaml+++ b/backend/plugin/advisor/pg/test/statement_create_specify_schema.yaml@@ -1,18 +1,18 @@- statement: CREATE TABLE t(id int);want:- - status: WARN+ - status: 2code: 216title: statement.create-specify-schemacontent: Table schema should be specified.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE public.t(id int);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/pg/test/statement_disallow_add_column_with_default.yaml b/backend/plugin/advisor/pg/test/statement_disallow_add_column_with_default.yamlindex d40cd46275..d4c8b5a070 100644--- a/backend/plugin/advisor/pg/test/statement_disallow_add_column_with_default.yaml+++ b/backend/plugin/advisor/pg/test/statement_disallow_add_column_with_default.yaml@@ -1,18 +1,18 @@- statement: ALTER TABLE tech_book ADD COLUMN c int;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book ADD COLUMN c int DEFAULT 0;want:- - status: WARN+ - status: 2code: 210title: statement.disallow-add-column-with-defaultcontent: Adding column with DEFAULT will locked the whole table and rewriting each rows- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/pg/test/statement_disallow_add_not_null.yaml b/backend/plugin/advisor/pg/test/statement_disallow_add_not_null.yamlindex 0b694be3b9..747259a2dc 100644--- a/backend/plugin/advisor/pg/test/statement_disallow_add_not_null.yaml+++ b/backend/plugin/advisor/pg/test/statement_disallow_add_not_null.yaml@@ -1,20 +1,20 @@- statement: alter table tech_book alter column name set not null;want:- - status: WARN+ - status: 2code: 212title: statement.disallow-add-not-nullcontent: Setting NOT NULL will block reads and writes. You can use CHECK ("name" IS NOT NULL) instead- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-alter table tech_book add constraint check_name_not_null check(name IS NOT NULL) NOT VALID;alter table tech_book validate constraint check_name_not_null;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/pg/test/statement_disallow_commit.yaml b/backend/plugin/advisor/pg/test/statement_disallow_commit.yamlindex 80ea802b96..00970f21b7 100644--- a/backend/plugin/advisor/pg/test/statement_disallow_commit.yaml+++ b/backend/plugin/advisor/pg/test/statement_disallow_commit.yaml@@ -3,13 +3,14 @@CREATE TABLE techBook(id int, name varchar(255));COMMIT;want:- - status: WARN+ - status: 2code: 206title: statement.disallow-commitcontent: 'Commit is not allowed, related statement: "COMMIT;"'- line: 3- column: 0- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-START TRANSACTION;CREATE TABLE techBook(id int, name varchar(255));@@ -19,17 +20,19 @@INSERT INTO techBook(id, name) VALUES(1, "book");COMMIT;want:- - status: WARN+ - status: 2code: 206title: statement.disallow-commitcontent: 'Commit is not allowed, related statement: "COMMIT;"'- line: 3- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 206title: statement.disallow-commitcontent: 'Commit is not allowed, related statement: "COMMIT;"'- line: 7- column: 0- details: ""+ detail: ""+ startposition:+ line: 7+ column: 0diff --git a/backend/plugin/advisor/pg/test/statement_disallow_mix_ddl_dml.yaml b/backend/plugin/advisor/pg/test/statement_disallow_mix_ddl_dml.yamlindex 0ddb8406dc..80436b6637 100644--- a/backend/plugin/advisor/pg/test/statement_disallow_mix_ddl_dml.yaml+++ b/backend/plugin/advisor/pg/test/statement_disallow_mix_ddl_dml.yaml@@ -1,6 +1,6 @@- statement: DELETE FROM tech_book WHERE a > 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""@@ -9,7 +9,7 @@details: ""- statement: UPDATE tech_book SET id = 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""@@ -18,7 +18,7 @@details: ""- statement: ALTER TABLE tech_book ADD COLUMN author TEXT; UPDATE tech_book SET id = 1;DELETE FROM tech_book WHERE a > 1;want:- - status: WARN+ - status: 2code: 228title: statement.disallow-mix-ddl-dmlcontent: Mixing DDL with DML is not alloweddiff --git a/backend/plugin/advisor/pg/test/statement_disallow_on_del_cascade.yaml b/backend/plugin/advisor/pg/test/statement_disallow_on_del_cascade.yamlindex 64a2f9cc88..b6d22a3d5e 100644--- a/backend/plugin/advisor/pg/test/statement_disallow_on_del_cascade.yaml+++ b/backend/plugin/advisor/pg/test/statement_disallow_on_del_cascade.yaml@@ -1,12 +1,11 @@- statement: TRUNCATE TABLE issues CASCADE;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE users (tenant_id integer REFERENCES tenants ON DELETE CASCADE,@@ -14,13 +13,14 @@PRIMARY KEY (tenant_id, user_id));want:- - status: WARN+ - status: 2code: 213title: statement.disallow-on-del-cascadecontent: The CASCADE option is not permitted for ON DELETE clauses- line: 1- column: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 1- statement: |-CREATE TABLE users (tenant_id integer,@@ -29,13 +29,12 @@);COMMENT ON TABLE users IS 'CASCADE COMMENT';want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-TRUNCATE TABLE tech_book CASCADE;DROP TABLE tech_book CASCADE;@@ -45,10 +44,11 @@PRIMARY KEY (tenant_id, user_id));want:- - status: WARN+ - status: 2code: 213title: statement.disallow-on-del-cascadecontent: The CASCADE option is not permitted for ON DELETE clauses- line: 3- column: 1- details: ""\ No newline at end of file+ detail: ""+ startposition:+ line: 3+ column: 1diff --git a/backend/plugin/advisor/pg/test/statement_disallow_rm_tbl_cascade.yaml b/backend/plugin/advisor/pg/test/statement_disallow_rm_tbl_cascade.yamlindex 194536a1a1..29cf40d44a 100644--- a/backend/plugin/advisor/pg/test/statement_disallow_rm_tbl_cascade.yaml+++ b/backend/plugin/advisor/pg/test/statement_disallow_rm_tbl_cascade.yaml@@ -1,12 +1,13 @@- statement: TRUNCATE TABLE issues CASCADE;want:- - status: WARN+ - status: 2code: 213title: statement.disallow-rm-tbl-cascadecontent: The use of CASCADE is not permitted when removing a table- line: 1- column: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 1- statement: |-CREATE TABLE users (tenant_id integer REFERENCES tenants ON DELETE CASCADE,@@ -14,13 +15,12 @@PRIMARY KEY (tenant_id, user_id));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE users (tenant_id integer,@@ -29,13 +29,12 @@);COMMENT ON TABLE users IS 'CASCADE COMMENT';want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-TRUNCATE TABLE tech_book CASCADE;DROP TABLE tech_book CASCADE;@@ -45,17 +44,19 @@PRIMARY KEY (tenant_id, user_id));want:- - status: WARN+ - status: 2code: 213title: statement.disallow-rm-tbl-cascadecontent: The use of CASCADE is not permitted when removing a table- line: 1- column: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 1+ - status: 2code: 213title: statement.disallow-rm-tbl-cascadecontent: The use of CASCADE is not permitted when removing a table- line: 2- column: 1- details: ""+ detail: ""+ startposition:+ line: 2+ column: 1diff --git a/backend/plugin/advisor/pg/test/statement_dml_dry_run.yaml b/backend/plugin/advisor/pg/test/statement_dml_dry_run.yamlindex 6935ed4653..b00f58a6f4 100644--- a/backend/plugin/advisor/pg/test/statement_dml_dry_run.yaml+++ b/backend/plugin/advisor/pg/test/statement_dml_dry_run.yaml@@ -1,18 +1,16 @@- statement: INSERT INTO tech_book values(1, 'a')want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: DELETE FROM tech_bookwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/pg/test/statement_insert_disallow_order_by_rand.yaml b/backend/plugin/advisor/pg/test/statement_insert_disallow_order_by_rand.yamlindex 0b77998925..574275ec5f 100644--- a/backend/plugin/advisor/pg/test/statement_insert_disallow_order_by_rand.yaml+++ b/backend/plugin/advisor/pg/test/statement_insert_disallow_order_by_rand.yaml@@ -1,18 +1,18 @@- statement: INSERT INTO tech_book VALUES(1, "a")want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: INSERT INTO tech_book SELECT * FROM tech_book ORDER BY random()want:- - status: WARN+ - status: 2code: 1108title: statement.insert.disallow-order-by-randcontent: The INSERT statement uses ORDER BY random() or random_between(), related statement "INSERT INTO tech_book SELECT * FROM tech_book ORDER BY random()"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/pg/test/statement_insert_must_specify_column.yaml b/backend/plugin/advisor/pg/test/statement_insert_must_specify_column.yamlindex 38e58e3f4c..f6ad536e44 100644--- a/backend/plugin/advisor/pg/test/statement_insert_must_specify_column.yaml+++ b/backend/plugin/advisor/pg/test/statement_insert_must_specify_column.yaml@@ -1,18 +1,18 @@- statement: INSERT INTO tech_book(id, name) VALUES (1, '1')want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: INSERT INTO tech_book VALUES (1, '1')want:- - status: WARN+ - status: 2code: 1107title: statement.insert.must-specify-columncontent: The INSERT statement must specify columns but "INSERT INTO tech_book VALUES (1, '1')" does not- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/pg/test/statement_insert_row_limit.yaml b/backend/plugin/advisor/pg/test/statement_insert_row_limit.yamlindex 9401798dca..9c4b4219a2 100644--- a/backend/plugin/advisor/pg/test/statement_insert_row_limit.yaml+++ b/backend/plugin/advisor/pg/test/statement_insert_row_limit.yaml@@ -1,27 +1,26 @@- statement: INSERT INTO tech_book values(1, 'a')want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: INSERT INTO tech_book values(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')want:- - status: WARN+ - status: 2code: 1101title: statement.insert.row-limitcontent: The statement "INSERT INTO tech_book values(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')" inserts 6 rows. The count exceeds 5.- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: INSERT INTO tech_book SELECT * FROM tech_book;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/pg/test/statement_maximum_limit_value.yaml b/backend/plugin/advisor/pg/test/statement_maximum_limit_value.yamlindex 3929343eaf..92506c1406 100644--- a/backend/plugin/advisor/pg/test/statement_maximum_limit_value.yaml+++ b/backend/plugin/advisor/pg/test/statement_maximum_limit_value.yaml@@ -1,9 +1,11 @@- statement: |SELECT * FROM employee LIMIT 1000000;want:- - status: WARN+ - status: 2code: 222title: statement.maximum-limit-value- content: |-- The limit value 1000000 exceeds the maximum allowed value 1000- line: 1+ content: The limit value 1000000 exceeds the maximum allowed value 1000+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/pg/test/statement_merge_alter_table.yaml b/backend/plugin/advisor/pg/test/statement_merge_alter_table.yamlindex 61035b6c43..ef2292d7b2 100644--- a/backend/plugin/advisor/pg/test/statement_merge_alter_table.yaml+++ b/backend/plugin/advisor/pg/test/statement_merge_alter_table.yaml@@ -1,21 +1,21 @@- statement: ALTER TABLE tech_book ADD COLUMN a intwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int);ALTER TABLE tech_book ADD COLUMN a int;ALTER TABLE t ADD COLUMN b int;want:- - status: WARN+ - status: 2code: 207title: statement.merge-alter-tablecontent: There are 2 statements to modify table `t`- line: 3- column: 0- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0diff --git a/backend/plugin/advisor/pg/test/statement_non_transactional.yaml b/backend/plugin/advisor/pg/test/statement_non_transactional.yamlindex 7911c65c4f..591be9373a 100644--- a/backend/plugin/advisor/pg/test/statement_non_transactional.yaml+++ b/backend/plugin/advisor/pg/test/statement_non_transactional.yaml@@ -1,27 +1,28 @@- statement: CREATE INDEX idx_tech_book_id_name ON tech_book(id, name)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE INDEX CONCURRENTLY tech_book_id_name ON tech_book(id, name)want:- - status: WARN+ - status: 2code: 230title: statement.non-transactionalcontent: This statement is non-transactional- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: VACUUM FULL tech_bookwant:- - status: WARN+ - status: 2code: 230title: statement.non-transactionalcontent: This statement is non-transactional- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/pg/test/statement_prior_backup_check.yaml b/backend/plugin/advisor/pg/test/statement_prior_backup_check.yamlindex 328b03fe13..dcd8f3bf18 100644--- a/backend/plugin/advisor/pg/test/statement_prior_backup_check.yaml+++ b/backend/plugin/advisor/pg/test/statement_prior_backup_check.yaml@@ -1,6 +1,6 @@- statement: DELETE FROM tech_book WHERE a > 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""@@ -9,7 +9,7 @@details: ""- statement: UPDATE tech_book SET id = 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""@@ -18,7 +18,7 @@details: ""- statement: UPDATE tech_book SET id = 1;DELETE FROM tech_book WHERE a > 1;want:- - status: WARN+ - status: 2code: 227title: statement.prior-backup-checkcontent: Found 1 DELETE, 1 UPDATE on table ``.`tech_book`, disallow mixing different types of DML statementsdiff --git a/backend/plugin/advisor/pg/test/statement_select_no_select_all.yaml b/backend/plugin/advisor/pg/test/statement_select_no_select_all.yamlindex 82302592d6..8105f035ce 100644--- a/backend/plugin/advisor/pg/test/statement_select_no_select_all.yaml+++ b/backend/plugin/advisor/pg/test/statement_select_no_select_all.yaml@@ -1,36 +1,38 @@- statement: SELECT * FROM twant:- - status: WARN+ - status: 2code: 203title: statement.select.no-select-allcontent: '"SELECT * FROM t" uses SELECT all'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT a, b FROM twant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: SELECT a, b FROM (SELECT * from t1, t2) twant:- - status: WARN+ - status: 2code: 203title: statement.select.no-select-allcontent: '"SELECT a, b FROM (SELECT * from t1, t2) t" uses SELECT all'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: INSERT INTO t SELECT * FROM t1want:- - status: WARN+ - status: 2code: 203title: statement.select.no-select-allcontent: '"INSERT INTO t SELECT * FROM t1" uses SELECT all'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/pg/test/statement_where_no_leading_wildcard_like.yaml b/backend/plugin/advisor/pg/test/statement_where_no_leading_wildcard_like.yamlindex 43769de859..cff6f75cc1 100644--- a/backend/plugin/advisor/pg/test/statement_where_no_leading_wildcard_like.yaml+++ b/backend/plugin/advisor/pg/test/statement_where_no_leading_wildcard_like.yaml@@ -1,45 +1,48 @@- statement: SELECT * FROM t WHERE a LIKE 'abc%'want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: SELECT * FROM t WHERE a LIKE '%abc'want:- - status: WARN+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: '"SELECT * FROM t WHERE a LIKE ''%abc''" uses leading wildcard LIKE'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT * FROM t WHERE a LIKE 'abc' OR a LIKE '%abc'want:- - status: WARN+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: '"SELECT * FROM t WHERE a LIKE ''abc'' OR a LIKE ''%abc''" uses leading wildcard LIKE'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc'want:- - status: WARN+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: '"SELECT * FROM t WHERE a LIKE ''%acc'' OR a LIKE ''%abc''" uses leading wildcard LIKE'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT * FROM (SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc') t1want:- - status: WARN+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: '"SELECT * FROM (SELECT * FROM t WHERE a LIKE ''%acc'' OR a LIKE ''%abc'') t1" uses leading wildcard LIKE'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/pg/test/statement_where_require.yaml b/backend/plugin/advisor/pg/test/statement_where_require.yamlindex 4c2b1a8cb0..35a263dc3c 100644--- a/backend/plugin/advisor/pg/test/statement_where_require.yaml+++ b/backend/plugin/advisor/pg/test/statement_where_require.yaml@@ -1,81 +1,80 @@- statement: INSERT INTO t VALUES(1)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: DELETE FROM t1want:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: '"DELETE FROM t1" requires WHERE clause'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: UPDATE t1 SET a = 1want:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: '"UPDATE t1 SET a = 1" requires WHERE clause'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: DELETE FROM t1 WHERE a > 0want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: UPDATE t1 SET a = 1 WHERE a > 10want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: SELECT a FROM twant:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: '"SELECT a FROM t" requires WHERE clause'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT a FROM t WHERE a > 0want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: SELECT a FROM t WHERE a > (SELECT max(id) FROM user)want:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: '"SELECT a FROM t WHERE a > (SELECT max(id) FROM user)" requires WHERE clause'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT 1want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/pg/test/system_charset_allowlist.yaml b/backend/plugin/advisor/pg/test/system_charset_allowlist.yamlindex a65eb3f315..8d47c4b4be 100644--- a/backend/plugin/advisor/pg/test/system_charset_allowlist.yaml+++ b/backend/plugin/advisor/pg/test/system_charset_allowlist.yaml@@ -1,36 +1,34 @@- statement: CREATE DATABASE test WITH ENCODING 'UTF8'want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE DATABASE testwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE DATABASE test WITH ENCODING 'LATIN1'want:- - status: WARN+ - status: 2code: 1001title: system.charset.allowlistcontent: '"" used disabled encoding ''latin1'''- line: 0- column: 0- details: ""+ detail: ""+ startposition:+ line: 0+ column: 0- statement: /* this is a comment */want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/pg/test/system_collation_allowlist.yaml b/backend/plugin/advisor/pg/test/system_collation_allowlist.yamlindex ce8dbd5df2..30e23aaac9 100644--- a/backend/plugin/advisor/pg/test/system_collation_allowlist.yaml+++ b/backend/plugin/advisor/pg/test/system_collation_allowlist.yaml@@ -1,36 +1,38 @@- statement: CREATE TABLE t(a text COLLATE utf8mb4_0900_ai_ci)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a text COLLATE "unknown")want:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlistcontent: Use disabled collation "unknown", related statement "CREATE TABLE t(a text COLLATE "unknown")"- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ADD COLUMN c1 text COLLATE "unknown"want:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlistcontent: Use disabled collation "unknown", related statement "ALTER TABLE tech_book ADD COLUMN c1 text COLLATE "unknown""- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ALTER COLUMN id TYPE text COLLATE "unknown"want:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlistcontent: Use disabled collation "unknown", related statement "ALTER TABLE tech_book ALTER COLUMN id TYPE text COLLATE "unknown""- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/pg/test/system_comment_length.yaml b/backend/plugin/advisor/pg/test/system_comment_length.yamlindex f9793de371..aaa838a6c6 100644--- a/backend/plugin/advisor/pg/test/system_comment_length.yaml+++ b/backend/plugin/advisor/pg/test/system_comment_length.yaml@@ -1,36 +1,36 @@- statement: comment on column public.name is 'is a column name'want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: comment on column public.name is 'is a to long column name'want:- - status: WARN+ - status: 2code: 1301title: system.comment.lengthcontent: The length of comment should be within 20 characters- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: comment on table public is 'is a table name'want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: comment on table public is 'is a to long table name long long long long long long long'want:- - status: WARN+ - status: 2code: 1301title: system.comment.lengthcontent: The length of comment should be within 20 characters- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/pg/test/table_disallow_partition.yaml b/backend/plugin/advisor/pg/test/table_disallow_partition.yamlindex 153bc89763..a22127598a 100644--- a/backend/plugin/advisor/pg/test/table_disallow_partition.yaml+++ b/backend/plugin/advisor/pg/test/table_disallow_partition.yaml@@ -1,27 +1,28 @@- statement: CREATE TABLE t(a int)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a int) PARTITION BY RANGE (a);want:- - status: WARN+ - status: 2code: 608title: table.disallow-partitioncontent: Table partition is forbidden, but "CREATE TABLE t(a int) PARTITION BY RANGE (a);" creates- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ATTACH PARTITION p1 DEFAULT;want:- - status: WARN+ - status: 2code: 608title: table.disallow-partitioncontent: Table partition is forbidden, but "ALTER TABLE tech_book ATTACH PARTITION p1 DEFAULT;" creates- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/pg/test/table_drop_naming_convention.yaml b/backend/plugin/advisor/pg/test/table_drop_naming_convention.yamlindex 6193fd1423..3e918f85ef 100644--- a/backend/plugin/advisor/pg/test/table_drop_naming_convention.yaml+++ b/backend/plugin/advisor/pg/test/table_drop_naming_convention.yaml@@ -1,27 +1,28 @@- statement: DROP TABLE IF EXISTS foo_deletewant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: DROP TABLE IF EXISTS foowant:- - status: WARN+ - status: 2code: 603title: table.drop-naming-conventioncontent: '`foo` mismatches drop table naming convention, naming format should be "_delete$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: DROP TABLE IF EXISTS foo_delete, barwant:- - status: WARN+ - status: 2code: 603title: table.drop-naming-conventioncontent: '`bar` mismatches drop table naming convention, naming format should be "_delete$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/pg/test/table_no_foreign_key.yaml b/backend/plugin/advisor/pg/test/table_no_foreign_key.yamlindex 1fd188c91e..dc5eefb4b7 100644--- a/backend/plugin/advisor/pg/test/table_no_foreign_key.yaml+++ b/backend/plugin/advisor/pg/test/table_no_foreign_key.yaml@@ -1,18 +1,20 @@- statement: ALTER TABLE tech_book ADD CONSTRAINT fk_tech_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id)want:- - status: WARN+ - status: 2code: 602title: table.no-foreign-keycontent: 'Foreign key is not allowed in the table "public"."tech_book", related statement: "ALTER TABLE tech_book ADD CONSTRAINT fk_tech_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id)"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id INT, author_id INT, CONSTRAINT fk_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id))want:- - status: WARN+ - status: 2code: 602title: table.no-foreign-keycontent: 'Foreign key is not allowed in the table "public"."book", related statement: "CREATE TABLE book(id INT, author_id INT, CONSTRAINT fk_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id))"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/pg/test/table_require_pk.yaml b/backend/plugin/advisor/pg/test/table_require_pk.yamlindex 281e278674..a1c7f53490 100644--- a/backend/plugin/advisor/pg/test/table_require_pk.yaml+++ b/backend/plugin/advisor/pg/test/table_require_pk.yaml@@ -1,74 +1,72 @@- statement: CREATE TABLE t(id INT PRIMARY KEY)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(id INT, PRIMARY KEY (id))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(id INT)want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: 'Table "public"."t" requires PRIMARY KEY, related statement: "CREATE TABLE t(id INT)"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE "tech_book" DROP CONSTRAINT "old_pk"want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: 'Table "public"."tech_book" requires PRIMARY KEY, related statement: "ALTER TABLE \"tech_book\" DROP CONSTRAINT \"old_pk\""'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE "tech_book" DROP CONSTRAINT "old_index"want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE "tech_book" DROP CONSTRAINT constraint_not_in_catalogwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE "tech_book" DROP COLUMN idwant:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: 'Table "public"."tech_book" requires PRIMARY KEY, related statement: "ALTER TABLE \"tech_book\" DROP COLUMN id"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-ALTER TABLE tech_book ADD COLUMN column_not_in_pk int;ALTER TABLE "tech_book" DROP COLUMN column_not_in_pk;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/snowflake/advisor_column_maximum_varchar_length.go b/backend/plugin/advisor/snowflake/advisor_column_maximum_varchar_length.goindex d92eb7b1a0..3b7467a6f5 100644--- a/backend/plugin/advisor/snowflake/advisor_column_maximum_varchar_length.go+++ b/backend/plugin/advisor/snowflake/advisor_column_maximum_varchar_length.go@@ -32,7 +32,7 @@ type ColumnMaximumVarcharLengthAdvisor struct {}// Check checks for maximum varchar length.-func (*ColumnMaximumVarcharLengthAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnMaximumVarcharLengthAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -64,19 +64,19 @@ func (*ColumnMaximumVarcharLengthAdvisor) Check(ctx advisor.Context, _ string) (type columnMaximumVarcharLengthChecker struct {*parser.BaseSnowflakeParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringmaximum int- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *columnMaximumVarcharLengthChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *columnMaximumVarcharLengthChecker) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -100,12 +100,14 @@ func (l *columnMaximumVarcharLengthChecker) EnterData_type(ctx *parser.Data_type}if length > l.maximum {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.VarcharLengthExceedsLimit,+ Code: advisor.VarcharLengthExceedsLimit.Int32(),Title: l.title,Content: fmt.Sprintf("The maximum varchar length is %d.", l.maximum),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/snowflake/advisor_column_no_null.go b/backend/plugin/advisor/snowflake/advisor_column_no_null.goindex 64b239ef34..97268ac286 100644--- a/backend/plugin/advisor/snowflake/advisor_column_no_null.go+++ b/backend/plugin/advisor/snowflake/advisor_column_no_null.go@@ -27,7 +27,7 @@ type ColumnNoNullAdvisor struct {}// Check checks for column no NULL value.-func (*ColumnNoNullAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnNoNullAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -54,10 +54,10 @@ func (*ColumnNoNullAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advitype columnNoNullChecker struct {*parser.BaseSnowflakeParserListener- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.Advice// currentOriginalTableName is the original table name of the current table.currentOriginalTableName string@@ -66,11 +66,11 @@ type columnNoNullChecker struct {}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *columnNoNullChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *columnNoNullChecker) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -86,12 +86,14 @@ func (l *columnNoNullChecker) EnterCreate_table(ctx *parser.Create_tableContext)// ExitCreate_table is called when production create_table is exited.func (l *columnNoNullChecker) ExitCreate_table(*parser.Create_tableContext) {for normalizedColumnName, columnNullableLine := range l.columnNullable {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.ColumnCannotNull,+ Code: advisor.ColumnCannotNull.Int32(),Title: l.title,Content: fmt.Sprintf("Column %s is nullable, which is not allowed.", normalizedColumnName),- Line: columnNullableLine,+ StartPosition: &storepb.Position{+ Line: int32(columnNullableLine),+ },})}l.currentOriginalTableName = ""@@ -142,12 +144,14 @@ func (l *columnNoNullChecker) EnterAlter_table(ctx *parser.Alter_tableContext) {// ExitAlter_table is called when production alter_table is exited.func (l *columnNoNullChecker) ExitAlter_table(*parser.Alter_tableContext) {for normalizedColumnName, columnNullableLine := range l.columnNullable {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.ColumnCannotNull,+ Code: advisor.ColumnCannotNull.Int32(),Title: l.title,Content: fmt.Sprintf("Column %s is nullable, which is not allowed.", normalizedColumnName),- Line: columnNullableLine,+ StartPosition: &storepb.Position{+ Line: int32(columnNullableLine),+ },})}l.currentOriginalTableName = ""@@ -187,12 +191,14 @@ func (l *columnNoNullChecker) EnterAlter_table_alter_column(ctx *parser.Alter_ta// ExitAlter_table_alter_column is called when production alter_table_alter_column is exited.func (l *columnNoNullChecker) ExitAlter_table_alter_column(*parser.Alter_table_alter_columnContext) {for normalizedColumnName, columnNullableLine := range l.columnNullable {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.ColumnCannotNull,+ Code: advisor.ColumnCannotNull.Int32(),Title: l.title,Content: fmt.Sprintf("After dropping NOT NULL of column %s, it will be nullable, which is not allowed.", normalizedColumnName),- Line: columnNullableLine,+ StartPosition: &storepb.Position{+ Line: int32(columnNullableLine),+ },})}l.currentOriginalTableName = ""diff --git a/backend/plugin/advisor/snowflake/advisor_column_require.go b/backend/plugin/advisor/snowflake/advisor_column_require.goindex 2db0ee77bc..cb38d6351e 100644--- a/backend/plugin/advisor/snowflake/advisor_column_require.go+++ b/backend/plugin/advisor/snowflake/advisor_column_require.go@@ -27,7 +27,7 @@ type ColumnRequireAdvisor struct {}// Check checks for column requirement.-func (*ColumnRequireAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnRequireAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -61,10 +61,10 @@ func (*ColumnRequireAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advtype columnRequireChecker struct {*parser.BaseSnowflakeParserListener- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.Advice// requireColumns is the required columns, the key is the normalized column name.requireColumns map[string]any@@ -78,11 +78,11 @@ type columnRequireChecker struct {}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *columnRequireChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *columnRequireChecker) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -127,12 +127,14 @@ func (l *columnRequireChecker) ExitCreate_table(ctx *parser.Create_tableContext)return columnNames[i] < columnNames[j]})for _, column := range columnNames {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NoRequiredColumn,+ Code: advisor.NoRequiredColumn.Int32(),Title: l.title,Content: fmt.Sprintf("Table %s missing required column %q", l.currentOriginalTableName, column),- Line: ctx.Column_decl_item_list().GetStop().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.Column_decl_item_list().GetStop().GetLine()),+ },})}l.currentOriginalTableName = ""@@ -173,12 +175,14 @@ func (l *columnRequireChecker) ExitAlter_table(ctx *parser.Alter_tableContext) {return columnNames[i] < columnNames[j]})for _, column := range columnNames {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NoRequiredColumn,+ Code: advisor.NoRequiredColumn.Int32(),Title: l.title,Content: fmt.Sprintf("Table %s missing required column %q", l.currentOriginalTableName, column),- Line: ctx.Table_column_action().GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.Table_column_action().GetStart().GetLine()),+ },})}l.currentOriginalTableName = ""diff --git a/backend/plugin/advisor/snowflake/advisor_migration_compatibility.go b/backend/plugin/advisor/snowflake/advisor_migration_compatibility.goindex e62f5668ce..a836cc4b31 100644--- a/backend/plugin/advisor/snowflake/advisor_migration_compatibility.go+++ b/backend/plugin/advisor/snowflake/advisor_migration_compatibility.go@@ -27,7 +27,7 @@ type MigrationCompatibilityAdvisor struct {}// Check checks for migration compatibility.-func (*MigrationCompatibilityAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*MigrationCompatibilityAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -56,7 +56,7 @@ func (*MigrationCompatibilityAdvisor) Check(ctx advisor.Context, _ string) ([]adtype migrationCompatibilityChecker struct {*parser.BaseSnowflakeParserListener- level advisor.Status+ level storepb.Advice_Statustitle string// normalizedLastCreateTableNameMap contain the last created table name in normalized format, e.g. "SNOWFLAKE.PUBLIC.TABLE", If there are IF NOT EXISTS, the value will be false.@@ -69,15 +69,15 @@ type migrationCompatibilityChecker struct {// currentDatabase is the current database name.currentDatabase string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *migrationCompatibilityChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *migrationCompatibilityChecker) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -118,14 +118,16 @@ func (l *migrationCompatibilityChecker) EnterDrop_table(ctx *parser.Drop_tableCo}level := l.levelif ok && !mustNewCreate {- level = advisor.Warn+ level = storepb.Advice_WARNING}- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: level,- Code: advisor.CompatibilityDropTable,+ Code: advisor.CompatibilityDropTable.Int32(),Title: l.title,Content: fmt.Sprintf("Drop table %q may cause incompatibility with the existing data and code", normalizedFullDropTableName),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}@@ -138,14 +140,16 @@ func (l *migrationCompatibilityChecker) EnterDrop_schema(ctx *parser.Drop_schema}level := l.levelif ok && !mustNewCreate {- level = advisor.Warn+ level = storepb.Advice_WARNING}- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: level,- Code: advisor.CompatibilityDropSchema,+ Code: advisor.CompatibilityDropSchema.Int32(),Title: l.title,Content: fmt.Sprintf("Drop schema %q may cause incompatibility with the existing data and code", normalizedFullDropSchemaName),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}@@ -158,14 +162,16 @@ func (l *migrationCompatibilityChecker) EnterDrop_database(ctx *parser.Drop_data}level := l.levelif ok && !mustNewCreate {- level = advisor.Warn+ level = storepb.Advice_WARNING}- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: level,- Code: advisor.CompatibilityDropDatabase,+ Code: advisor.CompatibilityDropDatabase.Int32(),Title: l.title,Content: fmt.Sprintf("Drop database %q may cause incompatibility with the existing data and code", normalizedFullDropDatabaseName),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}@@ -184,11 +190,13 @@ func (l *migrationCompatibilityChecker) EnterAlter_table(ctx *parser.Alter_tablefor _, columnName := range allColumnName {normalizedAllColumnNames = append(normalizedAllColumnNames, fmt.Sprintf("%q", snowsqlparser.NormalizeSnowSQLObjectNamePart(columnName.Id_())))}- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.CompatibilityDropColumn,+ Code: advisor.CompatibilityDropColumn.Int32(),Title: l.title,Content: fmt.Sprintf("Drop column %s may cause incompatibility with the existing data and code", strings.Join(normalizedAllColumnNames, ",")),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}diff --git a/backend/plugin/advisor/snowflake/advisor_naming_identifier_case.go b/backend/plugin/advisor/snowflake/advisor_naming_identifier_case.goindex 1aaaa54fbe..d3bc3f226a 100644--- a/backend/plugin/advisor/snowflake/advisor_naming_identifier_case.go+++ b/backend/plugin/advisor/snowflake/advisor_naming_identifier_case.go@@ -27,7 +27,7 @@ type NamingIdentifierCaseAdvisor struct {}// Check checks for identifier case.-func (*NamingIdentifierCaseAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingIdentifierCaseAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -53,21 +53,21 @@ func (*NamingIdentifierCaseAdvisor) Check(ctx advisor.Context, _ string) ([]advitype namingIdentifierCaseChecker struct {*parser.BaseSnowflakeParserListener- level advisor.Status+ level storepb.Advice_Statustitle string// currentOriginalTableName is the original table name in the statement.currentOriginalTableName string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *namingIdentifierCaseChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *namingIdentifierCaseChecker) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -111,12 +111,14 @@ func (l *namingIdentifierCaseChecker) EnterColumn_decl_item_list(ctx *parser.ColoriginalID := fullColDecl.Col_decl().Column_name().Id_()originalColName := snowsqlparser.NormalizeSnowSQLObjectNamePart(originalID)if strings.ToUpper(originalColName) != originalColName {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NamingCaseMismatch,+ Code: advisor.NamingCaseMismatch.Int32(),Title: l.title,Content: fmt.Sprintf("Identifier %q should be upper case", originalColName),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}@@ -132,12 +134,14 @@ func (l *namingIdentifierCaseChecker) EnterAlter_table(ctx *parser.Alter_tableCorenameToID := ctx.Table_column_action().Column_name(1).Id_()renameToColName := snowsqlparser.NormalizeSnowSQLObjectNamePart(renameToID)if strings.ToUpper(renameToColName) != renameToColName {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NamingCaseMismatch,+ Code: advisor.NamingCaseMismatch.Int32(),Title: l.title,Content: fmt.Sprintf("Identifier %q should be upper case", renameToColName),- Line: renameToID.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(renameToID.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/snowflake/advisor_naming_identifier_no_keyword.go b/backend/plugin/advisor/snowflake/advisor_naming_identifier_no_keyword.goindex d208fb6a1f..ee62982bfa 100644--- a/backend/plugin/advisor/snowflake/advisor_naming_identifier_no_keyword.go+++ b/backend/plugin/advisor/snowflake/advisor_naming_identifier_no_keyword.go@@ -26,7 +26,7 @@ type NamingIdentifierNoKeywordAdvisor struct {}// Check checks for identifier naming convention without keyword.-func (*NamingIdentifierNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingIdentifierNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -51,21 +51,21 @@ func (*NamingIdentifierNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([type namingIdentifierNoKeywordChecker struct {*parser.BaseSnowflakeParserListener- level advisor.Status+ level storepb.Advice_Statustitle string// currentOriginalTableName is the original table name in the statement.currentOriginalTableName string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *namingIdentifierNoKeywordChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *namingIdentifierNoKeywordChecker) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -109,12 +109,14 @@ func (l *namingIdentifierNoKeywordChecker) EnterColumn_decl_item_list(ctx *parseoriginalID := fullColDecl.Col_decl().Column_name().Id_()originalColName := snowsqlparser.NormalizeSnowSQLObjectNamePart(originalID)if snowsqlparser.IsSnowflakeKeyword(originalColName, false) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NameIsKeywordIdentifier,+ Code: advisor.NameIsKeywordIdentifier.Int32(),Title: l.title,Content: fmt.Sprintf("Identifier %s is a keyword and should be avoided", originalID.GetText()),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}@@ -130,12 +132,14 @@ func (l *namingIdentifierNoKeywordChecker) EnterAlter_table(ctx *parser.Alter_tarenameToID := ctx.Table_column_action().Column_name(1).Id_()renameToColName := snowsqlparser.NormalizeSnowSQLObjectNamePart(renameToID)if snowsqlparser.IsSnowflakeKeyword(renameToColName, false) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NameIsKeywordIdentifier,+ Code: advisor.NameIsKeywordIdentifier.Int32(),Title: l.title,Content: fmt.Sprintf("Identifier %s is a keyword and should be avoided", renameToID.GetText()),- Line: renameToID.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(renameToID.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/snowflake/advisor_naming_table.go b/backend/plugin/advisor/snowflake/advisor_naming_table.goindex 9ce0499771..e69752b101 100644--- a/backend/plugin/advisor/snowflake/advisor_naming_table.go+++ b/backend/plugin/advisor/snowflake/advisor_naming_table.go@@ -28,7 +28,7 @@ type NamingTableAdvisor struct {}// Check checks for table naming convention.-func (*NamingTableAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingTableAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -58,20 +58,20 @@ func (*NamingTableAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advictype namingTableListener struct {*parser.BaseSnowflakeParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringformat *regexp.RegexpmaxLength int- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *namingTableListener) generateAdvice() ([]advisor.Advice, error) {+func (l *namingTableListener) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -85,21 +85,25 @@ func (l *namingTableListener) EnterCreate_table(ctx *parser.Create_tableContext)tableName := strings.TrimPrefix(strings.TrimSuffix(objectName, `"`), `"`)if !l.format.MatchString(tableName) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NamingTableConventionMismatch,+ Code: advisor.NamingTableConventionMismatch.Int32(),Title: l.title,Content: fmt.Sprintf(`"%s" mismatches table naming convention, naming format should be %q`, tableName, l.format),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}if l.maxLength > 0 && len(tableName) > l.maxLength {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NamingTableConventionMismatch,+ Code: advisor.NamingTableConventionMismatch.Int32(),Title: l.title,Content: fmt.Sprintf("\"%s\" mismatches table naming convention, its length should be within %d characters", tableName, l.maxLength),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}@@ -120,21 +124,25 @@ func (l *namingTableListener) EnterAlter_table(ctx *parser.Alter_tableContext) {tableName := strings.TrimPrefix(strings.TrimSuffix(newObjectName, `"`), `"`)if !l.format.MatchString(tableName) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NamingTableConventionMismatch,+ Code: advisor.NamingTableConventionMismatch.Int32(),Title: l.title,Content: fmt.Sprintf(`"%s" mismatches table naming convention, naming format should be %q`, tableName, l.format),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}if l.maxLength > 0 && len(tableName) > l.maxLength {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NamingTableConventionMismatch,+ Code: advisor.NamingTableConventionMismatch.Int32(),Title: l.title,Content: fmt.Sprintf("\"%s\" mismatches table naming convention, its length should be within %d characters", tableName, l.maxLength),- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/snowflake/advisor_naming_table_no_keyword.go b/backend/plugin/advisor/snowflake/advisor_naming_table_no_keyword.goindex fe4df1c341..9053a8e65f 100644--- a/backend/plugin/advisor/snowflake/advisor_naming_table_no_keyword.go+++ b/backend/plugin/advisor/snowflake/advisor_naming_table_no_keyword.go@@ -26,7 +26,7 @@ type NamingTableNoKeywordAdvisor struct {}// Check checks for table naming convention without keyword.-func (*NamingTableNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingTableNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -51,18 +51,18 @@ func (*NamingTableNoKeywordAdvisor) Check(ctx advisor.Context, _ string) ([]advitype namingTableNoKeywordChecker struct {*parser.BaseSnowflakeParserListener- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *namingTableNoKeywordChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *namingTableNoKeywordChecker) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -74,9 +74,9 @@ func (l *namingTableNoKeywordChecker) generateAdvice() ([]advisor.Advice, error)func (l *namingTableNoKeywordChecker) EnterCreate_table(ctx *parser.Create_tableContext) {tableName := snowsqlparser.NormalizeSnowSQLObjectNamePart(ctx.Object_name().GetO())if snowsqlparser.IsSnowflakeKeyword(tableName, false) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NameIsKeywordIdentifier,+ Code: advisor.NameIsKeywordIdentifier.Int32(),Title: l.title,Content: fmt.Sprintf("Table name %q is a keyword identifier and should be avoided.", tableName),})@@ -91,9 +91,9 @@ func (l *namingTableNoKeywordChecker) EnterAlter_table(ctx *parser.Alter_tableCotableName := snowsqlparser.NormalizeSnowSQLObjectNamePart(ctx.Object_name(1).GetO())if snowsqlparser.IsSnowflakeKeyword(tableName, false) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.NameIsKeywordIdentifier,+ Code: advisor.NameIsKeywordIdentifier.Int32(),Title: l.title,Content: fmt.Sprintf("Table name %q is a keyword identifier and should be avoided.", tableName),})diff --git a/backend/plugin/advisor/snowflake/advisor_select_no_select_all.go b/backend/plugin/advisor/snowflake/advisor_select_no_select_all.goindex 19d50625a8..8e9e55125e 100644--- a/backend/plugin/advisor/snowflake/advisor_select_no_select_all.go+++ b/backend/plugin/advisor/snowflake/advisor_select_no_select_all.go@@ -23,7 +23,7 @@ type SelectNoSelectAllAdvisor struct {}// Check checks for no select all.-func (*SelectNoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*SelectNoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -48,18 +48,18 @@ func (*SelectNoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]advisortype selectNoSelectAllChecker struct {*parser.BaseSnowflakeParserListener- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *selectNoSelectAllChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *selectNoSelectAllChecker) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -71,12 +71,14 @@ func (l *selectNoSelectAllChecker) generateAdvice() ([]advisor.Advice, error) {func (l *selectNoSelectAllChecker) EnterSelect_list_elem(ctx *parser.Select_list_elemContext) {if v := ctx.Column_elem(); v != nil {if v.STAR() != nil {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.StatementSelectAll,+ Code: advisor.StatementSelectAll.Int32(),Title: l.title,Content: "Avoid using SELECT *.",- Line: v.STAR().GetSymbol().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(v.STAR().GetSymbol().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/snowflake/advisor_table_drop_naming_convention.go b/backend/plugin/advisor/snowflake/advisor_table_drop_naming_convention.goindex b005b01a24..7202f1d156 100644--- a/backend/plugin/advisor/snowflake/advisor_table_drop_naming_convention.go+++ b/backend/plugin/advisor/snowflake/advisor_table_drop_naming_convention.go@@ -27,7 +27,7 @@ type TableDropNamingConventionAdvisor struct {}// Check checks for table drop with naming convention.-func (*TableDropNamingConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableDropNamingConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -58,19 +58,19 @@ func (*TableDropNamingConventionAdvisor) Check(ctx advisor.Context, _ string) ([type tableDropNamingConventionChecker struct {*parser.BaseSnowflakeParserListener- level advisor.Status+ level storepb.Advice_Statustitle stringformat *regexp.Regexp- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *tableDropNamingConventionChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *tableDropNamingConventionChecker) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -81,12 +81,14 @@ func (l *tableDropNamingConventionChecker) generateAdvice() ([]advisor.Advice, efunc (l *tableDropNamingConventionChecker) EnterDrop_table(ctx *parser.Drop_tableContext) {normalizedObjectName := snowsqlparser.NormalizeSnowSQLObjectNamePart(ctx.Object_name().GetO())if !l.format.MatchString(normalizedObjectName) {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.TableDropNamingConventionMismatch,+ Code: advisor.TableDropNamingConventionMismatch.Int32(),Title: l.title,Content: fmt.Sprintf("%q mismatches drop table naming convention, naming format should be %q", normalizedObjectName, l.format),- Line: ctx.Object_name().GetO().GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.Object_name().GetO().GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/snowflake/advisor_table_no_foreign_key.go b/backend/plugin/advisor/snowflake/advisor_table_no_foreign_key.goindex 2a129a4b32..6ce65c0483 100644--- a/backend/plugin/advisor/snowflake/advisor_table_no_foreign_key.go+++ b/backend/plugin/advisor/snowflake/advisor_table_no_foreign_key.go@@ -26,7 +26,7 @@ type TableNoForeignKeyAdvisor struct {}// Check checks for table disallow foreign key.-func (*TableNoForeignKeyAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableNoForeignKeyAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -56,10 +56,10 @@ func (*TableNoForeignKeyAdvisor) Check(ctx advisor.Context, _ string) ([]advisortype tableNoForeignKeyChecker struct {*parser.BaseSnowflakeParserListener- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.AdvicecurrentConstraintAction currentConstraintAction// currentNormalizedTableName is the current table name, and it is normalized.@@ -78,23 +78,25 @@ type tableNoForeignKeyChecker struct {}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *tableNoForeignKeyChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *tableNoForeignKeyChecker) generateAdvice() ([]*storepb.Advice, error) {for tableName, times := range l.tableForeignKeyTimes {if times > 0 {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.TableHasFK,+ Code: advisor.TableHasFK.Int32(),Title: l.title,Content: fmt.Sprintf("FOREIGN KEY is not allowed in the table %s.", l.tableOriginalName[tableName]),- Line: l.tableLine[tableName],+ StartPosition: &storepb.Position{+ Line: int32(l.tableLine[tableName]),+ },})}}if len(l.adviceList) == 0 {- return []advisor.Advice{+ return []*storepb.Advice{{- Status: advisor.Success,- Code: advisor.Ok,+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",},diff --git a/backend/plugin/advisor/snowflake/advisor_table_require_pk.go b/backend/plugin/advisor/snowflake/advisor_table_require_pk.goindex f9f47eadbe..c934d6420b 100644--- a/backend/plugin/advisor/snowflake/advisor_table_require_pk.go+++ b/backend/plugin/advisor/snowflake/advisor_table_require_pk.go@@ -26,7 +26,7 @@ type TableRequirePkAdvisor struct {}// Check checks for table require primary key.-func (*TableRequirePkAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableRequirePkAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -56,10 +56,10 @@ func (*TableRequirePkAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Adtype tableRequirePkChecker struct {*parser.BaseSnowflakeParserListener- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.AdvicecurrentConstraintAction currentConstraintAction// currentNormalizedTableName is the current table name, and it is normalized.@@ -78,23 +78,25 @@ type tableRequirePkChecker struct {}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *tableRequirePkChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *tableRequirePkChecker) generateAdvice() ([]*storepb.Advice, error) {for tableName, has := range l.tableHasPrimaryKey {if !has {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.TableNoPK,+ Code: advisor.TableNoPK.Int32(),Title: l.title,Content: fmt.Sprintf("Table %s requires PRIMARY KEY.", l.tableOriginalName[tableName]),- Line: l.tableLine[tableName],+ StartPosition: &storepb.Position{+ Line: int32(l.tableLine[tableName]),+ },})}}if len(l.adviceList) == 0 {- return []advisor.Advice{+ return []*storepb.Advice{{- Status: advisor.Success,- Code: advisor.Ok,+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",},diff --git a/backend/plugin/advisor/snowflake/advisor_where_require.go b/backend/plugin/advisor/snowflake/advisor_where_require.goindex eb6252c40e..1f3d58dab5 100644--- a/backend/plugin/advisor/snowflake/advisor_where_require.go+++ b/backend/plugin/advisor/snowflake/advisor_where_require.go@@ -23,7 +23,7 @@ type WhereRequireAdvisor struct {}// Check checks for WHERE clause requirement.-func (*WhereRequireAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*WhereRequireAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {tree, ok := ctx.AST.(antlr.Tree)if !ok {return nil, errors.Errorf("failed to convert to Tree")@@ -48,18 +48,18 @@ func (*WhereRequireAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advitype whereRequireChecker struct {*parser.BaseSnowflakeParserListener- level advisor.Status+ level storepb.Advice_Statustitle string- adviceList []advisor.Advice+ adviceList []*storepb.Advice}// generateAdvice returns the advices generated by the listener, the advices must not be empty.-func (l *whereRequireChecker) generateAdvice() ([]advisor.Advice, error) {+func (l *whereRequireChecker) generateAdvice() ([]*storepb.Advice, error) {if len(l.adviceList) == 0 {- l.adviceList = append(l.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ l.adviceList = append(l.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -70,12 +70,14 @@ func (l *whereRequireChecker) generateAdvice() ([]advisor.Advice, error) {// EnterUpdate_statement is called when production update_statement is entered.func (l *whereRequireChecker) EnterUpdate_statement(ctx *parser.Update_statementContext) {if ctx.WHERE() == nil {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.StatementNoWhere,+ Code: advisor.StatementNoWhere.Int32(),Title: l.title,Content: "WHERE clause is required for UPDATE statement.",- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}@@ -83,12 +85,14 @@ func (l *whereRequireChecker) EnterUpdate_statement(ctx *parser.Update_statement// EnterDelete_statement is called when production delete_statement is entered.func (l *whereRequireChecker) EnterDelete_statement(ctx *parser.Delete_statementContext) {if ctx.WHERE() == nil {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.StatementNoWhere,+ Code: advisor.StatementNoWhere.Int32(),Title: l.title,Content: "WHERE clause is required for DELETE statement.",- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}@@ -104,12 +108,14 @@ func (l *whereRequireChecker) EnterQuery_statement(ctx *parser.Query_statementCo}// Allow SELECT queries without a FROM clause to proceed, e.g. SELECT 1.if optional.Where_clause() == nil && optional.From_clause() != nil {- l.adviceList = append(l.adviceList, advisor.Advice{+ l.adviceList = append(l.adviceList, &storepb.Advice{Status: l.level,- Code: advisor.StatementNoWhere,+ Code: advisor.StatementNoWhere.Int32(),Title: l.title,Content: "WHERE clause is required for SELECT statement.",- Line: ctx.GetStart().GetLine(),+ StartPosition: &storepb.Position{+ Line: int32(ctx.GetStart().GetLine()),+ },})}}diff --git a/backend/plugin/advisor/snowflake/test/column_maximum_varchar_length.yaml b/backend/plugin/advisor/snowflake/test/column_maximum_varchar_length.yamlindex 352d8dd40a..877c827f4e 100644--- a/backend/plugin/advisor/snowflake/test/column_maximum_varchar_length.yaml+++ b/backend/plugin/advisor/snowflake/test/column_maximum_varchar_length.yaml@@ -1,56 +1,66 @@- statement: CREATE TABLE CUSTOMER(NAME VARCHAR(20));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE CUSTOMER(NAME VARCHAR(3000));want:- - status: WARN+ - status: 2code: 422title: column.maximum-varchar-lengthcontent: The maximum varchar length is 2560.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE CUSTOMER(NAME VARCHAR);want:- - status: WARN+ - status: 2code: 422title: column.maximum-varchar-lengthcontent: The maximum varchar length is 2560.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE PUBLIC.CUSTOMER ADD NAME_2 VARCHAR(22225);want:- - status: WARN+ - status: 2code: 422title: column.maximum-varchar-lengthcontent: The maximum varchar length is 2560.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE PUBLIC.CUSTOMER MODIFY COLUMN NAME VARCHAR(22225);want:- - status: WARN+ - status: 2code: 422title: column.maximum-varchar-lengthcontent: The maximum varchar length is 2560.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE PUBLIC.CUSTOMER MODIFY COLUMN NAME VARCHAR(20);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE PUBLIC.CUSTOMER MODIFY COLUMN NAME SET DATA TYPE VARCHAR(22225);want:- - status: WARN+ - status: 2code: 422title: column.maximum-varchar-lengthcontent: The maximum varchar length is 2560.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/snowflake/test/column_no_null.yaml b/backend/plugin/advisor/snowflake/test/column_no_null.yamlindex 4bcfba22a0..8ae82986c8 100644--- a/backend/plugin/advisor/snowflake/test/column_no_null.yaml+++ b/backend/plugin/advisor/snowflake/test/column_no_null.yaml@@ -6,18 +6,22 @@address VARCHAR);want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column AGE is nullable, which is not allowed.- line: 4- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 4+ column: 0+ - status: 2code: 402title: column.no-nullcontent: Column ADDRESS is nullable, which is not allowed.- line: 5- details: ""+ detail: ""+ startposition:+ line: 5+ column: 0- statement: |-CREATE TABLE t (id INT,@@ -27,12 +31,14 @@PRIMARY KEY (id, age))want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column ADDRESS is nullable, which is not allowed.- line: 5- details: ""+ detail: ""+ startposition:+ line: 5+ column: 0- statement: |-CREATE TABLE t (id INT NOT NULL,@@ -41,33 +47,37 @@address VARCHAR NOT NULL);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE a ADD COLUMN age INT;want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: Column AGE is nullable, which is not allowed.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE a ADD COLUMN age INT NOT NULL;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE a ALTER COLUMN age DROP NOT NULL;want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: After dropping NOT NULL of column AGE, it will be nullable, which is not allowed.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/snowflake/test/column_required.yaml b/backend/plugin/advisor/snowflake/test/column_required.yamlindex c58fd77f65..c98e2f0ce2 100644--- a/backend/plugin/advisor/snowflake/test/column_required.yaml+++ b/backend/plugin/advisor/snowflake/test/column_required.yaml@@ -7,48 +7,58 @@"updater_id" INT);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t ("name" TEXT,"age" INT);want:- - status: WARN+ - status: 2code: 401title: column.requiredcontent: Table t missing required column "created_ts"- line: 3- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 401title: column.requiredcontent: Table t missing required column "creator_id"- line: 3- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 401title: column.requiredcontent: Table t missing required column "id"- line: 3- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 401title: column.requiredcontent: Table t missing required column "updated_ts"- line: 3- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 401title: column.requiredcontent: Table t missing required column "updater_id"- line: 3- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-CREATE TABLE t ("id" INT,@@ -57,33 +67,37 @@"updater_id" INT);want:- - status: WARN+ - status: 2code: 401title: column.requiredcontent: Table t missing required column "updated_ts"- line: 5- details: ""+ detail: ""+ startposition:+ line: 5+ column: 0- statement: ALTER TABLE t DROP COLUMN "created_ts";want:- - status: WARN+ - status: 2code: 401title: column.requiredcontent: Table t missing required column "created_ts"- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE t DROP COLUMN creator_id;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE TARGET_TABLE ALTER COLUMN description DROP DEFAULT, COLUMN description DROP NOT NULL;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/snowflake/test/naming_identifier_case.yaml b/backend/plugin/advisor/snowflake/test/naming_identifier_case.yamlindex 95dbd0efdf..8f761a0eec 100644--- a/backend/plugin/advisor/snowflake/test/naming_identifier_case.yaml+++ b/backend/plugin/advisor/snowflake/test/naming_identifier_case.yaml@@ -2,20 +2,20 @@-- The rule should be friendly with engine behavior(i.e. stored and resolved as uppercase characters if not quoted)CREATE TABLE t(id INT);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(ID INT);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(name VARCHAR,@@ -23,12 +23,14 @@"address" VARCHAR);want:- - status: WARN+ - status: 2code: 309title: naming.identifier.casecontent: Identifier "address" should be upper case- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE mytable_copy (name INT,@@ -36,12 +38,14 @@"address" VARCHAR) AS SELECT a + 1, b + 2 FROM mytable;want:- - status: WARN+ - status: 2code: 309title: naming.identifier.casecontent: Identifier "address" should be upper case- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE mytable_copy (name INT,@@ -49,25 +53,27 @@address VARCHAR) AS SELECT a + 1, b + 2 FROM mytable;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE mytable RENAME COLUMN name TO "address";want:- - status: WARN+ - status: 2code: 309title: naming.identifier.casecontent: Identifier "address" should be upper case- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE mytable RENAME COLUMN name TO address;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/snowflake/test/naming_identifier_no_keyword.yaml b/backend/plugin/advisor/snowflake/test/naming_identifier_no_keyword.yamlindex 98289af9d7..fa68c6a00b 100644--- a/backend/plugin/advisor/snowflake/test/naming_identifier_no_keyword.yaml+++ b/backend/plugin/advisor/snowflake/test/naming_identifier_no_keyword.yaml@@ -4,73 +4,81 @@"CONNECT" VARCHAR);want:- - status: WARN+ - status: 2code: 308title: naming.identifier.no-keywordcontent: Identifier "CONNECT" is a keyword and should be avoided- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(name VARCHAR,"connect" VARCHAR);want:- - status: WARN+ - status: 2code: 308title: naming.identifier.no-keywordcontent: Identifier "connect" is a keyword and should be avoided- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(name VARCHAR,age INT);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE mytable_copy (name INT,"connect" INT) AS SELECT a + 1, b + 2 FROM mytable;want:- - status: WARN+ - status: 2code: 308title: naming.identifier.no-keywordcontent: Identifier "connect" is a keyword and should be avoided- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE mytable_copy (name INT,age INT) AS SELECT a + 1, b + 2 FROM mytable;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE mytable RENAME COLUMN name TO "connect";want:- - status: WARN+ - status: 2code: 308title: naming.identifier.no-keywordcontent: Identifier "connect" is a keyword and should be avoided- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE mytable RENAME COLUMN name TO age;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/snowflake/test/naming_table.yaml b/backend/plugin/advisor/snowflake/test/naming_table.yamlindex ba4ed18c06..53792de611 100644--- a/backend/plugin/advisor/snowflake/test/naming_table.yaml+++ b/backend/plugin/advisor/snowflake/test/naming_table.yaml@@ -1,86 +1,100 @@- statement: CREATE TABLE UPPER_CASE_TABLE_NAME_WITHOUT_DOUBLE_QUOTES(ID INT);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE "UPPER_CASE_TABLE_NAME_WITH_DOUBLE_QUOTES"(ID INT);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE lower_case_table_name_without_double_quotes(ID INT);want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '"lower_case_table_name_without_double_quotes" mismatches table naming convention, naming format should be "^[A-Z]+(_[A-Z]+)*$"'- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE "lower_case_table_name_with_double_quotes"(ID INT);want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '"lower_case_table_name_with_double_quotes" mismatches table naming convention, naming format should be "^[A-Z]+(_[A-Z]+)*$"'- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: "CREATE TABLE \"\U0001F608EMOJI\U0001F604\"(ID INT);"want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: "\"\U0001F608EMOJI\U0001F604\" mismatches table naming convention, naming format should be \"^[A-Z]+(_[A-Z]+)*$\""- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE "lower_case_table_with_double_quotes" RENAME TO UPPER_CASE_TABLE_NAME_WITHOUT_DOUBLE_QUOTES;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE UPPER_CASE_TABLE_NAME RENAME TO "lower_case_table_with_double_quotes";want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '"lower_case_table_with_double_quotes" mismatches table naming convention, naming format should be "^[A-Z]+(_[A-Z]+)*$"'- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE UPPER_CASE_TABLE_NAME_WITHOUT_DOUBLE_QUOTES(ID INT);ALTER TABLE UPPER_CASE_TABLE_NAME_WITHOUT_DOUBLE_QUOTES RENAME TO "lower_case_table_with_double_quotes";want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '"lower_case_table_with_double_quotes" mismatches table naming convention, naming format should be "^[A-Z]+(_[A-Z]+)*$"'- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE "lower_case_table_name_with_double_quotes"(ID INT);ALTER TABLE "lower_case_table_name_with_double_quotes" RENAME TO UPPER_CASE_TABLE_NAME_WITHOUT_DOUBLE_QUOTES;want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '"lower_case_table_name_with_double_quotes" mismatches table naming convention, naming format should be "^[A-Z]+(_[A-Z]+)*$"'- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE "lowercase"(ID INT);ALTER TABLE another_schema."lower_case" RENAME TO another_schema.UPPER_CASE_TABLE_NAME_WITHOUT_DOUBLE_QUOTES;want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '"lowercase" mismatches table naming convention, naming format should be "^[A-Z]+(_[A-Z]+)*$"'- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/snowflake/test/naming_table_no_keyword.yaml b/backend/plugin/advisor/snowflake/test/naming_table_no_keyword.yamlindex 9ae09a2370..3eb75f0767 100644--- a/backend/plugin/advisor/snowflake/test/naming_table_no_keyword.yaml+++ b/backend/plugin/advisor/snowflake/test/naming_table_no_keyword.yaml@@ -1,32 +1,32 @@- statement: CREATE TABLE "CONNECT"(ID INT);want:- - status: WARN+ - status: 2code: 308title: naming.table.no-keywordcontent: Table name "CONNECT" is a keyword identifier and should be avoided.- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE "DB_NAME"."SCHEMA_NAME"."CONNECT"(ID INT);want:- - status: WARN+ - status: 2code: 308title: naming.table.no-keywordcontent: Table name "CONNECT" is a keyword identifier and should be avoided.- line: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE "DB_NAME"."SCHEMA_NAME"."TABLE_NAME"(ID INT);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE "DB_NAME"."SCHEMA_NAME"."TABLE_NAME" RENAME TO "CONNECT";want:- - status: WARN+ - status: 2code: 308title: naming.table.no-keywordcontent: Table name "CONNECT" is a keyword identifier and should be avoided.- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/snowflake/test/schema_backward_compatibility.yaml b/backend/plugin/advisor/snowflake/test/schema_backward_compatibility.yamlindex a8cb61587e..b979710ed6 100644--- a/backend/plugin/advisor/snowflake/test/schema_backward_compatibility.yaml+++ b/backend/plugin/advisor/snowflake/test/schema_backward_compatibility.yaml@@ -1,52 +1,62 @@- statement: DROP DATABASE DB;want:- - status: WARN+ - status: 2code: 101title: schema.backward-compatibilitycontent: Drop database "DB" may cause incompatibility with the existing data and code- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: DROP SCHEMA SCHEMA1;want:- - status: WARN+ - status: 2code: 112title: schema.backward-compatibilitycontent: Drop schema "TEST_DB.SCHEMA1" may cause incompatibility with the existing data and code- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: DROP TABLE T;want:- - status: WARN+ - status: 2code: 103title: schema.backward-compatibilitycontent: Drop table "TEST_DB.PUBLIC.T" may cause incompatibility with the existing data and code- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE T DROP COLUMN COL1;want:- - status: WARN+ - status: 2code: 105title: schema.backward-compatibilitycontent: Drop column "COL1" may cause incompatibility with the existing data and code- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE IF NOT EXISTS T(ID INT);DROP TABLE T;want:- - status: WARN+ - status: 2code: 103title: schema.backward-compatibilitycontent: Drop table "TEST_DB.PUBLIC.T" may cause incompatibility with the existing data and code- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE T(ID INT);DROP TABLE T;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/snowflake/test/statement_select_no_select_all.yaml b/backend/plugin/advisor/snowflake/test/statement_select_no_select_all.yamlindex e0c5ddbd9c..da283d21ee 100644--- a/backend/plugin/advisor/snowflake/test/statement_select_no_select_all.yaml+++ b/backend/plugin/advisor/snowflake/test/statement_select_no_select_all.yaml@@ -1,32 +1,38 @@- statement: SELECT * FROM twant:- - status: WARN+ - status: 2code: 203title: statement.select.no-select-allcontent: Avoid using SELECT *.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT a, b FROM twant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: SELECT a, b FROM (SELECT * from t1, t2) twant:- - status: WARN+ - status: 2code: 203title: statement.select.no-select-allcontent: Avoid using SELECT *.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: INSERT INTO t SELECT * FROM t1want:- - status: WARN+ - status: 2code: 203title: statement.select.no-select-allcontent: Avoid using SELECT *.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/snowflake/test/statement_where_require.yaml b/backend/plugin/advisor/snowflake/test/statement_where_require.yamlindex d63f4e3ecc..4cf478d636 100644--- a/backend/plugin/advisor/snowflake/test/statement_where_require.yaml+++ b/backend/plugin/advisor/snowflake/test/statement_where_require.yaml@@ -1,59 +1,67 @@- statement: SELECT * FROM (SELECT * FROM TARGET_TABLE) AS a WHERE a.id = 1;want:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: WHERE clause is required for SELECT statement.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: UPDATE t SET a = 1;want:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: WHERE clause is required for UPDATE statement.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: UPDATE t SET a = 1 WHERE b = 2;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: DELETE FROM t;want:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: WHERE clause is required for DELETE statement.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: DELETE FROM t WHERE a = 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: SELECT * FROM t;want:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: WHERE clause is required for SELECT statement.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT * FROM t WHERE b = 2;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-withalbum_info_1976 as (select m.album_ID, m.album_name, b.band_name@@ -65,18 +73,22 @@select album_name, band_namefrom Journey_album_info_1976;want:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: WHERE clause is required for SELECT statement.- line: 1- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 202title: statement.where.requirecontent: WHERE clause is required for SELECT statement.- line: 5- details: ""+ detail: ""+ startposition:+ line: 5+ column: 0- statement: |-MERGE INTO target_table USING (SELECT id, description FROM source_table@@ -84,17 +96,19 @@ON target_table.id = filtered_source_table.idWHEN MATCHED THEN UPDATE SET target_table.a = filtered_source_table.b;want:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: WHERE clause is required for SELECT statement.- line: 2- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: SELECT 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/snowflake/test/table_drop_naming_convention.yaml b/backend/plugin/advisor/snowflake/test/table_drop_naming_convention.yamlindex 3e3fccce27..c6f285f3a6 100644--- a/backend/plugin/advisor/snowflake/test/table_drop_naming_convention.yaml+++ b/backend/plugin/advisor/snowflake/test/table_drop_naming_convention.yaml@@ -1,16 +1,18 @@- statement: DROP TABLE IF EXISTS "FOO_delete"want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: DROP TABLE IF EXISTS FOOwant:- - status: WARN+ - status: 2code: 603title: table.drop-naming-conventioncontent: '"FOO" mismatches drop table naming convention, naming format should be "_delete$"'- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/snowflake/test/table_no_foreign_key.yaml b/backend/plugin/advisor/snowflake/test/table_no_foreign_key.yamlindex e26cb2b9c7..fdd3900752 100644--- a/backend/plugin/advisor/snowflake/test/table_no_foreign_key.yaml+++ b/backend/plugin/advisor/snowflake/test/table_no_foreign_key.yaml@@ -6,12 +6,14 @@POSITION VARCHAR(100));want:- - status: WARN+ - status: 2code: 602title: table.no-foreign-keycontent: FOREIGN KEY is not allowed in the table CUSTOMER.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE CUSTOMER(@@ -21,12 +23,14 @@(ID) REFERENCES PERSON(ID));want:- - status: WARN+ - status: 2code: 602title: table.no-foreign-keycontent: FOREIGN KEY is not allowed in the table CUSTOMER.- line: 6- details: ""+ detail: ""+ startposition:+ line: 6+ column: 0- statement: |-CREATE TABLE CUSTOMER(@@ -36,12 +40,14 @@);ALTER TABLE CUSTOMER ADD (ID) REFERENCES PERSON(ID);want:- - status: WARN+ - status: 2code: 602title: table.no-foreign-keycontent: FOREIGN KEY is not allowed in the table CUSTOMER.- line: 7- details: ""+ detail: ""+ startposition:+ line: 7+ column: 0- statement: |-CREATE TABLE "ANOTHER_SCHEMA"."CUSTOMER"(@@ -51,12 +57,14 @@);ALTER TABLE CUSTOMER DROP FOREIGN KEY (ID);want:- - status: WARN+ - status: 2code: 602title: table.no-foreign-keycontent: FOREIGN KEY is not allowed in the table "ANOTHER_SCHEMA"."CUSTOMER".- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE CUSTOMER(@@ -66,12 +74,12 @@);ALTER TABLE CUSTOMER DROP FOREIGN KEY (ID);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE CUSTOMER(@@ -87,9 +95,11 @@);ALTER TABLE CUSTOMER ADD CONSTRAINT FK_CUSTOMER_PERSON FOREIGN KEY (ID) REFERENCES PERSON(ID);want:- - status: WARN+ - status: 2code: 602title: table.no-foreign-keycontent: FOREIGN KEY is not allowed in the table CUSTOMER.- line: 13- details: ""+ detail: ""+ startposition:+ line: 13+ column: 0diff --git a/backend/plugin/advisor/snowflake/test/table_require_pk.yaml b/backend/plugin/advisor/snowflake/test/table_require_pk.yamlindex 072f73179b..2206504b86 100644--- a/backend/plugin/advisor/snowflake/test/table_require_pk.yaml+++ b/backend/plugin/advisor/snowflake/test/table_require_pk.yaml@@ -6,12 +6,12 @@POSITION VARCHAR(100));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE CUSTOMER(@@ -21,12 +21,12 @@CONSTRAINT PK_CUSTOMER PRIMARY KEY (ID));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE CUSTOMER(@@ -35,12 +35,14 @@POSITION VARCHAR(100));want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table CUSTOMER requires PRIMARY KEY.- line: 1- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE CUSTOMER(@@ -50,12 +52,14 @@);ALTER TABLE CUSTOMER DROP PRIMARY KEY(ID);want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table CUSTOMER requires PRIMARY KEY.- line: 7- details: ""+ detail: ""+ startposition:+ line: 7+ column: 0- statement: |-CREATE TABLE CUSTOMER(@@ -65,12 +69,12 @@);ALTER TABLE CUSTOMER ADD CONSTRAINT PK_CUSTOMER PRIMARY KEY (ID);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE CUSTOMER(@@ -80,12 +84,12 @@);ALTER TABLE "PUBLIC"."CUSTOMER" ADD CONSTRAINT PK_CUSTOMER PRIMARY KEY (ID);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE CUSTOMER(@@ -102,12 +106,14 @@POSITION VARCHAR(100));want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table CUSTOMER requires PRIMARY KEY.- line: 9- details: ""+ detail: ""+ startposition:+ line: 9+ column: 0- statement: |-CREATE TABLE CUSTOMER(@@ -135,15 +141,19 @@ALTER TABLE CUSTOMER DROP PRIMARY KEY(ID);ALTER TABLE ORDERING DROP PRIMARY KEY(ORDER_ID);want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table CUSTOMER requires PRIMARY KEY.- line: 24- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 24+ column: 0+ - status: 2code: 601title: table.require-pkcontent: Table ORDERING requires PRIMARY KEY.- line: 25- details: ""+ detail: ""+ startposition:+ line: 25+ column: 0diff --git a/backend/plugin/advisor/sql_review.go b/backend/plugin/advisor/sql_review.goindex 0f10128f21..e9e7b7e4b0 100644--- a/backend/plugin/advisor/sql_review.go+++ b/backend/plugin/advisor/sql_review.go@@ -493,7 +493,7 @@ type SQLReviewCheckContext struct {CurrentDatabase string}-func syntaxCheck(statement string, checkContext SQLReviewCheckContext) (any, []Advice) {+func syntaxCheck(statement string, checkContext SQLReviewCheckContext) (any, []*storepb.Advice) {switch checkContext.DbType {case storepb.Engine_TIDB:return tidbSyntaxCheck(statement)@@ -510,39 +510,45 @@ func syntaxCheck(statement string, checkContext SQLReviewCheckContext) (any, []Acase storepb.Engine_DYNAMODB:return partiqlSyntaxCheck(statement)}- return nil, []Advice{+ return nil, []*storepb.Advice{{- Status: Error,- Code: Unsupported,+ Status: storepb.Advice_ERROR,+ Code: Unsupported.Int32(),Title: "Unsupported database type",Content: fmt.Sprintf("Unsupported database type %s", checkContext.DbType),- Line: 1,+ StartPosition: &storepb.Position{+ Line: 1,+ },},}}-func partiqlSyntaxCheck(statement string) (any, []Advice) {+func partiqlSyntaxCheck(statement string) (any, []*storepb.Advice) {result, err := partiqlparser.ParsePartiQL(statement)if err != nil {if syntaxErr, ok := err.(*base.SyntaxError); ok {- return nil, []Advice{+ return nil, []*storepb.Advice{{- Status: Warn,- Code: StatementSyntaxError,+ Status: storepb.Advice_WARNING,+ Code: StatementSyntaxError.Int32(),Title: SyntaxErrorTitle,Content: syntaxErr.Message,- Line: syntaxErr.Line,- Column: syntaxErr.Column,+ StartPosition: &storepb.Position{+ Line: int32(syntaxErr.Line),+ Column: int32(syntaxErr.Column),+ },},}}- return nil, []Advice{+ return nil, []*storepb.Advice{{- Status: Warn,- Code: Internal,+ Status: storepb.Advice_WARNING,+ Code: Internal.Int32(),Title: "Parse error",Content: err.Error(),- Line: 1,+ StartPosition: &storepb.Position{+ Line: 1,+ },},}}@@ -554,28 +560,32 @@ func partiqlSyntaxCheck(statement string) (any, []Advice) {return result.Tree, nil}-func mssqlSyntaxCheck(statement string) (any, []Advice) {+func mssqlSyntaxCheck(statement string) (any, []*storepb.Advice) {result, err := tsqlparser.ParseTSQL(statement)if err != nil {if syntaxErr, ok := err.(*base.SyntaxError); ok {- return nil, []Advice{+ return nil, []*storepb.Advice{{- Status: Warn,- Code: StatementSyntaxError,+ Status: storepb.Advice_WARNING,+ Code: StatementSyntaxError.Int32(),Title: SyntaxErrorTitle,Content: syntaxErr.Message,- Line: syntaxErr.Line,- Column: syntaxErr.Column,+ StartPosition: &storepb.Position{+ Line: int32(syntaxErr.Line),+ Column: int32(syntaxErr.Column),+ },},}}- return nil, []Advice{+ return nil, []*storepb.Advice{{- Status: Warn,- Code: Internal,+ Status: storepb.Advice_WARNING,+ Code: Internal.Int32(),Title: "Parse error",Content: err.Error(),- Line: 1,+ StartPosition: &storepb.Position{+ Line: 1,+ },},}}@@ -587,28 +597,32 @@ func mssqlSyntaxCheck(statement string) (any, []Advice) {return result.Tree, nil}-func snowflakeSyntaxCheck(statement string) (any, []Advice) {+func snowflakeSyntaxCheck(statement string) (any, []*storepb.Advice) {result, err := snowsqlparser.ParseSnowSQL(statement + ";")if err != nil {if syntaxErr, ok := err.(*base.SyntaxError); ok {- return nil, []Advice{+ return nil, []*storepb.Advice{{- Status: Warn,- Code: StatementSyntaxError,+ Status: storepb.Advice_WARNING,+ Code: StatementSyntaxError.Int32(),Title: SyntaxErrorTitle,Content: syntaxErr.Message,- Line: syntaxErr.Line,- Column: syntaxErr.Column,+ StartPosition: &storepb.Position{+ Line: int32(syntaxErr.Line),+ Column: int32(syntaxErr.Column),+ },},}}- return nil, []Advice{+ return nil, []*storepb.Advice{{- Status: Warn,- Code: Internal,+ Status: storepb.Advice_WARNING,+ Code: Internal.Int32(),Title: "Parse error",Content: err.Error(),- Line: 1,+ StartPosition: &storepb.Position{+ Line: 1,+ },},}}@@ -619,28 +633,32 @@ func snowflakeSyntaxCheck(statement string) (any, []Advice) {return result.Tree, nil}-func oracleSyntaxCheck(statement string) (any, []Advice) {+func oracleSyntaxCheck(statement string) (any, []*storepb.Advice) {tree, _, err := plsqlparser.ParsePLSQL(statement + ";")if err != nil {if syntaxErr, ok := err.(*base.SyntaxError); ok {- return nil, []Advice{+ return nil, []*storepb.Advice{{- Status: Warn,- Code: StatementSyntaxError,+ Status: storepb.Advice_WARNING,+ Code: StatementSyntaxError.Int32(),Title: SyntaxErrorTitle,Content: syntaxErr.Message,- Line: syntaxErr.Line,- Column: syntaxErr.Column,+ StartPosition: &storepb.Position{+ Line: int32(syntaxErr.Line),+ Column: int32(syntaxErr.Column),+ },},}}- return nil, []Advice{+ return nil, []*storepb.Advice{{- Status: Warn,- Code: Internal,+ Status: storepb.Advice_WARNING,+ Code: Internal.Int32(),Title: "Parse error",Content: err.Error(),- Line: 1,+ StartPosition: &storepb.Position{+ Line: 1,+ },},}}@@ -648,27 +666,31 @@ func oracleSyntaxCheck(statement string) (any, []Advice) {return tree, nil}-func postgresSyntaxCheck(statement string) (any, []Advice) {+func postgresSyntaxCheck(statement string) (any, []*storepb.Advice) {nodes, err := pgrawparser.Parse(pgrawparser.ParseContext{}, statement)if err != nil {if _, ok := err.(*pgrawparser.ConvertError); ok {- return nil, []Advice{+ return nil, []*storepb.Advice{{- Status: Error,- Code: Internal,+ Status: storepb.Advice_ERROR,+ Code: Internal.Int32(),Title: "Parser conversion error",Content: err.Error(),- Line: calculatePostgresErrorLine(statement),+ StartPosition: &storepb.Position{+ Line: int32(calculatePostgresErrorLine(statement)),+ },},}}- return nil, []Advice{+ return nil, []*storepb.Advice{{- Status: Error,- Code: StatementSyntaxError,+ Status: storepb.Advice_ERROR,+ Code: StatementSyntaxError.Int32(),Title: SyntaxErrorTitle,Content: err.Error(),- Line: calculatePostgresErrorLine(statement),+ StartPosition: &storepb.Position{+ Line: int32(calculatePostgresErrorLine(statement)),+ },},}}@@ -707,28 +729,32 @@ func newTiDBParser() *tidbparser.Parser {return p}-func mysqlSyntaxCheck(statement string) (any, []Advice) {+func mysqlSyntaxCheck(statement string) (any, []*storepb.Advice) {res, err := mysqlparser.ParseMySQL(statement)if err != nil {if syntaxErr, ok := err.(*base.SyntaxError); ok {- return nil, []Advice{+ return nil, []*storepb.Advice{{- Status: Error,- Code: StatementSyntaxError,+ Status: storepb.Advice_ERROR,+ Code: StatementSyntaxError.Int32(),Title: SyntaxErrorTitle,Content: syntaxErr.Message,- Line: syntaxErr.Line,- Column: syntaxErr.Column,+ StartPosition: &storepb.Position{+ Line: int32(syntaxErr.Line),+ Column: int32(syntaxErr.Column),+ },},}}- return nil, []Advice{+ return nil, []*storepb.Advice{{- Status: Error,- Code: Internal,+ Status: storepb.Advice_ERROR,+ Code: Internal.Int32(),Title: "Parse error",Content: err.Error(),- Line: 1,+ StartPosition: &storepb.Position{+ Line: 1,+ },},}}@@ -754,34 +780,38 @@ func relocationTiDBErrorLine(errorMessage string, baseLine int) string {return modified}-func tidbSyntaxCheck(statement string) (any, []Advice) {+func tidbSyntaxCheck(statement string) (any, []*storepb.Advice) {singleSQLs, err := base.SplitMultiSQL(storepb.Engine_TIDB, statement)if err != nil {- return nil, []Advice{+ return nil, []*storepb.Advice{{- Status: Warn,- Code: Internal,+ Status: storepb.Advice_WARNING,+ Code: Internal.Int32(),Title: "Syntax error",Content: err.Error(),- Line: 1,+ StartPosition: &storepb.Position{+ Line: 1,+ },},}}p := newTiDBParser()var returnNodes []tidbast.StmtNode- var adviceList []Advice+ var adviceList []*storepb.AdvicebaseLine := 0for _, singleSQL := range singleSQLs {nodes, _, err := p.Parse(singleSQL.Text, "", "")if err != nil {- return nil, []Advice{+ return nil, []*storepb.Advice{{- Status: Warn,- Code: Internal,+ Status: storepb.Advice_WARNING,+ Code: Internal.Int32(),Title: "Parse error",Content: relocationTiDBErrorLine(err.Error(), baseLine),- Line: 1 + baseLine,+ StartPosition: &storepb.Position{+ Line: int32(baseLine + 1),+ },},}}@@ -795,12 +825,14 @@ func tidbSyntaxCheck(statement string) (any, []Advice) {node.SetOriginTextPosition(singleSQL.LastLine)if n, ok := node.(*tidbast.CreateTableStmt); ok {if err := tidbbbparser.SetLineForMySQLCreateTableStmt(n); err != nil {- return nil, append(adviceList, Advice{- Status: Error,- Code: Internal,+ return nil, append(adviceList, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: Internal.Int32(),Title: "Set line error",Content: err.Error(),- Line: singleSQL.LastLine,+ StartPosition: &storepb.Position{+ Line: int32(singleSQL.LastLine),+ },})}}@@ -812,7 +844,7 @@ func tidbSyntaxCheck(statement string) (any, []Advice) {}// SQLReviewCheck checks the statements with sql review rules.-func SQLReviewCheck(statements string, ruleList []*storepb.SQLReviewRule, checkContext SQLReviewCheckContext) ([]Advice, error) {+func SQLReviewCheck(statements string, ruleList []*storepb.SQLReviewRule, checkContext SQLReviewCheckContext) ([]*storepb.Advice, error) {ast, result := syntaxCheck(statements, checkContext)if ast == nil || len(ruleList) == 0 {return result, nil@@ -874,12 +906,12 @@ func SQLReviewCheck(statements string, ruleList []*storepb.SQLReviewRule, checkC}sort.SliceStable(result, func(i, j int) bool {// Error is 2, warning is 1. So the error (value 2) should come first.- return result[i].Status.GetPriority() > result[j].Status.GetPriority()+ return result[i].Status.Number() > result[j].Status.Number()})if len(result) == 0 {- result = append(result, Advice{- Status: Success,- Code: Ok,+ result = append(result, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: Ok.Int32(),Title: "OK",Content: "",})@@ -887,148 +919,180 @@ func SQLReviewCheck(statements string, ruleList []*storepb.SQLReviewRule, checkCreturn result, nil}-func convertWalkThroughErrorToAdvice(checkContext SQLReviewCheckContext, err error) ([]Advice, error) {+func convertWalkThroughErrorToAdvice(checkContext SQLReviewCheckContext, err error) ([]*storepb.Advice, error) {walkThroughError, ok := err.(*catalog.WalkThroughError)if !ok {return nil, err}- var res []Advice+ var res []*storepb.Adviceswitch walkThroughError.Type {case catalog.ErrorTypeUnsupported:- res = append(res, Advice{- Status: Error,- Code: Unsupported,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: Unsupported.Int32(),Title: walkThroughError.Content,Content: "",- Line: walkThroughError.Line,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },})case catalog.ErrorTypeParseError:- res = append(res, Advice{- Status: Error,- Code: StatementSyntaxError,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: StatementSyntaxError.Int32(),Title: SyntaxErrorTitle,Content: walkThroughError.Content,})case catalog.ErrorTypeDeparseError:- res = append(res, Advice{- Status: Error,- Code: Internal,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: Internal.Int32(),Title: "Internal error for walk-through",Content: walkThroughError.Content,- Line: walkThroughError.Line,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },})case catalog.ErrorTypeAccessOtherDatabase:- res = append(res, Advice{- Status: Error,- Code: NotCurrentDatabase,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: NotCurrentDatabase.Int32(),Title: "Access other database",Content: walkThroughError.Content,- Line: walkThroughError.Line,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },})case catalog.ErrorTypeDatabaseIsDeleted:- res = append(res, Advice{- Status: Error,- Code: DatabaseIsDeleted,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: DatabaseIsDeleted.Int32(),Title: "Access deleted database",Content: walkThroughError.Content,- Line: walkThroughError.Line,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },})case catalog.ErrorTypeTableExists:- res = append(res, Advice{- Status: Error,- Code: TableExists,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: TableExists.Int32(),Title: "Table already exists",Content: walkThroughError.Content,- Line: walkThroughError.Line,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },})case catalog.ErrorTypeTableNotExists:- res = append(res, Advice{- Status: Error,- Code: TableNotExists,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: TableNotExists.Int32(),Title: "Table does not exist",Content: walkThroughError.Content,- Line: walkThroughError.Line,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },})case catalog.ErrorTypeColumnExists:- res = append(res, Advice{- Status: Error,- Code: ColumnExists,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: ColumnExists.Int32(),Title: "Column already exists",Content: walkThroughError.Content,- Line: walkThroughError.Line,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },})case catalog.ErrorTypeColumnNotExists:- res = append(res, Advice{- Status: Error,- Code: ColumnNotExists,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: ColumnNotExists.Int32(),Title: "Column does not exist",Content: walkThroughError.Content,- Line: walkThroughError.Line,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },})case catalog.ErrorTypeDropAllColumns:- res = append(res, Advice{- Status: Error,- Code: DropAllColumns,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: DropAllColumns.Int32(),Title: "Drop all columns",Content: walkThroughError.Content,- Line: walkThroughError.Line,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },})case catalog.ErrorTypePrimaryKeyExists:- res = append(res, Advice{- Status: Error,- Code: PrimaryKeyExists,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: PrimaryKeyExists.Int32(),Title: "Primary key exists",Content: walkThroughError.Content,- Line: walkThroughError.Line,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },})case catalog.ErrorTypeIndexExists:- res = append(res, Advice{- Status: Error,- Code: IndexExists,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: IndexExists.Int32(),Title: "Index exists",Content: walkThroughError.Content,- Line: walkThroughError.Line,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },})case catalog.ErrorTypeIndexEmptyKeys:- res = append(res, Advice{- Status: Error,- Code: IndexEmptyKeys,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: IndexEmptyKeys.Int32(),Title: "Index empty keys",Content: walkThroughError.Content,- Line: walkThroughError.Line,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },})case catalog.ErrorTypePrimaryKeyNotExists:- res = append(res, Advice{- Status: Error,- Code: PrimaryKeyNotExists,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: PrimaryKeyNotExists.Int32(),Title: "Primary key does not exist",Content: walkThroughError.Content,- Line: walkThroughError.Line,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },})case catalog.ErrorTypeIndexNotExists:- res = append(res, Advice{- Status: Error,- Code: IndexNotExists,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: IndexNotExists.Int32(),Title: "Index does not exist",Content: walkThroughError.Content,- Line: walkThroughError.Line,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },})case catalog.ErrorTypeIncorrectIndexName:- res = append(res, Advice{- Status: Error,- Code: IncorrectIndexName,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: IncorrectIndexName.Int32(),Title: "Incorrect index name",Content: walkThroughError.Content,- Line: walkThroughError.Line,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },})case catalog.ErrorTypeSpatialIndexKeyNullable:- res = append(res, Advice{- Status: Error,- Code: SpatialIndexKeyNullable,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: SpatialIndexKeyNullable.Int32(),Title: "Spatial index key must be NOT NULL",Content: walkThroughError.Content,- Line: walkThroughError.Line,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },})case catalog.ErrorTypeColumnIsReferencedByView:details := ""@@ -1044,13 +1108,15 @@ func convertWalkThroughErrorToAdvice(checkContext SQLReviewCheckContext, err err}}- res = append(res, Advice{- Status: Error,- Code: ColumnIsReferencedByView,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: ColumnIsReferencedByView.Int32(),Title: "Column is referenced by view",Content: walkThroughError.Content,- Line: walkThroughError.Line,- Details: details,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },+ Detail: details,})case catalog.ErrorTypeTableIsReferencedByView:details := ""@@ -1066,29 +1132,35 @@ func convertWalkThroughErrorToAdvice(checkContext SQLReviewCheckContext, err err}}- res = append(res, Advice{- Status: Error,- Code: TableIsReferencedByView,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: TableIsReferencedByView.Int32(),Title: "Table is referenced by view",Content: walkThroughError.Content,- Line: walkThroughError.Line,- Details: details,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },+ Detail: details,})case catalog.ErrorTypeInvalidColumnTypeForDefaultValue:- res = append(res, Advice{- Status: Error,- Code: InvalidColumnDefault,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: InvalidColumnDefault.Int32(),Title: "Invalid column default value",Content: walkThroughError.Content,- Line: walkThroughError.Line,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },})default:- res = append(res, Advice{- Status: Error,- Code: Internal,+ res = append(res, &storepb.Advice{+ Status: storepb.Advice_ERROR,+ Code: Internal.Int32(),Title: fmt.Sprintf("Failed to walk-through with code %d", walkThroughError.Type),Content: walkThroughError.Content,- Line: walkThroughError.Line,+ StartPosition: &storepb.Position{+ Line: int32(walkThroughError.Line),+ },})}diff --git a/backend/plugin/advisor/tidb/advisor_charset_allowlist.go b/backend/plugin/advisor/tidb/advisor_charset_allowlist.goindex 66ae45f297..79a4490c26 100644--- a/backend/plugin/advisor/tidb/advisor_charset_allowlist.go+++ b/backend/plugin/advisor/tidb/advisor_charset_allowlist.go@@ -27,7 +27,7 @@ type CharsetAllowlistAdvisor struct {}// Check checks for charset allowlist.-func (*CharsetAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*CharsetAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -56,9 +56,9 @@ func (*CharsetAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -67,8 +67,8 @@ func (*CharsetAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.}type charsetAllowlistChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -138,12 +138,14 @@ func (checker *charsetAllowlistChecker) Enter(in ast.Node) (ast.Node, bool) {}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" used disabled charset '%s'", checker.text, disabledCharset),- Line: line,+ StartPosition: &storepb.Position{+ Line: int32(line),+ },})}diff --git a/backend/plugin/advisor/tidb/advisor_collation_allowlist.go b/backend/plugin/advisor/tidb/advisor_collation_allowlist.goindex 2ca5e87508..09bb2c5f83 100644--- a/backend/plugin/advisor/tidb/advisor_collation_allowlist.go+++ b/backend/plugin/advisor/tidb/advisor_collation_allowlist.go@@ -27,7 +27,7 @@ type CollationAllowlistAdvisor struct {}// Check checks for collation allowlist.-func (*CollationAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*CollationAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -57,9 +57,9 @@ func (*CollationAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -68,8 +68,8 @@ func (*CollationAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}type collationAllowlistChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -139,12 +139,14 @@ func (checker *collationAllowlistChecker) Enter(in ast.Node) (ast.Node, bool) {}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" used disabled collation '%s'", checker.text, disabledCollation),- Line: line,+ StartPosition: &storepb.Position{+ Line: int32(line),+ },})}diff --git a/backend/plugin/advisor/tidb/advisor_colum_require_default.go b/backend/plugin/advisor/tidb/advisor_colum_require_default.goindex a991636f7d..d87c9d17e3 100644--- a/backend/plugin/advisor/tidb/advisor_colum_require_default.go+++ b/backend/plugin/advisor/tidb/advisor_colum_require_default.go@@ -28,7 +28,7 @@ type ColumRequireDefaultAdvisor struct {}// Check checks for column default requirement.-func (*ColumRequireDefaultAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumRequireDefaultAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -50,9 +50,9 @@ func (*ColumRequireDefaultAdvisor) Check(ctx advisor.Context, _ string) ([]advis}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -61,8 +61,8 @@ func (*ColumRequireDefaultAdvisor) Check(ctx advisor.Context, _ string) ([]advis}type columRequireDefaultChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -111,12 +111,14 @@ func (checker *columRequireDefaultChecker) Enter(in ast.Node) (ast.Node, bool) {}for _, column := range columnList {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NoDefault,+ Code: advisor.NoDefault.Int32(),Title: checker.title,Content: fmt.Sprintf("Column `%s`.`%s` doesn't have DEFAULT.", column.table, column.column),- Line: column.line,+ StartPosition: &storepb.Position{+ Line: int32(column.line),+ },})}diff --git a/backend/plugin/advisor/tidb/advisor_column_auto_increment_initial_value.go b/backend/plugin/advisor/tidb/advisor_column_auto_increment_initial_value.goindex 6090c85c6c..51708a68f0 100644--- a/backend/plugin/advisor/tidb/advisor_column_auto_increment_initial_value.go+++ b/backend/plugin/advisor/tidb/advisor_column_auto_increment_initial_value.go@@ -26,7 +26,7 @@ type ColumnAutoIncrementInitialValueAdvisor struct {}// Check checks for auto-increment column initial value.-func (*ColumnAutoIncrementInitialValueAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnAutoIncrementInitialValueAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -53,9 +53,9 @@ func (*ColumnAutoIncrementInitialValueAdvisor) Check(ctx advisor.Context, _ stri}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -64,8 +64,8 @@ func (*ColumnAutoIncrementInitialValueAdvisor) Check(ctx advisor.Context, _ stri}type columnAutoIncrementInitialValueChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -78,12 +78,14 @@ func (checker *columnAutoIncrementInitialValueChecker) Enter(in ast.Node) (ast.Nfor _, option := range createTable.Options {if option.Tp == ast.TableOptionAutoIncrement {if option.UintValue != uint64(checker.value) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.AutoIncrementColumnInitialValueNotMatch,+ Code: advisor.AutoIncrementColumnInitialValueNotMatch.Int32(),Title: checker.title,Content: fmt.Sprintf("The initial auto-increment value in table `%s` is %v, which doesn't equal %v", createTable.Table.Name.O, option.UintValue, checker.value),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}}diff --git a/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_integer.go b/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_integer.goindex d9402fafec..7309419a75 100644--- a/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_integer.go+++ b/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_integer.go@@ -28,7 +28,7 @@ type ColumnAutoIncrementMustIntegerAdvisor struct {}// Check checks for auto-increment column type.-func (*ColumnAutoIncrementMustIntegerAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnAutoIncrementMustIntegerAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -50,9 +50,9 @@ func (*ColumnAutoIncrementMustIntegerAdvisor) Check(ctx advisor.Context, _ strin}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -61,8 +61,8 @@ func (*ColumnAutoIncrementMustIntegerAdvisor) Check(ctx advisor.Context, _ strin}type columnAutoIncrementMustIntegerChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -114,12 +114,14 @@ func (checker *columnAutoIncrementMustIntegerChecker) Enter(in ast.Node) (ast.No}for _, column := range columnList {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.AutoIncrementColumnNotInteger,+ Code: advisor.AutoIncrementColumnNotInteger.Int32(),Title: checker.title,Content: fmt.Sprintf("Auto-increment column `%s`.`%s` requires integer type", column.table, column.column),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}diff --git a/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_unsigned.go b/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_unsigned.goindex c87f48433e..c787ef3486 100644--- a/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_unsigned.go+++ b/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_unsigned.go@@ -27,7 +27,7 @@ type ColumnAutoIncrementMustUnsignedAdvisor struct {}// Check checks for unsigned auto-increment column.-func (*ColumnAutoIncrementMustUnsignedAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnAutoIncrementMustUnsignedAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -49,9 +49,9 @@ func (*ColumnAutoIncrementMustUnsignedAdvisor) Check(ctx advisor.Context, _ stri}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -60,8 +60,8 @@ func (*ColumnAutoIncrementMustUnsignedAdvisor) Check(ctx advisor.Context, _ stri}type columnAutoIncrementMustUnsignedChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -107,12 +107,14 @@ func (checker *columnAutoIncrementMustUnsignedChecker) Enter(in ast.Node) (ast.N}for _, column := range columnList {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.AutoIncrementColumnSigned,+ Code: advisor.AutoIncrementColumnSigned.Int32(),Title: checker.title,Content: fmt.Sprintf("Auto-increment column `%s`.`%s` is not UNSIGNED type", column.table, column.column),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}diff --git a/backend/plugin/advisor/tidb/advisor_column_comment_convention.go b/backend/plugin/advisor/tidb/advisor_column_comment_convention.goindex 33c0bf9a44..4e4806aabf 100644--- a/backend/plugin/advisor/tidb/advisor_column_comment_convention.go+++ b/backend/plugin/advisor/tidb/advisor_column_comment_convention.go@@ -27,7 +27,7 @@ type ColumnCommentConventionAdvisor struct {}// Check checks for column comment convention.-func (*ColumnCommentConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnCommentConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -55,9 +55,9 @@ func (*ColumnCommentConventionAdvisor) Check(ctx advisor.Context, _ string) ([]a}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -66,8 +66,8 @@ func (*ColumnCommentConventionAdvisor) Check(ctx advisor.Context, _ string) ([]a}type columnCommentConventionChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -128,21 +128,25 @@ func (checker *columnCommentConventionChecker) Enter(in ast.Node) (ast.Node, boofor _, column := range columnList {if checker.required && !column.exist {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NoColumnComment,+ Code: advisor.NoColumnComment.Int32(),Title: checker.title,Content: fmt.Sprintf("Column `%s`.`%s` requires comments", column.table, column.column),- Line: column.line,+ StartPosition: &storepb.Position{+ Line: int32(column.line),+ },})}if checker.maxLength >= 0 && len(column.comment) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.ColumnCommentTooLong,+ Code: advisor.ColumnCommentTooLong.Int32(),Title: checker.title,Content: fmt.Sprintf("The length of column `%s`.`%s` comment should be within %d characters", column.table, column.column, checker.maxLength),- Line: column.line,+ StartPosition: &storepb.Position{+ Line: int32(column.line),+ },})}}@@ -161,9 +165,9 @@ func (checker *columnCommentConventionChecker) columnComment(column *ast.ColumnDcomment, err := restoreNode(option.Expr, format.RestoreStringWithoutCharset)if err != nil {comment = ""- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: "Internal error for parsing column comment",Content: fmt.Sprintf("\"%q\" meet internal error %s", checker.text, err),})diff --git a/backend/plugin/advisor/tidb/advisor_column_current_time_count_limit.go b/backend/plugin/advisor/tidb/advisor_column_current_time_count_limit.goindex d023e5e018..89255ad047 100644--- a/backend/plugin/advisor/tidb/advisor_column_current_time_count_limit.go+++ b/backend/plugin/advisor/tidb/advisor_column_current_time_count_limit.go@@ -34,7 +34,7 @@ type ColumnCurrentTimeCountLimitAdvisor struct {}// Check checks for current time column count limit.-func (*ColumnCurrentTimeCountLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnCurrentTimeCountLimitAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -60,8 +60,8 @@ func (*ColumnCurrentTimeCountLimitAdvisor) Check(ctx advisor.Context, _ string)}type columnCurrentTimeCountLimitChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -75,7 +75,7 @@ type tableData struct {line int}-func (checker *columnCurrentTimeCountLimitChecker) generateAdvice() []advisor.Advice {+func (checker *columnCurrentTimeCountLimitChecker) generateAdvice() []*storepb.Advice {var tableList []tableDatafor _, table := range checker.tableSet {tableList = append(tableList, table)@@ -85,28 +85,32 @@ func (checker *columnCurrentTimeCountLimitChecker) generateAdvice() []advisor.Ad})for _, table := range tableList {if table.defaultCurrentTimeCount > maxDefaultCurrentTimeColumCount {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DefaultCurrentTimeColumnCountExceedsLimit,+ Code: advisor.DefaultCurrentTimeColumnCountExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("Table `%s` has %d DEFAULT CURRENT_TIMESTAMP() columns. The count greater than %d.", table.tableName, table.defaultCurrentTimeCount, maxDefaultCurrentTimeColumCount),- Line: table.line,+ StartPosition: &storepb.Position{+ Line: int32(table.line),+ },})}if table.onUpdateCurrentTimeCount > maxOnUpdateCurrentTimeColumnCount {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.OnUpdateCurrentTimeColumnCountExceedsLimit,+ Code: advisor.OnUpdateCurrentTimeColumnCountExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("Table `%s` has %d ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than %d.", table.tableName, table.onUpdateCurrentTimeCount, maxOnUpdateCurrentTimeColumnCount),- Line: table.line,+ StartPosition: &storepb.Position{+ Line: int32(table.line),+ },})}}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/tidb/advisor_column_disallow_changing.go b/backend/plugin/advisor/tidb/advisor_column_disallow_changing.goindex bfb311c685..3d6311564e 100644--- a/backend/plugin/advisor/tidb/advisor_column_disallow_changing.go+++ b/backend/plugin/advisor/tidb/advisor_column_disallow_changing.go@@ -26,7 +26,7 @@ type ColumnDisallowChangingAdvisor struct {}// Check checks for disallow CHANGE COLUMN statement.-func (*ColumnDisallowChangingAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnDisallowChangingAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -48,9 +48,9 @@ func (*ColumnDisallowChangingAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -59,8 +59,8 @@ func (*ColumnDisallowChangingAdvisor) Check(ctx advisor.Context, _ string) ([]ad}type columnDisallowChangingChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -71,12 +71,14 @@ func (checker *columnDisallowChangingChecker) Enter(in ast.Node) (ast.Node, boolif node, ok := in.(*ast.AlterTableStmt); ok {for _, spec := range node.Specs {if spec.Tp == ast.AlterTableChangeColumn {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.UseChangeColumnStatement,+ Code: advisor.UseChangeColumnStatement.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" contains CHANGE COLUMN statement", checker.text),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})break}diff --git a/backend/plugin/advisor/tidb/advisor_column_disallow_changing_order.go b/backend/plugin/advisor/tidb/advisor_column_disallow_changing_order.goindex be85d0fd87..7dac32eff2 100644--- a/backend/plugin/advisor/tidb/advisor_column_disallow_changing_order.go+++ b/backend/plugin/advisor/tidb/advisor_column_disallow_changing_order.go@@ -26,7 +26,7 @@ type ColumnDisallowChangingOrderAdvisor struct {}// Check checks for disallow changing column order.-func (*ColumnDisallowChangingOrderAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnDisallowChangingOrderAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -48,9 +48,9 @@ func (*ColumnDisallowChangingOrderAdvisor) Check(ctx advisor.Context, _ string)}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -59,8 +59,8 @@ func (*ColumnDisallowChangingOrderAdvisor) Check(ctx advisor.Context, _ string)}type columnDisallowChangingOrderChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -72,12 +72,14 @@ func (checker *columnDisallowChangingOrderChecker) Enter(in ast.Node) (ast.Node,for _, spec := range node.Specs {if (spec.Tp == ast.AlterTableChangeColumn || spec.Tp == ast.AlterTableModifyColumn) &&spec.Position.Tp != ast.ColumnPositionNone {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.ChangeColumnOrder,+ Code: advisor.ChangeColumnOrder.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" changes column order", checker.text),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})break}diff --git a/backend/plugin/advisor/tidb/advisor_column_disallow_changing_type.go b/backend/plugin/advisor/tidb/advisor_column_disallow_changing_type.goindex c5fb0b11a5..0a4c16f440 100644--- a/backend/plugin/advisor/tidb/advisor_column_disallow_changing_type.go+++ b/backend/plugin/advisor/tidb/advisor_column_disallow_changing_type.go@@ -28,7 +28,7 @@ type ColumnDisallowChangingTypeAdvisor struct {}// Check checks for disallow changing column type..-func (*ColumnDisallowChangingTypeAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnDisallowChangingTypeAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -51,9 +51,9 @@ func (*ColumnDisallowChangingTypeAdvisor) Check(ctx advisor.Context, _ string) (}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -62,8 +62,8 @@ func (*ColumnDisallowChangingTypeAdvisor) Check(ctx advisor.Context, _ string) (}type columnDisallowChangingTypeChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -88,12 +88,14 @@ func (checker *columnDisallowChangingTypeChecker) Enter(in ast.Node) (ast.Node,}if changeType {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.ChangeColumnType,+ Code: advisor.ChangeColumnType.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" changes column type", checker.text),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}diff --git a/backend/plugin/advisor/tidb/advisor_column_disallow_drop_in_index.go b/backend/plugin/advisor/tidb/advisor_column_disallow_drop_in_index.goindex 8e92c1b424..70f74ea83f 100644--- a/backend/plugin/advisor/tidb/advisor_column_disallow_drop_in_index.go+++ b/backend/plugin/advisor/tidb/advisor_column_disallow_drop_in_index.go@@ -27,7 +27,7 @@ type ColumnDisallowDropInIndexAdvisor struct {}// Check checks for disallow Drop COLUMN in index statement.-func (*ColumnDisallowDropInIndexAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnDisallowDropInIndexAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -52,9 +52,9 @@ func (*ColumnDisallowDropInIndexAdvisor) Check(ctx advisor.Context, _ string) ([}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -64,8 +64,8 @@ func (*ColumnDisallowDropInIndexAdvisor) Check(ctx advisor.Context, _ string) ([}type columnDisallowDropInIndexChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringtables tableState // the variable mean whether the column in index.@@ -112,12 +112,14 @@ func (checker *columnDisallowDropInIndexChecker) dropColumn(in ast.Node) (ast.NocolName := spec.OldColumnName.Name.String()if !checker.canDrop(table, colName) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DropIndexColumn,+ Code: advisor.DropIndexColumn.Int32(),Title: checker.title,Content: fmt.Sprintf("`%s`.`%s` cannot drop index column", table, colName),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}}diff --git a/backend/plugin/advisor/tidb/advisor_column_disallow_set_charset.go b/backend/plugin/advisor/tidb/advisor_column_disallow_set_charset.goindex 3bcbb14e4e..9ea8c55a89 100644--- a/backend/plugin/advisor/tidb/advisor_column_disallow_set_charset.go+++ b/backend/plugin/advisor/tidb/advisor_column_disallow_set_charset.go@@ -26,7 +26,7 @@ type ColumnDisallowSetCharsetAdvisor struct {}// Check checks for disallow set column charset.-func (*ColumnDisallowSetCharsetAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnDisallowSetCharsetAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -48,9 +48,9 @@ func (*ColumnDisallowSetCharsetAdvisor) Check(ctx advisor.Context, _ string) ([]}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -59,8 +59,8 @@ func (*ColumnDisallowSetCharsetAdvisor) Check(ctx advisor.Context, _ string) ([]}type columnDisallowSetCharsetChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -101,12 +101,14 @@ func (checker *columnDisallowSetCharsetChecker) Enter(in ast.Node) (ast.Node, bo}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.SetColumnCharset,+ Code: advisor.SetColumnCharset.Int32(),Title: checker.title,Content: fmt.Sprintf("Disallow set column charset but \"%s\" does", checker.text),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}diff --git a/backend/plugin/advisor/tidb/advisor_column_maximum_character_length.go b/backend/plugin/advisor/tidb/advisor_column_maximum_character_length.goindex 445bf711fa..348a2a5bf4 100644--- a/backend/plugin/advisor/tidb/advisor_column_maximum_character_length.go+++ b/backend/plugin/advisor/tidb/advisor_column_maximum_character_length.go@@ -27,7 +27,7 @@ type ColumnMaximumCharacterLengthAdvisor struct {}// Check checks for maximum character length.-func (*ColumnMaximumCharacterLengthAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnMaximumCharacterLengthAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -54,9 +54,9 @@ func (*ColumnMaximumCharacterLengthAdvisor) Check(ctx advisor.Context, _ string)}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,8 +65,8 @@ func (*ColumnMaximumCharacterLengthAdvisor) Check(ctx advisor.Context, _ string)}type columnMaximumCharacterLengthChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -115,12 +115,14 @@ func (checker *columnMaximumCharacterLengthChecker) Enter(in ast.Node) (ast.Node}if tableName != "" {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.CharLengthExceedsLimit,+ Code: advisor.CharLengthExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("The length of the CHAR column `%s` is bigger than %d, please use VARCHAR instead", columnName, checker.maximum),- Line: line,+ StartPosition: &storepb.Position{+ Line: int32(line),+ },})}diff --git a/backend/plugin/advisor/tidb/advisor_column_no_null.go b/backend/plugin/advisor/tidb/advisor_column_no_null.goindex 4f19a7d6d0..08580d2e48 100644--- a/backend/plugin/advisor/tidb/advisor_column_no_null.go+++ b/backend/plugin/advisor/tidb/advisor_column_no_null.go@@ -26,7 +26,7 @@ type ColumnNoNullAdvisor struct {}// Check checks for column no NULL value.-func (*ColumnNoNullAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnNoNullAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -51,14 +51,14 @@ func (*ColumnNoNullAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advi}type columnNoNullChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringcolumnSet map[string]columnNamecatalog *catalog.Finder}-func (checker *columnNoNullChecker) generateAdvice() []advisor.Advice {+func (checker *columnNoNullChecker) generateAdvice() []*storepb.Advice {var columnList []columnNamefor _, column := range checker.columnSet {columnList = append(columnList, column)@@ -76,20 +76,22 @@ func (checker *columnNoNullChecker) generateAdvice() []advisor.Advice {ColumnName: column.columnName,})if col != nil && col.Nullable() {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.ColumnCannotNull,+ Code: advisor.ColumnCannotNull.Int32(),Title: checker.title,Content: fmt.Sprintf("`%s`.`%s` cannot have NULL value", column.tableName, column.columnName),- Line: column.line,+ StartPosition: &storepb.Position{+ Line: int32(column.line),+ },})}}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/tidb/advisor_column_required.go b/backend/plugin/advisor/tidb/advisor_column_required.goindex 721d7e233b..43cb3444a9 100644--- a/backend/plugin/advisor/tidb/advisor_column_required.go+++ b/backend/plugin/advisor/tidb/advisor_column_required.go@@ -26,7 +26,7 @@ type ColumnRequirementAdvisor struct {}// Check checks for the column requirement.-func (*ColumnRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -60,8 +60,8 @@ func (*ColumnRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]advisor}type columnRequirementChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringrequiredColumns columnSettables tableState@@ -114,7 +114,7 @@ func (*columnRequirementChecker) Leave(in ast.Node) (ast.Node, bool) {return in, true}-func (v *columnRequirementChecker) generateAdviceList() []advisor.Advice {+func (v *columnRequirementChecker) generateAdviceList() []*storepb.Advice {// Order it cause the random iteration order in Go, see https://go.dev/blog/mapstableList := v.tables.tableList()for _, tableName := range tableList {@@ -128,20 +128,22 @@ func (v *columnRequirementChecker) generateAdviceList() []advisor.Advice {if len(missingColumns) > 0 {// Order it cause the random iteration order in Go, see https://go.dev/blog/mapssort.Strings(missingColumns)- v.adviceList = append(v.adviceList, advisor.Advice{+ v.adviceList = append(v.adviceList, &storepb.Advice{Status: v.level,- Code: advisor.NoRequiredColumn,+ Code: advisor.NoRequiredColumn.Int32(),Title: v.title,Content: fmt.Sprintf("Table `%s` requires columns: %s", tableName, strings.Join(missingColumns, ", ")),- Line: v.line[tableName],+ StartPosition: &storepb.Position{+ Line: int32(v.line[tableName]),+ },})}}if len(v.adviceList) == 0 {- v.adviceList = append(v.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ v.adviceList = append(v.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/tidb/advisor_column_set_default_for_not_null.go b/backend/plugin/advisor/tidb/advisor_column_set_default_for_not_null.goindex 6261b920e2..2aaee1fe45 100644--- a/backend/plugin/advisor/tidb/advisor_column_set_default_for_not_null.go+++ b/backend/plugin/advisor/tidb/advisor_column_set_default_for_not_null.go@@ -26,7 +26,7 @@ type ColumnSetDefaultForNotNullAdvisor struct {}// Check checks for set default value for not null column.-func (*ColumnSetDefaultForNotNullAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnSetDefaultForNotNullAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -47,9 +47,9 @@ func (*ColumnSetDefaultForNotNullAdvisor) Check(ctx advisor.Context, _ string) (}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -58,8 +58,8 @@ func (*ColumnSetDefaultForNotNullAdvisor) Check(ctx advisor.Context, _ string) (}type columnSetDefaultForNotNullChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext string}@@ -121,12 +121,14 @@ func (checker *columnSetDefaultForNotNullChecker) Enter(in ast.Node) (ast.Node,}for _, column := range notNullColumnWithNoDefault {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NotNullColumnWithNoDefault,+ Code: advisor.NotNullColumnWithNoDefault.Int32(),Title: checker.title,Content: fmt.Sprintf("Column `%s`.`%s` is NOT NULL but doesn't have DEFAULT", column.tableName, column.columnName),- Line: column.line,+ StartPosition: &storepb.Position{+ Line: int32(column.line),+ },})}diff --git a/backend/plugin/advisor/tidb/advisor_column_type_disallow_list.go b/backend/plugin/advisor/tidb/advisor_column_type_disallow_list.goindex 7761b020d1..057cfd6ca7 100644--- a/backend/plugin/advisor/tidb/advisor_column_type_disallow_list.go+++ b/backend/plugin/advisor/tidb/advisor_column_type_disallow_list.go@@ -27,7 +27,7 @@ type ColumnTypeDisallowListAdvisor struct {}// Check checks for column type restriction.-func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -57,9 +57,9 @@ func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -68,8 +68,8 @@ func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]ad}type columnTypeDisallowListChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -127,12 +127,14 @@ func (checker *columnTypeDisallowListChecker) Enter(in ast.Node) (ast.Node, bool}for _, column := range columnList {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DisabledColumnType,+ Code: advisor.DisabledColumnType.Int32(),Title: checker.title,Content: fmt.Sprintf("Disallow column type %s but column `%s`.`%s` is", column.tp, column.table, column.column),- Line: column.line,+ StartPosition: &storepb.Position{+ Line: int32(column.line),+ },})}diff --git a/backend/plugin/advisor/tidb/advisor_database_drop_empty_db.go b/backend/plugin/advisor/tidb/advisor_database_drop_empty_db.goindex 0637087533..8c1a76d4b6 100644--- a/backend/plugin/advisor/tidb/advisor_database_drop_empty_db.go+++ b/backend/plugin/advisor/tidb/advisor_database_drop_empty_db.go@@ -25,7 +25,7 @@ type DatabaseAllowDropIfEmptyAdvisor struct {}// Check checks for drop table naming convention.-func (*DatabaseAllowDropIfEmptyAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*DatabaseAllowDropIfEmptyAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -46,9 +46,9 @@ func (*DatabaseAllowDropIfEmptyAdvisor) Check(ctx advisor.Context, _ string) ([]}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -57,8 +57,8 @@ func (*DatabaseAllowDropIfEmptyAdvisor) Check(ctx advisor.Context, _ string) ([]}type allowDropEmptyDBChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringcatalog *catalog.Finder}@@ -67,20 +67,24 @@ type allowDropEmptyDBChecker struct {func (v *allowDropEmptyDBChecker) Enter(in ast.Node) (ast.Node, bool) {if node, ok := in.(*ast.DropDatabaseStmt); ok {if v.catalog.Origin.DatabaseName() != node.Name.O {- v.adviceList = append(v.adviceList, advisor.Advice{+ v.adviceList = append(v.adviceList, &storepb.Advice{Status: v.level,- Code: advisor.NotCurrentDatabase,+ Code: advisor.NotCurrentDatabase.Int32(),Title: v.title,Content: fmt.Sprintf("Database `%s` that is trying to be deleted is not the current database `%s`", node.Name, v.catalog.Origin.DatabaseName()),- Line: node.OriginTextPosition(),+ StartPosition: &storepb.Position{+ Line: int32(node.OriginTextPosition()),+ },})} else if !v.catalog.Origin.HasNoTable() {- v.adviceList = append(v.adviceList, advisor.Advice{+ v.adviceList = append(v.adviceList, &storepb.Advice{Status: v.level,- Code: advisor.DatabaseNotEmpty,+ Code: advisor.DatabaseNotEmpty.Int32(),Title: v.title,Content: fmt.Sprintf("Database `%s` is not allowed to drop if not empty", node.Name),- Line: node.OriginTextPosition(),+ StartPosition: &storepb.Position{+ Line: int32(node.OriginTextPosition()),+ },})}}diff --git a/backend/plugin/advisor/tidb/advisor_index_key_number_limit.go b/backend/plugin/advisor/tidb/advisor_index_key_number_limit.goindex 13fcbac2fa..80bd9d9374 100644--- a/backend/plugin/advisor/tidb/advisor_index_key_number_limit.go+++ b/backend/plugin/advisor/tidb/advisor_index_key_number_limit.go@@ -26,7 +26,7 @@ type IndexKeyNumberLimitAdvisor struct {}// Check checks for index key number limit.-func (*IndexKeyNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*IndexKeyNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -53,9 +53,9 @@ func (*IndexKeyNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advis}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -64,8 +64,8 @@ func (*IndexKeyNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advis}type indexKeyNumberLimitChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -112,12 +112,14 @@ func (checker *indexKeyNumberLimitChecker) Enter(in ast.Node) (ast.Node, bool) {}for _, index := range indexList {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.IndexKeyNumberExceedsLimit,+ Code: advisor.IndexKeyNumberExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("The number of index `%s` in table `%s` should be not greater than %d", index.index, index.table, checker.max),- Line: index.line,+ StartPosition: &storepb.Position{+ Line: int32(index.line),+ },})}diff --git a/backend/plugin/advisor/tidb/advisor_index_no_duplicate_column.go b/backend/plugin/advisor/tidb/advisor_index_no_duplicate_column.goindex e2e6c51309..b1cfcb3c7f 100644--- a/backend/plugin/advisor/tidb/advisor_index_no_duplicate_column.go+++ b/backend/plugin/advisor/tidb/advisor_index_no_duplicate_column.go@@ -26,7 +26,7 @@ type IndexNoDuplicateColumnAdvisor struct {}// Check checks for no duplicate columns in index.-func (*IndexNoDuplicateColumnAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*IndexNoDuplicateColumnAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -48,9 +48,9 @@ func (*IndexNoDuplicateColumnAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -59,8 +59,8 @@ func (*IndexNoDuplicateColumnAdvisor) Check(ctx advisor.Context, _ string) ([]ad}type indexNoDuplicateColumnChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -130,12 +130,14 @@ func (checker *indexNoDuplicateColumnChecker) Enter(in ast.Node) (ast.Node, bool}for _, column := range columnList {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.DuplicateColumnInIndex,+ Code: advisor.DuplicateColumnInIndex.Int32(),Title: checker.title,Content: fmt.Sprintf("%s `%s` has duplicate column `%s`.`%s`", column.tp, column.index, column.table, column.column),- Line: column.line,+ StartPosition: &storepb.Position{+ Line: int32(column.line),+ },})}diff --git a/backend/plugin/advisor/tidb/advisor_index_pk_type.go b/backend/plugin/advisor/tidb/advisor_index_pk_type.goindex 09f399f032..f78758d093 100644--- a/backend/plugin/advisor/tidb/advisor_index_pk_type.go+++ b/backend/plugin/advisor/tidb/advisor_index_pk_type.go@@ -29,7 +29,7 @@ type IndexPkTypeAdvisor struct {}// Check checks for correct type of PK.-func (*IndexPkTypeAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*IndexPkTypeAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -52,9 +52,9 @@ func (*IndexPkTypeAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advic}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -88,8 +88,8 @@ func (t tableNewColumn) delete(tableName string, columnName string) {}type indexPkTypeChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringline map[string]intcatalog *catalog.Finder@@ -141,12 +141,14 @@ func (v *indexPkTypeChecker) Enter(in ast.Node) (ast.Node, bool) {}}for _, pd := range pkDataList {- v.adviceList = append(v.adviceList, advisor.Advice{+ v.adviceList = append(v.adviceList, &storepb.Advice{Status: v.level,- Code: advisor.IndexPKType,+ Code: advisor.IndexPKType.Int32(),Title: v.title,Content: fmt.Sprintf("Columns in primary key must be INT/BIGINT but `%s`.`%s` is %s", pd.table, pd.column, pd.columnType),- Line: pd.line,+ StartPosition: &storepb.Position{+ Line: int32(pd.line),+ },})}return in, falsediff --git a/backend/plugin/advisor/tidb/advisor_index_primary_key_type_allowlist.go b/backend/plugin/advisor/tidb/advisor_index_primary_key_type_allowlist.goindex 22d04a7a5c..cd85d0d9dd 100644--- a/backend/plugin/advisor/tidb/advisor_index_primary_key_type_allowlist.go+++ b/backend/plugin/advisor/tidb/advisor_index_primary_key_type_allowlist.go@@ -29,7 +29,7 @@ type IndexPrimaryKeyTypeAllowlistAdvisor struct {}// Check checks for primary key type allowlist.-func (*IndexPrimaryKeyTypeAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*IndexPrimaryKeyTypeAllowlistAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -62,9 +62,9 @@ func (*IndexPrimaryKeyTypeAllowlistAdvisor) Check(ctx advisor.Context, _ string)}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -73,8 +73,8 @@ func (*IndexPrimaryKeyTypeAllowlistAdvisor) Check(ctx advisor.Context, _ string)}type indexPrimaryKeyTypeAllowlistChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -121,12 +121,14 @@ func (v *indexPrimaryKeyTypeAllowlistChecker) Enter(in ast.Node) (ast.Node, bool}}for _, pd := range pkDataList {- v.adviceList = append(v.adviceList, advisor.Advice{+ v.adviceList = append(v.adviceList, &storepb.Advice{Status: v.level,- Code: advisor.IndexPKType,+ Code: advisor.IndexPKType.Int32(),Title: v.title,Content: fmt.Sprintf("The column `%s` in table `%s` is one of the primary key, but its type \"%s\" is not in allowlist", pd.column, pd.table, pd.columnType),- Line: pd.line,+ StartPosition: &storepb.Position{+ Line: int32(pd.line),+ },})}return in, falsediff --git a/backend/plugin/advisor/tidb/advisor_index_total_number_limit.go b/backend/plugin/advisor/tidb/advisor_index_total_number_limit.goindex 185b2b76f2..9bf47047c9 100644--- a/backend/plugin/advisor/tidb/advisor_index_total_number_limit.go+++ b/backend/plugin/advisor/tidb/advisor_index_total_number_limit.go@@ -28,7 +28,7 @@ type IndexTotalNumberLimitAdvisor struct {}// Check checks for index total number limit.-func (*IndexTotalNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*IndexTotalNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -60,8 +60,8 @@ func (*IndexTotalNumberLimitAdvisor) Check(ctx advisor.Context, _ string) ([]adv}type indexTotalNumberLimitChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -70,7 +70,7 @@ type indexTotalNumberLimitChecker struct {catalog *catalog.Finder}-func (checker *indexTotalNumberLimitChecker) generateAdvice() []advisor.Advice {+func (checker *indexTotalNumberLimitChecker) generateAdvice() []*storepb.Advice {type tableName struct {name stringline int@@ -90,20 +90,22 @@ func (checker *indexTotalNumberLimitChecker) generateAdvice() []advisor.Advice {for _, table := range tableList {tableInfo := checker.catalog.Final.FindTable(&catalog.TableFind{TableName: table.name})if tableInfo != nil && tableInfo.CountIndex() > checker.max {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.IndexCountExceedsLimit,+ Code: advisor.IndexCountExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("The count of index in table `%s` should be no more than %d, but found %d", table.name, checker.max, tableInfo.CountIndex()),- Line: table.line,+ StartPosition: &storepb.Position{+ Line: int32(table.line),+ },})}}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/tidb/advisor_index_type_no_blob.go b/backend/plugin/advisor/tidb/advisor_index_type_no_blob.goindex dab21394fc..7138194030 100644--- a/backend/plugin/advisor/tidb/advisor_index_type_no_blob.go+++ b/backend/plugin/advisor/tidb/advisor_index_type_no_blob.go@@ -30,7 +30,7 @@ type IndexTypeNoBlobAdvisor struct {}// Check checks for index type no blob.-func (*IndexTypeNoBlobAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*IndexTypeNoBlobAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -54,9 +54,9 @@ func (*IndexTypeNoBlobAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.A}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,8 +65,8 @@ func (*IndexTypeNoBlobAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.A}type indexTypeNoBlobChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -118,12 +118,14 @@ func (v *indexTypeNoBlobChecker) Enter(in ast.Node) (ast.Node, bool) {}}for _, pd := range pkDataList {- v.adviceList = append(v.adviceList, advisor.Advice{+ v.adviceList = append(v.adviceList, &storepb.Advice{Status: v.level,- Code: advisor.IndexTypeNoBlob,+ Code: advisor.IndexTypeNoBlob.Int32(),Title: v.title,Content: fmt.Sprintf("Columns in index must not be BLOB but `%s`.`%s` is %s", pd.table, pd.column, pd.columnType),- Line: pd.line,+ StartPosition: &storepb.Position{+ Line: int32(pd.line),+ },})}return in, falsediff --git a/backend/plugin/advisor/tidb/advisor_insert_disallow_order_by_rand.go b/backend/plugin/advisor/tidb/advisor_insert_disallow_order_by_rand.goindex f1d4d84a23..98fbb88a2c 100644--- a/backend/plugin/advisor/tidb/advisor_insert_disallow_order_by_rand.go+++ b/backend/plugin/advisor/tidb/advisor_insert_disallow_order_by_rand.go@@ -26,7 +26,7 @@ type InsertDisallowOrderByRandAdvisor struct {}// Check checks for to disallow order by rand in INSERT statements.-func (*InsertDisallowOrderByRandAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*InsertDisallowOrderByRandAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -48,9 +48,9 @@ func (*InsertDisallowOrderByRandAdvisor) Check(ctx advisor.Context, _ string) ([}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -59,8 +59,8 @@ func (*InsertDisallowOrderByRandAdvisor) Check(ctx advisor.Context, _ string) ([}type insertDisallowOrderByRandChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -87,12 +87,14 @@ func (checker *insertDisallowOrderByRandChecker) Enter(in ast.Node) (ast.Node, b}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" uses ORDER BY RAND in the INSERT statement", checker.text),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}diff --git a/backend/plugin/advisor/tidb/advisor_insert_must_specify_column.go b/backend/plugin/advisor/tidb/advisor_insert_must_specify_column.goindex 114be5b6b5..99f1d7b205 100644--- a/backend/plugin/advisor/tidb/advisor_insert_must_specify_column.go+++ b/backend/plugin/advisor/tidb/advisor_insert_must_specify_column.go@@ -26,7 +26,7 @@ type InsertMustSpecifyColumnAdvisor struct {}// Check checks for to enforce column specified.-func (*InsertMustSpecifyColumnAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*InsertMustSpecifyColumnAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -48,9 +48,9 @@ func (*InsertMustSpecifyColumnAdvisor) Check(ctx advisor.Context, _ string) ([]a}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -59,8 +59,8 @@ func (*InsertMustSpecifyColumnAdvisor) Check(ctx advisor.Context, _ string) ([]a}type insertMustSpecifyColumnChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -70,12 +70,14 @@ type insertMustSpecifyColumnChecker struct {func (checker *insertMustSpecifyColumnChecker) Enter(in ast.Node) (ast.Node, bool) {if node, ok := in.(*ast.InsertStmt); ok {if node.Columns == nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.InsertNotSpecifyColumn,+ Code: advisor.InsertNotSpecifyColumn.Int32(),Title: checker.title,Content: fmt.Sprintf("The INSERT statement must specify columns but \"%s\" does not", checker.text),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}}diff --git a/backend/plugin/advisor/tidb/advisor_migration_compatibility.go b/backend/plugin/advisor/tidb/advisor_migration_compatibility.goindex 56f4da6351..76870716b9 100644--- a/backend/plugin/advisor/tidb/advisor_migration_compatibility.go+++ b/backend/plugin/advisor/tidb/advisor_migration_compatibility.go@@ -25,7 +25,7 @@ type CompatibilityAdvisor struct {}// Check checks schema backward compatibility.-func (*CompatibilityAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*CompatibilityAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -45,9 +45,9 @@ func (*CompatibilityAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Adv}if len(c.adviceList) == 0 {- c.adviceList = append(c.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ c.adviceList = append(c.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -56,8 +56,8 @@ func (*CompatibilityAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Adv}type compatibilityChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringlastCreateTable string}@@ -157,12 +157,14 @@ func (v *compatibilityChecker) Enter(in ast.Node) (ast.Node, bool) {}if code != advisor.Ok {- v.adviceList = append(v.adviceList, advisor.Advice{+ v.adviceList = append(v.adviceList, &storepb.Advice{Status: v.level,- Code: code,+ Code: code.Int32(),Title: v.title,Content: fmt.Sprintf("\"%s\" may cause incompatibility with the existing data and code", in.Text()),- Line: in.OriginTextPosition(),+ StartPosition: &storepb.Position{+ Line: int32(in.OriginTextPosition()),+ },})}return in, falsediff --git a/backend/plugin/advisor/tidb/advisor_naming_auto_increment_column.go b/backend/plugin/advisor/tidb/advisor_naming_auto_increment_column.goindex 6f75c60ca2..178130ce36 100644--- a/backend/plugin/advisor/tidb/advisor_naming_auto_increment_column.go+++ b/backend/plugin/advisor/tidb/advisor_naming_auto_increment_column.go@@ -27,7 +27,7 @@ type NamingAutoIncrementColumnAdvisor struct {}// Check checks for auto-increment naming convention.-func (*NamingAutoIncrementColumnAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingAutoIncrementColumnAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -55,9 +55,9 @@ func (*NamingAutoIncrementColumnAdvisor) Check(ctx advisor.Context, _ string) ([}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -66,8 +66,8 @@ func (*NamingAutoIncrementColumnAdvisor) Check(ctx advisor.Context, _ string) ([}type namingAutoIncrementColumnChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -124,21 +124,25 @@ func (checker *namingAutoIncrementColumnChecker) Enter(in ast.Node) (ast.Node, bfor _, column := range columnList {if !checker.format.MatchString(column.name) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingAutoIncrementColumnConventionMismatch,+ Code: advisor.NamingAutoIncrementColumnConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("`%s`.`%s` mismatches auto_increment column naming convention, naming format should be %q", tableName, column.name, checker.format),- Line: column.line,+ StartPosition: &storepb.Position{+ Line: int32(column.line),+ },})}if checker.maxLength > 0 && len(column.name) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingAutoIncrementColumnConventionMismatch,+ Code: advisor.NamingAutoIncrementColumnConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("`%s`.`%s` mismatches auto_increment column naming convention, its length should be within %d characters", tableName, column.name, checker.maxLength),- Line: column.line,+ StartPosition: &storepb.Position{+ Line: int32(column.line),+ },})}}diff --git a/backend/plugin/advisor/tidb/advisor_naming_column.go b/backend/plugin/advisor/tidb/advisor_naming_column.goindex e719491610..9ef072a57c 100644--- a/backend/plugin/advisor/tidb/advisor_naming_column.go+++ b/backend/plugin/advisor/tidb/advisor_naming_column.go@@ -25,7 +25,7 @@ type NamingColumnConventionAdvisor struct {}// Check checks for column naming convention.-func (*NamingColumnConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingColumnConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -52,9 +52,9 @@ func (*NamingColumnConventionAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -64,8 +64,8 @@ func (*NamingColumnConventionAdvisor) Check(ctx advisor.Context, _ string) ([]ad}type namingColumnConventionChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat *regexp.RegexpmaxLength int@@ -121,21 +121,25 @@ func (v *namingColumnConventionChecker) Enter(in ast.Node) (ast.Node, bool) {for _, column := range columnList {if !v.format.MatchString(column.name) {- v.adviceList = append(v.adviceList, advisor.Advice{+ v.adviceList = append(v.adviceList, &storepb.Advice{Status: v.level,- Code: advisor.NamingColumnConventionMismatch,+ Code: advisor.NamingColumnConventionMismatch.Int32(),Title: v.title,Content: fmt.Sprintf("`%s`.`%s` mismatches column naming convention, naming format should be %q", tableName, column.name, v.format),- Line: column.line,+ StartPosition: &storepb.Position{+ Line: int32(column.line),+ },})}if v.maxLength > 0 && len(column.name) > v.maxLength {- v.adviceList = append(v.adviceList, advisor.Advice{+ v.adviceList = append(v.adviceList, &storepb.Advice{Status: v.level,- Code: advisor.NamingColumnConventionMismatch,+ Code: advisor.NamingColumnConventionMismatch.Int32(),Title: v.title,Content: fmt.Sprintf("`%s`.`%s` mismatches column naming convention, its length should be within %d characters", tableName, column.name, v.maxLength),- Line: column.line,+ StartPosition: &storepb.Position{+ Line: int32(column.line),+ },})}}diff --git a/backend/plugin/advisor/tidb/advisor_naming_foreign_key_convention.go b/backend/plugin/advisor/tidb/advisor_naming_foreign_key_convention.goindex cdcd06eb8f..79afec5c3a 100644--- a/backend/plugin/advisor/tidb/advisor_naming_foreign_key_convention.go+++ b/backend/plugin/advisor/tidb/advisor_naming_foreign_key_convention.go@@ -25,7 +25,7 @@ type NamingFKConventionAdvisor struct {}// Check checks for foreign key naming convention.-func (*NamingFKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingFKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -52,9 +52,9 @@ func (*NamingFKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -64,8 +64,8 @@ func (*NamingFKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}type namingFKConventionChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat stringmaxLength int@@ -79,30 +79,34 @@ func (checker *namingFKConventionChecker) Enter(in ast.Node) (ast.Node, bool) {for _, indexData := range indexDataList {regex, err := getTemplateRegexp(checker.format, checker.templateList, indexData.metaData)if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: "Internal error for foreign key naming convention rule",Content: fmt.Sprintf("%q meet internal error %q", in.Text(), err.Error()),})continue}if !regex.MatchString(indexData.indexName) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingFKConventionMismatch,+ Code: advisor.NamingFKConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("Foreign key in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),- Line: indexData.line,+ StartPosition: &storepb.Position{+ Line: int32(indexData.line),+ },})}if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingFKConventionMismatch,+ Code: advisor.NamingFKConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("Foreign key `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),- Line: indexData.line,+ StartPosition: &storepb.Position{+ Line: int32(indexData.line),+ },})}}diff --git a/backend/plugin/advisor/tidb/advisor_naming_index_convention.go b/backend/plugin/advisor/tidb/advisor_naming_index_convention.goindex c63bb774ad..21e05cd20a 100644--- a/backend/plugin/advisor/tidb/advisor_naming_index_convention.go+++ b/backend/plugin/advisor/tidb/advisor_naming_index_convention.go@@ -27,7 +27,7 @@ type NamingIndexConventionAdvisor struct {}// Check checks for index naming convention.-func (*NamingIndexConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingIndexConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -55,9 +55,9 @@ func (*NamingIndexConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adv}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -67,8 +67,8 @@ func (*NamingIndexConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adv}type namingIndexConventionChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat stringmaxLength int@@ -83,30 +83,34 @@ func (checker *namingIndexConventionChecker) Enter(in ast.Node) (ast.Node, bool)for _, indexData := range indexDataList {regex, err := getTemplateRegexp(checker.format, checker.templateList, indexData.metaData)if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: "Internal error for index naming convention rule",Content: fmt.Sprintf("%q meet internal error %q", in.Text(), err.Error()),})continue}if !regex.MatchString(indexData.indexName) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingIndexConventionMismatch,+ Code: advisor.NamingIndexConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("Index in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),- Line: indexData.line,+ StartPosition: &storepb.Position{+ Line: int32(indexData.line),+ },})}if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingIndexConventionMismatch,+ Code: advisor.NamingIndexConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("Index `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),- Line: indexData.line,+ StartPosition: &storepb.Position{+ Line: int32(indexData.line),+ },})}}diff --git a/backend/plugin/advisor/tidb/advisor_naming_table.go b/backend/plugin/advisor/tidb/advisor_naming_table.goindex e79b65fa34..7b3aa68a8c 100644--- a/backend/plugin/advisor/tidb/advisor_naming_table.go+++ b/backend/plugin/advisor/tidb/advisor_naming_table.go@@ -25,7 +25,7 @@ type NamingTableConventionAdvisor struct {}// Check checks for table naming convention.-func (*NamingTableConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingTableConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -50,9 +50,9 @@ func (*NamingTableConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adv}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -61,8 +61,8 @@ func (*NamingTableConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adv}type namingTableConventionChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat *regexp.RegexpmaxLength int@@ -93,21 +93,25 @@ func (v *namingTableConventionChecker) Enter(in ast.Node) (ast.Node, bool) {for _, tableName := range tableNames {if !v.format.MatchString(tableName) {- v.adviceList = append(v.adviceList, advisor.Advice{+ v.adviceList = append(v.adviceList, &storepb.Advice{Status: v.level,- Code: advisor.NamingTableConventionMismatch,+ Code: advisor.NamingTableConventionMismatch.Int32(),Title: v.title,Content: fmt.Sprintf("`%s` mismatches table naming convention, naming format should be %q", tableName, v.format),- Line: in.OriginTextPosition(),+ StartPosition: &storepb.Position{+ Line: int32(in.OriginTextPosition()),+ },})}if v.maxLength > 0 && len(tableName) > v.maxLength {- v.adviceList = append(v.adviceList, advisor.Advice{+ v.adviceList = append(v.adviceList, &storepb.Advice{Status: v.level,- Code: advisor.NamingTableConventionMismatch,+ Code: advisor.NamingTableConventionMismatch.Int32(),Title: v.title,Content: fmt.Sprintf("`%s` mismatches table naming convention, its length should be within %d characters", tableName, v.maxLength),- Line: in.OriginTextPosition(),+ StartPosition: &storepb.Position{+ Line: int32(in.OriginTextPosition()),+ },})}}diff --git a/backend/plugin/advisor/tidb/advisor_naming_unique_key_convention.go b/backend/plugin/advisor/tidb/advisor_naming_unique_key_convention.goindex c62051d3b9..e1a8dd09e9 100644--- a/backend/plugin/advisor/tidb/advisor_naming_unique_key_convention.go+++ b/backend/plugin/advisor/tidb/advisor_naming_unique_key_convention.go@@ -26,7 +26,7 @@ type NamingUKConventionAdvisor struct {}// Check checks for index naming convention.-func (*NamingUKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NamingUKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -54,9 +54,9 @@ func (*NamingUKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,8 +65,8 @@ func (*NamingUKConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}type namingUKConventionChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat stringmaxLength int@@ -81,30 +81,34 @@ func (checker *namingUKConventionChecker) Enter(in ast.Node) (ast.Node, bool) {for _, indexData := range indexDataList {regex, err := getTemplateRegexp(checker.format, checker.templateList, indexData.metaData)if err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: "Internal error for unique key naming convention rule",Content: fmt.Sprintf("%q meet internal error %q", in.Text(), err.Error()),})continue}if !regex.MatchString(indexData.indexName) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingUKConventionMismatch,+ Code: advisor.NamingUKConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("Unique key in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),- Line: indexData.line,+ StartPosition: &storepb.Position{+ Line: int32(indexData.line),+ },})}if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NamingUKConventionMismatch,+ Code: advisor.NamingUKConventionMismatch.Int32(),Title: checker.title,Content: fmt.Sprintf("Unique key `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),- Line: indexData.line,+ StartPosition: &storepb.Position{+ Line: int32(indexData.line),+ },})}}diff --git a/backend/plugin/advisor/tidb/advisor_statement_disallow_mix_ddl_dml.go b/backend/plugin/advisor/tidb/advisor_statement_disallow_mix_ddl_dml.goindex b43982cd1f..59862879c2 100644--- a/backend/plugin/advisor/tidb/advisor_statement_disallow_mix_ddl_dml.go+++ b/backend/plugin/advisor/tidb/advisor_statement_disallow_mix_ddl_dml.go@@ -23,7 +23,7 @@ type StatementDisallowMixDDLDMLAdvisor struct {}// Check checks for no mixed DDL and DML.-func (*StatementDisallowMixDDLDMLAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementDisallowMixDDLDMLAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -35,7 +35,7 @@ func (*StatementDisallowMixDDLDMLAdvisor) Check(ctx advisor.Context, _ string) (}title := string(ctx.Rule.Type)- var adviceList []advisor.Advice+ var adviceList []*storepb.Advicevar hasDDL, hasDML boolfor _, stmtNode := range root {var isDDL, isDML bool@@ -49,22 +49,26 @@ func (*StatementDisallowMixDDLDMLAdvisor) Check(ctx advisor.Context, _ string) (switch ctx.ChangeType {case storepb.PlanCheckRunConfig_DDL, storepb.PlanCheckRunConfig_SDL, storepb.PlanCheckRunConfig_DDL_GHOST:if isDML {- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: level,Title: title,Content: fmt.Sprintf("Alter schema can only run DDL, \"%s\" is not DDL", stmtNode.Text()),- Code: advisor.StatementDisallowMixDDLDML,- Line: stmtNode.OriginTextPosition(),+ Code: advisor.StatementDisallowMixDDLDML.Int32(),+ StartPosition: &storepb.Position{+ Line: int32(stmtNode.OriginTextPosition()),+ },})}case storepb.PlanCheckRunConfig_DML:if isDDL {- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: level,Title: title,Content: fmt.Sprintf("Data change can only run DML, \"%s\" is not DML", stmtNode.Text()),- Code: advisor.StatementDisallowMixDDLDML,- Line: stmtNode.OriginTextPosition(),+ Code: advisor.StatementDisallowMixDDLDML.Int32(),+ StartPosition: &storepb.Position{+ Line: int32(stmtNode.OriginTextPosition()),+ },})}}@@ -80,18 +84,18 @@ func (*StatementDisallowMixDDLDMLAdvisor) Check(ctx advisor.Context, _ string) (}if hasDDL && hasDML {- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: level,Title: title,Content: "Mixing DDL with DML is not allowed",- Code: advisor.StatementDisallowMixDDLDML,+ Code: advisor.StatementDisallowMixDDLDML.Int32(),})}if len(adviceList) == 0 {- adviceList = append(adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ adviceList = append(adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/tidb/advisor_statement_dml_dry_run.go b/backend/plugin/advisor/tidb/advisor_statement_dml_dry_run.goindex d6be905658..1afea05afc 100644--- a/backend/plugin/advisor/tidb/advisor_statement_dml_dry_run.go+++ b/backend/plugin/advisor/tidb/advisor_statement_dml_dry_run.go@@ -28,7 +28,7 @@ type StatementDmlDryRunAdvisor struct {}// Check checks for DML dry run.-func (*StatementDmlDryRunAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementDmlDryRunAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -54,9 +54,9 @@ func (*StatementDmlDryRunAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,8 +65,8 @@ func (*StatementDmlDryRunAdvisor) Check(ctx advisor.Context, _ string) ([]adviso}type statementDmlDryRunChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -79,12 +79,14 @@ func (checker *statementDmlDryRunChecker) Enter(in ast.Node) (ast.Node, bool) {switch node := in.(type) {case *ast.InsertStmt, *ast.UpdateStmt, *ast.DeleteStmt:if _, err := advisor.Query(checker.ctx, checker.driver, fmt.Sprintf("EXPLAIN %s", node.Text())); err != nil {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementDMLDryRunFailed,+ Code: advisor.StatementDMLDryRunFailed.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" dry runs failed: %s", node.Text(), err.Error()),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}}diff --git a/backend/plugin/advisor/tidb/advisor_statement_maximum_limit_value.go b/backend/plugin/advisor/tidb/advisor_statement_maximum_limit_value.goindex fa2fdea310..26d9f221fb 100644--- a/backend/plugin/advisor/tidb/advisor_statement_maximum_limit_value.go+++ b/backend/plugin/advisor/tidb/advisor_statement_maximum_limit_value.go@@ -27,7 +27,7 @@ type StatementMaximumLimitValueAdvisor struct {}// Check checks for LIMIT maximum value in SELECT statements.-func (*StatementMaximumLimitValueAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementMaximumLimitValueAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -55,9 +55,9 @@ func (*StatementMaximumLimitValueAdvisor) Check(ctx advisor.Context, _ string) (}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -66,8 +66,8 @@ func (*StatementMaximumLimitValueAdvisor) Check(ctx advisor.Context, _ string) (}type statementMaximumLimitValueChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -81,12 +81,14 @@ func (checker *statementMaximumLimitValueChecker) Enter(in ast.Node) (ast.Node,if ve, ok := node.Limit.Count.(*driver.ValueExpr); ok {limitVal := ve.GetInt64()if limitVal > int64(checker.limitMaxValue) {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementExceedMaximumLimitValue,+ Code: advisor.StatementExceedMaximumLimitValue.Int32(),Title: checker.title,Content: fmt.Sprintf("The limit value %d exceeds the maximum allowed value %d", limitVal, checker.limitMaxValue),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}}diff --git a/backend/plugin/advisor/tidb/advisor_statement_merge_alter_table.go b/backend/plugin/advisor/tidb/advisor_statement_merge_alter_table.goindex d422a7fcad..3f64784637 100644--- a/backend/plugin/advisor/tidb/advisor_statement_merge_alter_table.go+++ b/backend/plugin/advisor/tidb/advisor_statement_merge_alter_table.go@@ -27,7 +27,7 @@ type StatementMergeAlterTableAdvisor struct {}// Check checks for merging ALTER TABLE statements.-func (*StatementMergeAlterTableAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementMergeAlterTableAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -53,8 +53,8 @@ func (*StatementMergeAlterTableAdvisor) Check(ctx advisor.Context, _ string) ([]}type statementMergeAlterTableChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -98,7 +98,7 @@ func (*statementMergeAlterTableChecker) Leave(in ast.Node) (ast.Node, bool) {return in, true}-func (checker *statementMergeAlterTableChecker) generateAdvice() []advisor.Advice {+func (checker *statementMergeAlterTableChecker) generateAdvice() []*storepb.Advice {var tableList []tableStatementfor _, table := range checker.tableMap {tableList = append(tableList, table)@@ -109,20 +109,22 @@ func (checker *statementMergeAlterTableChecker) generateAdvice() []advisor.Advicfor _, table := range tableList {if table.count > 1 {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementRedundantAlterTable,+ Code: advisor.StatementRedundantAlterTable.Int32(),Title: checker.title,Content: fmt.Sprintf("There are %d statements to modify table `%s`", table.count, table.name),- Line: table.lastLine,+ StartPosition: &storepb.Position{+ Line: int32(table.lastLine),+ },})}}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/tidb/advisor_statement_prior_backup_check.go b/backend/plugin/advisor/tidb/advisor_statement_prior_backup_check.goindex a9e67a4192..ffd707cc73 100644--- a/backend/plugin/advisor/tidb/advisor_statement_prior_backup_check.go+++ b/backend/plugin/advisor/tidb/advisor_statement_prior_backup_check.go@@ -26,12 +26,12 @@ type StatementPriorBackupCheckAdvisor struct {}// Check checks for no mixed DDL and DML.-func (*StatementPriorBackupCheckAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {- var adviceList []advisor.Advice+func (*StatementPriorBackupCheckAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {+ var adviceList []*storepb.Adviceif ctx.PreUpdateBackupDetail == nil || ctx.ChangeType != storepb.PlanCheckRunConfig_DML {- adviceList = append(adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ adviceList = append(adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -56,23 +56,27 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx advisor.Context, _ string) ([}if isDDL {- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: level,Title: title,Content: "Prior backup cannot deal with mixed DDL and DML statements",- Code: advisor.StatementPriorBackupCheck,- Line: stmtNode.OriginTextPosition(),+ Code: advisor.StatementPriorBackupCheck.Int32(),+ StartPosition: &storepb.Position{+ Line: int32(stmtNode.OriginTextPosition()),+ },})}}if !databaseExists(ctx.Context, ctx.Driver, extractDatabaseName(ctx.PreUpdateBackupDetail.Database)) {- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: level,Title: title,Content: fmt.Sprintf("Need database %q to do prior backup but it does not exist", ctx.PreUpdateBackupDetail.Database),- Code: advisor.DatabaseNotExists,- Line: 0,+ Code: advisor.DatabaseNotExists.Int32(),+ StartPosition: &storepb.Position{+ Line: 0,+ },})}@@ -85,12 +89,14 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx advisor.Context, _ string) ([checker.text = stmtNode.Text()checker.line = stmtNode.OriginTextPosition()if err := checker.extractNode(stmtNode); err != nil {- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: checker.title,Content: fmt.Sprintf("Failed to extract node, error: %s", err),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}}@@ -106,9 +112,9 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx advisor.Context, _ string) ([}content = strings.TrimSuffix(content, ",")content += fmt.Sprintf(" on table `%s`.`%s`, disallow mixing different types of DML statements", table.database, table.table)- adviceList = append(adviceList, advisor.Advice{+ adviceList = append(adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementPriorBackupCheck,+ Code: advisor.StatementPriorBackupCheck.Int32(),Title: checker.title,Content: content,})@@ -116,9 +122,9 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx advisor.Context, _ string) ([}if len(adviceList) == 0 {- adviceList = append(adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ adviceList = append(adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -144,7 +150,7 @@ func databaseExists(ctx context.Context, driver *sql.DB, database string) bool {}type statementDisallowMixDMLChecker struct {- level advisor.Status+ level storepb.Advice_Statustitle stringtext stringline intdiff --git a/backend/plugin/advisor/tidb/advisor_stmt_disallow_commit.go b/backend/plugin/advisor/tidb/advisor_stmt_disallow_commit.goindex 1255b81f84..e71ee7dce4 100644--- a/backend/plugin/advisor/tidb/advisor_stmt_disallow_commit.go+++ b/backend/plugin/advisor/tidb/advisor_stmt_disallow_commit.go@@ -26,7 +26,7 @@ type StatementDisallowCommitAdvisor struct {}// Check checks for index type no blob.-func (*StatementDisallowCommitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementDisallowCommitAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -48,9 +48,9 @@ func (*StatementDisallowCommitAdvisor) Check(ctx advisor.Context, _ string) ([]a}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -59,8 +59,8 @@ func (*StatementDisallowCommitAdvisor) Check(ctx advisor.Context, _ string) ([]a}type statementDisallowCommitChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -69,12 +69,14 @@ type statementDisallowCommitChecker struct {// Enter implements the ast.Visitor interface.func (c *statementDisallowCommitChecker) Enter(in ast.Node) (ast.Node, bool) {if _, ok := in.(*ast.CommitStmt); ok {- c.adviceList = append(c.adviceList, advisor.Advice{+ c.adviceList = append(c.adviceList, &storepb.Advice{Status: c.level,- Code: advisor.StatementDisallowCommit,+ Code: advisor.StatementDisallowCommit.Int32(),Title: c.title,Content: fmt.Sprintf("Commit is not allowed, related statement: \"%s\"", c.text),- Line: c.line,+ StartPosition: &storepb.Position{+ Line: int32(c.line),+ },})}diff --git a/backend/plugin/advisor/tidb/advisor_stmt_disallow_limit.go b/backend/plugin/advisor/tidb/advisor_stmt_disallow_limit.goindex 759a27220d..e62a66938b 100644--- a/backend/plugin/advisor/tidb/advisor_stmt_disallow_limit.go+++ b/backend/plugin/advisor/tidb/advisor_stmt_disallow_limit.go@@ -26,7 +26,7 @@ type StatementDisallowLimitAdvisor struct {}// Check checks for no LIMIT clause in INSERT/UPDATE statement.-func (*StatementDisallowLimitAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*StatementDisallowLimitAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -48,9 +48,9 @@ func (*StatementDisallowLimitAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -59,8 +59,8 @@ func (*StatementDisallowLimitAdvisor) Check(ctx advisor.Context, _ string) ([]ad}type statementDisallowLimitChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -85,12 +85,14 @@ func (checker *statementDisallowLimitChecker) Enter(in ast.Node) (ast.Node, bool}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but \"%s\" uses", checker.text),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}diff --git a/backend/plugin/advisor/tidb/advisor_stmt_disallow_order_by.go b/backend/plugin/advisor/tidb/advisor_stmt_disallow_order_by.goindex bca65f4339..debaed9d50 100644--- a/backend/plugin/advisor/tidb/advisor_stmt_disallow_order_by.go+++ b/backend/plugin/advisor/tidb/advisor_stmt_disallow_order_by.go@@ -26,7 +26,7 @@ type DisallowOrderByAdvisor struct {}// Check checks for no ORDER BY clause in DELETE/UPDATE statements.-func (*DisallowOrderByAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*DisallowOrderByAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -48,9 +48,9 @@ func (*DisallowOrderByAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.A}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -59,8 +59,8 @@ func (*DisallowOrderByAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.A}type disallowOrderByChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -81,12 +81,14 @@ func (checker *disallowOrderByChecker) Enter(in ast.Node) (ast.Node, bool) {}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("ORDER BY clause is forbidden in DELETE and UPDATE statements, but \"%s\" uses", checker.text),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}return in, falsediff --git a/backend/plugin/advisor/tidb/advisor_stmt_no_leading_wildcard_like.go b/backend/plugin/advisor/tidb/advisor_stmt_no_leading_wildcard_like.goindex 9b2c470a36..06e28f68bc 100644--- a/backend/plugin/advisor/tidb/advisor_stmt_no_leading_wildcard_like.go+++ b/backend/plugin/advisor/tidb/advisor_stmt_no_leading_wildcard_like.go@@ -29,7 +29,7 @@ type NoLeadingWildcardLikeAdvisor struct {}// Check checks for no leading wildcard LIKE.-func (*NoLeadingWildcardLikeAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NoLeadingWildcardLikeAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -47,20 +47,22 @@ func (*NoLeadingWildcardLikeAdvisor) Check(ctx advisor.Context, _ string) ([]adv(stmtNode).Accept(checker)if checker.leadingWildcardLike {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.StatementLeadingWildcardLike,+ Code: advisor.StatementLeadingWildcardLike.Int32(),Title: string(ctx.Rule.Type),Content: fmt.Sprintf("\"%s\" uses leading wildcard LIKE", checker.text),- Line: stmtNode.OriginTextPosition(),+ StartPosition: &storepb.Position{+ Line: int32(stmtNode.OriginTextPosition()),+ },})}}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -69,8 +71,8 @@ func (*NoLeadingWildcardLikeAdvisor) Check(ctx advisor.Context, _ string) ([]adv}type noLeadingWildcardLikeChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustext stringleadingWildcardLike bool}@@ -80,9 +82,9 @@ func (v *noLeadingWildcardLikeChecker) Enter(in ast.Node) (ast.Node, bool) {if node, ok := in.(*ast.PatternLikeOrIlikeExpr); !v.leadingWildcardLike && ok {pattern, err := restoreNode(node.Pattern, format.RestoreStringWithoutCharset)if err != nil {- v.adviceList = append(v.adviceList, advisor.Advice{+ v.adviceList = append(v.adviceList, &storepb.Advice{Status: v.level,- Code: advisor.Internal,+ Code: advisor.Internal.Int32(),Title: "Internal error for no leading wildcard LIKE rule",Content: fmt.Sprintf("\"%s\" meet internal error %q", v.text, err.Error()),})diff --git a/backend/plugin/advisor/tidb/advisor_stmt_no_select_all.go b/backend/plugin/advisor/tidb/advisor_stmt_no_select_all.goindex ebf2bd904b..241a007b02 100644--- a/backend/plugin/advisor/tidb/advisor_stmt_no_select_all.go+++ b/backend/plugin/advisor/tidb/advisor_stmt_no_select_all.go@@ -24,7 +24,7 @@ type NoSelectAllAdvisor struct {}// Check checks for no "select *".-func (*NoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*NoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -45,9 +45,9 @@ func (*NoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advic}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -56,8 +56,8 @@ func (*NoSelectAllAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advic}type noSelectAllChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -68,12 +68,14 @@ func (v *noSelectAllChecker) Enter(in ast.Node) (ast.Node, bool) {if node, ok := in.(*ast.SelectStmt); ok {for _, field := range node.Fields.Fields {if field.WildCard != nil {- v.adviceList = append(v.adviceList, advisor.Advice{+ v.adviceList = append(v.adviceList, &storepb.Advice{Status: v.level,- Code: advisor.StatementSelectAll,+ Code: advisor.StatementSelectAll.Int32(),Title: v.title,Content: fmt.Sprintf("\"%s\" uses SELECT all", v.text),- Line: v.line,+ StartPosition: &storepb.Position{+ Line: int32(v.line),+ },})break}diff --git a/backend/plugin/advisor/tidb/advisor_stmt_where_required.go b/backend/plugin/advisor/tidb/advisor_stmt_where_required.goindex 0b4009b671..7835368032 100644--- a/backend/plugin/advisor/tidb/advisor_stmt_where_required.go+++ b/backend/plugin/advisor/tidb/advisor_stmt_where_required.go@@ -25,7 +25,7 @@ type WhereRequirementAdvisor struct {}// Check checks for the WHERE clause requirement.-func (*WhereRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*WhereRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -46,9 +46,9 @@ func (*WhereRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -57,8 +57,8 @@ func (*WhereRequirementAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.}type whereRequirementChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -87,12 +87,14 @@ func (v *whereRequirementChecker) Enter(in ast.Node) (ast.Node, bool) {}if code != advisor.Ok {- v.adviceList = append(v.adviceList, advisor.Advice{+ v.adviceList = append(v.adviceList, &storepb.Advice{Status: v.level,- Code: code,+ Code: code.Int32(),Title: v.title,Content: fmt.Sprintf("\"%s\" requires WHERE clause", v.text),- Line: v.line,+ StartPosition: &storepb.Position{+ Line: int32(v.line),+ },})}return in, falsediff --git a/backend/plugin/advisor/tidb/advisor_table_comment_convention.go b/backend/plugin/advisor/tidb/advisor_table_comment_convention.goindex cb80bf9a86..6c957ef6b8 100644--- a/backend/plugin/advisor/tidb/advisor_table_comment_convention.go+++ b/backend/plugin/advisor/tidb/advisor_table_comment_convention.go@@ -26,7 +26,7 @@ type TableCommentConventionAdvisor struct {}// Check checks for table comment convention.-func (*TableCommentConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableCommentConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -54,9 +54,9 @@ func (*TableCommentConventionAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -65,8 +65,8 @@ func (*TableCommentConventionAdvisor) Check(ctx advisor.Context, _ string) ([]ad}type tableCommentConventionChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -79,21 +79,25 @@ func (checker *tableCommentConventionChecker) Enter(in ast.Node) (ast.Node, boolif node, ok := in.(*ast.CreateTableStmt); ok {exist, comment := tableComment(node.Options)if checker.required && !exist {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.NoTableComment,+ Code: advisor.NoTableComment.Int32(),Title: checker.title,Content: fmt.Sprintf("Table `%s` requires comments", node.Table.Name.O),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}if checker.maxLength >= 0 && len(comment) > checker.maxLength {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.TableCommentTooLong,+ Code: advisor.TableCommentTooLong.Int32(),Title: checker.title,Content: fmt.Sprintf("The length of table `%s` comment should be within %d characters", node.Table.Name.O, checker.maxLength),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}}diff --git a/backend/plugin/advisor/tidb/advisor_table_disallow_partition.go b/backend/plugin/advisor/tidb/advisor_table_disallow_partition.goindex 54a77d7757..0a0519c9db 100644--- a/backend/plugin/advisor/tidb/advisor_table_disallow_partition.go+++ b/backend/plugin/advisor/tidb/advisor_table_disallow_partition.go@@ -26,7 +26,7 @@ type TableDisallowPartitionAdvisor struct {}// Check checks for disallow table partition.-func (*TableDisallowPartitionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableDisallowPartitionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {stmtList, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -48,9 +48,9 @@ func (*TableDisallowPartitionAdvisor) Check(ctx advisor.Context, _ string) ([]ad}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -59,8 +59,8 @@ func (*TableDisallowPartitionAdvisor) Check(ctx advisor.Context, _ string) ([]ad}type tableDisallowPartitionChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtext stringline int@@ -84,12 +84,14 @@ func (checker *tableDisallowPartitionChecker) Enter(in ast.Node) (ast.Node, bool}if code != advisor.Ok {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: code,+ Code: code.Int32(),Title: checker.title,Content: fmt.Sprintf("Table partition is forbidden, but \"%s\" creates", checker.text),- Line: checker.line,+ StartPosition: &storepb.Position{+ Line: int32(checker.line),+ },})}diff --git a/backend/plugin/advisor/tidb/advisor_table_drop_naming_convention.go b/backend/plugin/advisor/tidb/advisor_table_drop_naming_convention.goindex a14ceeea44..031aee0602 100644--- a/backend/plugin/advisor/tidb/advisor_table_drop_naming_convention.go+++ b/backend/plugin/advisor/tidb/advisor_table_drop_naming_convention.go@@ -25,7 +25,7 @@ type TableDropNamingConventionAdvisor struct {}// Check checks for drop table naming convention.-func (*TableDropNamingConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableDropNamingConventionAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -50,9 +50,9 @@ func (*TableDropNamingConventionAdvisor) Check(ctx advisor.Context, _ string) ([}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -61,8 +61,8 @@ func (*TableDropNamingConventionAdvisor) Check(ctx advisor.Context, _ string) ([}type namingDropTableConventionChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringformat *regexp.Regexp}@@ -72,12 +72,14 @@ func (v *namingDropTableConventionChecker) Enter(in ast.Node) (ast.Node, bool) {if node, ok := in.(*ast.DropTableStmt); ok {for _, table := range node.Tables {if !v.format.MatchString(table.Name.O) {- v.adviceList = append(v.adviceList, advisor.Advice{+ v.adviceList = append(v.adviceList, &storepb.Advice{Status: v.level,- Code: advisor.TableDropNamingConventionMismatch,+ Code: advisor.TableDropNamingConventionMismatch.Int32(),Title: v.title,Content: fmt.Sprintf("`%s` mismatches drop table naming convention, naming format should be %q", table.Name.O, v.format),- Line: node.OriginTextPosition(),+ StartPosition: &storepb.Position{+ Line: int32(node.OriginTextPosition()),+ },})}}diff --git a/backend/plugin/advisor/tidb/advisor_table_no_fk.go b/backend/plugin/advisor/tidb/advisor_table_no_fk.goindex 5f72412201..df68f5b923 100644--- a/backend/plugin/advisor/tidb/advisor_table_no_fk.go+++ b/backend/plugin/advisor/tidb/advisor_table_no_fk.go@@ -24,7 +24,7 @@ type TableNoFKAdvisor struct {}// Check checks table disallow foreign key.-func (*TableNoFKAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableNoFKAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -43,9 +43,9 @@ func (*TableNoFKAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice,}if len(checker.adviceList) == 0 {- checker.adviceList = append(checker.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ checker.adviceList = append(checker.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})@@ -55,8 +55,8 @@ func (*TableNoFKAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice,}type tableNoFKChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle string}@@ -66,24 +66,28 @@ func (checker *tableNoFKChecker) Enter(in ast.Node) (ast.Node, bool) {case *ast.CreateTableStmt:for _, constraint := range node.Constraints {if constraint.Tp == ast.ConstraintForeignKey {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.TableHasFK,+ Code: advisor.TableHasFK.Int32(),Title: checker.title,Content: fmt.Sprintf("Foreign key is not allowed in the table `%s`", node.Table.Name),- Line: constraint.OriginTextPosition(),+ StartPosition: &storepb.Position{+ Line: int32(constraint.OriginTextPosition()),+ },})}}case *ast.AlterTableStmt:for _, spec := range node.Specs {if spec.Tp == ast.AlterTableAddConstraint && spec.Constraint.Tp == ast.ConstraintForeignKey {- checker.adviceList = append(checker.adviceList, advisor.Advice{+ checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,- Code: advisor.TableHasFK,+ Code: advisor.TableHasFK.Int32(),Title: checker.title,Content: fmt.Sprintf("Foreign key is not allowed in the table `%s`", node.Table.Name),- Line: in.OriginTextPosition(),+ StartPosition: &storepb.Position{+ Line: int32(in.OriginTextPosition()),+ },})}}diff --git a/backend/plugin/advisor/tidb/advisor_table_require_pk.go b/backend/plugin/advisor/tidb/advisor_table_require_pk.goindex b848ccf2b1..54d600cb0b 100644--- a/backend/plugin/advisor/tidb/advisor_table_require_pk.go+++ b/backend/plugin/advisor/tidb/advisor_table_require_pk.go@@ -30,7 +30,7 @@ type TableRequirePKAdvisor struct {}// Check checks table requires PK.-func (*TableRequirePKAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {+func (*TableRequirePKAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.Advice, error) {root, ok := ctx.AST.([]ast.StmtNode)if !ok {return nil, errors.Errorf("failed to convert to StmtNode")@@ -56,8 +56,8 @@ func (*TableRequirePKAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Ad}type tableRequirePKChecker struct {- adviceList []advisor.Advice- level advisor.Status+ adviceList []*storepb.Advice+ level storepb.Advice_Statustitle stringtables tablePKline map[string]int@@ -125,24 +125,26 @@ func (*tableRequirePKChecker) Leave(in ast.Node) (ast.Node, bool) {return in, true}-func (v *tableRequirePKChecker) generateAdviceList() []advisor.Advice {+func (v *tableRequirePKChecker) generateAdviceList() []*storepb.Advice {tableList := v.tables.tableList()for _, tableName := range tableList {if len(v.tables[tableName]) == 0 {- v.adviceList = append(v.adviceList, advisor.Advice{+ v.adviceList = append(v.adviceList, &storepb.Advice{Status: v.level,- Code: advisor.TableNoPK,+ Code: advisor.TableNoPK.Int32(),Title: v.title,Content: fmt.Sprintf("Table `%s` requires PRIMARY KEY", tableName),- Line: v.line[tableName],+ StartPosition: &storepb.Position{+ Line: int32(v.line[tableName]),+ },})}}if len(v.adviceList) == 0 {- v.adviceList = append(v.adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ v.adviceList = append(v.adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})diff --git a/backend/plugin/advisor/tidb/test/column_auto_increment_initial_value.yaml b/backend/plugin/advisor/tidb/test/column_auto_increment_initial_value.yamlindex 29a78e057a..f13707e24d 100644--- a/backend/plugin/advisor/tidb/test/column_auto_increment_initial_value.yaml+++ b/backend/plugin/advisor/tidb/test/column_auto_increment_initial_value.yaml@@ -1,27 +1,26 @@- statement: CREATE TABLE t(a int)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a int auto_increment) auto_increment = 20want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a int auto_increment) auto_increment = 2want:- - status: WARN+ - status: 2code: 416title: column.auto-increment-initial-valuecontent: The initial auto-increment value in table `t` is 2, which doesn't equal 20- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/tidb/test/column_auto_increment_must_integer.yaml b/backend/plugin/advisor/tidb/test/column_auto_increment_must_integer.yamlindex aec1a6caa2..a97500bc08 100644--- a/backend/plugin/advisor/tidb/test/column_auto_increment_must_integer.yaml+++ b/backend/plugin/advisor/tidb/test/column_auto_increment_must_integer.yaml@@ -1,51 +1,54 @@- statement: CREATE TABLE t(a INT AUTO_INCREMENT)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a varchar(255) AUTO_INCREMENT)want:- - status: WARN+ - status: 2code: 410title: column.auto-increment-must-integercontent: Auto-increment column `t`.`a` requires integer type- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t(b int);ALTER TABLE t ADD COLUMN a varchar(255) AUTO_INCREMENTwant:- - status: WARN+ - status: 2code: 410title: column.auto-increment-must-integercontent: Auto-increment column `t`.`a` requires integer type- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t MODIFY COLUMN a varchar(255) AUTO_INCREMENTwant:- - status: WARN+ - status: 2code: 410title: column.auto-increment-must-integercontent: Auto-increment column `t`.`a` requires integer type- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(b int);ALTER TABLE t CHANGE COLUMN b a varchar(255) AUTO_INCREMENTwant:- - status: WARN+ - status: 2code: 410title: column.auto-increment-must-integercontent: Auto-increment column `t`.`a` requires integer type- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/tidb/test/column_auto_increment_must_unsigned.yaml b/backend/plugin/advisor/tidb/test/column_auto_increment_must_unsigned.yamlindex 859ad0f9b6..234571c7ef 100644--- a/backend/plugin/advisor/tidb/test/column_auto_increment_must_unsigned.yaml+++ b/backend/plugin/advisor/tidb/test/column_auto_increment_must_unsigned.yaml@@ -1,51 +1,54 @@- statement: CREATE TABLE t(a INT UNSIGNED AUTO_INCREMENT)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a INT AUTO_INCREMENT)want:- - status: WARN+ - status: 2code: 417title: column.auto-increment-must-unsignedcontent: Auto-increment column `t`.`a` is not UNSIGNED type- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t(b int);ALTER TABLE t ADD COLUMN a INT AUTO_INCREMENTwant:- - status: WARN+ - status: 2code: 417title: column.auto-increment-must-unsignedcontent: Auto-increment column `t`.`a` is not UNSIGNED type- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t MODIFY COLUMN a INT AUTO_INCREMENTwant:- - status: WARN+ - status: 2code: 417title: column.auto-increment-must-unsignedcontent: Auto-increment column `t`.`a` is not UNSIGNED type- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(b int);ALTER TABLE t CHANGE COLUMN b a INT AUTO_INCREMENTwant:- - status: WARN+ - status: 2code: 417title: column.auto-increment-must-unsignedcontent: Auto-increment column `t`.`a` is not UNSIGNED type- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/tidb/test/column_comment.yaml b/backend/plugin/advisor/tidb/test/column_comment.yamlindex 16fa221e8a..13645accad 100644--- a/backend/plugin/advisor/tidb/test/column_comment.yaml+++ b/backend/plugin/advisor/tidb/test/column_comment.yaml@@ -1,101 +1,110 @@- statement: CREATE TABLE t(a int COMMENT 'comments')want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int COMMENT 'some comments',b int,c int)want:- - status: WARN+ - status: 2code: 409title: column.commentcontent: The length of column `t`.`a` comment should be within 10 characters- line: 2- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 408title: column.commentcontent: Column `t`.`b` requires comments- line: 3- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 408title: column.commentcontent: Column `t`.`c` requires comments- line: 4- column: 0- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0- statement: |-CREATE TABLE t(a int COMMENT 'comment');ALTER TABLE t ADD COLUMN b intwant:- - status: WARN+ - status: 2code: 408title: column.commentcontent: Column `t`.`b` requires comments- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int COMMENT 'this is comment');ALTER TABLE t CHANGE COLUMN a b intwant:- - status: WARN+ - status: 2code: 409title: column.commentcontent: The length of column `t`.`a` comment should be within 10 characters- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 408title: column.commentcontent: Column `t`.`b` requires comments- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(b int COMMENT 'It is comment');ALTER TABLE t MODIFY COLUMN b intwant:- - status: WARN+ - status: 2code: 409title: column.commentcontent: The length of column `t`.`b` comment should be within 10 characters- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 408title: column.commentcontent: Column `t`.`b` requires comments- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(b int COMMENT 'It is COMMENT');ALTER TABLE t MODIFY COLUMN b int COMMENT 'abcdefghiakljhakljdsfalugelkhnabsdguelkadf'want:- - status: WARN+ - status: 2code: 409title: column.commentcontent: The length of column `t`.`b` comment should be within 10 characters- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 409title: column.commentcontent: The length of column `t`.`b` comment should be within 10 characters- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/tidb/test/column_current_time_count_limit.yaml b/backend/plugin/advisor/tidb/test/column_current_time_count_limit.yamlindex b6cac63f04..539f28a2af 100644--- a/backend/plugin/advisor/tidb/test/column_current_time_count_limit.yaml+++ b/backend/plugin/advisor/tidb/test/column_current_time_count_limit.yaml@@ -1,12 +1,11 @@- statement: CREATE TABLE t(a timestamp, b timestamp)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a timestamp default now(),@@ -14,34 +13,37 @@c timestamp default localtime)want:- - status: WARN+ - status: 2code: 418title: column.current-time-count-limitcontent: Table `t` has 3 DEFAULT CURRENT_TIMESTAMP() columns. The count greater than 2.- line: 5- column: 0- details: ""+ detail: ""+ startposition:+ line: 5+ column: 0- statement: |-CREATE TABLE t(a timestamp default now() on update localtime,b timestamp default current_timestamp() on update localtimestamp())want:- - status: WARN+ - status: 2code: 419title: column.current-time-count-limitcontent: Table `t` has 2 ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than 1.- line: 4- column: 0- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0- statement: |-ALTER TABLE tech_book ADD COLUMN a timestamp default now() on update localtime;ALTER TABLE tech_book ADD COLUMN b timestamp default current_timestamp() on update localtimestamp();want:- - status: WARN+ - status: 2code: 419title: column.current-time-count-limitcontent: Table `tech_book` has 2 ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than 1.- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/tidb/test/column_disallow_change.yaml b/backend/plugin/advisor/tidb/test/column_disallow_change.yamlindex 552342ee84..f5beb6a5c3 100644--- a/backend/plugin/advisor/tidb/test/column_disallow_change.yaml+++ b/backend/plugin/advisor/tidb/test/column_disallow_change.yaml@@ -2,21 +2,21 @@CREATE TABLE t(b int);ALTER TABLE t ADD COLUMN a intwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(b int);ALTER TABLE t CHANGE COLUMN b a intwant:- - status: WARN+ - status: 2code: 406title: column.disallow-changecontent: '"ALTER TABLE t CHANGE COLUMN b a int" contains CHANGE COLUMN statement'- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/tidb/test/column_disallow_change_type.yaml b/backend/plugin/advisor/tidb/test/column_disallow_change_type.yamlindex baba5e7b50..dea3618e77 100644--- a/backend/plugin/advisor/tidb/test/column_disallow_change_type.yaml+++ b/backend/plugin/advisor/tidb/test/column_disallow_change_type.yaml@@ -1,36 +1,38 @@- statement: ALTER TABLE tech_book MODIFY id INTEGER UNSIGNEDwant:- - status: WARN+ - status: 2code: 403title: column.disallow-change-typecontent: '"ALTER TABLE tech_book MODIFY id INTEGER UNSIGNED" changes column type'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book MODIFY id intwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book MODIFY id bigintwant:- - status: WARN+ - status: 2code: 403title: column.disallow-change-typecontent: '"ALTER TABLE tech_book MODIFY id bigint" changes column type'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book CHANGE name uname varchar(20)want:- - status: WARN+ - status: 2code: 403title: column.disallow-change-typecontent: '"ALTER TABLE tech_book CHANGE name uname varchar(20)" changes column type'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/tidb/test/column_disallow_changing_order.yaml b/backend/plugin/advisor/tidb/test/column_disallow_changing_order.yamlindex 22dcc0a1c5..27206f2252 100644--- a/backend/plugin/advisor/tidb/test/column_disallow_changing_order.yaml+++ b/backend/plugin/advisor/tidb/test/column_disallow_changing_order.yaml@@ -2,54 +2,57 @@CREATE TABLE t(a int);ALTER TABLE t MODIFY COLUMN a intwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int);ALTER TABLE t MODIFY COLUMN a int FIRSTwant:- - status: WARN+ - status: 2code: 407title: column.disallow-changing-ordercontent: '"ALTER TABLE t MODIFY COLUMN a int FIRST" changes column order'- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(b int, a1 int);ALTER TABLE t CHANGE COLUMN a1 a int FIRSTwant:- - status: WARN+ - status: 2code: 407title: column.disallow-changing-ordercontent: '"ALTER TABLE t CHANGE COLUMN a1 a int FIRST" changes column order'- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int, b int);ALTER TABLE t MODIFY COLUMN a int AFTER bwant:- - status: WARN+ - status: 2code: 407title: column.disallow-changing-ordercontent: '"ALTER TABLE t MODIFY COLUMN a int AFTER b" changes column order'- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a1 int, b int);ALTER TABLE t CHANGE COLUMN a1 a int AFTER bwant:- - status: WARN+ - status: 2code: 407title: column.disallow-changing-ordercontent: '"ALTER TABLE t CHANGE COLUMN a1 a int AFTER b" changes column order'- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/tidb/test/column_disallow_drop_in_index.yaml b/backend/plugin/advisor/tidb/test/column_disallow_drop_in_index.yamlindex 2d6a5dfa4e..31eb8c7f32 100644--- a/backend/plugin/advisor/tidb/test/column_disallow_drop_in_index.yaml+++ b/backend/plugin/advisor/tidb/test/column_disallow_drop_in_index.yaml@@ -2,63 +2,65 @@CREATE TABLE t(a int, b int, INDEX idx_a(a));ALTER TABLE t DROP COLUMN bwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int, b int, INDEX idx_b(b));ALTER TABLE t DROP COLUMN bwant:- - status: WARN+ - status: 2code: 424title: column.disallow-drop-in-indexcontent: '`t`.`b` cannot drop index column'- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int, c int, INDEX idx_ac(a,c));ALTER TABLE t DROP COLUMN cwant:- - status: WARN+ - status: 2code: 424title: column.disallow-drop-in-indexcontent: '`t`.`c` cannot drop index column'- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int, b int, INDEX idx_a(a));CREATE TABLE y(a int, b int);ALTER TABLE y DROP COLUMN awant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int,b int, c int, INDEX idx_ac(a,c));ALTER TABLE t DROP COLUMN a;ALTER TABLE t DROP COLUMN cwant:- - status: WARN+ - status: 2code: 424title: column.disallow-drop-in-indexcontent: '`t`.`a` cannot drop index column'- line: 2- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 424title: column.disallow-drop-in-indexcontent: '`t`.`c` cannot drop index column'- line: 3- column: 0- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0diff --git a/backend/plugin/advisor/tidb/test/column_disallow_set_charset.yaml b/backend/plugin/advisor/tidb/test/column_disallow_set_charset.yamlindex 528e63522d..e55a466e48 100644--- a/backend/plugin/advisor/tidb/test/column_disallow_set_charset.yaml+++ b/backend/plugin/advisor/tidb/test/column_disallow_set_charset.yaml@@ -2,55 +2,57 @@CREATE TABLE dt_relation_temp(objto int);ALTER TABLE dt_relation_temp ADD COLUMN infos json null comment'关系信息点'AFTER`objto`;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a varchar(20))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a varchar(20) CHARSET ascii)want:- - status: WARN+ - status: 2code: 414title: column.disallow-set-charsetcontent: Disallow set column charset but "CREATE TABLE t(a varchar(20) CHARSET ascii)" does- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ADD COLUMN a varchar(20) CHARSET asciiwant:- - status: WARN+ - status: 2code: 414title: column.disallow-set-charsetcontent: Disallow set column charset but "ALTER TABLE tech_book ADD COLUMN a varchar(20) CHARSET ascii" does- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book MODIFY COLUMN id varchar(20) CHARSET asciiwant:- - status: WARN+ - status: 2code: 414title: column.disallow-set-charsetcontent: Disallow set column charset but "ALTER TABLE tech_book MODIFY COLUMN id varchar(20) CHARSET ascii" does- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book CHANGE COLUMN name name varchar(20) CHARSET asciiwant:- - status: WARN+ - status: 2code: 414title: column.disallow-set-charsetcontent: Disallow set column charset but "ALTER TABLE tech_book CHANGE COLUMN name name varchar(20) CHARSET ascii" does- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/tidb/test/column_maximum_character_length.yaml b/backend/plugin/advisor/tidb/test/column_maximum_character_length.yamlindex 430c7fdd54..27b57a5a98 100644--- a/backend/plugin/advisor/tidb/test/column_maximum_character_length.yaml+++ b/backend/plugin/advisor/tidb/test/column_maximum_character_length.yaml@@ -1,54 +1,56 @@- statement: CREATE TABLE t(name char(20));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(name varchar(225));want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(name char(225));want:- - status: WARN+ - status: 2code: 415title: column.maximum-character-lengthcontent: The length of the CHAR column `name` is bigger than 20, please use VARCHAR instead- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ADD COLUMN name_2 char(225)want:- - status: WARN+ - status: 2code: 415title: column.maximum-character-lengthcontent: The length of the CHAR column `name_2` is bigger than 20, please use VARCHAR instead- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book CHANGE COLUMN name name char(225)want:- - status: WARN+ - status: 2code: 415title: column.maximum-character-lengthcontent: The length of the CHAR column `name` is bigger than 20, please use VARCHAR instead- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book MODIFY COLUMN name char(225)want:- - status: WARN+ - status: 2code: 415title: column.maximum-character-lengthcontent: The length of the CHAR column `name` is bigger than 20, please use VARCHAR instead- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/tidb/test/column_no_null.yaml b/backend/plugin/advisor/tidb/test/column_no_null.yamlindex 003d69e0b4..29c9dff49e 100644--- a/backend/plugin/advisor/tidb/test/column_no_null.yaml+++ b/backend/plugin/advisor/tidb/test/column_no_null.yaml@@ -3,88 +3,91 @@id int,name varchar(255))want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: '`book`.`id` cannot have NULL value'- line: 2- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 402title: column.no-nullcontent: '`book`.`name` cannot have NULL value'- line: 3- column: 0- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255))want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: '`book`.`name` cannot have NULL value'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id int NOT NULL, name varchar(255))want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: '`book`.`name` cannot have NULL value'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255) NOT NULL)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(a int NOT NULL);ALTER TABLE book ADD COLUMN (id int, name varchar(255) NOT NULL);want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: '`book`.`id` cannot have NULL value'- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE book(a int NOT NULL);ALTER TABLE book ADD COLUMN (id int PRIMARY KEY, name varchar(255) NOT NULL);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int NOT NULL);ALTER TABLE book CHANGE COLUMN id name varchar(255);want:- - status: WARN+ - status: 2code: 402title: column.no-nullcontent: '`book`.`name` cannot have NULL value'- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE book(id int NOT NULL);ALTER TABLE book CHANGE COLUMN id name varchar(255) NOT NULL;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/tidb/test/column_require_default.yaml b/backend/plugin/advisor/tidb/test/column_require_default.yamlindex 80bd03490e..9bc061d303 100644--- a/backend/plugin/advisor/tidb/test/column_require_default.yaml+++ b/backend/plugin/advisor/tidb/test/column_require_default.yaml@@ -1,41 +1,43 @@- statement: CREATE TABLE t(a int primary key, b int default 1)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int,b int default 1)want:- - status: WARN+ - status: 2code: 420title: column.require-defaultcontent: Column `t`.`a` doesn't have DEFAULT.- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-ALTER TABLE tech_book ADD COLUMN a BLOB;ALTER TABLE tech_book ADD COLUMN b timestamp;ALTER TABLE tech_book MODIFY COLUMN a varchar(220);want:- - status: WARN+ - status: 2code: 420title: column.require-defaultcontent: Column `tech_book`.`b` doesn't have DEFAULT.- line: 2- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 420title: column.require-defaultcontent: Column `tech_book`.`a` doesn't have DEFAULT.- line: 3- column: 0- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0diff --git a/backend/plugin/advisor/tidb/test/column_required.yaml b/backend/plugin/advisor/tidb/test/column_required.yamlindex 464a9cfe88..c23d786f82 100644--- a/backend/plugin/advisor/tidb/test/column_required.yaml+++ b/backend/plugin/advisor/tidb/test/column_required.yaml@@ -1,12 +1,13 @@- statement: CREATE TABLE book(id int)want:- - status: WARN+ - status: 2code: 401title: column.requiredcontent: 'Table `book` requires columns: created_ts, creator_id, updated_ts, updater_id'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE book(id int,@@ -15,13 +16,12 @@updater_id int,updated_ts timestamp)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int,@@ -31,13 +31,14 @@updated_ts timestamp);ALTER TABLE book RENAME COLUMN creator_id TO creator;want:- - status: WARN+ - status: 2code: 401title: column.requiredcontent: 'Table `book` requires columns: creator_id'- line: 7- column: 0- details: ""+ detail: ""+ startposition:+ line: 7+ column: 0- statement: |-CREATE TABLE book(id int,@@ -47,13 +48,12 @@updated_ts timestamp);ALTER TABLE book RENAME COLUMN creator TO creator_id;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int,@@ -63,13 +63,14 @@updated_ts timestamp);ALTER TABLE book CHANGE COLUMN creator_id creator int;want:- - status: WARN+ - status: 2code: 401title: column.requiredcontent: 'Table `book` requires columns: creator_id'- line: 7- column: 0- details: ""+ detail: ""+ startposition:+ line: 7+ column: 0- statement: |-CREATE TABLE book(id int,@@ -79,13 +80,12 @@updated_ts timestamp);ALTER TABLE book CHANGE COLUMN creator creator_id int;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int,@@ -95,13 +95,14 @@updated_ts timestamp);ALTER TABLE book DROP COLUMN creator_id;want:- - status: WARN+ - status: 2code: 401title: column.requiredcontent: 'Table `book` requires columns: creator_id'- line: 7- column: 0- details: ""+ detail: ""+ startposition:+ line: 7+ column: 0- statement: |-CREATE TABLE book(id int,@@ -112,13 +113,12 @@content varchar(255));ALTER TABLE book DROP COLUMN content;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int,@@ -127,13 +127,14 @@updated_ts timestamp);ALTER TABLE book ADD COLUMN content varchar(255);want:- - status: WARN+ - status: 2code: 401title: column.requiredcontent: 'Table `book` requires columns: updater_id'- line: 5- column: 0- details: ""+ detail: ""+ startposition:+ line: 5+ column: 0- statement: |-CREATE TABLE book(id int,@@ -143,13 +144,12 @@updated_ts timestamp);ALTER TABLE book ADD COLUMN creator_id int;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int,@@ -161,20 +161,22 @@created_ts timestamp,updated_ts timestamp)want:- - status: WARN+ - status: 2code: 401title: column.requiredcontent: 'Table `book` requires columns: creator_id'- line: 5- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 5+ column: 0+ - status: 2code: 401title: column.requiredcontent: 'Table `student` requires columns: creator_id, updater_id'- line: 9- column: 0- details: ""+ detail: ""+ startposition:+ line: 9+ column: 0- statement: |-CREATE TABLE book(id int,@@ -184,10 +186,9 @@updated_ts timestamp);DROP TABLE book;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/tidb/test/column_set_default_for_not_null.yaml b/backend/plugin/advisor/tidb/test/column_set_default_for_not_null.yamlindex c86d77f109..46ef28ca09 100644--- a/backend/plugin/advisor/tidb/test/column_set_default_for_not_null.yaml+++ b/backend/plugin/advisor/tidb/test/column_set_default_for_not_null.yaml@@ -3,121 +3,119 @@id int PRIMARY KEY DEFAULT 0)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int PRIMARY KEY)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int NOT NULL)want:- - status: WARN+ - status: 2code: 404title: column.set-default-for-not-nullcontent: Column `book`.`id` is NOT NULL but doesn't have DEFAULT- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE book(id int,PRIMARY KEY (id))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(a int);ALTER TABLE book ADD COLUMN id int PRIMARY KEYwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(a int);ALTER TABLE book ADD COLUMN id int NOT NULLwant:- - status: WARN+ - status: 2code: 404title: column.set-default-for-not-nullcontent: Column `book`.`id` is NOT NULL but doesn't have DEFAULT- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE book(id int);ALTER TABLE book MODIFY COLUMN id int NOT NULLwant:- - status: WARN+ - status: 2code: 404title: column.set-default-for-not-nullcontent: Column `book`.`id` is NOT NULL but doesn't have DEFAULT- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE book(id int);ALTER TABLE book MODIFY COLUMN id int PRIMARY KEYwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(uid int);ALTER TABLE book CHANGE COLUMN uid id int PRIMARY KEYwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(uid int);ALTER TABLE book CHANGE COLUMN uid id int NOT NULLwant:- - status: WARN+ - status: 2code: 404title: column.set-default-for-not-nullcontent: Column `book`.`id` is NOT NULL but doesn't have DEFAULT- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: "\n\t\t\t\tCREATE TABLE book(uid int, id int);\n\t\t\t\tALTER TABLE book \n\t\t\t\t\tCHANGE COLUMN uid uid int NOT NULL DEFAULT 0,\n\t\t\t\t\tMODIFY COLUMN id int PRIMARY KEY DEFAULT 0,\n\t\t\t\t\tADD COLUMN name varchar(20) NOT NULL DEFAULT ''\n\t\t\t\t"want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/tidb/test/column_type_disallow_list.yaml b/backend/plugin/advisor/tidb/test/column_type_disallow_list.yamlindex 3a18137232..b1da7c7f9e 100644--- a/backend/plugin/advisor/tidb/test/column_type_disallow_list.yaml+++ b/backend/plugin/advisor/tidb/test/column_type_disallow_list.yaml@@ -1,40 +1,42 @@- statement: CREATE TABLE t(a int)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a JSON, b BLOB, c TEXT)want:- - status: WARN+ - status: 2code: 411title: column.type-disallow-listcontent: Disallow column type JSON but column `t`.`a` is- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t(d int);ALTER TABLE t add COLUMN (a JSON, b BLOB, c TEXT)want:- - status: WARN+ - status: 2code: 411title: column.type-disallow-listcontent: Disallow column type JSON but column `t`.`a` is- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(c int, b int);ALTER TABLE t CHANGE COLUMN c a JSON, MODIFY b BLOBwant:- - status: WARN+ - status: 2code: 411title: column.type-disallow-listcontent: Disallow column type JSON but column `t`.`a` is- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/tidb/test/database_drop_empty_database.yaml b/backend/plugin/advisor/tidb/test/database_drop_empty_database.yamlindex 3c5e481b0b..d2cd6cdea6 100644--- a/backend/plugin/advisor/tidb/test/database_drop_empty_database.yaml+++ b/backend/plugin/advisor/tidb/test/database_drop_empty_database.yaml@@ -1,9 +1,10 @@- statement: DROP DATABASE IF EXISTS testwant:- - status: WARN+ - status: 2code: 701title: database.drop-empty-databasecontent: Database `test` is not allowed to drop if not empty- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/tidb/test/engine_mysql_use_innodb.yaml b/backend/plugin/advisor/tidb/test/engine_mysql_use_innodb.yamlindex 70190f0dda..83b551d698 100644--- a/backend/plugin/advisor/tidb/test/engine_mysql_use_innodb.yaml+++ b/backend/plugin/advisor/tidb/test/engine_mysql_use_innodb.yaml@@ -1,6 +1,6 @@- statement: CREATE TABLE book(id int) ENGINE = INNODBwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""@@ -8,7 +8,7 @@details: ""- statement: CREATE TABLE book(id int)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""@@ -16,7 +16,7 @@details: ""- statement: CREATE TABLE book(id int) ENGINE = CSVwant:- - status: WARN+ - status: 2code: 501title: engine.mysql.use-innodbcontent: |-@@ -26,7 +26,7 @@details: ""- statement: ALTER TABLE tech_book ENGINE = INNODBwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""@@ -34,7 +34,7 @@details: ""- statement: ALTER TABLE tech_book ENGINE = CSVwant:- - status: WARN+ - status: 2code: 501title: engine.mysql.use-innodbcontent: |-@@ -44,7 +44,7 @@details: ""- statement: SET default_storage_engine=INNODBwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""@@ -52,7 +52,7 @@details: ""- statement: SET default_storage_engine=CSVwant:- - status: WARN+ - status: 2code: 501title: engine.mysql.use-innodbcontent: |-diff --git a/backend/plugin/advisor/tidb/test/index_key_number_limit.yaml b/backend/plugin/advisor/tidb/test/index_key_number_limit.yamlindex 18a4ac8e38..7fb624d864 100644--- a/backend/plugin/advisor/tidb/test/index_key_number_limit.yaml+++ b/backend/plugin/advisor/tidb/test/index_key_number_limit.yaml@@ -1,55 +1,58 @@- statement: CREATE TABLE t(a int, b int, primary key (a, b))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int,b int,primary key pk (a, b, b, b, b, b, b))want:- - status: WARN+ - status: 2code: 802title: index.key-number-limitcontent: The number of index `pk` in table `t` should be not greater than 5- line: 4- column: 0- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0- statement: |-CREATE TABLE t(a int, b int, c int, d int, e int, f int, g int);CREATE INDEX idx ON t(a, b, c, d, e, f, g)want:- - status: WARN+ - status: 2code: 802title: index.key-number-limitcontent: The number of index `idx` in table `t` should be not greater than 5- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int, b int, c int, d int, e int, f int, g int);ALTER TABLE t ADD UNIQUE KEY uk (a, b, c, d, e, f, g)want:- - status: WARN+ - status: 2code: 802title: index.key-number-limitcontent: The number of index `uk` in table `t` should be not greater than 5- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int, b int, c int, d int, e int, f int, g int);ALTER TABLE t ADD FOREIGN KEY uk (a, b, c, d, e, f, g) REFERENCES t1(a, b, c, d, e, f, g)want:- - status: WARN+ - status: 2code: 802title: index.key-number-limitcontent: The number of index `uk` in table `t` should be not greater than 5- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/tidb/test/index_no_duplicate_column.yaml b/backend/plugin/advisor/tidb/test/index_no_duplicate_column.yamlindex 2391dcd8cb..2ee2f43a08 100644--- a/backend/plugin/advisor/tidb/test/index_no_duplicate_column.yaml+++ b/backend/plugin/advisor/tidb/test/index_no_duplicate_column.yaml@@ -1,76 +1,81 @@- statement: CREATE TABLE t (a int, PRIMARY KEY (a))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t (a int,INDEX idx_a (a, a))want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: INDEX `idx_a` has duplicate column `t`.`a`- line: 3- column: 0- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-CREATE TABLE t(a int);CREATE INDEX idx_a on t(a, a)want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: INDEX `idx_a` has duplicate column `t`.`a`- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD INDEX idx_a (a, a)want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: INDEX `idx_a` has duplicate column `t`.`a`- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD PRIMARY KEY pk_a (a, a)want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: PRIMARY KEY `pk_a` has duplicate column `t`.`a`- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD UNIQUE KEY uk_a (a, a)want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: UNIQUE KEY `uk_a` has duplicate column `t`.`a`- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD FOREIGN KEY fk_a (a, a) REFERENCES t1(a, b)want:- - status: WARN+ - status: 2code: 812title: index.no-duplicate-columncontent: FOREIGN KEY `fk_a` has duplicate column `t`.`a`- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/tidb/test/index_pk_type_limit.yaml b/backend/plugin/advisor/tidb/test/index_pk_type_limit.yamlindex 422c310214..159a70387a 100644--- a/backend/plugin/advisor/tidb/test/index_pk_type_limit.yaml+++ b/backend/plugin/advisor/tidb/test/index_pk_type_limit.yaml@@ -1,229 +1,232 @@- statement: CREATE TABLE t(id VARCHAR(5) PRIMARY KEY)want:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(id INT PRIMARY KEY)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(id VARCHAR(5), PRIMARY KEY(id))want:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(id INT, id2 VARCHAR(5), id3 VARCHAR(5), PRIMARY KEY(id, id2, id3))want:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id3` is varchar(5)- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(id INT, id2 BIGINT, PRIMARY KEY(id, id2))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(id INT, PRIMARY KEY(id))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id VARCHAR(5) PRIMARY KEYwant:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id INT PRIMARY KEYwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id VARCHAR(5), ADD PRIMARY KEY (id)want:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id INT, ADD COLUMN id2 VARCHAR(5), ADD COLUMN id3 VARCHAR(5), ADD PRIMARY KEY (id, id2, id3)want:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)- line: 2- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id3` is varchar(5)- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id INT, ADD COLUMN id2 BIGINT, ADD PRIMARY KEY (id, id2)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id BIGINT, ADD PRIMARY KEY (id)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id VARCHAR(5));ALTER TABLE t ADD PRIMARY KEY(id);want:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id INT, id2 VARCHAR(5), id3 VARCHAR(5));ALTER TABLE t ADD PRIMARY KEY(id, id2, id3);want:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)- line: 2- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id3` is varchar(5)- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id INT, id2 BIGINT);ALTER TABLE t ADD PRIMARY KEY(id, id2);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id BIGINT);ALTER TABLE t ADD PRIMARY KEY(id);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id int);ALTER TABLE t MODIFY COLUMN id VARCHAR(5) PRIMARY KEY;want:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id int);ALTER TABLE t MODIFY COLUMN id INT(5) PRIMARY KEY;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id int);ALTER TABLE t CHANGE COLUMN id id2 VARCHAR(5) PRIMARY KEYwant:- - status: WARN+ - status: 2code: 803title: index.pk-type-limitcontent: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id int);ALTER TABLE t CHANGE COLUMN id id2 INT(5) PRIMARY KEYwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/tidb/test/index_primary_key_type_allowlist.yaml b/backend/plugin/advisor/tidb/test/index_primary_key_type_allowlist.yamlindex 2bbd8bdad6..c6e5edff56 100644--- a/backend/plugin/advisor/tidb/test/index_primary_key_type_allowlist.yaml+++ b/backend/plugin/advisor/tidb/test/index_primary_key_type_allowlist.yaml@@ -1,229 +1,232 @@- statement: CREATE TABLE t(id VARCHAR(5) PRIMARY KEY)want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(id INT PRIMARY KEY)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(id VARCHAR(5), PRIMARY KEY(id))want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(id INT, id2 VARCHAR(5), id3 VARCHAR(5), PRIMARY KEY(id, id2, id3))want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id2` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id3` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(id INT, id2 BIGINT, PRIMARY KEY(id, id2))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(id INT, PRIMARY KEY(id))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id VARCHAR(5) PRIMARY KEYwant:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id INT PRIMARY KEYwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id VARCHAR(5), ADD PRIMARY KEY (id)want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id INT, ADD COLUMN id2 VARCHAR(5), ADD COLUMN id3 VARCHAR(5), ADD PRIMARY KEY (id, id2, id3)want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id2` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 2- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id3` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id INT, ADD COLUMN id2 BIGINT, ADD PRIMARY KEY (id, id2)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN id BIGINT, ADD PRIMARY KEY (id)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id VARCHAR(5));ALTER TABLE t ADD PRIMARY KEY(id);want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id INT, id2 VARCHAR(5), id3 VARCHAR(5));ALTER TABLE t ADD PRIMARY KEY(id, id2, id3);want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id2` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 2- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id3` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id INT, id2 BIGINT);ALTER TABLE t ADD PRIMARY KEY(id, id2);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id BIGINT);ALTER TABLE t ADD PRIMARY KEY(id);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id int);ALTER TABLE t MODIFY COLUMN id VARCHAR(5) PRIMARY KEY;want:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id int);ALTER TABLE t MODIFY COLUMN id INT(5) PRIMARY KEY;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id int);ALTER TABLE t CHANGE COLUMN id id2 VARCHAR(5) PRIMARY KEYwant:- - status: WARN+ - status: 2code: 803title: index.primary-key-type-allowlistcontent: The column `id2` in table `t` is one of the primary key, but its type "varchar" is not in allowlist- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id int);ALTER TABLE t CHANGE COLUMN id id2 INT(5) PRIMARY KEYwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/tidb/test/index_total_number_limit.yaml b/backend/plugin/advisor/tidb/test/index_total_number_limit.yamlindex d4d81e90f8..2ee4ea04b9 100644--- a/backend/plugin/advisor/tidb/test/index_total_number_limit.yaml+++ b/backend/plugin/advisor/tidb/test/index_total_number_limit.yaml@@ -1,21 +1,19 @@- statement: CREATE TABLE t(a int, b int, c int, unique key(a, b, c))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE INDEX idx_id_name on tech_book(id, name)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE INDEX idx_id_name_1 on tech_book(id, name);CREATE INDEX idx_id_name_2 on tech_book(id, name);@@ -23,13 +21,14 @@CREATE INDEX idx_id_name_4 on tech_book(id, name);CREATE INDEX idx_id_name_5 on tech_book(id, name);want:- - status: WARN+ - status: 2code: 813title: index.total-number-limitcontent: The count of index in table `tech_book` should be no more than 5, but found 8- line: 5- column: 0- details: ""+ detail: ""+ startposition:+ line: 5+ column: 0- statement: |-CREATE TABLE t(a int PRIMARY KEY, b int, c int);CREATE INDEX idx_a_b_1 on t(a, b);@@ -38,13 +37,14 @@CREATE INDEX idx_a_b_4 on t(a, b);CREATE INDEX idx_a_b_5 on t(a, b);want:- - status: WARN+ - status: 2code: 813title: index.total-number-limitcontent: The count of index in table `t` should be no more than 5, but found 6- line: 6- column: 0- details: ""+ detail: ""+ startposition:+ line: 6+ column: 0- statement: |-CREATE TABLE t(a int PRIMARY KEY,@@ -56,10 +56,11 @@INDEX idx_a_b_4 (a, b),INDEX idx_a_b_5 (a, b));want:- - status: WARN+ - status: 2code: 813title: index.total-number-limitcontent: The count of index in table `t` should be no more than 5, but found 6- line: 9- column: 0- details: ""+ detail: ""+ startposition:+ line: 9+ column: 0diff --git a/backend/plugin/advisor/tidb/test/index_type_no_blob.yaml b/backend/plugin/advisor/tidb/test/index_type_no_blob.yamlindex 76f3194216..dc0378f9c3 100644--- a/backend/plugin/advisor/tidb/test/index_type_no_blob.yaml+++ b/backend/plugin/advisor/tidb/test/index_type_no_blob.yaml@@ -1,162 +1,177 @@- statement: CREATE TABLE t(b BLOB, PRIMARY KEY(b(10)))want:- - status: WARN+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`b` is blob- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(b BLOB, mb MEDIUMBLOB, lb LONGBLOB, id INT, PRIMARY KEY(b(1), mb(2), lb(3), id))want:- - status: WARN+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`b` is blob- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`lb` is longblob- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`mb` is mediumblob- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(b BLOB, mb MEDIUMBLOB, lb LONGBLOB, id INT, UNIQUE INDEX(b(1), mb(2), lb(3), id))want:- - status: WARN+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`b` is blob- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`lb` is longblob- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`mb` is mediumblob- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(b BLOB, mb MEDIUMBLOB, lb LONGBLOB, id iNT, INDEX(b(1), mb(2), lb(3), id))want:- - status: WARN+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`b` is blob- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`lb` is longblob- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`mb` is mediumblob- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(id INT, PRIMARY KEY(id))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN b BLOB, ADD COLUMN id INT, ADD PRIMARY KEY(b(1), id)want:- - status: WARN+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`b` is blob- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN b BLOB, ADD COLUMN mb MEDIUMBLOB, ADD COLUMN lb LONGBLOB, ADD COLUMN id INT, ADD UNIQUE INDEX(b(1), mb(2), lb(3), id)want:- - status: WARN+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`b` is blob- line: 2- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`lb` is longblob- line: 2- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`mb` is mediumblob- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN b BLOB, ADD COLUMN mb MEDIUMBLOB, ADD COLUMN lb LONGBLOB, ADD COLUMN id INT, ADD INDEX(b(1), mb(2), lb(3), id)want:- - status: WARN+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`b` is blob- line: 2- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`lb` is longblob- line: 2- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`mb` is mediumblob- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t ADD COLUMN b BLOB, ADD COLUMN mb MEDIUMBLOB, ADD COLUMN lb LONGBLOB, ADD COLUMN id INT, ADD INDEX(id)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(b blob, mb mediumblob, lb longblob, id int);CREATE INDEX idx_b ON t(b(5));@@ -164,35 +179,37 @@CREATE INDEX idx_lb ON t(lb(5));CREATE INDEX idx_id ON t(id);want:- - status: WARN+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`b` is blob- line: 2- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 2+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`mb` is mediumblob- line: 3- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 804title: index.type-no-blobcontent: Columns in index must not be BLOB but `t`.`lb` is longblob- line: 4- column: 0- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0- statement: |-CREATE TABLE t(b blob, mb mediumblob, lb longblob, id int);CREATE INDEX idx_id ON t(id);want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/tidb/test/naming_column.yaml b/backend/plugin/advisor/tidb/test/naming_column.yamlindex 377f2b7ab7..79c69d7e06 100644--- a/backend/plugin/advisor/tidb/test/naming_column.yaml+++ b/backend/plugin/advisor/tidb/test/naming_column.yaml@@ -1,50 +1,51 @@- statement: CREATE TABLE book(id int, creatorId int)want:- - status: WARN+ - status: 2code: 302title: naming.columncontent: '`book`.`creatorId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id int, gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx int)want:- - status: WARN+ - status: 2code: 302title: naming.columncontent: '`book`.`gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx` mismatches column naming convention, its length should be within 64 characters'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id int, creator_id int)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int, creator_id int);ALTER TABLE book RENAME COLUMN creator_id TO creatorIdwant:- - status: WARN+ - status: 2code: 302title: naming.columncontent: '`book`.`creatorId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: ALTER TABLE tech_book RENAME COLUMN id TO creator_id;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int,@@ -54,31 +55,30 @@updated_ts timestamp);ALTER TABLE book CHANGE COLUMN creator_id creatorId int;want:- - status: WARN+ - status: 2code: 302title: naming.columncontent: '`book`.`creatorId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 7- column: 0- details: ""+ detail: ""+ startposition:+ line: 7+ column: 0- statement: ALTER TABLE tech_book CHANGE COLUMN id creator_id int;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book DROP COLUMN id;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE book(id int,@@ -87,13 +87,14 @@updated_ts timestamp);ALTER TABLE book ADD COLUMN contentString varchar(255);want:- - status: WARN+ - status: 2code: 302title: naming.columncontent: '`book`.`contentString` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 6- column: 0- details: ""+ detail: ""+ startposition:+ line: 6+ column: 0- statement: |-CREATE TABLE book(id int,@@ -105,31 +106,35 @@createdTs timestamp,updatedTs timestamp);want:- - status: WARN+ - status: 2code: 302title: naming.columncontent: '`book`.`createdTs` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 3- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 302title: naming.columncontent: '`book`.`updaterId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 4- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 4+ column: 0+ - status: 2code: 302title: naming.columncontent: '`student`.`createdTs` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 8- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 8+ column: 0+ - status: 2code: 302title: naming.columncontent: '`student`.`updatedTs` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 9- column: 0- details: ""+ detail: ""+ startposition:+ line: 9+ column: 0diff --git a/backend/plugin/advisor/tidb/test/naming_column_auto_increment.yaml b/backend/plugin/advisor/tidb/test/naming_column_auto_increment.yamlindex 4400f8cb7a..cf33e687b3 100644--- a/backend/plugin/advisor/tidb/test/naming_column_auto_increment.yaml+++ b/backend/plugin/advisor/tidb/test/naming_column_auto_increment.yaml@@ -1,45 +1,48 @@- statement: CREATE TABLE book(id int AUTO_INCREMENT)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE book(a int AUTO_INCREMENT)want:- - status: WARN+ - status: 2code: 307title: naming.column.auto-incrementcontent: '`book`.`a` mismatches auto_increment column naming convention, naming format should be "^id$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ADD COLUMN a int AUTO_INCREMENTwant:- - status: WARN+ - status: 2code: 307title: naming.column.auto-incrementcontent: '`tech_book`.`a` mismatches auto_increment column naming convention, naming format should be "^id$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book CHANGE COLUMN id a int AUTO_INCREMENTwant:- - status: WARN+ - status: 2code: 307title: naming.column.auto-incrementcontent: '`tech_book`.`a` mismatches auto_increment column naming convention, naming format should be "^id$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book MODIFY COLUMN name int AUTO_INCREMENTwant:- - status: WARN+ - status: 2code: 307title: naming.column.auto-incrementcontent: '`tech_book`.`name` mismatches auto_increment column naming convention, naming format should be "^id$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/tidb/test/naming_index_fk.yaml b/backend/plugin/advisor/tidb/test/naming_index_fk.yamlindex a66dae1f28..c500e15f2a 100644--- a/backend/plugin/advisor/tidb/test/naming_index_fk.yaml+++ b/backend/plugin/advisor/tidb/test/naming_index_fk.yaml@@ -1,61 +1,62 @@- statement: ALTER TABLE tech_book ADD CONSTRAINT fk_tech_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book ADD CONSTRAINT fk_author_id FOREIGN KEY (author_id) REFERENCES author (id)want:- - status: WARN+ - status: 2code: 305title: naming.index.fkcontent: Foreign key in table `tech_book` mismatches the naming convention, expect "^$|^fk_tech_book_author_id_author_id$" but found `fk_author_id`- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ADD CONSTRAINT rvemempmcmmhutaskvcidmwaldtfjdgmcpkhmibtadfydtkexpuzczrrneucthfwk FOREIGN KEY (author_id) REFERENCES author (id)want:- - status: WARN+ - status: 2code: 305title: naming.index.fkcontent: Foreign key `rvemempmcmmhutaskvcidmwaldtfjdgmcpkhmibtadfydtkexpuzczrrneucthfwk` in table `tech_book` mismatches the naming convention, its length should be within 64 characters- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 305title: naming.index.fkcontent: Foreign key in table `tech_book` mismatches the naming convention, expect "^$|^fk_tech_book_author_id_author_id$" but found `rvemempmcmmhutaskvcidmwaldtfjdgmcpkhmibtadfydtkexpuzczrrneucthfwk`- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id INT, author_id INT, FOREIGN KEY fk_book_author_id_author_id (author_id) REFERENCES author (id))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE book(id INT, author_id INT, FOREIGN KEY (author_id) REFERENCES author (id))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE book(id INT, author_id INT, FOREIGN KEY fk_book_author_id (author_id) REFERENCES author (id))want:- - status: WARN+ - status: 2code: 305title: naming.index.fkcontent: Foreign key in table `book` mismatches the naming convention, expect "^$|^fk_book_author_id_author_id$" but found `fk_book_author_id`- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/tidb/test/naming_index_idx.yaml b/backend/plugin/advisor/tidb/test/naming_index_idx.yamlindex 5fb8f7e591..eaa23b6793 100644--- a/backend/plugin/advisor/tidb/test/naming_index_idx.yaml+++ b/backend/plugin/advisor/tidb/test/naming_index_idx.yaml@@ -1,88 +1,88 @@- statement: CREATE INDEX idx_tech_book_id_name ON tech_book(id, name)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE INDEX tech_book_id_name ON tech_book(id, name)want:- - status: WARN+ - status: 2code: 303title: naming.index.idxcontent: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `tech_book_id_name`- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE INDEX afvjwsgrbgqzjfrkmbcoxzstznuypasijbbcdykoboredqovetzfcmmqliaelyavw ON tech_book(id, name)want:- - status: WARN+ - status: 2code: 303title: naming.index.idxcontent: Index `afvjwsgrbgqzjfrkmbcoxzstznuypasijbbcdykoboredqovetzfcmmqliaelyavw` in table `tech_book` mismatches the naming convention, its length should be within 64 characters- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 303title: naming.index.idxcontent: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `afvjwsgrbgqzjfrkmbcoxzstznuypasijbbcdykoboredqovetzfcmmqliaelyavw`- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book RENAME INDEX old_index TO idx_tech_book_id_namewant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book RENAME INDEX old_index TO idx_tech_bookwant:- - status: WARN+ - status: 2code: 303title: naming.index.idxcontent: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `idx_tech_book`- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ADD INDEX idx_tech_book_id_name (id, name)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book ADD INDEX tech_book_id_name (id, name)want:- - status: WARN+ - status: 2code: 303title: naming.index.idxcontent: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `tech_book_id_name`- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE tech_book_copy(id INT PRIMARY KEY, name VARCHAR(20), INDEX idx_tech_book_copy_name (name))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE tech_book_copy(id INT PRIMARY KEY, name VARCHAR(20), INDEX (name))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/tidb/test/naming_index_uk.yaml b/backend/plugin/advisor/tidb/test/naming_index_uk.yamlindex d0e2c690f0..6b0d29071a 100644--- a/backend/plugin/advisor/tidb/test/naming_index_uk.yaml+++ b/backend/plugin/advisor/tidb/test/naming_index_uk.yaml@@ -1,97 +1,96 @@- statement: CREATE UNIQUE INDEX uk_tech_book_id_name ON tech_book(id, name)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE UNIQUE INDEX tech_book_id_name ON tech_book(id, name)want:- - status: WARN+ - status: 2code: 304title: naming.index.ukcontent: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `tech_book_id_name`- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE UNIQUE INDEX qtzmquwvlnttctfluoouxelxeliltcfzzstrtyocogwwyiyrflmrkbhbfasynlacy ON tech_book(id, name)want:- - status: WARN+ - status: 2code: 304title: naming.index.ukcontent: Unique key `qtzmquwvlnttctfluoouxelxeliltcfzzstrtyocogwwyiyrflmrkbhbfasynlacy` in table `tech_book` mismatches the naming convention, its length should be within 64 characters- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 304title: naming.index.ukcontent: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `qtzmquwvlnttctfluoouxelxeliltcfzzstrtyocogwwyiyrflmrkbhbfasynlacy`- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book ADD UNIQUE uk_tech_book_id_name (id, name)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book ADD UNIQUE tech_book_id_name (id, name)want:- - status: WARN+ - status: 2code: 304title: naming.index.ukcontent: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `tech_book_id_name`- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book RENAME INDEX old_uk TO uk_tech_book_id_namewant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book RENAME INDEX old_uk TO uk_tech_bookwant:- - status: WARN+ - status: 2code: 304title: naming.index.ukcontent: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `uk_tech_book`- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id INT PRIMARY KEY, name VARCHAR(20), UNIQUE INDEX uk_book_name (name))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE book(id INT PRIMARY KEY, name VARCHAR(20), UNIQUE KEY (name))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE book(id INT PRIMARY KEY, name VARCHAR(20), UNIQUE INDEX (name))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/tidb/test/naming_table.yaml b/backend/plugin/advisor/tidb/test/naming_table.yamlindex 54a8cd5abb..4270f00b12 100644--- a/backend/plugin/advisor/tidb/test/naming_table.yaml+++ b/backend/plugin/advisor/tidb/test/naming_table.yaml@@ -1,79 +1,82 @@- statement: CREATE TABLE techBook(id int, name varchar(255))want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '`techBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE tech_book_copy(id int, name varchar(255))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE cjnubexocfhqoogdmihudyahmmghviqkzvpixnwvxtxumvuannpwdcbtsgwrvzpde(id int, name varchar(255))want:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '`cjnubexocfhqoogdmihudyahmmghviqkzvpixnwvxtxumvuannpwdcbtsgwrvzpde` mismatches table naming convention, its length should be within 64 characters'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book RENAME TO TechBookwant:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '`TechBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book RENAME TO tech_book_copywant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: RENAME TABLE tech_book TO tech_book_copy, tech_book_copy TO LiteraryBookwant:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '`LiteraryBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE literary_book(a int);RENAME TABLE tech_book TO TechBook, literary_book TO LiteraryBookwant:- - status: WARN+ - status: 2code: 301title: naming.tablecontent: '`LiteraryBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 1+ column: 0+ - status: 2code: 301title: naming.tablecontent: '`TechBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE literary_book(a int);RENAME TABLE tech_book TO tech_book_copy, literary_book TO literary_book_copywant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/tidb/test/schema_backward_compatibility.yaml b/backend/plugin/advisor/tidb/test/schema_backward_compatibility.yamlindex 8b8c9764da..2095297d09 100644--- a/backend/plugin/advisor/tidb/test/schema_backward_compatibility.yaml+++ b/backend/plugin/advisor/tidb/test/schema_backward_compatibility.yaml@@ -1,45 +1,50 @@- statement: ALTER TABLE tech_book CHANGE name f2 TEXTwant:- - status: WARN+ - status: 2code: 111title: schema.backward-compatibilitycontent: '"ALTER TABLE tech_book CHANGE name f2 TEXT" may cause incompatibility with the existing data and code'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book MODIFY name TEXTwant:- - status: WARN+ - status: 2code: 111title: schema.backward-compatibilitycontent: '"ALTER TABLE tech_book MODIFY name TEXT" may cause incompatibility with the existing data and code'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book MODIFY name TEXT NULLwant:- - status: WARN+ - status: 2code: 111title: schema.backward-compatibilitycontent: '"ALTER TABLE tech_book MODIFY name TEXT NULL" may cause incompatibility with the existing data and code'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book MODIFY name TEXT NOT NULLwant:- - status: WARN+ - status: 2code: 111title: schema.backward-compatibilitycontent: '"ALTER TABLE tech_book MODIFY name TEXT NOT NULL" may cause incompatibility with the existing data and code'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book MODIFY name TEXT COMMENT 'bla'want:- - status: WARN+ - status: 2code: 111title: schema.backward-compatibilitycontent: '"ALTER TABLE tech_book MODIFY name TEXT COMMENT ''bla''" may cause incompatibility with the existing data and code'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/tidb/test/statement_affected_row_limit.yaml b/backend/plugin/advisor/tidb/test/statement_affected_row_limit.yamlindex 58391995e6..3d5a9061f8 100644--- a/backend/plugin/advisor/tidb/test/statement_affected_row_limit.yaml+++ b/backend/plugin/advisor/tidb/test/statement_affected_row_limit.yaml@@ -1,6 +1,6 @@- statement: DELETE FROM tech_book WHERE a > 1want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""@@ -8,7 +8,7 @@details: ""- statement: UPDATE tech_book SET id = 1want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""diff --git a/backend/plugin/advisor/tidb/test/statement_disallow_commit.yaml b/backend/plugin/advisor/tidb/test/statement_disallow_commit.yamlindex 80ea802b96..00970f21b7 100644--- a/backend/plugin/advisor/tidb/test/statement_disallow_commit.yaml+++ b/backend/plugin/advisor/tidb/test/statement_disallow_commit.yaml@@ -3,13 +3,14 @@CREATE TABLE techBook(id int, name varchar(255));COMMIT;want:- - status: WARN+ - status: 2code: 206title: statement.disallow-commitcontent: 'Commit is not allowed, related statement: "COMMIT;"'- line: 3- column: 0- details: ""+ detail: ""+ startposition:+ line: 3+ column: 0- statement: |-START TRANSACTION;CREATE TABLE techBook(id int, name varchar(255));@@ -19,17 +20,19 @@INSERT INTO techBook(id, name) VALUES(1, "book");COMMIT;want:- - status: WARN+ - status: 2code: 206title: statement.disallow-commitcontent: 'Commit is not allowed, related statement: "COMMIT;"'- line: 3- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 206title: statement.disallow-commitcontent: 'Commit is not allowed, related statement: "COMMIT;"'- line: 7- column: 0- details: ""+ detail: ""+ startposition:+ line: 7+ column: 0diff --git a/backend/plugin/advisor/tidb/test/statement_disallow_limit.yaml b/backend/plugin/advisor/tidb/test/statement_disallow_limit.yamlindex 8537d64be6..68fef9cda5 100644--- a/backend/plugin/advisor/tidb/test/statement_disallow_limit.yaml+++ b/backend/plugin/advisor/tidb/test/statement_disallow_limit.yaml@@ -1,45 +1,48 @@- statement: ""want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: INSERT INTO tech_book SELECT * FROM tech_book LIMIT 1want:- - status: WARN+ - status: 2code: 1103title: statement.disallow-limitcontent: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO tech_book SELECT * FROM tech_book LIMIT 1" uses- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: INSERT INTO tech_book SELECT * FROM tech_book UNION SELECT * FROM tech_book LIMIT 1want:- - status: WARN+ - status: 2code: 1103title: statement.disallow-limitcontent: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO tech_book SELECT * FROM tech_book UNION SELECT * FROM tech_book LIMIT 1" uses- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: UPDATE tech_book SET name = 'my name' LIMIT 10want:- - status: WARN+ - status: 2code: 1102title: statement.disallow-limitcontent: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "UPDATE tech_book SET name = 'my name' LIMIT 10" uses- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: DELETE FROM tech_book LIMIT 10want:- - status: WARN+ - status: 2code: 1106title: statement.disallow-limitcontent: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "DELETE FROM tech_book LIMIT 10" uses- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/tidb/test/statement_disallow_mix_ddl_dml.yaml b/backend/plugin/advisor/tidb/test/statement_disallow_mix_ddl_dml.yamlindex 0ddb8406dc..80436b6637 100644--- a/backend/plugin/advisor/tidb/test/statement_disallow_mix_ddl_dml.yaml+++ b/backend/plugin/advisor/tidb/test/statement_disallow_mix_ddl_dml.yaml@@ -1,6 +1,6 @@- statement: DELETE FROM tech_book WHERE a > 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""@@ -9,7 +9,7 @@details: ""- statement: UPDATE tech_book SET id = 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""@@ -18,7 +18,7 @@details: ""- statement: ALTER TABLE tech_book ADD COLUMN author TEXT; UPDATE tech_book SET id = 1;DELETE FROM tech_book WHERE a > 1;want:- - status: WARN+ - status: 2code: 228title: statement.disallow-mix-ddl-dmlcontent: Mixing DDL with DML is not alloweddiff --git a/backend/plugin/advisor/tidb/test/statement_disallow_order_by.yaml b/backend/plugin/advisor/tidb/test/statement_disallow_order_by.yamlindex e6c666ce19..0e61539404 100644--- a/backend/plugin/advisor/tidb/test/statement_disallow_order_by.yaml+++ b/backend/plugin/advisor/tidb/test/statement_disallow_order_by.yaml@@ -1,27 +1,28 @@- statement: INSERT INTO tech_book values(1, 'a')want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: UPDATE tech_book SET name = 'my name' ORDER BY idwant:- - status: WARN+ - status: 2code: 1104title: statement.disallow-order-bycontent: ORDER BY clause is forbidden in DELETE and UPDATE statements, but "UPDATE tech_book SET name = 'my name' ORDER BY id" uses- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: DELETE FROM tech_book ORDER BY idwant:- - status: WARN+ - status: 2code: 1105title: statement.disallow-order-bycontent: ORDER BY clause is forbidden in DELETE and UPDATE statements, but "DELETE FROM tech_book ORDER BY id" uses- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/tidb/test/statement_dml_dry_run.yaml b/backend/plugin/advisor/tidb/test/statement_dml_dry_run.yamlindex 6935ed4653..b00f58a6f4 100644--- a/backend/plugin/advisor/tidb/test/statement_dml_dry_run.yaml+++ b/backend/plugin/advisor/tidb/test/statement_dml_dry_run.yaml@@ -1,18 +1,16 @@- statement: INSERT INTO tech_book values(1, 'a')want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: DELETE FROM tech_bookwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/tidb/test/statement_insert_disallow_order_by_rand.yaml b/backend/plugin/advisor/tidb/test/statement_insert_disallow_order_by_rand.yamlindex 69aad4c807..c4e44200a1 100644--- a/backend/plugin/advisor/tidb/test/statement_insert_disallow_order_by_rand.yaml+++ b/backend/plugin/advisor/tidb/test/statement_insert_disallow_order_by_rand.yaml@@ -1,18 +1,18 @@- statement: INSERT INTO tech_book VALUES(1, "a")want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: INSERT INTO tech_book SELECT * FROM tech_book ORDER BY rand()want:- - status: WARN+ - status: 2code: 1108title: statement.insert.disallow-order-by-randcontent: '"INSERT INTO tech_book SELECT * FROM tech_book ORDER BY rand()" uses ORDER BY RAND in the INSERT statement'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/tidb/test/statement_insert_must_specify_column.yaml b/backend/plugin/advisor/tidb/test/statement_insert_must_specify_column.yamlindex 38e58e3f4c..f6ad536e44 100644--- a/backend/plugin/advisor/tidb/test/statement_insert_must_specify_column.yaml+++ b/backend/plugin/advisor/tidb/test/statement_insert_must_specify_column.yaml@@ -1,18 +1,18 @@- statement: INSERT INTO tech_book(id, name) VALUES (1, '1')want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: INSERT INTO tech_book VALUES (1, '1')want:- - status: WARN+ - status: 2code: 1107title: statement.insert.must-specify-columncontent: The INSERT statement must specify columns but "INSERT INTO tech_book VALUES (1, '1')" does not- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/tidb/test/statement_insert_row_limit.yaml b/backend/plugin/advisor/tidb/test/statement_insert_row_limit.yamlindex 82dc610691..8fba6e672a 100644--- a/backend/plugin/advisor/tidb/test/statement_insert_row_limit.yaml+++ b/backend/plugin/advisor/tidb/test/statement_insert_row_limit.yaml@@ -1,6 +1,6 @@- statement: INSERT INTO tech_book values(1, 'a')want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""@@ -8,7 +8,7 @@details: ""- statement: INSERT INTO tech_book values(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')want:- - status: WARN+ - status: 2code: 1101title: statement.insert.row-limitcontent: |-@@ -18,7 +18,7 @@details: ""- statement: INSERT INTO tech_book SELECT * FROM tech_bookwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""diff --git a/backend/plugin/advisor/tidb/test/statement_maximum_limit_value.yaml b/backend/plugin/advisor/tidb/test/statement_maximum_limit_value.yamlindex 3929343eaf..92506c1406 100644--- a/backend/plugin/advisor/tidb/test/statement_maximum_limit_value.yaml+++ b/backend/plugin/advisor/tidb/test/statement_maximum_limit_value.yaml@@ -1,9 +1,11 @@- statement: |SELECT * FROM employee LIMIT 1000000;want:- - status: WARN+ - status: 2code: 222title: statement.maximum-limit-value- content: |-- The limit value 1000000 exceeds the maximum allowed value 1000- line: 1+ content: The limit value 1000000 exceeds the maximum allowed value 1000+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/tidb/test/statement_merge_alter_table.yaml b/backend/plugin/advisor/tidb/test/statement_merge_alter_table.yamlindex 4d79e8a62b..774637ea04 100644--- a/backend/plugin/advisor/tidb/test/statement_merge_alter_table.yaml+++ b/backend/plugin/advisor/tidb/test/statement_merge_alter_table.yaml@@ -1,60 +1,64 @@- statement: ALTER TABLE tech_book ADD COLUMN a intwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-ALTER TABLE tech_book ADD COLUMN a int;ALTER TABLE tech_book ADD COLUMN b int;want:- - status: WARN+ - status: 2code: 207title: statement.merge-alter-tablecontent: There are 2 statements to modify table `tech_book`- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE tech_book ADD COLUMN a int;ALTER TABLE t ADD COLUMN b int;ALTER TABLE tech_book ADD COLUMN b int;want:- - status: WARN+ - status: 2code: 207title: statement.merge-alter-tablecontent: There are 2 statements to modify table `t`- line: 3- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 207title: statement.merge-alter-tablecontent: There are 2 statements to modify table `tech_book`- line: 4- column: 0- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE tech_book ADD COLUMN a int;ALTER TABLE tech_book ADD COLUMN b int;ALTER TABLE t ADD COLUMN b int;want:- - status: WARN+ - status: 2code: 207title: statement.merge-alter-tablecontent: There are 2 statements to modify table `tech_book`- line: 3- column: 0- details: ""- - status: WARN+ detail: ""+ startposition:+ line: 3+ column: 0+ - status: 2code: 207title: statement.merge-alter-tablecontent: There are 2 statements to modify table `t`- line: 4- column: 0- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0diff --git a/backend/plugin/advisor/tidb/test/statement_prior_backup_check.yaml b/backend/plugin/advisor/tidb/test/statement_prior_backup_check.yamlindex 328b03fe13..dcd8f3bf18 100644--- a/backend/plugin/advisor/tidb/test/statement_prior_backup_check.yaml+++ b/backend/plugin/advisor/tidb/test/statement_prior_backup_check.yaml@@ -1,6 +1,6 @@- statement: DELETE FROM tech_book WHERE a > 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""@@ -9,7 +9,7 @@details: ""- statement: UPDATE tech_book SET id = 1;want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""@@ -18,7 +18,7 @@details: ""- statement: UPDATE tech_book SET id = 1;DELETE FROM tech_book WHERE a > 1;want:- - status: WARN+ - status: 2code: 227title: statement.prior-backup-checkcontent: Found 1 DELETE, 1 UPDATE on table ``.`tech_book`, disallow mixing different types of DML statementsdiff --git a/backend/plugin/advisor/tidb/test/statement_select_no_select_all.yaml b/backend/plugin/advisor/tidb/test/statement_select_no_select_all.yamlindex ea456905cd..4c38d11ba6 100644--- a/backend/plugin/advisor/tidb/test/statement_select_no_select_all.yaml+++ b/backend/plugin/advisor/tidb/test/statement_select_no_select_all.yaml@@ -1,27 +1,28 @@- statement: SELECT * FROM twant:- - status: WARN+ - status: 2code: 203title: statement.select.no-select-allcontent: '"SELECT * FROM t" uses SELECT all'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT a, b FROM twant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: SELECT a, b FROM (SELECT * from t1 JOIN t2) twant:- - status: WARN+ - status: 2code: 203title: statement.select.no-select-allcontent: '"SELECT a, b FROM (SELECT * from t1 JOIN t2) t" uses SELECT all'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/tidb/test/statement_where_no_leading_wildcard_like.yaml b/backend/plugin/advisor/tidb/test/statement_where_no_leading_wildcard_like.yamlindex 43769de859..cff6f75cc1 100644--- a/backend/plugin/advisor/tidb/test/statement_where_no_leading_wildcard_like.yaml+++ b/backend/plugin/advisor/tidb/test/statement_where_no_leading_wildcard_like.yaml@@ -1,45 +1,48 @@- statement: SELECT * FROM t WHERE a LIKE 'abc%'want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: SELECT * FROM t WHERE a LIKE '%abc'want:- - status: WARN+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: '"SELECT * FROM t WHERE a LIKE ''%abc''" uses leading wildcard LIKE'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT * FROM t WHERE a LIKE 'abc' OR a LIKE '%abc'want:- - status: WARN+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: '"SELECT * FROM t WHERE a LIKE ''abc'' OR a LIKE ''%abc''" uses leading wildcard LIKE'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc'want:- - status: WARN+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: '"SELECT * FROM t WHERE a LIKE ''%acc'' OR a LIKE ''%abc''" uses leading wildcard LIKE'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT * FROM (SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc') t1want:- - status: WARN+ - status: 2code: 204title: statement.where.no-leading-wildcard-likecontent: '"SELECT * FROM (SELECT * FROM t WHERE a LIKE ''%acc'' OR a LIKE ''%abc'') t1" uses leading wildcard LIKE'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/tidb/test/statement_where_require.yaml b/backend/plugin/advisor/tidb/test/statement_where_require.yamlindex 47b4ea23d7..cce2ea7f50 100644--- a/backend/plugin/advisor/tidb/test/statement_where_require.yaml+++ b/backend/plugin/advisor/tidb/test/statement_where_require.yaml@@ -1,81 +1,80 @@- statement: INSERT INTO tech_book(id) values (1)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: DELETE FROM tech_bookwant:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: '"DELETE FROM tech_book" requires WHERE clause'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: UPDATE tech_book SET id = 1want:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: '"UPDATE tech_book SET id = 1" requires WHERE clause'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: DELETE FROM tech_book WHERE id > 0want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: UPDATE tech_book SET id = 1 WHERE id > 10want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: SELECT id FROM tech_bookwant:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: '"SELECT id FROM tech_book" requires WHERE clause'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT id FROM tech_book WHERE id > 0want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: SELECT id FROM tech_book WHERE id > (SELECT max(id) FROM tech_book)want:- - status: WARN+ - status: 2code: 202title: statement.where.requirecontent: '"SELECT id FROM tech_book WHERE id > (SELECT max(id) FROM tech_book)" requires WHERE clause'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: SELECT CURDATE()want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/tidb/test/system_charset_allowlist.yaml b/backend/plugin/advisor/tidb/test/system_charset_allowlist.yamlindex 95782f26d7..6217ae7eac 100644--- a/backend/plugin/advisor/tidb/test/system_charset_allowlist.yaml+++ b/backend/plugin/advisor/tidb/test/system_charset_allowlist.yaml@@ -1,98 +1,102 @@- statement: CREATE TABLE t(a int) CHARSET utf8mb4want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a varchar(255))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a int) CHARSET asciiwant:- - status: WARN+ - status: 2code: 1001title: system.charset.allowlistcontent: '"CREATE TABLE t(a int) CHARSET ascii" used disabled charset ''ascii'''- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t CHARSET asciiwant:- - status: WARN+ - status: 2code: 1001title: system.charset.allowlistcontent: '"ALTER TABLE t CHARSET ascii" used disabled charset ''ascii'''- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: ALTER DATABASE test CHARSET asciiwant:- - status: WARN+ - status: 2code: 1001title: system.charset.allowlistcontent: '"ALTER DATABASE test CHARSET ascii" used disabled charset ''ascii'''- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(a varchar(255) CHARSET ascii)want:- - status: WARN+ - status: 2code: 1001title: system.charset.allowlistcontent: '"CREATE TABLE t(a varchar(255) CHARSET ascii)" used disabled charset ''ascii'''- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t(b int);ALTER TABLE t ADD COLUMN a varchar(255) CHARSET asciiwant:- - status: WARN+ - status: 2code: 1001title: system.charset.allowlistcontent: '"ALTER TABLE t ADD COLUMN a varchar(255) CHARSET ascii" used disabled charset ''ascii'''- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t MODIFY COLUMN a varchar(255) CHARSET asciiwant:- - status: WARN+ - status: 2code: 1001title: system.charset.allowlistcontent: '"ALTER TABLE t MODIFY COLUMN a varchar(255) CHARSET ascii" used disabled charset ''ascii'''- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARSET asciiwant:- - status: WARN+ - status: 2code: 1001title: system.charset.allowlistcontent: '"ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARSET ascii" used disabled charset ''ascii'''- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: /* this is a comment */want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: nulldiff --git a/backend/plugin/advisor/tidb/test/system_collation_allowlist.yaml b/backend/plugin/advisor/tidb/test/system_collation_allowlist.yamlindex 133ecd3b4e..ceb9ec68fb 100644--- a/backend/plugin/advisor/tidb/test/system_collation_allowlist.yaml+++ b/backend/plugin/advisor/tidb/test/system_collation_allowlist.yaml@@ -1,89 +1,96 @@- statement: CREATE TABLE t(a int) COLLATE utf8mb4_polish_ciwant:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlistcontent: '"CREATE TABLE t(a int) COLLATE utf8mb4_polish_ci" used disabled collation ''utf8mb4_polish_ci'''- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(a varchar(255))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(a int) COLLATE latin1_binwant:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlistcontent: '"CREATE TABLE t(a int) COLLATE latin1_bin" used disabled collation ''latin1_bin'''- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t COLLATE latin1_binwant:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlistcontent: '"ALTER TABLE t COLLATE latin1_bin" used disabled collation ''latin1_bin'''- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: ALTER DATABASE test COLLATE latin1_binwant:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlistcontent: '"ALTER DATABASE test COLLATE latin1_bin" used disabled collation ''latin1_bin'''- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin)want:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlistcontent: '"CREATE TABLE t(a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin)" used disabled collation ''latin1_bin'''- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t(b int);ALTER TABLE t ADD COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_binwant:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlistcontent: '"ALTER TABLE t ADD COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin" used disabled collation ''latin1_bin'''- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t MODIFY COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_binwant:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlistcontent: '"ALTER TABLE t MODIFY COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin" used disabled collation ''latin1_bin'''- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(a int);ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARACTER SET latin1 COLLATE latin1_binwant:- - status: WARN+ - status: 2code: 1201title: system.collation.allowlistcontent: '"ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin" used disabled collation ''latin1_bin'''- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/tidb/test/table_comment.yaml b/backend/plugin/advisor/tidb/test/table_comment.yamlindex f78e65b759..49b3c3ad11 100644--- a/backend/plugin/advisor/tidb/test/table_comment.yaml+++ b/backend/plugin/advisor/tidb/test/table_comment.yaml@@ -1,27 +1,30 @@- statement: CREATE TABLE t(a int) COMMENT 'some comments'want:- - status: WARN+ - status: 2code: 606title: table.commentcontent: The length of table `t` comment should be within 10 characters- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(a int)want:- - status: WARN+ - status: 2code: 605title: table.commentcontent: Table `t` requires comments- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE t(a int) COMMENT 'sdlfkjalkseblkjduafelbnlsdfkljayue'want:- - status: WARN+ - status: 2code: 606title: table.commentcontent: The length of table `t` comment should be within 10 characters- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/tidb/test/table_disallow_partition.yaml b/backend/plugin/advisor/tidb/test/table_disallow_partition.yamlindex e0f7470fd0..40f12e3ba3 100644--- a/backend/plugin/advisor/tidb/test/table_disallow_partition.yaml+++ b/backend/plugin/advisor/tidb/test/table_disallow_partition.yaml@@ -1,19 +1,18 @@- statement: CREATE TABLE t(a int)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(a int) PARTITION BY RANGE (a) (PARTITION p0 VALUES LESS THAN (6),PARTITION p1 VALUES LESS THAN (11))want:- - status: WARN+ - status: 2code: 608title: table.disallow-partitioncontent: |-@@ -21,16 +20,17 @@PARTITION p0 VALUES LESS THAN (6),PARTITION p1 VALUES LESS THAN (11))" creates- line: 4- column: 0- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0- statement: |-ALTER TABLE tech_book PARTITION BY RANGE (a) (PARTITION p0 VALUES LESS THAN (6),PARTITION p1 VALUES LESS THAN (11))want:- - status: WARN+ - status: 2code: 608title: table.disallow-partitioncontent: |-@@ -38,6 +38,7 @@PARTITION p0 VALUES LESS THAN (6),PARTITION p1 VALUES LESS THAN (11))" creates- line: 4- column: 0- details: ""+ detail: ""+ startposition:+ line: 4+ column: 0diff --git a/backend/plugin/advisor/tidb/test/table_drop_naming_convention.yaml b/backend/plugin/advisor/tidb/test/table_drop_naming_convention.yamlindex 6193fd1423..3e918f85ef 100644--- a/backend/plugin/advisor/tidb/test/table_drop_naming_convention.yaml+++ b/backend/plugin/advisor/tidb/test/table_drop_naming_convention.yaml@@ -1,27 +1,28 @@- statement: DROP TABLE IF EXISTS foo_deletewant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: DROP TABLE IF EXISTS foowant:- - status: WARN+ - status: 2code: 603title: table.drop-naming-conventioncontent: '`foo` mismatches drop table naming convention, naming format should be "_delete$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: DROP TABLE IF EXISTS foo_delete, barwant:- - status: WARN+ - status: 2code: 603title: table.drop-naming-conventioncontent: '`bar` mismatches drop table naming convention, naming format should be "_delete$"'- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/tidb/test/table_no_foreign_key.yaml b/backend/plugin/advisor/tidb/test/table_no_foreign_key.yamlindex b12608cae0..b9ecbc1fec 100644--- a/backend/plugin/advisor/tidb/test/table_no_foreign_key.yaml+++ b/backend/plugin/advisor/tidb/test/table_no_foreign_key.yaml@@ -1,18 +1,20 @@- statement: ALTER TABLE tech_book ADD CONSTRAINT fk_tech_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id)want:- - status: WARN+ - status: 2code: 602title: table.no-foreign-keycontent: Foreign key is not allowed in the table `tech_book`- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: CREATE TABLE book(id INT, author_id INT, FOREIGN KEY fk_book_author_id_author_id (author_id) REFERENCES author (id))want:- - status: WARN+ - status: 2code: 602title: table.no-foreign-keycontent: Foreign key is not allowed in the table `book`- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0diff --git a/backend/plugin/advisor/tidb/test/table_require_pk.yaml b/backend/plugin/advisor/tidb/test/table_require_pk.yamlindex a5b0c0f0c0..7f581825ac 100644--- a/backend/plugin/advisor/tidb/test/table_require_pk.yaml+++ b/backend/plugin/advisor/tidb/test/table_require_pk.yaml@@ -1,173 +1,168 @@- statement: CREATE TABLE t(id INT PRIMARY KEY)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(id INT, PRIMARY KEY (id))want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: CREATE TABLE t(id INT)want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table `t` requires PRIMARY KEY- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: |-CREATE TABLE t(id INT);DROP TABLE twant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id INT);ALTER TABLE t ADD CONSTRAINT PRIMARY KEY (id)want:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id INT PRIMARY KEY);ALTER TABLE t DROP PRIMARY KEYwant:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table `t` requires PRIMARY KEY- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id INT PRIMARY KEY);ALTER TABLE t DROP INDEX `PRIMARY`want:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table `t` requires PRIMARY KEY- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: |-CREATE TABLE t(id INT);ALTER TABLE t ADD COLUMN name varchar(30) PRIMARY KEYwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id INT);ALTER TABLE t CHANGE COLUMN id id INT PRIMARY KEYwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book CHANGE COLUMN id uid INTwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id INT);ALTER TABLE t MODIFY COLUMN id INT PRIMARY KEYwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: ALTER TABLE tech_book MODIFY COLUMN id INTwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id INT, name varchar(30), PRIMARY KEY(id, name));ALTER TABLE t DROP COLUMN idwant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-CREATE TABLE t(id INT, name varchar(30), comment varchar(255), PRIMARY KEY(id, name));ALTER TABLE t DROP COLUMN id, DROP COLUMN namewant:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table `t` requires PRIMARY KEY- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0- statement: ALTER TABLE tech_book ADD COLUMN a int, DROP COLUMN id, DROP COLUMN namewant:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table `tech_book` requires PRIMARY KEY- line: 1- column: 0- details: ""+ detail: ""+ startposition:+ line: 1+ column: 0- statement: ALTER TABLE tech_book DROP COLUMN namewant:- - status: SUCCESS+ - status: 1code: 0title: OKcontent: ""- line: 0- column: 0- details: ""+ detail: ""+ startposition: null- statement: |-ALTER TABLE tech_book CHANGE COLUMN id uid int;ALTER TABLE tech_book ADD COLUMN a int, DROP COLUMN uid, DROP COLUMN namewant:- - status: WARN+ - status: 2code: 601title: table.require-pkcontent: Table `tech_book` requires PRIMARY KEY- line: 2- column: 0- details: ""+ detail: ""+ startposition:+ line: 2+ column: 0diff --git a/backend/plugin/advisor/utils_for_tests.go b/backend/plugin/advisor/utils_for_tests.goindex 5550392b79..7254cadae8 100644--- a/backend/plugin/advisor/utils_for_tests.go+++ b/backend/plugin/advisor/utils_for_tests.go@@ -147,8 +147,8 @@ var (// TestCase is the data struct for test.type TestCase struct {- Statement string `yaml:"statement"`- Want []Advice `yaml:"want"`+ Statement string `yaml:"statement"`+ Want []*storepb.Advice `yaml:"want"`}type testCatalog struct {@@ -228,8 +228,8 @@ func RunSQLReviewRuleTest(t *testing.T, rule SQLReviewRuleType, dbType storepb.EadviceList, err := SQLReviewCheck(tc.Statement, ruleList, ctx)// Sort adviceList by (line, content)sort.Slice(adviceList, func(i, j int) bool {- if adviceList[i].Line != adviceList[j].Line {- return adviceList[i].Line < adviceList[j].Line+ if adviceList[i].GetStartPosition().Line != adviceList[j].GetStartPosition().Line {+ return adviceList[i].GetStartPosition().Line < adviceList[j].GetStartPosition().Line}return adviceList[i].Content < adviceList[j].Content})diff --git a/backend/runner/plancheck/statement_advise_executor.go b/backend/runner/plancheck/statement_advise_executor.goindex c1432097ac..407cd4fc81 100644--- a/backend/runner/plancheck/statement_advise_executor.go+++ b/backend/runner/plancheck/statement_advise_executor.go@@ -180,11 +180,11 @@ func (e *StatementAdviseExecutor) runForDatabaseTarget(ctx context.Context, conffor _, advice := range adviceList {status := storepb.PlanCheckRunResult_Result_SUCCESSswitch advice.Status {- case advisor.Success:+ case storepb.Advice_SUCCESS:continue- case advisor.Warn:+ case storepb.Advice_WARNING:status = storepb.PlanCheckRunResult_Result_WARNING- case advisor.Error:+ case storepb.Advice_ERROR:status = storepb.PlanCheckRunResult_Result_ERROR}@@ -195,10 +195,10 @@ func (e *StatementAdviseExecutor) runForDatabaseTarget(ctx context.Context, confCode: 0,Report: &storepb.PlanCheckRunResult_Result_SqlReviewReport_{SqlReviewReport: &storepb.PlanCheckRunResult_Result_SqlReviewReport{- Line: int32(advice.Line),- Column: int32(advice.Column),- Code: advice.Code.Int32(),- Detail: advice.Details,+ Line: advice.GetStartPosition().Line,+ Column: advice.GetStartPosition().Column,+ Code: advice.Code,+ Detail: advice.Detail,},},})@@ -370,11 +370,11 @@ func (e *StatementAdviseExecutor) runForDatabaseGroupTarget(ctx context.Context,for _, advice := range adviceList {status := storepb.PlanCheckRunResult_Result_SUCCESSswitch advice.Status {- case advisor.Success:+ case storepb.Advice_SUCCESS:continue- case advisor.Warn:+ case storepb.Advice_WARNING:status = storepb.PlanCheckRunResult_Result_WARNING- case advisor.Error:+ case storepb.Advice_ERROR:status = storepb.PlanCheckRunResult_Result_ERROR}@@ -385,10 +385,10 @@ func (e *StatementAdviseExecutor) runForDatabaseGroupTarget(ctx context.Context,Code: 0,Report: &storepb.PlanCheckRunResult_Result_SqlReviewReport_{SqlReviewReport: &storepb.PlanCheckRunResult_Result_SqlReviewReport{- Line: int32(advice.Line),- Column: int32(advice.Column),- Code: advice.Code.Int32(),- Detail: advice.Details,+ Line: advice.GetStartPosition().Line,+ Column: advice.GetStartPosition().Column,+ Code: advice.Code,+ Detail: advice.Detail,},},})diff --git a/backend/sql-server/advise.go b/backend/sql-server/advise.goindex b59236f052..bcebefacb1 100644--- a/backend/sql-server/advise.go+++ b/backend/sql-server/advise.go@@ -59,7 +59,7 @@ func (s *Server) registerAdvisorRoutes(g *echo.Group) {// @Param databaseType body string true "The database type." Enums(MYSQL, POSTGRES, TIDB, OCEANBASE, SNOWFLAKE, MSSQL)// @Param templateId body string false "The SQL check template id. Required if the config is not specified." Enums(bb.sql-review.prod, bb.sql-review.dev)// @Param override body string false "The SQL check config override string in YAML format. Check https://github.com/bytebase/bytebase/tree/main/backend/plugin/advisor/config/sql-review.override.yaml for example. Required if the template is not specified."-// @Success 200 {array} advisor.Advice+// @Success 200 {array} storepb.Advice// @Failure 400 {object} echo.HTTPError// @Failure 500 {object} echo.HTTPError// @Router /advise [post].@@ -139,8 +139,8 @@ func sqlCheck(statement string,ruleList []*storepb.SQLReviewRule,catalog catalog.Catalog,-) ([]advisor.Advice, error) {- var adviceList []advisor.Advice+) ([]*storepb.Advice, error) {+ var adviceList []*storepb.Adviceres, err := advisor.SQLReviewCheck(statement, ruleList, advisor.SQLReviewCheckContext{Charset: dbCharacterSet,@@ -154,16 +154,16 @@ func sqlCheck(return nil, err}- adviceLevel := advisor.Success+ adviceLevel := storepb.Advice_SUCCESSfor _, advice := range res {switch advice.Status {- case advisor.Warn:- if adviceLevel != advisor.Error {- adviceLevel = advisor.Warn+ case storepb.Advice_WARNING:+ if adviceLevel != storepb.Advice_ERROR {+ adviceLevel = storepb.Advice_WARNING}- case advisor.Error:- adviceLevel = advisor.Error- case advisor.Success:+ case storepb.Advice_ERROR:+ adviceLevel = storepb.Advice_ERROR+ case storepb.Advice_SUCCESS:continue}@@ -171,9 +171,9 @@ func sqlCheck(}if len(adviceList) == 0 {- adviceList = append(adviceList, advisor.Advice{- Status: advisor.Success,- Code: advisor.Ok,+ adviceList = append(adviceList, &storepb.Advice{+ Status: storepb.Advice_SUCCESS,+ Code: advisor.Ok.Int32(),Title: "OK",Content: "",})