Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor(backend): relocate postgres and parser helpers (#21503)
p0ny7079dfc1ecb4
diff --git a/backend/bin/server/cmd/recovery.go b/backend/bin/server/cmd/recovery.goindex 482f383cf3..5af5ebcbbf 100644--- a/backend/bin/server/cmd/recovery.go+++ b/backend/bin/server/cmd/recovery.go@@ -106,7 +106,7 @@ func openRecoveryBackend(ctx context.Context) (*recoveryBackend, error) {return newRecoveryBackend(stores, nil), nil}- pgURL := fmt.Sprintf("host=%s port=%d user=bb database=bb", common.GetPostgresSocketDir(), profile.DatastorePort)+ pgURL := fmt.Sprintf("host=%s port=%d user=bb database=bb", postgres.GetPostgresSocketDir(), profile.DatastorePort)if stores, err := store.New(ctx, pgURL, false); err == nil {return newRecoveryBackend(stores, nil), nil}diff --git a/backend/common/position.go b/backend/common/position.goindex 784cb3cb10..687dcc2a10 100644--- a/backend/common/position.go+++ b/backend/common/position.go@@ -2,21 +2,9 @@package commonimport (- "math"-storepb "github.com/bytebase/bytebase/backend/generated-go/store")-func safeIntToInt32(v int) int32 {- if v > math.MaxInt32 {- return math.MaxInt32- }- if v < math.MinInt32 {- return math.MinInt32- }- return int32(v)-}-// ANTLRPosition is a position in a text expressed as one-based line and// zero-based column character (code point) offset integrated with ANTLR4.type ANTLRPosition struct {@@ -63,22 +51,6 @@ func ConvertANTLRPositionToPosition(a *ANTLRPosition, text string) *storepb.Posi}}-func ConvertANTLRLineToPosition(line int) *storepb.Position {- // ANTLR line numbers are 1-based, and Position uses 1-based line numbering.- // Just pass through the value, handling the 0 case for safety.- positionLine := max(line, 1)- return &storepb.Position{- Line: safeIntToInt32(positionLine),- }-}--func ConvertTiDBParserErrorPositionToPosition(line, column int32) *storepb.Position {- return &storepb.Position{- Line: max(line, 1),- Column: max(column, 1),- }-}-// ConvertANTLRTokenToExclusiveEndPosition converts an ANTLR token position to an exclusive end Position.// The end token's line and column (0-based) plus its text are used to calculate where the position// should point to (after the last character of the token).diff --git a/backend/common/position_test.go b/backend/common/position_test.goindex 793adad8f2..0ab14d23e6 100644--- a/backend/common/position_test.go+++ b/backend/common/position_test.go@@ -43,43 +43,3 @@ func TestConvertANTLRPositionToPosition(t *testing.T) {})}}--func TestConvertTiDBParserErrorPositionToPosition(t *testing.T) {- testCases := []struct {- name string- line int32- column int32- expectedLine int32- expectedCol int32- }{- {- name: "normal position",- line: 2,- column: 10,- expectedLine: 2,- expectedCol: 10,- },- {- name: "line less than 1",- line: 0,- column: 5,- expectedLine: 1,- expectedCol: 5,- },- {- name: "column less than 1",- line: 3,- column: 0,- expectedLine: 3,- expectedCol: 1,- },- }-- for _, tc := range testCases {- t.Run(tc.name, func(t *testing.T) {- pos := ConvertTiDBParserErrorPositionToPosition(tc.line, tc.column)- require.Equal(t, tc.expectedLine, pos.Line, "line mismatch")- require.Equal(t, tc.expectedCol, pos.Column, "column mismatch")- })- }-}diff --git a/backend/common/util.go b/backend/common/util.goindex d4de41f25b..d4f43c146f 100644--- a/backend/common/util.go+++ b/backend/common/util.go@@ -77,21 +77,6 @@ func RandomString(n int) (string, error) {return sb.String(), nil}-// HasPrefixes returns true if the string s has any of the given prefixes.-func HasPrefixes(src string, prefixes ...string) bool {- for _, prefix := range prefixes {- if strings.HasPrefix(src, prefix) {- return true- }- }- return false-}--// GetPostgresSocketDir returns the postgres socket directory of Bytebase.-func GetPostgresSocketDir() string {- return "/tmp"-}-// TruncateString truncates the string to have a maximum length of `limit` characters.func TruncateString(str string, limit int) (string, bool) {chars := 0diff --git a/backend/common/util_test.go b/backend/common/util_test.goindex 6372844cdc..19d98b9343 100644--- a/backend/common/util_test.go+++ b/backend/common/util_test.go@@ -14,42 +14,6 @@ import ("google.golang.org/protobuf/reflect/protoreflect")-func TestHasPrefixes(t *testing.T) {- type args struct {- src string- prefixes []string- }- tests := []struct {- name string- args args- want bool- }{- {- name: "has prefixes",- args: args{- src: "abc",- prefixes: []string{"a", "b", "c"},- },- want: true,- },- {- name: "has no matching prefix",- args: args{- src: "this is a sentence",- prefixes: []string{"that", "x", "y"},- },- want: false,- },- }- for i := range tests {- tt := tests[i]- t.Run(tt.name, func(t *testing.T) {- got := HasPrefixes(tt.args.src, tt.args.prefixes...)- assert.Equal(t, got, tt.want)- })- }-}-func TestTruncateString(t *testing.T) {tests := []struct {name stringdiff --git a/backend/component/sample/selfhost/manager.go b/backend/component/sample/selfhost/manager.goindex 8f80dfad47..29acf8dbf9 100644--- a/backend/component/sample/selfhost/manager.go+++ b/backend/component/sample/selfhost/manager.go@@ -285,7 +285,7 @@ func dataSource(profile *config.Profile, entry *storepb.SelfHostSampleInstanceSeId: "admin",Type: storepb.DataSourceType_ADMIN,Username: entry.RoleName,- Host: common.GetPostgresSocketDir(),+ Host: postgres.GetPostgresSocketDir(),Port: strconv.Itoa(profile.Port + 3 + int(entry.PortOffset)),Database: entry.DatabaseName,}diff --git a/backend/plugin/advisor/mysql/rule_builtin_prior_backup_check.go b/backend/plugin/advisor/mysql/rule_builtin_prior_backup_check.goindex fb1313b73a..5ebe8dc306 100644--- a/backend/plugin/advisor/mysql/rule_builtin_prior_backup_check.go+++ b/backend/plugin/advisor/mysql/rule_builtin_prior_backup_check.go@@ -64,7 +64,7 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx context.Context, checkCtx advTitle: title,Content: "Prior backup cannot deal with mixed DDL and DML statements",Code: code.BuiltinPriorBackupCheck.Int32(),- StartPosition: common.ConvertANTLRLineToPosition(stmt.BaseLine()),+ StartPosition: base.ConvertANTLRLineToPosition(stmt.BaseLine()),})}}diff --git a/backend/plugin/advisor/mysql/rule_charset_allowlist.go b/backend/plugin/advisor/mysql/rule_charset_allowlist.goindex 48b3713321..fdef1f73b5 100644--- a/backend/plugin/advisor/mysql/rule_charset_allowlist.go+++ b/backend/plugin/advisor/mysql/rule_charset_allowlist.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -82,7 +82,7 @@ func (r *charsetAllowlistOmniRule) checkCharset(charset string, line int) {Code: code.DisabledCharset.Int32(),Title: r.Title,Content: fmt.Sprintf("\"%s\" used disabled charset '%s'", r.QueryText(), charset),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})}}diff --git a/backend/plugin/advisor/mysql/rule_collation_allowlist.go b/backend/plugin/advisor/mysql/rule_collation_allowlist.goindex 998293e83c..79bf20ea79 100644--- a/backend/plugin/advisor/mysql/rule_collation_allowlist.go+++ b/backend/plugin/advisor/mysql/rule_collation_allowlist.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -82,7 +82,7 @@ func (r *collationAllowlistOmniRule) checkCollation(collation string, line int)Code: code.DisabledCollation.Int32(),Title: r.Title,Content: fmt.Sprintf("\"%s\" used disabled collation '%s'", r.QueryText(), collation),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})}}diff --git a/backend/plugin/advisor/mysql/rule_column_disallow_changing.go b/backend/plugin/advisor/mysql/rule_column_disallow_changing.goindex cced9cc890..06395013e5 100644--- a/backend/plugin/advisor/mysql/rule_column_disallow_changing.go+++ b/backend/plugin/advisor/mysql/rule_column_disallow_changing.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -67,7 +67,7 @@ func (r *columnDisallowChangingOmniRule) OnStatement(node ast.Node) {Code: code.UseChangeColumnStatement.Int32(),Title: r.Title,Content: fmt.Sprintf("\"%s\" contains CHANGE COLUMN statement", r.QueryText()),- StartPosition: common.ConvertANTLRLineToPosition(int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.ContentStartLine())),})}}diff --git a/backend/plugin/advisor/mysql/rule_column_disallow_changing_order.go b/backend/plugin/advisor/mysql/rule_column_disallow_changing_order.goindex 6959aed8b8..5516bd2710 100644--- a/backend/plugin/advisor/mysql/rule_column_disallow_changing_order.go+++ b/backend/plugin/advisor/mysql/rule_column_disallow_changing_order.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -70,7 +70,7 @@ func (r *columnDisallowChangingOrderOmniRule) OnStatement(node ast.Node) {Code: code.ChangeColumnOrder.Int32(),Title: r.Title,Content: fmt.Sprintf("\"%s\" changes column order", r.QueryText()),- StartPosition: common.ConvertANTLRLineToPosition(int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.ContentStartLine())),})}default:diff --git a/backend/plugin/advisor/mysql/rule_column_disallow_changing_type.go b/backend/plugin/advisor/mysql/rule_column_disallow_changing_type.goindex ed32ac4164..d8c17c0f8f 100644--- a/backend/plugin/advisor/mysql/rule_column_disallow_changing_type.go+++ b/backend/plugin/advisor/mysql/rule_column_disallow_changing_type.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -140,7 +140,7 @@ func (r *columnDisallowChangingTypeOmniRule) checkColumnType(tableName, columnNaCode: code.ChangeColumnType.Int32(),Title: r.Title,Content: fmt.Sprintf("\"%s\" changes column type", r.QueryText()),- StartPosition: common.ConvertANTLRLineToPosition(int(r.LocToLine(loc))),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.LocToLine(loc))),})}}diff --git a/backend/plugin/advisor/mysql/rule_column_disallow_drop.go b/backend/plugin/advisor/mysql/rule_column_disallow_drop.goindex 4cf70390ab..23e29e3b86 100644--- a/backend/plugin/advisor/mysql/rule_column_disallow_drop.go+++ b/backend/plugin/advisor/mysql/rule_column_disallow_drop.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -65,7 +65,7 @@ func (r *columnDisallowDropOmniRule) OnStatement(node ast.Node) {Code: code.DropColumn.Int32(),Title: r.Title,Content: fmt.Sprintf("drops column \"%s\" of table \"%s\"", cmd.Name, tableName),- StartPosition: common.ConvertANTLRLineToPosition(int(r.LocToLine(cmd.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.LocToLine(cmd.Loc))),})}}diff --git a/backend/plugin/advisor/mysql/rule_column_disallow_drop_in_index.go b/backend/plugin/advisor/mysql/rule_column_disallow_drop_in_index.goindex 1d367bc53d..45d4b964ac 100644--- a/backend/plugin/advisor/mysql/rule_column_disallow_drop_in_index.go+++ b/backend/plugin/advisor/mysql/rule_column_disallow_drop_in_index.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -119,7 +119,7 @@ func (r *columnDisallowDropInIndexOmniRule) checkAlterTable(n *ast.AlterTableStmCode: code.DropIndexColumn.Int32(),Title: r.Title,Content: fmt.Sprintf("`%s`.`%s` cannot drop index column", tableName, columnName),- StartPosition: common.ConvertANTLRLineToPosition(int(r.LocToLine(cmd.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.LocToLine(cmd.Loc))),})}}diff --git a/backend/plugin/advisor/mysql/rule_column_disallow_set_charset.go b/backend/plugin/advisor/mysql/rule_column_disallow_set_charset.goindex 9d8d6fc0a3..721b6ce8d7 100644--- a/backend/plugin/advisor/mysql/rule_column_disallow_set_charset.go+++ b/backend/plugin/advisor/mysql/rule_column_disallow_set_charset.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -75,7 +75,7 @@ func (r *columnDisallowSetCharsetOmniRule) checkCreateTable(n *ast.CreateTableStCode: code.SetColumnCharset.Int32(),Title: r.Title,Content: fmt.Sprintf("Disallow set column charset but \"%s\" does", r.QueryText()),- StartPosition: common.ConvertANTLRLineToPosition(int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.ContentStartLine())),})}}@@ -121,7 +121,7 @@ func (r *columnDisallowSetCharsetOmniRule) checkAlterTable(n *ast.AlterTableStmtCode: code.SetColumnCharset.Int32(),Title: r.Title,Content: fmt.Sprintf("Disallow set column charset but \"%s\" does", r.QueryText()),- StartPosition: common.ConvertANTLRLineToPosition(int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.ContentStartLine())),})}}diff --git a/backend/plugin/advisor/mysql/rule_column_no_null.go b/backend/plugin/advisor/mysql/rule_column_no_null.goindex 408ac9aa80..89e42dd9e9 100644--- a/backend/plugin/advisor/mysql/rule_column_no_null.go+++ b/backend/plugin/advisor/mysql/rule_column_no_null.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -120,7 +120,7 @@ func (r *columnNoNullOmniRule) generateAdvice() {Code: code.ColumnCannotNull.Int32(),Title: r.Title,Content: fmt.Sprintf("`%s`.`%s` cannot have NULL value", column.tableName, column.columnName),- StartPosition: common.ConvertANTLRLineToPosition(column.line),+ StartPosition: base.ConvertANTLRLineToPosition(column.line),})}}diff --git a/backend/plugin/advisor/mysql/rule_column_require_charset.go b/backend/plugin/advisor/mysql/rule_column_require_charset.goindex 5c86ce5f23..8dcc34e2b0 100644--- a/backend/plugin/advisor/mysql/rule_column_require_charset.go+++ b/backend/plugin/advisor/mysql/rule_column_require_charset.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -73,7 +73,7 @@ func (r *columnRequireCharsetOmniRule) checkCreateTable(n *ast.CreateTableStmt)Code: code.NoCharset.Int32(),Title: r.Title,Content: fmt.Sprintf("Column %s does not have a character set specified", col.Name),- StartPosition: common.ConvertANTLRLineToPosition(int(r.LocToLine(col.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.LocToLine(col.Loc))),})}}@@ -95,7 +95,7 @@ func (r *columnRequireCharsetOmniRule) checkAlterTable(n *ast.AlterTableStmt) {Code: code.NoCharset.Int32(),Title: r.Title,Content: fmt.Sprintf("Column %s does not have a character set specified", cmd.Column.Name),- StartPosition: common.ConvertANTLRLineToPosition(int(r.LocToLine(cmd.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.LocToLine(cmd.Loc))),})}}@@ -110,7 +110,7 @@ func (r *columnRequireCharsetOmniRule) checkAlterTable(n *ast.AlterTableStmt) {Code: code.NoCharset.Int32(),Title: r.Title,Content: fmt.Sprintf("Column %s does not have a character set specified", col.Name),- StartPosition: common.ConvertANTLRLineToPosition(int(r.LocToLine(cmd.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.LocToLine(cmd.Loc))),})}}diff --git a/backend/plugin/advisor/mysql/rule_column_require_collation.go b/backend/plugin/advisor/mysql/rule_column_require_collation.goindex 534bddf97a..141e10880e 100644--- a/backend/plugin/advisor/mysql/rule_column_require_collation.go+++ b/backend/plugin/advisor/mysql/rule_column_require_collation.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -72,7 +72,7 @@ func (r *columnRequireCollationOmniRule) checkCreateTable(n *ast.CreateTableStmtCode: code.NoCollation.Int32(),Title: r.Title,Content: fmt.Sprintf("Column %s does not have a collation specified", col.Name),- StartPosition: common.ConvertANTLRLineToPosition(int(r.LocToLine(col.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.LocToLine(col.Loc))),})}}@@ -93,7 +93,7 @@ func (r *columnRequireCollationOmniRule) checkAlterTable(n *ast.AlterTableStmt)Code: code.NoCollation.Int32(),Title: r.Title,Content: fmt.Sprintf("Column %s does not have a collation specified", cmd.Column.Name),- StartPosition: common.ConvertANTLRLineToPosition(int(r.LocToLine(cmd.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.LocToLine(cmd.Loc))),})}}@@ -107,7 +107,7 @@ func (r *columnRequireCollationOmniRule) checkAlterTable(n *ast.AlterTableStmt)Code: code.NoCollation.Int32(),Title: r.Title,Content: fmt.Sprintf("Column %s does not have a collation specified", col.Name),- StartPosition: common.ConvertANTLRLineToPosition(int(r.LocToLine(cmd.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.LocToLine(cmd.Loc))),})}}diff --git a/backend/plugin/advisor/mysql/rule_database_drop_empty_db.go b/backend/plugin/advisor/mysql/rule_database_drop_empty_db.goindex ffe91e7266..179a07d891 100644--- a/backend/plugin/advisor/mysql/rule_database_drop_empty_db.go+++ b/backend/plugin/advisor/mysql/rule_database_drop_empty_db.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -67,7 +67,7 @@ func (r *databaseDropEmptyDBOmniRule) OnStatement(node ast.Node) {Code: code.NotCurrentDatabase.Int32(),Title: r.Title,Content: fmt.Sprintf("Database `%s` that is trying to be deleted is not the current database `%s`", dbName, r.originMetadata.DatabaseName()),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})} else if !r.originMetadata.HasNoTable() {r.AddAdvice(&storepb.Advice{@@ -75,7 +75,7 @@ func (r *databaseDropEmptyDBOmniRule) OnStatement(node ast.Node) {Code: code.DatabaseNotEmpty.Int32(),Title: r.Title,Content: fmt.Sprintf("Database `%s` is not allowed to drop if not empty", dbName),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})}}diff --git a/backend/plugin/advisor/mysql/rule_disallow_procedure.go b/backend/plugin/advisor/mysql/rule_disallow_procedure.goindex 2e67e5df3b..1cc2497526 100644--- a/backend/plugin/advisor/mysql/rule_disallow_procedure.go+++ b/backend/plugin/advisor/mysql/rule_disallow_procedure.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"advisorcode "github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -60,7 +60,7 @@ func (r *procedureDisallowCreateOmniRule) OnStatement(node ast.Node) {Code: advisorcode.DisallowCreateProcedure.Int32(),Title: r.Title,Content: fmt.Sprintf("Procedure is forbidden, but \"%s\" creates", r.QueryText()),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),})}}diff --git a/backend/plugin/advisor/mysql/rule_event_disallow_create.go b/backend/plugin/advisor/mysql/rule_event_disallow_create.goindex bd18a10dbc..eedbe6163d 100644--- a/backend/plugin/advisor/mysql/rule_event_disallow_create.go+++ b/backend/plugin/advisor/mysql/rule_event_disallow_create.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"advisorcode "github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -60,7 +60,7 @@ func (r *eventDisallowCreateOmniRule) OnStatement(node ast.Node) {Code: advisorcode.DisallowCreateEvent.Int32(),Title: r.Title,Content: fmt.Sprintf("Event is forbidden, but \"%s\" creates", r.QueryText()),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),})}}diff --git a/backend/plugin/advisor/mysql/rule_function_disallow_create.go b/backend/plugin/advisor/mysql/rule_function_disallow_create.goindex 6a52a4a383..6b1e3ec9a4 100644--- a/backend/plugin/advisor/mysql/rule_function_disallow_create.go+++ b/backend/plugin/advisor/mysql/rule_function_disallow_create.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"advisorcode "github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -60,7 +60,7 @@ func (r *functionDisallowCreateOmniRule) OnStatement(node ast.Node) {Code: advisorcode.DisallowCreateFunction.Int32(),Title: r.Title,Content: fmt.Sprintf("Function is forbidden, but \"%s\" creates", r.QueryText()),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),})}}diff --git a/backend/plugin/advisor/mysql/rule_function_disallowed_list.go b/backend/plugin/advisor/mysql/rule_function_disallowed_list.goindex 51407a355f..6235d64f67 100644--- a/backend/plugin/advisor/mysql/rule_function_disallowed_list.go+++ b/backend/plugin/advisor/mysql/rule_function_disallowed_list.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -91,7 +91,7 @@ func (r *functionDisallowedListOmniRule) checkExpr(expr ast.ExprNode) {Code: code.DisabledFunction.Int32(),Title: r.Title,Content: fmt.Sprintf("Function \"%s\" is disallowed, but \"%s\" uses", fn.Name, r.QueryText()),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(fn.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(fn.Loc))),})}return truediff --git a/backend/plugin/advisor/mysql/rule_index_key_number_limit.go b/backend/plugin/advisor/mysql/rule_index_key_number_limit.goindex 5d3c244ce3..b752e69a16 100644--- a/backend/plugin/advisor/mysql/rule_index_key_number_limit.go+++ b/backend/plugin/advisor/mysql/rule_index_key_number_limit.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -123,7 +123,7 @@ func (r *indexKeyNumberLimitOmniRule) handleConstraint(tableName string, constraCode: code.IndexKeyNumberExceedsLimit.Int32(),Title: r.Title,Content: fmt.Sprintf("The number of index `%s` in table `%s` should be not greater than %d", indexName, tableName, r.max),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(line)),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(line)),})}}@@ -145,7 +145,7 @@ func (r *indexKeyNumberLimitOmniRule) checkCreateIndex(n *ast.CreateIndexStmt) {Code: code.IndexKeyNumberExceedsLimit.Int32(),Title: r.Title,Content: fmt.Sprintf("The number of index `%s` in table `%s` should be not greater than %d", indexName, tableName, r.max),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),})}}diff --git a/backend/plugin/advisor/mysql/rule_index_no_duplicate_column.go b/backend/plugin/advisor/mysql/rule_index_no_duplicate_column.goindex c50c3c4036..be771c6ef2 100644--- a/backend/plugin/advisor/mysql/rule_index_no_duplicate_column.go+++ b/backend/plugin/advisor/mysql/rule_index_no_duplicate_column.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -119,7 +119,7 @@ func (r *indexNoDuplicateColumnOmniRule) checkCreateIndex(n *ast.CreateIndexStmtCode: code.DuplicateColumnInIndex.Int32(),Title: r.Title,Content: fmt.Sprintf("%s`%s` has duplicate column `%s`.`%s`", indexType, indexName, tableName, column),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),})}}@@ -158,7 +158,7 @@ func (r *indexNoDuplicateColumnOmniRule) handleConstraint(tableName string, consCode: code.DuplicateColumnInIndex.Int32(),Title: r.Title,Content: fmt.Sprintf("%s`%s` has duplicate column `%s`.`%s`", indexType, indexName, tableName, column),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(line)),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(line)),})}}diff --git a/backend/plugin/advisor/mysql/rule_index_pk_type.go b/backend/plugin/advisor/mysql/rule_index_pk_type.goindex 016352a007..5012a50e65 100644--- a/backend/plugin/advisor/mysql/rule_index_pk_type.go+++ b/backend/plugin/advisor/mysql/rule_index_pk_type.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/mysql/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -168,7 +168,7 @@ func (r *indexPkTypeOmniRule) addAdvice(tableName, columnName, columnType stringCode: code.IndexPKType.Int32(),Title: r.Title,Content: fmt.Sprintf("Columns in primary key must be INT/BIGINT but `%s`.`%s` is %s", tableName, columnName, columnType),- StartPosition: common.ConvertANTLRLineToPosition(lineNumber),+ StartPosition: base.ConvertANTLRLineToPosition(lineNumber),})}}diff --git a/backend/plugin/advisor/mysql/rule_index_primary_key_type_allowlist.go b/backend/plugin/advisor/mysql/rule_index_primary_key_type_allowlist.goindex 2a788c606d..60711ba1a2 100644--- a/backend/plugin/advisor/mysql/rule_index_primary_key_type_allowlist.go+++ b/backend/plugin/advisor/mysql/rule_index_primary_key_type_allowlist.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/mysql/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -92,7 +92,7 @@ func (r *indexPrimaryKeyTypeAllowlistOmniRule) checkCreateTable(n *ast.CreateTabCode: code.IndexPKType.Int32(),Title: r.Title,Content: fmt.Sprintf("The column `%s` in table `%s` is one of the primary key, but its type \"%s\" is not in allowlist", col.Name, tableName, columnType),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(col.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(col.Loc))),})}}@@ -131,7 +131,7 @@ func (r *indexPrimaryKeyTypeAllowlistOmniRule) checkAlterTable(n *ast.AlterTableCode: code.IndexPKType.Int32(),Title: r.Title,Content: fmt.Sprintf("The column `%s` in table `%s` is one of the primary key, but its type \"%s\" is not in allowlist", col.Name, tableName, columnType),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),})}}@@ -150,7 +150,7 @@ func (r *indexPrimaryKeyTypeAllowlistOmniRule) checkAlterTable(n *ast.AlterTableCode: code.IndexPKType.Int32(),Title: r.Title,Content: fmt.Sprintf("The column `%s` in table `%s` is one of the primary key, but its type \"%s\" is not in allowlist", col.Name, tableName, columnType),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),})}}@@ -170,7 +170,7 @@ func (r *indexPrimaryKeyTypeAllowlistOmniRule) checkAlterTable(n *ast.AlterTableCode: code.IndexPKType.Int32(),Title: r.Title,Content: fmt.Sprintf("The column `%s` in table `%s` is one of the primary key, but its type \"%s\" is not in allowlist", col.Name, tableName, columnType),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),})}}@@ -202,7 +202,7 @@ func (r *indexPrimaryKeyTypeAllowlistOmniRule) checkConstraint(tableName string,Code: code.IndexPKType.Int32(),Title: r.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),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(line)),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(line)),})}}diff --git a/backend/plugin/advisor/mysql/rule_index_total_number_limit.go b/backend/plugin/advisor/mysql/rule_index_total_number_limit.goindex f42bd5f8dd..7707d3d541 100644--- a/backend/plugin/advisor/mysql/rule_index_total_number_limit.go+++ b/backend/plugin/advisor/mysql/rule_index_total_number_limit.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/mysql/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -112,7 +112,7 @@ func (r *indexTotalNumberLimitOmniRule) generateAdvice() []*storepb.Advice {Code: code.IndexCountExceedsLimit.Int32(),Title: r.Title,Content: fmt.Sprintf("The count of index in table `%s` should be no more than %d, but found %d", table.name, r.max, len(tableInfo.GetProto().Indexes)),- StartPosition: common.ConvertANTLRLineToPosition(table.line),+ StartPosition: base.ConvertANTLRLineToPosition(table.line),})}}diff --git a/backend/plugin/advisor/mysql/rule_index_type_allow_list.go b/backend/plugin/advisor/mysql/rule_index_type_allow_list.goindex 8214a8ce79..51a3905266 100644--- a/backend/plugin/advisor/mysql/rule_index_type_allow_list.go+++ b/backend/plugin/advisor/mysql/rule_index_type_allow_list.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -143,6 +143,6 @@ func (r *indexTypeAllowListOmniRule) validateIndexType(indexType string, line inCode: code.IndexTypeNotAllowed.Int32(),Title: r.Title,Content: fmt.Sprintf("Index type `%s` is not allowed", indexType),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(line)),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(line)),})}diff --git a/backend/plugin/advisor/mysql/rule_index_type_no_blob.go b/backend/plugin/advisor/mysql/rule_index_type_no_blob.goindex 7fdc6caae7..8c87cf70d6 100644--- a/backend/plugin/advisor/mysql/rule_index_type_no_blob.go+++ b/backend/plugin/advisor/mysql/rule_index_type_no_blob.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/mysql/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -198,7 +198,7 @@ func (r *indexTypeNoBlobOmniRule) addAdvice(tableName, columnName, columnType stCode: code.IndexTypeNoBlob.Int32(),Title: r.Title,Content: fmt.Sprintf("Columns in index must not be BLOB but `%s`.`%s` is %s", tableName, columnName, columnType),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(line)),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(line)),})}}diff --git a/backend/plugin/advisor/mysql/rule_insert_disallow_order_by_rand.go b/backend/plugin/advisor/mysql/rule_insert_disallow_order_by_rand.goindex a806f96207..22949eedae 100644--- a/backend/plugin/advisor/mysql/rule_insert_disallow_order_by_rand.go+++ b/backend/plugin/advisor/mysql/rule_insert_disallow_order_by_rand.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -85,7 +85,7 @@ func (r *insertDisallowOrderByRandOmniRule) checkSelectForRandOrderBy(sel *ast.SCode: code.InsertUseOrderByRand.Int32(),Title: r.Title,Content: fmt.Sprintf("\"%s\" uses ORDER BY RAND in the INSERT statement", text),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.ContentStartLine())),})}}diff --git a/backend/plugin/advisor/mysql/rule_insert_must_specify_column.go b/backend/plugin/advisor/mysql/rule_insert_must_specify_column.goindex a4a1c3c426..b32b77881f 100644--- a/backend/plugin/advisor/mysql/rule_insert_must_specify_column.go+++ b/backend/plugin/advisor/mysql/rule_insert_must_specify_column.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -66,7 +66,7 @@ func (r *insertMustSpecifyColumnOmniRule) OnStatement(node ast.Node) {Code: code.InsertNotSpecifyColumn.Int32(),Title: r.Title,Content: fmt.Sprintf("The INSERT statement must specify columns but \"%s\" does not", text),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.ContentStartLine())),})return}@@ -78,7 +78,7 @@ func (r *insertMustSpecifyColumnOmniRule) OnStatement(node ast.Node) {Code: code.InsertNotSpecifyColumn.Int32(),Title: r.Title,Content: fmt.Sprintf("The INSERT statement must specify columns but \"%s\" does not", text),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.ContentStartLine())),})}}diff --git a/backend/plugin/advisor/mysql/rule_insert_row_limit.go b/backend/plugin/advisor/mysql/rule_insert_row_limit.goindex 8ad5558b0b..47de78f1db 100644--- a/backend/plugin/advisor/mysql/rule_insert_row_limit.go+++ b/backend/plugin/advisor/mysql/rule_insert_row_limit.go@@ -8,11 +8,11 @@ import ("github.com/bytebase/omni/mysql/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"mysqldriver "github.com/bytebase/bytebase/backend/plugin/db/mysql"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"mysqlparser "github.com/bytebase/bytebase/backend/plugin/parser/mysql")@@ -62,7 +62,7 @@ func (*InsertRowLimitAdvisor) Check(ctx context.Context, checkCtx advisor.ContexbaseLine := stmt.BaseLine()text := strings.TrimRight(strings.TrimSpace(stmt.Text), ";") + ";"- position := common.ConvertANTLRLineToPosition(baseLine + int(mysqlparser.ByteOffsetToRunePosition(stmt.Text, contentStartIndex(stmt.Text)).Line))+ position := base.ConvertANTLRLineToPosition(baseLine + int(mysqlparser.ByteOffsetToRunePosition(stmt.Text, contentStartIndex(stmt.Text)).Line))// INSERT ... SELECT and INSERT ... TABLE: use EXPLAIN to count rows.if ins.Select != nil || ins.TableSource != nil {diff --git a/backend/plugin/advisor/mysql/rule_migration_compatibility.go b/backend/plugin/advisor/mysql/rule_migration_compatibility.goindex fa5aeabfd6..c2e3c47376 100644--- a/backend/plugin/advisor/mysql/rule_migration_compatibility.go+++ b/backend/plugin/advisor/mysql/rule_migration_compatibility.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -76,7 +76,7 @@ func (r *compatibilityOmniRule) addIncompat(c code.Code, loc ast.Loc) {Code: c.Int32(),Title: r.Title,Content: fmt.Sprintf("\"%s\" may cause incompatibility with the existing data and code", r.QueryText()),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(loc))),})}diff --git a/backend/plugin/advisor/mysql/rule_naming_auto_increment_column.go b/backend/plugin/advisor/mysql/rule_naming_auto_increment_column.goindex fa5bc99ef2..ad40ba8f9e 100644--- a/backend/plugin/advisor/mysql/rule_naming_auto_increment_column.go+++ b/backend/plugin/advisor/mysql/rule_naming_auto_increment_column.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/mysql/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -115,7 +115,7 @@ func (r *namingAutoIncrementColumnOmniRule) handleAutoIncrementColumn(tableName,Code: code.NamingAutoIncrementColumnConventionMismatch.Int32(),Title: r.Title,Content: fmt.Sprintf("`%s`.`%s` mismatches auto_increment column naming convention, naming format should be %q", tableName, columnName, r.format),- StartPosition: common.ConvertANTLRLineToPosition(absoluteLine),+ StartPosition: base.ConvertANTLRLineToPosition(absoluteLine),})}if r.maxLength > 0 && len(columnName) > r.maxLength {@@ -124,7 +124,7 @@ func (r *namingAutoIncrementColumnOmniRule) handleAutoIncrementColumn(tableName,Code: code.NamingAutoIncrementColumnConventionMismatch.Int32(),Title: r.Title,Content: fmt.Sprintf("`%s`.`%s` mismatches auto_increment column naming convention, its length should be within %d characters", tableName, columnName, r.maxLength),- StartPosition: common.ConvertANTLRLineToPosition(absoluteLine),+ StartPosition: base.ConvertANTLRLineToPosition(absoluteLine),})}}diff --git a/backend/plugin/advisor/mysql/rule_naming_column.go b/backend/plugin/advisor/mysql/rule_naming_column.goindex 7d07f04004..a0bfd4dd2a 100644--- a/backend/plugin/advisor/mysql/rule_naming_column.go+++ b/backend/plugin/advisor/mysql/rule_naming_column.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/mysql/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var _ advisor.Advisor = (*NamingColumnConventionAdvisor)(nil)@@ -120,7 +120,7 @@ func (r *namingColumnOmniRule) handleColumn(tableName, columnName string, lineNuCode: code.NamingColumnConventionMismatch.Int32(),Title: r.Title,Content: fmt.Sprintf("`%s`.`%s` mismatches column naming convention, naming format should be %q", tableName, columnName, r.format),- StartPosition: common.ConvertANTLRLineToPosition(absoluteLine),+ StartPosition: base.ConvertANTLRLineToPosition(absoluteLine),})}if r.maxLength > 0 && len(columnName) > r.maxLength {@@ -129,7 +129,7 @@ func (r *namingColumnOmniRule) handleColumn(tableName, columnName string, lineNuCode: code.NamingColumnConventionMismatch.Int32(),Title: r.Title,Content: fmt.Sprintf("`%s`.`%s` mismatches column naming convention, its length should be within %d characters", tableName, columnName, r.maxLength),- StartPosition: common.ConvertANTLRLineToPosition(absoluteLine),+ StartPosition: base.ConvertANTLRLineToPosition(absoluteLine),})}}diff --git a/backend/plugin/advisor/mysql/rule_naming_foreign_key_convention.go b/backend/plugin/advisor/mysql/rule_naming_foreign_key_convention.goindex 97f2768b5d..76042362e6 100644--- a/backend/plugin/advisor/mysql/rule_naming_foreign_key_convention.go+++ b/backend/plugin/advisor/mysql/rule_naming_foreign_key_convention.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/mysql/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -150,7 +150,7 @@ func (r *namingFKOmniRule) handleIndexList(indexDataList []*fkIndexMetaData) {Code: code.NamingFKConventionMismatch.Int32(),Title: r.Title,Content: fmt.Sprintf("Foreign key in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),- StartPosition: common.ConvertANTLRLineToPosition(indexData.line),+ StartPosition: base.ConvertANTLRLineToPosition(indexData.line),})}if r.maxLength > 0 && len(indexData.indexName) > r.maxLength {@@ -159,7 +159,7 @@ func (r *namingFKOmniRule) handleIndexList(indexDataList []*fkIndexMetaData) {Code: code.NamingFKConventionMismatch.Int32(),Title: r.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, r.maxLength),- StartPosition: common.ConvertANTLRLineToPosition(indexData.line),+ StartPosition: base.ConvertANTLRLineToPosition(indexData.line),})}}diff --git a/backend/plugin/advisor/mysql/rule_naming_identifier_no_keyword.go b/backend/plugin/advisor/mysql/rule_naming_identifier_no_keyword.goindex 630d444ed6..2f0d54988d 100644--- a/backend/plugin/advisor/mysql/rule_naming_identifier_no_keyword.go+++ b/backend/plugin/advisor/mysql/rule_naming_identifier_no_keyword.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -135,7 +135,7 @@ func (r *namingIdentifierNoKeywordOmniRule) checkIdentifierAtLine(identifier strCode: code.NameIsKeywordIdentifier.Int32(),Title: r.Title,Content: fmt.Sprintf("Identifier %q is a keyword and should be avoided", identifier),- StartPosition: common.ConvertANTLRLineToPosition(absoluteLine),+ StartPosition: base.ConvertANTLRLineToPosition(absoluteLine),})}diff --git a/backend/plugin/advisor/mysql/rule_naming_index_convention.go b/backend/plugin/advisor/mysql/rule_naming_index_convention.goindex fc617af889..741e245378 100644--- a/backend/plugin/advisor/mysql/rule_naming_index_convention.go+++ b/backend/plugin/advisor/mysql/rule_naming_index_convention.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/mysql/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -206,7 +206,7 @@ func (r *namingIndexOmniRule) handleIndexList(indexDataList []*indexMetaData) {Code: code.NamingIndexConventionMismatch.Int32(),Title: r.Title,Content: fmt.Sprintf("Index in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),- StartPosition: common.ConvertANTLRLineToPosition(indexData.line),+ StartPosition: base.ConvertANTLRLineToPosition(indexData.line),})}if r.maxLength > 0 && len(indexData.indexName) > r.maxLength {@@ -215,7 +215,7 @@ func (r *namingIndexOmniRule) handleIndexList(indexDataList []*indexMetaData) {Code: code.NamingIndexConventionMismatch.Int32(),Title: r.Title,Content: fmt.Sprintf("Index `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, r.maxLength),- StartPosition: common.ConvertANTLRLineToPosition(indexData.line),+ StartPosition: base.ConvertANTLRLineToPosition(indexData.line),})}}diff --git a/backend/plugin/advisor/mysql/rule_naming_table.go b/backend/plugin/advisor/mysql/rule_naming_table.goindex 7406f22c21..197631a639 100644--- a/backend/plugin/advisor/mysql/rule_naming_table.go+++ b/backend/plugin/advisor/mysql/rule_naming_table.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/mysql/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -102,7 +102,7 @@ func (r *namingTableOmniRule) handleTableName(tableName string, lineNumber int32Code: code.NamingTableConventionMismatch.Int32(),Title: r.Title,Content: fmt.Sprintf("`%s` mismatches table naming convention, naming format should be %q", tableName, r.format),- StartPosition: common.ConvertANTLRLineToPosition(absoluteLine),+ StartPosition: base.ConvertANTLRLineToPosition(absoluteLine),})}if r.maxLength > 0 && len(tableName) > r.maxLength {@@ -111,7 +111,7 @@ func (r *namingTableOmniRule) handleTableName(tableName string, lineNumber int32Code: code.NamingTableConventionMismatch.Int32(),Title: r.Title,Content: fmt.Sprintf("`%s` mismatches table naming convention, its length should be within %d characters", tableName, r.maxLength),- StartPosition: common.ConvertANTLRLineToPosition(absoluteLine),+ StartPosition: base.ConvertANTLRLineToPosition(absoluteLine),})}}diff --git a/backend/plugin/advisor/mysql/rule_naming_unique_key_convention.go b/backend/plugin/advisor/mysql/rule_naming_unique_key_convention.goindex 0f17e367b5..dfc18e08c5 100644--- a/backend/plugin/advisor/mysql/rule_naming_unique_key_convention.go+++ b/backend/plugin/advisor/mysql/rule_naming_unique_key_convention.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/mysql/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -206,7 +206,7 @@ func (r *namingUKOmniRule) handleIndexList(indexDataList []*ukIndexMetaData) {Code: code.NamingUKConventionMismatch.Int32(),Title: r.Title,Content: fmt.Sprintf("Unique key in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),- StartPosition: common.ConvertANTLRLineToPosition(indexData.line),+ StartPosition: base.ConvertANTLRLineToPosition(indexData.line),})}if r.maxLength > 0 && len(indexData.indexName) > r.maxLength {@@ -215,7 +215,7 @@ func (r *namingUKOmniRule) handleIndexList(indexDataList []*ukIndexMetaData) {Code: code.NamingUKConventionMismatch.Int32(),Title: r.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, r.maxLength),- StartPosition: common.ConvertANTLRLineToPosition(indexData.line),+ StartPosition: base.ConvertANTLRLineToPosition(indexData.line),})}}diff --git a/backend/plugin/advisor/mysql/rule_online_migration.go b/backend/plugin/advisor/mysql/rule_online_migration.goindex 86a1536542..68b5da9099 100644--- a/backend/plugin/advisor/mysql/rule_online_migration.go+++ b/backend/plugin/advisor/mysql/rule_online_migration.go@@ -166,8 +166,8 @@ func (r *onlineMigrationOmniRule) OnStatement(node ast.Node) {Code: code.AdviseOnlineMigrationForStatement.Int32(),Title: r.Title,Content: fmt.Sprintf("Estimated table row count of %q is %d exceeding the set value %d. Consider using online migration for this statement", fmt.Sprintf("%s.%s", resource.Database, resource.Table), tableRows, r.minRows),- StartPosition: common.ConvertANTLRLineToPosition(startLine),- EndPosition: common.ConvertANTLRLineToPosition(endLine),+ StartPosition: base.ConvertANTLRLineToPosition(startLine),+ EndPosition: base.ConvertANTLRLineToPosition(endLine),})}breakdiff --git a/backend/plugin/advisor/mysql/rule_statement_add_column_without_position.go b/backend/plugin/advisor/mysql/rule_statement_add_column_without_position.goindex 234a88cb42..889e26660c 100644--- a/backend/plugin/advisor/mysql/rule_statement_add_column_without_position.go+++ b/backend/plugin/advisor/mysql/rule_statement_add_column_without_position.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -74,7 +74,7 @@ func (r *addColumnWithoutPositionOmniRule) OnStatement(node ast.Node) {Code: code.StatementAddColumnWithPosition.Int32(),Title: r.Title,Content: fmt.Sprintf("add column with position \"%s\"", position),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.ContentStartLine())),})}}diff --git a/backend/plugin/advisor/mysql/rule_statement_affected_row_limit.go b/backend/plugin/advisor/mysql/rule_statement_affected_row_limit.goindex e90388d107..9ab3a55cc5 100644--- a/backend/plugin/advisor/mysql/rule_statement_affected_row_limit.go+++ b/backend/plugin/advisor/mysql/rule_statement_affected_row_limit.go@@ -8,11 +8,11 @@ import ("github.com/bytebase/omni/mysql/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"mysqldriver "github.com/bytebase/bytebase/backend/plugin/db/mysql"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"mysqlparser "github.com/bytebase/bytebase/backend/plugin/parser/mysql")@@ -65,7 +65,7 @@ func (*StatementAffectedRowLimitAdvisor) Check(ctx context.Context, checkCtx advbaseLine := stmt.BaseLine()text := strings.TrimRight(strings.TrimSpace(stmt.Text), ";") + ";"- position := common.ConvertANTLRLineToPosition(baseLine + int(mysqlparser.ByteOffsetToRunePosition(stmt.Text, contentStartIndex(stmt.Text)).Line))+ position := base.ConvertANTLRLineToPosition(baseLine + int(mysqlparser.ByteOffsetToRunePosition(stmt.Text, contentStartIndex(stmt.Text)).Line))if !explains.Spend(position) {continuediff --git a/backend/plugin/advisor/mysql/rule_statement_disallow_truncate.go b/backend/plugin/advisor/mysql/rule_statement_disallow_truncate.goindex ff7ee42ff7..93a94aa11b 100644--- a/backend/plugin/advisor/mysql/rule_statement_disallow_truncate.go+++ b/backend/plugin/advisor/mysql/rule_statement_disallow_truncate.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var _ advisor.Advisor = (*StatementDisallowTruncateAdvisor)(nil)@@ -74,7 +74,7 @@ func (r *statementDisallowTruncateOmniRule) emitTable(tbl *ast.TableRef, loc astCode: code.StatementDisallowTruncate.Int32(),Title: r.Title,Content: fmt.Sprintf(`TRUNCATE TABLE %q is not allowed: TRUNCATE auto-commits (breaking surrounding transactional work), bypasses triggers, and resets AUTO_INCREMENT. Prior-backup treats this as DDL and does not produce row-level snapshots.`, qualifyMySQLName(tbl)),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(loc))),})}@@ -84,7 +84,7 @@ func (r *statementDisallowTruncateOmniRule) emitPartition(tbl *ast.TableRef, parCode: code.StatementDisallowTruncate.Int32(),Title: r.Title,Content: fmt.Sprintf(`ALTER TABLE %q TRUNCATE PARTITION %q is not allowed: partition truncate shares the auto-commit and prior-backup gaps of TRUNCATE TABLE on MySQL.`, qualifyMySQLName(tbl), partition),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(loc))),})}diff --git a/backend/plugin/advisor/mysql/rule_statement_dml_dry_run.go b/backend/plugin/advisor/mysql/rule_statement_dml_dry_run.goindex 58b18dc48c..32b9b42730 100644--- a/backend/plugin/advisor/mysql/rule_statement_dml_dry_run.go+++ b/backend/plugin/advisor/mysql/rule_statement_dml_dry_run.go@@ -11,6 +11,7 @@ import (storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"mysqlparser "github.com/bytebase/bytebase/backend/plugin/parser/mysql")@@ -74,7 +75,7 @@ func (*StatementDmlDryRunAdvisor) Check(ctx context.Context, checkCtx advisor.CoCode: code.StatementDMLDryRunFailed.Int32(),Title: title,Content: fmt.Sprintf("\"%s\" dry runs failed: %s", text, err.Error()),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})}diff --git a/backend/plugin/advisor/mysql/rule_statement_merge_alter_table.go b/backend/plugin/advisor/mysql/rule_statement_merge_alter_table.goindex 982aa5f5af..8f20c031ed 100644--- a/backend/plugin/advisor/mysql/rule_statement_merge_alter_table.go+++ b/backend/plugin/advisor/mysql/rule_statement_merge_alter_table.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -116,7 +116,7 @@ func (r *mergeAlterTableOmniRule) generateAdvice() {Code: code.StatementRedundantAlterTable.Int32(),Title: r.Title,Content: fmt.Sprintf("There are %d statements to modify table `%s`", table.count, table.name),- StartPosition: common.ConvertANTLRLineToPosition(table.lastLine),+ StartPosition: base.ConvertANTLRLineToPosition(table.lastLine),})}}diff --git a/backend/plugin/advisor/mysql/rule_statement_where_disallow_using_function.go b/backend/plugin/advisor/mysql/rule_statement_where_disallow_using_function.goindex 45f5e00182..008f84e926 100644--- a/backend/plugin/advisor/mysql/rule_statement_where_disallow_using_function.go+++ b/backend/plugin/advisor/mysql/rule_statement_where_disallow_using_function.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -551,7 +551,7 @@ func (r *whereDisallowFuncOmniRule) addFunctionAdvice(funcName, col string, locCode: code.StatementDisallowFunctionsAndCalculations.Int32(),Title: r.Title,Content: fmt.Sprintf("Function %q is applied to indexed column %q in the WHERE clause, which prevents index usage", funcName, col),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(loc))),})}@@ -561,7 +561,7 @@ func (r *whereDisallowFuncOmniRule) addCalculationAdvice(col string, loc ast.LocCode: code.StatementDisallowFunctionsAndCalculations.Int32(),Title: r.Title,Content: fmt.Sprintf("Calculation is applied to indexed column %q in the WHERE clause, which prevents index usage", col),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(loc))),})}diff --git a/backend/plugin/advisor/mysql/rule_statement_where_maximum_logical_operator_count.go b/backend/plugin/advisor/mysql/rule_statement_where_maximum_logical_operator_count.goindex f3d099809f..aff2bc000d 100644--- a/backend/plugin/advisor/mysql/rule_statement_where_maximum_logical_operator_count.go+++ b/backend/plugin/advisor/mysql/rule_statement_where_maximum_logical_operator_count.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/mysql/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"mysqlparser "github.com/bytebase/bytebase/backend/plugin/parser/mysql")@@ -122,7 +122,7 @@ func (r *maxLogicalOperatorOmniRule) checkExpr(expr ast.ExprNode, text string) {Code: code.StatementWhereMaximumLogicalOperatorCount.Int32(),Title: r.Title,Content: fmt.Sprintf("Number of tokens (%d) in the OR predicate operation exceeds limit (%d) in statement %q.", orCount, r.maximum, text),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(line)),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(line)),})}// Check IN lists.@@ -180,7 +180,7 @@ func (r *maxLogicalOperatorOmniRule) walkExprForIn(expr ast.ExprNode, text strinCode: code.StatementWhereMaximumLogicalOperatorCount.Int32(),Title: r.Title,Content: fmt.Sprintf("Number of tokens (%d) in IN predicate operation exceeds limit (%d) in statement %q.", count, r.maximum, text),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(e.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(e.Loc))),})}return falsediff --git a/backend/plugin/advisor/mysql/rule_statement_where_no_equal_null.go b/backend/plugin/advisor/mysql/rule_statement_where_no_equal_null.goindex eeca614590..dc6f6e92a2 100644--- a/backend/plugin/advisor/mysql/rule_statement_where_no_equal_null.go+++ b/backend/plugin/advisor/mysql/rule_statement_where_no_equal_null.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -65,7 +65,7 @@ func (r *whereNoEqualNullOmniRule) OnStatement(node ast.Node) {Code: code.StatementWhereNoEqualNull.Int32(),Title: r.Title,Content: fmt.Sprintf("WHERE clause contains equal null: %s", text),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(bin.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(bin.Loc))),})}}diff --git a/backend/plugin/advisor/mysql/rule_stmt_disallow_commit.go b/backend/plugin/advisor/mysql/rule_stmt_disallow_commit.goindex 3d2e49269a..7f22df5b3c 100644--- a/backend/plugin/advisor/mysql/rule_stmt_disallow_commit.go+++ b/backend/plugin/advisor/mysql/rule_stmt_disallow_commit.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -63,6 +63,6 @@ func (r *disallowCommitOmniRule) OnStatement(node ast.Node) {Code: code.StatementDisallowCommit.Int32(),Title: r.Title,Content: fmt.Sprintf("Commit is not allowed, related statement: \"%s\"", text),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),})}diff --git a/backend/plugin/advisor/mysql/rule_stmt_disallow_limit.go b/backend/plugin/advisor/mysql/rule_stmt_disallow_limit.goindex 82538b25c9..ac4dd5e274 100644--- a/backend/plugin/advisor/mysql/rule_stmt_disallow_limit.go+++ b/backend/plugin/advisor/mysql/rule_stmt_disallow_limit.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -102,6 +102,6 @@ func (r *disallowLimitOmniRule) addLimitAdvice(c code.Code, text string, _ ast.LCode: c.Int32(),Title: r.Title,Content: fmt.Sprintf("LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but \"%s\" uses", text),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.ContentStartLine())),})}diff --git a/backend/plugin/advisor/mysql/rule_stmt_disallow_order_by.go b/backend/plugin/advisor/mysql/rule_stmt_disallow_order_by.goindex df3842d58f..76fcbfbfff 100644--- a/backend/plugin/advisor/mysql/rule_stmt_disallow_order_by.go+++ b/backend/plugin/advisor/mysql/rule_stmt_disallow_order_by.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -73,6 +73,6 @@ func (r *disallowOrderByOmniRule) addOrderByAdvice(c code.Code, text string, locCode: c.Int32(),Title: r.Title,Content: fmt.Sprintf("ORDER BY clause is forbidden in DELETE and UPDATE statements, but \"%s\" uses", text),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(loc))),})}diff --git a/backend/plugin/advisor/mysql/rule_stmt_no_leading_wildcard_like.go b/backend/plugin/advisor/mysql/rule_stmt_no_leading_wildcard_like.goindex 2e2aff5dff..ea39c98df1 100644--- a/backend/plugin/advisor/mysql/rule_stmt_no_leading_wildcard_like.go+++ b/backend/plugin/advisor/mysql/rule_stmt_no_leading_wildcard_like.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -73,7 +73,7 @@ func (r *noLeadingWildcardLikeOmniRule) checkLikeExpr(like *ast.LikeExpr, text sCode: code.StatementLeadingWildcardLike.Int32(),Title: r.Title,Content: fmt.Sprintf("\"%s\" uses leading wildcard LIKE", text),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(like.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(like.Loc))),})}}diff --git a/backend/plugin/advisor/mysql/rule_stmt_no_select_all.go b/backend/plugin/advisor/mysql/rule_stmt_no_select_all.goindex 28e466aff6..dfc6f999e9 100644--- a/backend/plugin/advisor/mysql/rule_stmt_no_select_all.go+++ b/backend/plugin/advisor/mysql/rule_stmt_no_select_all.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -70,7 +70,7 @@ func (r *noSelectAllOmniRule) OnStatement(node ast.Node) {Code: code.StatementSelectAll.Int32(),Title: r.Title,Content: fmt.Sprintf("\"%s\" uses SELECT all", text),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.findStarLine(target))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.findStarLine(target))),})}}diff --git a/backend/plugin/advisor/mysql/rule_stmt_require_algorithm_or_lock_options.go b/backend/plugin/advisor/mysql/rule_stmt_require_algorithm_or_lock_options.goindex 6beb04e4eb..3813485562 100644--- a/backend/plugin/advisor/mysql/rule_stmt_require_algorithm_or_lock_options.go+++ b/backend/plugin/advisor/mysql/rule_stmt_require_algorithm_or_lock_options.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -85,7 +85,7 @@ func (r *requireAlgoLockOmniRule) OnStatement(node ast.Node) {Code: int32(r.errorCode),Title: r.Title,Content: "ALTER TABLE statement should include " + r.requiredOption + " option",- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.ContentStartLine())),})}}diff --git a/backend/plugin/advisor/mysql/rule_stmt_where_requirement_for_select.go b/backend/plugin/advisor/mysql/rule_stmt_where_requirement_for_select.goindex 89fb103077..ef8a00cb96 100644--- a/backend/plugin/advisor/mysql/rule_stmt_where_requirement_for_select.go+++ b/backend/plugin/advisor/mysql/rule_stmt_where_requirement_for_select.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -95,7 +95,7 @@ func (r *whereRequirementForSelectOmniRule) checkSelectStmt(sel *ast.SelectStmt,Code: code.StatementNoWhere.Int32(),Title: r.Title,Content: fmt.Sprintf("\"%s\" requires WHERE clause", text),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(sel.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(sel.Loc))),})}diff --git a/backend/plugin/advisor/mysql/rule_stmt_where_requirement_for_update_delete.go b/backend/plugin/advisor/mysql/rule_stmt_where_requirement_for_update_delete.goindex 431f15feea..7b0cb12e6d 100644--- a/backend/plugin/advisor/mysql/rule_stmt_where_requirement_for_update_delete.go+++ b/backend/plugin/advisor/mysql/rule_stmt_where_requirement_for_update_delete.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -62,7 +62,7 @@ func (r *whereRequirementForUpdateDeleteOmniRule) OnStatement(node ast.Node) {Code: code.StatementNoWhere.Int32(),Title: r.Title,Content: fmt.Sprintf("\"%s\" requires WHERE clause", text),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.ContentStartLine())),})}case *ast.UpdateStmt:@@ -72,7 +72,7 @@ func (r *whereRequirementForUpdateDeleteOmniRule) OnStatement(node ast.Node) {Code: code.StatementNoWhere.Int32(),Title: r.Title,Content: fmt.Sprintf("\"%s\" requires WHERE clause", text),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.ContentStartLine())),})}default:diff --git a/backend/plugin/advisor/mysql/rule_table_comment_convention.go b/backend/plugin/advisor/mysql/rule_table_comment_convention.goindex c8d651d469..e0c0d938f7 100644--- a/backend/plugin/advisor/mysql/rule_table_comment_convention.go+++ b/backend/plugin/advisor/mysql/rule_table_comment_convention.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -84,7 +84,7 @@ func (r *tableCommentConventionOmniRule) checkCreateTable(n *ast.CreateTableStmtCode: code.CommentEmpty.Int32(),Title: r.Title,Content: fmt.Sprintf("Table `%s` requires comments", tableName),- StartPosition: common.ConvertANTLRLineToPosition(int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.ContentStartLine())),})}if r.payload.MaxLength >= 0 && int32(len(comment)) > r.payload.MaxLength {@@ -93,7 +93,7 @@ func (r *tableCommentConventionOmniRule) checkCreateTable(n *ast.CreateTableStmtCode: code.CommentTooLong.Int32(),Title: r.Title,Content: fmt.Sprintf("The length of table `%s` comment should be within %d characters", tableName, r.payload.MaxLength),- StartPosition: common.ConvertANTLRLineToPosition(int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.ContentStartLine())),})}}diff --git a/backend/plugin/advisor/mysql/rule_table_disallow_ddl.go b/backend/plugin/advisor/mysql/rule_table_disallow_ddl.goindex cd8785291c..5514a536c8 100644--- a/backend/plugin/advisor/mysql/rule_table_disallow_ddl.go+++ b/backend/plugin/advisor/mysql/rule_table_disallow_ddl.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -88,7 +88,7 @@ func (r *tableDisallowDDLOmniRule) checkTableName(tableName string, lineNumber iCode: code.TableDisallowDDL.Int32(),Title: r.Title,Content: fmt.Sprintf("DDL is disallowed on table %s.", tableName),- StartPosition: common.ConvertANTLRLineToPosition(absoluteLine),+ StartPosition: base.ConvertANTLRLineToPosition(absoluteLine),})return}diff --git a/backend/plugin/advisor/mysql/rule_table_disallow_dml.go b/backend/plugin/advisor/mysql/rule_table_disallow_dml.goindex fdc63e7db1..3d3b7eebbb 100644--- a/backend/plugin/advisor/mysql/rule_table_disallow_dml.go+++ b/backend/plugin/advisor/mysql/rule_table_disallow_dml.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -82,7 +82,7 @@ func (r *tableDisallowDMLOmniRule) checkTableName(tableName string, lineNumber iCode: code.TableDisallowDML.Int32(),Title: r.Title,Content: fmt.Sprintf("DML is disallowed on table %s.", tableName),- StartPosition: common.ConvertANTLRLineToPosition(absoluteLine),+ StartPosition: base.ConvertANTLRLineToPosition(absoluteLine),})return}diff --git a/backend/plugin/advisor/mysql/rule_table_disallow_partition.go b/backend/plugin/advisor/mysql/rule_table_disallow_partition.goindex bb8abfb764..64810889ff 100644--- a/backend/plugin/advisor/mysql/rule_table_disallow_partition.go+++ b/backend/plugin/advisor/mysql/rule_table_disallow_partition.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"advisorcode "github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -68,7 +68,7 @@ func (r *tableDisallowPartitionOmniRule) checkCreateTable(n *ast.CreateTableStmtCode: advisorcode.CreateTablePartition.Int32(),Title: r.Title,Content: fmt.Sprintf("Table partition is forbidden, but \"%s\" creates", r.QueryText()),- StartPosition: common.ConvertANTLRLineToPosition(int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.ContentStartLine())),})}}@@ -84,7 +84,7 @@ func (r *tableDisallowPartitionOmniRule) checkAlterTable(n *ast.AlterTableStmt)Code: advisorcode.CreateTablePartition.Int32(),Title: r.Title,Content: fmt.Sprintf("Table partition is forbidden, but \"%s\" creates", r.QueryText()),- StartPosition: common.ConvertANTLRLineToPosition(int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.ContentStartLine())),})return}diff --git a/backend/plugin/advisor/mysql/rule_table_disallow_set_charset.go b/backend/plugin/advisor/mysql/rule_table_disallow_set_charset.goindex 93afcae6d8..fac718bec4 100644--- a/backend/plugin/advisor/mysql/rule_table_disallow_set_charset.go+++ b/backend/plugin/advisor/mysql/rule_table_disallow_set_charset.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -66,7 +66,7 @@ func (r *tableDisallowSetCharsetOmniRule) checkCreateTable(n *ast.CreateTableStmCode: code.DisallowSetCharset.Int32(),Title: r.Title,Content: fmt.Sprintf("Set charset on tables is disallowed, but \"%s\" uses", r.QueryText()),- StartPosition: common.ConvertANTLRLineToPosition(int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.ContentStartLine())),})}}@@ -83,7 +83,7 @@ func (r *tableDisallowSetCharsetOmniRule) checkAlterTable(n *ast.AlterTableStmt)Code: code.DisallowSetCharset.Int32(),Title: r.Title,Content: fmt.Sprintf("Set charset on tables is disallowed, but \"%s\" uses", r.QueryText()),- StartPosition: common.ConvertANTLRLineToPosition(int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.ContentStartLine())),})}}diff --git a/backend/plugin/advisor/mysql/rule_table_disallow_trigger.go b/backend/plugin/advisor/mysql/rule_table_disallow_trigger.goindex ffe17df336..ebfe07b0e7 100644--- a/backend/plugin/advisor/mysql/rule_table_disallow_trigger.go+++ b/backend/plugin/advisor/mysql/rule_table_disallow_trigger.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"advisorcode "github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -60,7 +60,7 @@ func (r *tableDisallowTriggerOmniRule) OnStatement(node ast.Node) {Code: advisorcode.CreateTableTrigger.Int32(),Title: r.Title,Content: fmt.Sprintf("Trigger is forbidden, but \"%s\" creates", r.QueryText()),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),})}}diff --git a/backend/plugin/advisor/mysql/rule_table_drop_naming_convention.go b/backend/plugin/advisor/mysql/rule_table_drop_naming_convention.goindex d9d7cd2162..46265a2c4e 100644--- a/backend/plugin/advisor/mysql/rule_table_drop_naming_convention.go+++ b/backend/plugin/advisor/mysql/rule_table_drop_naming_convention.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/mysql/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -77,7 +77,7 @@ func (r *tableDropNamingConventionOmniRule) OnStatement(node ast.Node) {Code: code.TableDropNamingConventionMismatch.Int32(),Title: r.Title,Content: fmt.Sprintf("`%s` mismatches drop table naming convention, naming format should be %q", tbl.Name, r.format),- StartPosition: common.ConvertANTLRLineToPosition(absoluteLine),+ StartPosition: base.ConvertANTLRLineToPosition(absoluteLine),})}}diff --git a/backend/plugin/advisor/mysql/rule_table_limit_size.go b/backend/plugin/advisor/mysql/rule_table_limit_size.goindex b38387f53f..1fde4314d7 100644--- a/backend/plugin/advisor/mysql/rule_table_limit_size.go+++ b/backend/plugin/advisor/mysql/rule_table_limit_size.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/mysql/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")func init() {@@ -110,7 +110,7 @@ func (r *tableLimitSizeOmniRule) generateAdvice() {Code: code.TableExceedLimitSize.Int32(),Title: r.Title,Content: fmt.Sprintf("Apply DDL on large table '%s' ( %d rows ) will lock table for a long time", tabName, tableRows),- StartPosition: common.ConvertANTLRLineToPosition(int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.ContentStartLine())),})}}diff --git a/backend/plugin/advisor/mysql/rule_table_no_duplicate_index.go b/backend/plugin/advisor/mysql/rule_table_no_duplicate_index.goindex b1284bfa5f..1b704f898e 100644--- a/backend/plugin/advisor/mysql/rule_table_no_duplicate_index.go+++ b/backend/plugin/advisor/mysql/rule_table_no_duplicate_index.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -91,7 +91,7 @@ func (r *tableNoDuplicateIndexOmniRule) checkCreateTable(n *ast.CreateTableStmt)Code: code.DuplicateIndexInTable.Int32(),Title: r.Title,Content: fmt.Sprintf("`%s` has duplicate index `%s`", tableName, index.indexName),- StartPosition: common.ConvertANTLRLineToPosition(index.line),+ StartPosition: base.ConvertANTLRLineToPosition(index.line),})}}@@ -119,7 +119,7 @@ func (r *tableNoDuplicateIndexOmniRule) checkAlterTable(n *ast.AlterTableStmt) {Code: code.DuplicateIndexInTable.Int32(),Title: r.Title,Content: fmt.Sprintf("`%s` has duplicate index `%s`", tableName, index.indexName),- StartPosition: common.ConvertANTLRLineToPosition(index.line),+ StartPosition: base.ConvertANTLRLineToPosition(index.line),})}}@@ -184,7 +184,7 @@ func (r *tableNoDuplicateIndexOmniRule) checkCreateIndex(n *ast.CreateIndexStmt)Code: code.DuplicateIndexInTable.Int32(),Title: r.Title,Content: fmt.Sprintf("`%s` has duplicate index `%s`", tableName, dup.indexName),- StartPosition: common.ConvertANTLRLineToPosition(dup.line),+ StartPosition: base.ConvertANTLRLineToPosition(dup.line),})}}diff --git a/backend/plugin/advisor/mysql/rule_table_no_fk.go b/backend/plugin/advisor/mysql/rule_table_no_fk.goindex bc3674517a..060b11258c 100644--- a/backend/plugin/advisor/mysql/rule_table_no_fk.go+++ b/backend/plugin/advisor/mysql/rule_table_no_fk.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -73,7 +73,7 @@ func (r *tableNoFKOmniRule) checkCreateTable(n *ast.CreateTableStmt) {Code: code.TableHasFK.Int32(),Title: r.Title,Content: fmt.Sprintf("Foreign key is not allowed in the table `%s`", tableName),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(constraint.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(constraint.Loc))),})}}@@ -94,7 +94,7 @@ func (r *tableNoFKOmniRule) checkAlterTable(n *ast.AlterTableStmt) {Code: code.TableHasFK.Int32(),Title: r.Title,Content: fmt.Sprintf("Foreign key is not allowed in the table `%s`", tableName),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(cmd.Constraint.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(cmd.Constraint.Loc))),})}}diff --git a/backend/plugin/advisor/mysql/rule_table_require_charset.go b/backend/plugin/advisor/mysql/rule_table_require_charset.goindex 191c2a1923..b11ec1002c 100644--- a/backend/plugin/advisor/mysql/rule_table_require_charset.go+++ b/backend/plugin/advisor/mysql/rule_table_require_charset.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -79,7 +79,7 @@ func (r *tableRequireCharsetOmniRule) checkCreateTable(n *ast.CreateTableStmt) {Code: code.NoCharset.Int32(),Title: r.Title,Content: fmt.Sprintf("Table %s does not have a character set specified", tableName),- StartPosition: common.ConvertANTLRLineToPosition(int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.ContentStartLine())),})}}diff --git a/backend/plugin/advisor/mysql/rule_table_require_collation.go b/backend/plugin/advisor/mysql/rule_table_require_collation.goindex 12a9e19f5c..c104c8dc9e 100644--- a/backend/plugin/advisor/mysql/rule_table_require_collation.go+++ b/backend/plugin/advisor/mysql/rule_table_require_collation.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -79,7 +79,7 @@ func (r *tableRequireCollationOmniRule) checkCreateTable(n *ast.CreateTableStmt)Code: code.NoCollation.Int32(),Title: r.Title,Content: fmt.Sprintf("Table %s does not have a collation specified", tableName),- StartPosition: common.ConvertANTLRLineToPosition(int(r.ContentStartLine())),+ StartPosition: base.ConvertANTLRLineToPosition(int(r.ContentStartLine())),})}}diff --git a/backend/plugin/advisor/mysql/rule_table_require_pk.go b/backend/plugin/advisor/mysql/rule_table_require_pk.goindex 7163c17b18..7933a9bd22 100644--- a/backend/plugin/advisor/mysql/rule_table_require_pk.go+++ b/backend/plugin/advisor/mysql/rule_table_require_pk.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -194,7 +194,7 @@ func (r *tableRequirePKOmniRule) generateAdviceList() {Code: code.TableNoPK.Int32(),Title: r.Title,Content: fmt.Sprintf("Table `%s` requires PRIMARY KEY", tableName),- StartPosition: common.ConvertANTLRLineToPosition(r.line[tableName]),+ StartPosition: base.ConvertANTLRLineToPosition(r.line[tableName]),})}}diff --git a/backend/plugin/advisor/mysql/rule_use_innodb.go b/backend/plugin/advisor/mysql/rule_use_innodb.goindex 73ca91ec49..a3ca62dd04 100644--- a/backend/plugin/advisor/mysql/rule_use_innodb.go+++ b/backend/plugin/advisor/mysql/rule_use_innodb.go@@ -10,8 +10,7 @@ import (storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"advisorcode "github.com/bytebase/bytebase/backend/plugin/advisor/code"-- "github.com/bytebase/bytebase/backend/common"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")const (@@ -126,6 +125,6 @@ func (r *useInnoDBOmniRule) addAdvice(content string, lineNumber int32) {Code: advisorcode.NotInnoDBEngine.Int32(),Title: r.Title,Content: fmt.Sprintf("\"%s;\" doesn't use InnoDB engine", content),- StartPosition: common.ConvertANTLRLineToPosition(absoluteLine),+ StartPosition: base.ConvertANTLRLineToPosition(absoluteLine),})}diff --git a/backend/plugin/advisor/mysql/rule_view_disallow_create.go b/backend/plugin/advisor/mysql/rule_view_disallow_create.goindex 944bd86d8e..102ef7a115 100644--- a/backend/plugin/advisor/mysql/rule_view_disallow_create.go+++ b/backend/plugin/advisor/mysql/rule_view_disallow_create.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"advisorcode "github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -60,7 +60,7 @@ func (r *viewDisallowCreateOmniRule) OnStatement(node ast.Node) {Code: advisorcode.DisallowCreateView.Int32(),Title: r.Title,Content: fmt.Sprintf("View is forbidden, but \"%s\" creates", r.QueryText()),- StartPosition: common.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),+ StartPosition: base.ConvertANTLRLineToPosition(r.BaseLine + int(r.LocToLine(n.Loc))),})}}diff --git a/backend/plugin/advisor/oceanbase/advisor_disallow_offline_ddl.go b/backend/plugin/advisor/oceanbase/advisor_disallow_offline_ddl.goindex be4a678703..410c6064a9 100644--- a/backend/plugin/advisor/oceanbase/advisor_disallow_offline_ddl.go+++ b/backend/plugin/advisor/oceanbase/advisor_disallow_offline_ddl.go@@ -10,10 +10,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"mysqlparser "github.com/bytebase/bytebase/backend/plugin/parser/mysql")@@ -182,6 +182,6 @@ func (checker *disallowOfflineDdlChecker) advice(line int, operation string) {Code: code.StatementOfflineDDL.Int32(),Title: checker.title,Content: fmt.Sprintf("%s is an offline DDL operation.", operation),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})}diff --git a/backend/plugin/advisor/oceanbase/advisor_insert_row_limit.go b/backend/plugin/advisor/oceanbase/advisor_insert_row_limit.goindex ba3d970d82..3ee1228cfb 100644--- a/backend/plugin/advisor/oceanbase/advisor_insert_row_limit.go+++ b/backend/plugin/advisor/oceanbase/advisor_insert_row_limit.go@@ -9,10 +9,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"mysqlparser "github.com/bytebase/bytebase/backend/plugin/parser/mysql")@@ -87,7 +87,7 @@ func (checker *insertRowLimitChecker) handleInsertQueryExpression(text string, lif checker.driver == nil {return}- if !checker.explains.Spend(common.ConvertANTLRLineToPosition(line)) {+ if !checker.explains.Spend(base.ConvertANTLRLineToPosition(line)) {return}@@ -98,7 +98,7 @@ func (checker *insertRowLimitChecker) handleInsertQueryExpression(text string, lCode: code.InsertTooManyRows.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" dry runs failed: %s", text, err.Error()),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})return}@@ -109,7 +109,7 @@ func (checker *insertRowLimitChecker) handleInsertQueryExpression(text string, lCode: code.Internal.Int32(),Title: checker.title,Content: fmt.Sprintf("failed to get row count for \"%s\": %s", text, err.Error()),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})} else if rowCount > int64(checker.maxRow) {checker.adviceList = append(checker.adviceList, &storepb.Advice{@@ -117,7 +117,7 @@ func (checker *insertRowLimitChecker) handleInsertQueryExpression(text string, lCode: code.InsertTooManyRows.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" inserts %d rows. The count exceeds %d.", text, rowCount, checker.maxRow),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})}}@@ -129,7 +129,7 @@ func (checker *insertRowLimitChecker) handleNoInsertQueryExpression(text string,Code: code.InsertTooManyRows.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" inserts %d rows. The count exceeds %d.", text, len(stmt.Values), checker.maxRow),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})}}diff --git a/backend/plugin/advisor/oceanbase/advisor_statement_affected_row_limit.go b/backend/plugin/advisor/oceanbase/advisor_statement_affected_row_limit.goindex 40c836ecf5..ed84155822 100644--- a/backend/plugin/advisor/oceanbase/advisor_statement_affected_row_limit.go+++ b/backend/plugin/advisor/oceanbase/advisor_statement_affected_row_limit.go@@ -9,10 +9,10 @@ import ("github.com/bytebase/omni/mysql/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"mysqlparser "github.com/bytebase/bytebase/backend/plugin/parser/mysql")@@ -79,7 +79,7 @@ type statementAffectedRowLimitChecker struct {}func (checker *statementAffectedRowLimitChecker) handleStmt(text string, lineNumber int) {- if !checker.explains.Spend(common.ConvertANTLRLineToPosition(lineNumber)) {+ if !checker.explains.Spend(base.ConvertANTLRLineToPosition(lineNumber)) {return}res, err := advisor.Query(checker.ctx, advisor.QueryContext{}, checker.driver, storepb.Engine_OCEANBASE, fmt.Sprintf("EXPLAIN format=json %s", text))@@ -89,7 +89,7 @@ func (checker *statementAffectedRowLimitChecker) handleStmt(text string, lineNumCode: code.StatementAffectedRowExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" dry runs failed: %s", text, err.Error()),- StartPosition: common.ConvertANTLRLineToPosition(lineNumber),+ StartPosition: base.ConvertANTLRLineToPosition(lineNumber),})} else {rowCount, err := getEstimatedRowsFromJSON(res)@@ -99,7 +99,7 @@ func (checker *statementAffectedRowLimitChecker) handleStmt(text string, lineNumCode: code.Internal.Int32(),Title: checker.title,Content: fmt.Sprintf("failed to get row count for \"%s\": %s", text, err.Error()),- StartPosition: common.ConvertANTLRLineToPosition(lineNumber),+ StartPosition: base.ConvertANTLRLineToPosition(lineNumber),})} else if rowCount > int64(checker.maxRow) {checker.adviceList = append(checker.adviceList, &storepb.Advice{@@ -107,7 +107,7 @@ func (checker *statementAffectedRowLimitChecker) handleStmt(text string, lineNumCode: code.StatementAffectedRowExceedsLimit.Int32(),Title: checker.title,Content: fmt.Sprintf("\"%s\" affected %d rows (estimated). The count exceeds %d.", text, rowCount, checker.maxRow),- StartPosition: common.ConvertANTLRLineToPosition(lineNumber),+ StartPosition: base.ConvertANTLRLineToPosition(lineNumber),})}}diff --git a/backend/plugin/advisor/oracle/rule_column_add_not_null_column_require_default.go b/backend/plugin/advisor/oracle/rule_column_add_not_null_column_require_default.goindex f2bfb85114..040c8f5dbb 100644--- a/backend/plugin/advisor/oracle/rule_column_add_not_null_column_require_default.go+++ b/backend/plugin/advisor/oracle/rule_column_add_not_null_column_require_default.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/oracle/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -76,7 +76,7 @@ func (r *ColumnAddNotNullColumnRequireDefaultRule) OnStatement(node ast.Node) {r.level,code.NotNullColumnWithNoDefault.Int32(),fmt.Sprintf("Adding not null column %q requires default.", col.Name),- common.ConvertANTLRLineToPosition(r.locLine(col.Loc)),+ base.ConvertANTLRLineToPosition(r.locLine(col.Loc)),)}}diff --git a/backend/plugin/advisor/oracle/rule_column_comment_convention.go b/backend/plugin/advisor/oracle/rule_column_comment_convention.goindex 12ddf7ef31..12dc5325bd 100644--- a/backend/plugin/advisor/oracle/rule_column_comment_convention.go+++ b/backend/plugin/advisor/oracle/rule_column_comment_convention.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/oracle/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -112,7 +112,7 @@ func (r *ColumnCommentConventionRule) GetAdviceList() ([]*storepb.Advice, error)r.level,code.CommentEmpty.Int32(),fmt.Sprintf("Comment is required for column %s", normalizeIdentifierName(columnName)),- common.ConvertANTLRLineToPosition(r.columnLine[columnName]),+ base.ConvertANTLRLineToPosition(r.columnLine[columnName]),)}} else {@@ -121,7 +121,7 @@ func (r *ColumnCommentConventionRule) GetAdviceList() ([]*storepb.Advice, error)r.level,code.CommentTooLong.Int32(),fmt.Sprintf("Column %s comment is too long. The length of comment should be within %d characters", normalizeIdentifierName(columnName), r.payload.MaxLength),- common.ConvertANTLRLineToPosition(r.columnLine[columnName]),+ base.ConvertANTLRLineToPosition(r.columnLine[columnName]),)}}diff --git a/backend/plugin/advisor/oracle/rule_column_maximum_character_length.go b/backend/plugin/advisor/oracle/rule_column_maximum_character_length.goindex 3a164c3f20..b82b7c472d 100644--- a/backend/plugin/advisor/oracle/rule_column_maximum_character_length.go+++ b/backend/plugin/advisor/oracle/rule_column_maximum_character_length.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/oracle/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -85,7 +85,7 @@ func (r *ColumnMaximumCharacterLengthRule) OnStatement(node ast.Node) {r.level,code.CharLengthExceedsLimit.Int32(),fmt.Sprintf("The maximum character length is %d.", r.maximum),- common.ConvertANTLRLineToPosition(r.locLine(col.TypeName.Loc)),+ base.ConvertANTLRLineToPosition(r.locLine(col.TypeName.Loc)),)})}diff --git a/backend/plugin/advisor/oracle/rule_column_maximum_varchar_length.go b/backend/plugin/advisor/oracle/rule_column_maximum_varchar_length.goindex 23ef9b268c..4e53f1acbf 100644--- a/backend/plugin/advisor/oracle/rule_column_maximum_varchar_length.go+++ b/backend/plugin/advisor/oracle/rule_column_maximum_varchar_length.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/oracle/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -85,7 +85,7 @@ func (r *ColumnMaximumVarcharLengthRule) OnStatement(node ast.Node) {r.level,code.VarcharLengthExceedsLimit.Int32(),fmt.Sprintf("The maximum varchar length is %d.", r.maximum),- common.ConvertANTLRLineToPosition(r.locLine(col.TypeName.Loc)),+ base.ConvertANTLRLineToPosition(r.locLine(col.TypeName.Loc)),)})}diff --git a/backend/plugin/advisor/oracle/rule_column_no_null.go b/backend/plugin/advisor/oracle/rule_column_no_null.goindex e9d1e627dc..a0bc14b164 100644--- a/backend/plugin/advisor/oracle/rule_column_no_null.go+++ b/backend/plugin/advisor/oracle/rule_column_no_null.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/oracle/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -126,7 +126,7 @@ func (r *ColumnNoNullRule) GetAdviceList() ([]*storepb.Advice, error) {r.level,code.ColumnCannotNull.Int32(),fmt.Sprintf("Column %q is nullable, which is not allowed.", lastIdentifier(columnID)),- common.ConvertANTLRLineToPosition(line),+ base.ConvertANTLRLineToPosition(line),)}return r.BaseRule.GetAdviceList()diff --git a/backend/plugin/advisor/oracle/rule_column_require.go b/backend/plugin/advisor/oracle/rule_column_require.goindex 5f8b9005aa..b6cf3264b2 100644--- a/backend/plugin/advisor/oracle/rule_column_require.go+++ b/backend/plugin/advisor/oracle/rule_column_require.go@@ -10,10 +10,10 @@ import ("github.com/bytebase/omni/oracle/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -119,7 +119,7 @@ func (r *ColumnRequireRule) addMissingColumnsAdvice(tableName string, missing cor.level,code.NoRequiredColumn.Int32(),fmt.Sprintf("Table %q requires columns: %s", tableName, strings.Join(missingColumns, ", ")),- common.ConvertANTLRLineToPosition(line),+ base.ConvertANTLRLineToPosition(line),)}diff --git a/backend/plugin/advisor/oracle/rule_column_require_default.go b/backend/plugin/advisor/oracle/rule_column_require_default.goindex b01cb5b6e0..9adcdffd61 100644--- a/backend/plugin/advisor/oracle/rule_column_require_default.go+++ b/backend/plugin/advisor/oracle/rule_column_require_default.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/oracle/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -120,7 +120,7 @@ func (r *ColumnRequireDefaultRule) GetAdviceList() ([]*storepb.Advice, error) {r.level,code.NoDefault.Int32(),fmt.Sprintf("Column %q doesn't have default value", lastIdentifier(columnID)),- common.ConvertANTLRLineToPosition(line),+ base.ConvertANTLRLineToPosition(line),)}return r.BaseRule.GetAdviceList()diff --git a/backend/plugin/advisor/oracle/rule_column_type_disallow_list.go b/backend/plugin/advisor/oracle/rule_column_type_disallow_list.goindex cf02f9f5a0..51ca6376f6 100644--- a/backend/plugin/advisor/oracle/rule_column_type_disallow_list.go+++ b/backend/plugin/advisor/oracle/rule_column_type_disallow_list.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/oracle/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -76,7 +76,7 @@ func (r *ColumnTypeDisallowListRule) OnStatement(node ast.Node) {r.level,code.DisabledColumnType.Int32(),fmt.Sprintf("Disallow column type %s but column \"%s\" is", typeName, col.Name),- common.ConvertANTLRLineToPosition(r.locLine(col.TypeName.Loc)),+ base.ConvertANTLRLineToPosition(r.locLine(col.TypeName.Loc)),)return}diff --git a/backend/plugin/advisor/oracle/rule_index_key_number_limit.go b/backend/plugin/advisor/oracle/rule_index_key_number_limit.goindex 27f61eb59e..50ffde6bb3 100644--- a/backend/plugin/advisor/oracle/rule_index_key_number_limit.go+++ b/backend/plugin/advisor/oracle/rule_index_key_number_limit.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/oracle/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -77,7 +77,7 @@ func (r *IndexKeyNumberLimitRule) OnStatement(node ast.Node) {r.level,code.IndexKeyNumberExceedsLimit.Int32(),fmt.Sprintf("Index key number should be less than or equal to %d", r.max),- common.ConvertANTLRLineToPosition(r.locLine(n.Loc)),+ base.ConvertANTLRLineToPosition(r.locLine(n.Loc)),)}case *ast.CreateTableStmt:@@ -103,7 +103,7 @@ func (r *IndexKeyNumberLimitRule) checkConstraint(c *ast.TableConstraint) {r.level,code.IndexKeyNumberExceedsLimit.Int32(),fmt.Sprintf("Index key number should be less than or equal to %d", r.max),- common.ConvertANTLRLineToPosition(r.locLine(c.Loc)),+ base.ConvertANTLRLineToPosition(r.locLine(c.Loc)),)}}diff --git a/backend/plugin/advisor/oracle/rule_insert_must_specify_column.go b/backend/plugin/advisor/oracle/rule_insert_must_specify_column.goindex 83b5bf4038..c4e156c8ab 100644--- a/backend/plugin/advisor/oracle/rule_insert_must_specify_column.go+++ b/backend/plugin/advisor/oracle/rule_insert_must_specify_column.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/oracle/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -70,7 +70,7 @@ func (r *InsertMustSpecifyColumnRule) OnStatement(node ast.Node) {r.level,code.InsertNotSpecifyColumn.Int32(),"INSERT statement should specify column name.",- common.ConvertANTLRLineToPosition(r.locLine(n.Loc)),+ base.ConvertANTLRLineToPosition(r.locLine(n.Loc)),)}for _, item := range listItems(n.MultiTable) {@@ -80,7 +80,7 @@ func (r *InsertMustSpecifyColumnRule) OnStatement(node ast.Node) {r.level,code.InsertNotSpecifyColumn.Int32(),"INSERT statement should specify column name.",- common.ConvertANTLRLineToPosition(r.locLine(clause.Loc)),+ base.ConvertANTLRLineToPosition(r.locLine(clause.Loc)),)}}diff --git a/backend/plugin/advisor/oracle/rule_naming_identifier_case.go b/backend/plugin/advisor/oracle/rule_naming_identifier_case.goindex 6a423503a4..055bd809de 100644--- a/backend/plugin/advisor/oracle/rule_naming_identifier_case.go+++ b/backend/plugin/advisor/oracle/rule_naming_identifier_case.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/oracle/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -70,7 +70,7 @@ func (r *NamingIdentifierCaseRule) OnStatement(node ast.Node) {r.level,code.NamingCaseMismatch.Int32(),fmt.Sprintf("Identifier %q should be upper case", ident.name),- common.ConvertANTLRLineToPosition(r.locLine(ident.loc)),+ base.ConvertANTLRLineToPosition(r.locLine(ident.loc)),)}} else if ident.name != strings.ToLower(ident.name) {@@ -78,7 +78,7 @@ func (r *NamingIdentifierCaseRule) OnStatement(node ast.Node) {r.level,code.NamingCaseMismatch.Int32(),fmt.Sprintf("Identifier %q should be lower case", ident.name),- common.ConvertANTLRLineToPosition(r.locLine(ident.loc)),+ base.ConvertANTLRLineToPosition(r.locLine(ident.loc)),)}}diff --git a/backend/plugin/advisor/oracle/rule_naming_identifier_no_keyword.go b/backend/plugin/advisor/oracle/rule_naming_identifier_no_keyword.goindex 97f572bc76..5c30f5e661 100644--- a/backend/plugin/advisor/oracle/rule_naming_identifier_no_keyword.go+++ b/backend/plugin/advisor/oracle/rule_naming_identifier_no_keyword.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/oracle/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"plsqlparser "github.com/bytebase/bytebase/backend/plugin/parser/plsql")@@ -66,7 +66,7 @@ func (r *NamingIdentifierNoKeywordRule) OnStatement(node ast.Node) {r.level,code.NameIsKeywordIdentifier.Int32(),fmt.Sprintf("Identifier %q is a keyword and should be avoided", ident.name),- common.ConvertANTLRLineToPosition(r.locLine(ident.loc)),+ base.ConvertANTLRLineToPosition(r.locLine(ident.loc)),)}}diff --git a/backend/plugin/advisor/oracle/rule_naming_table.go b/backend/plugin/advisor/oracle/rule_naming_table.goindex 2d0de04be3..133435bcb9 100644--- a/backend/plugin/advisor/oracle/rule_naming_table.go+++ b/backend/plugin/advisor/oracle/rule_naming_table.go@@ -9,10 +9,10 @@ import ("github.com/bytebase/omni/oracle/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -101,7 +101,7 @@ func (r *NamingTableRule) checkTableName(tableName string, loc ast.Loc) {r.level,code.NamingTableConventionMismatch.Int32(),fmt.Sprintf(`"%s" mismatches table naming convention, naming format should be %q`, tableName, r.format),- common.ConvertANTLRLineToPosition(r.locLine(loc)),+ base.ConvertANTLRLineToPosition(r.locLine(loc)),)}if r.maxLength > 0 && len(tableName) > r.maxLength {@@ -109,7 +109,7 @@ func (r *NamingTableRule) checkTableName(tableName string, loc ast.Loc) {r.level,code.NamingTableConventionMismatch.Int32(),fmt.Sprintf("\"%s\" mismatches table naming convention, its length should be within %d characters", tableName, r.maxLength),- common.ConvertANTLRLineToPosition(r.locLine(loc)),+ base.ConvertANTLRLineToPosition(r.locLine(loc)),)}}diff --git a/backend/plugin/advisor/oracle/rule_naming_table_no_keyword.go b/backend/plugin/advisor/oracle/rule_naming_table_no_keyword.goindex 9f6e90fce2..2bd7f4d7af 100644--- a/backend/plugin/advisor/oracle/rule_naming_table_no_keyword.go+++ b/backend/plugin/advisor/oracle/rule_naming_table_no_keyword.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/oracle/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"plsqlparser "github.com/bytebase/bytebase/backend/plugin/parser/plsql")@@ -79,7 +79,7 @@ func (r *NamingTableNoKeywordRule) checkTableName(tableName string, loc ast.Loc)r.level,code.NameIsKeywordIdentifier.Int32(),fmt.Sprintf("Table name %q is a keyword identifier and should be avoided.", tableName),- common.ConvertANTLRLineToPosition(r.locLine(loc)),+ base.ConvertANTLRLineToPosition(r.locLine(loc)),)}}diff --git a/backend/plugin/advisor/oracle/rule_select_no_select_all.go b/backend/plugin/advisor/oracle/rule_select_no_select_all.goindex 734e80a38d..a79ea849b9 100644--- a/backend/plugin/advisor/oracle/rule_select_no_select_all.go+++ b/backend/plugin/advisor/oracle/rule_select_no_select_all.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/oracle/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -70,7 +70,7 @@ func (r *SelectNoSelectAllRule) OnStatement(node ast.Node) {r.level,code.StatementSelectAll.Int32(),"Avoid using SELECT *.",- common.ConvertANTLRLineToPosition(r.locLine(target.Loc)),+ base.ConvertANTLRLineToPosition(r.locLine(target.Loc)),)})}diff --git a/backend/plugin/advisor/oracle/rule_statement_disallow_truncate.go b/backend/plugin/advisor/oracle/rule_statement_disallow_truncate.goindex 15fb376839..6bf4c08663 100644--- a/backend/plugin/advisor/oracle/rule_statement_disallow_truncate.go+++ b/backend/plugin/advisor/oracle/rule_statement_disallow_truncate.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/oracle/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")// Oracle grammar snapshot (PlSqlParser.g4 v0.0.0-20260417075056-…):@@ -68,7 +68,7 @@ func (r *StatementDisallowTruncateRule) OnStatement(node ast.Node) {r.level,code.StatementDisallowTruncate.Int32(),fmt.Sprintf(`TRUNCATE TABLE %q is not allowed: it issues an implicit COMMIT and cannot be rolled back. Any prior uncommitted work in the same transaction is also committed. Prior-backup treats this as DDL and does not produce row-level snapshots.`, name),- common.ConvertANTLRLineToPosition(r.locLine(n.Loc)),+ base.ConvertANTLRLineToPosition(r.locLine(n.Loc)),)case *ast.AlterTableStmt:table := omniLastObjectName(n.Name)@@ -104,7 +104,7 @@ func (r *StatementDisallowTruncateRule) OnStatement(node ast.Node) {r.level,code.StatementDisallowTruncate.Int32(),fmt.Sprintf(`ALTER TABLE %q TRUNCATE %s %q is not allowed: partition truncate shares the implicit-commit gap of TRUNCATE TABLE on Oracle. Prior-backup treats this as DDL and does not produce row-level snapshots.`, table, keyword, target),- common.ConvertANTLRLineToPosition(r.locLine(cmd.Loc)),+ base.ConvertANTLRLineToPosition(r.locLine(cmd.Loc)),)}default:diff --git a/backend/plugin/advisor/oracle/rule_statement_dml_dry_run.go b/backend/plugin/advisor/oracle/rule_statement_dml_dry_run.goindex 7fc2b08f84..a5c225fdda 100644--- a/backend/plugin/advisor/oracle/rule_statement_dml_dry_run.go+++ b/backend/plugin/advisor/oracle/rule_statement_dml_dry_run.go@@ -11,6 +11,7 @@ import (storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -91,7 +92,7 @@ func (r *StatementDmlDryRunRule) handleStmt(text string, lineNumber int) {r.level,code.StatementDMLDryRunFailed.Int32(),fmt.Sprintf("Failed to dry run statement at line %d: %v", lineNumber, err),- common.ConvertANTLRLineToPosition(lineNumber),+ base.ConvertANTLRLineToPosition(lineNumber),)}}diff --git a/backend/plugin/advisor/oracle/rule_statement_where_disallow_functions_and_calculations.go b/backend/plugin/advisor/oracle/rule_statement_where_disallow_functions_and_calculations.goindex 27cb6c9265..9ec6312a2c 100644--- a/backend/plugin/advisor/oracle/rule_statement_where_disallow_functions_and_calculations.go+++ b/backend/plugin/advisor/oracle/rule_statement_where_disallow_functions_and_calculations.go@@ -9,10 +9,10 @@ import (metadatapb "github.com/bytebase/omni/metadata""github.com/bytebase/omni/oracle/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -565,7 +565,7 @@ func (r *WhereDisallowFunctionsAndCalculationsRule) addOmniFunctionAdvice(funcNaCode: code.StatementDisallowFunctionsAndCalculations.Int32(),Title: r.title,Content: content,- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})}@@ -580,7 +580,7 @@ func (r *WhereDisallowFunctionsAndCalculationsRule) addOmniCalculationAdvice(colCode: code.StatementDisallowFunctionsAndCalculations.Int32(),Title: r.title,Content: content,- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})}diff --git a/backend/plugin/advisor/oracle/rule_table_comment_convention.go b/backend/plugin/advisor/oracle/rule_table_comment_convention.goindex 3ca5db6a26..72970815e7 100644--- a/backend/plugin/advisor/oracle/rule_table_comment_convention.go+++ b/backend/plugin/advisor/oracle/rule_table_comment_convention.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/oracle/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -96,7 +96,7 @@ func (r *TableCommentConventionRule) GetAdviceList() ([]*storepb.Advice, error)r.level,code.CommentEmpty.Int32(),fmt.Sprintf("Comment is required for table %s", normalizeIdentifierName(tableName)),- common.ConvertANTLRLineToPosition(r.tableLine[tableName]),+ base.ConvertANTLRLineToPosition(r.tableLine[tableName]),)}} else {@@ -105,7 +105,7 @@ func (r *TableCommentConventionRule) GetAdviceList() ([]*storepb.Advice, error)r.level,code.CommentTooLong.Int32(),fmt.Sprintf("Table %s comment is too long. The length of comment should be within %d characters", normalizeIdentifierName(tableName), r.payload.MaxLength),- common.ConvertANTLRLineToPosition(r.tableLine[tableName]),+ base.ConvertANTLRLineToPosition(r.tableLine[tableName]),)}}diff --git a/backend/plugin/advisor/oracle/rule_table_no_foreign_key.go b/backend/plugin/advisor/oracle/rule_table_no_foreign_key.goindex e8a3c0a173..07d8d1bbc7 100644--- a/backend/plugin/advisor/oracle/rule_table_no_foreign_key.go+++ b/backend/plugin/advisor/oracle/rule_table_no_foreign_key.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/oracle/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -108,7 +108,7 @@ func (r *TableNoForeignKeyRule) GetAdviceList() ([]*storepb.Advice, error) {r.level,code.TableHasFK.Int32(),fmt.Sprintf("Foreign key is not allowed in the table %s.", normalizeIdentifierName(tableName)),- common.ConvertANTLRLineToPosition(r.tableLine[tableName]),+ base.ConvertANTLRLineToPosition(r.tableLine[tableName]),)}}diff --git a/backend/plugin/advisor/oracle/rule_table_require_pk.go b/backend/plugin/advisor/oracle/rule_table_require_pk.goindex 5c963f3bd2..a17c001522 100644--- a/backend/plugin/advisor/oracle/rule_table_require_pk.go+++ b/backend/plugin/advisor/oracle/rule_table_require_pk.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/oracle/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -122,7 +122,7 @@ func (r *TableRequirePKRule) GetAdviceList() ([]*storepb.Advice, error) {r.level,code.TableNoPK.Int32(),fmt.Sprintf("Table %s requires PRIMARY KEY.", normalizeIdentifierName(tableName)),- common.ConvertANTLRLineToPosition(r.tableLine[tableName]),+ base.ConvertANTLRLineToPosition(r.tableLine[tableName]),)}}diff --git a/backend/plugin/advisor/oracle/rule_where_no_leading_wildcard_like.go b/backend/plugin/advisor/oracle/rule_where_no_leading_wildcard_like.goindex 904c2f5db4..e3c0057d96 100644--- a/backend/plugin/advisor/oracle/rule_where_no_leading_wildcard_like.go+++ b/backend/plugin/advisor/oracle/rule_where_no_leading_wildcard_like.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/oracle/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -72,7 +72,7 @@ func (r *WhereNoLeadingWildcardLikeRule) OnStatement(node ast.Node) {r.level,code.StatementLeadingWildcardLike.Int32(),"Avoid using leading wildcard LIKE.",- common.ConvertANTLRLineToPosition(r.locLine(like.Loc)),+ base.ConvertANTLRLineToPosition(r.locLine(like.Loc)),)})}diff --git a/backend/plugin/advisor/oracle/rule_where_require_for_select.go b/backend/plugin/advisor/oracle/rule_where_require_for_select.goindex 347d56ef27..dbd5796921 100644--- a/backend/plugin/advisor/oracle/rule_where_require_for_select.go+++ b/backend/plugin/advisor/oracle/rule_where_require_for_select.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/oracle/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -77,7 +77,7 @@ func (r *WhereRequireForSelectRule) OnStatement(node ast.Node) {r.level,code.StatementNoWhere.Int32(),"WHERE clause is required for SELECT statement.",- common.ConvertANTLRLineToPosition(r.locLine(selectStmt.Loc)),+ base.ConvertANTLRLineToPosition(r.locLine(selectStmt.Loc)),)}})diff --git a/backend/plugin/advisor/oracle/rule_where_require_for_update_delete.go b/backend/plugin/advisor/oracle/rule_where_require_for_update_delete.goindex 8676f5f6d8..b6c4686751 100644--- a/backend/plugin/advisor/oracle/rule_where_require_for_update_delete.go+++ b/backend/plugin/advisor/oracle/rule_where_require_for_update_delete.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/oracle/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -65,7 +65,7 @@ func (r *WhereRequireForUpdateDeleteRule) OnStatement(node ast.Node) {r.level,code.StatementNoWhere.Int32(),"WHERE clause is required for UPDATE statement.",- common.ConvertANTLRLineToPosition(r.locLine(n.Loc)),+ base.ConvertANTLRLineToPosition(r.locLine(n.Loc)),)}case *ast.DeleteStmt:@@ -74,7 +74,7 @@ func (r *WhereRequireForUpdateDeleteRule) OnStatement(node ast.Node) {r.level,code.StatementNoWhere.Int32(),"WHERE clause is required for DELETE statement.",- common.ConvertANTLRLineToPosition(r.locLine(n.Loc)),+ base.ConvertANTLRLineToPosition(r.locLine(n.Loc)),)}case *ast.PLSQLBlock:diff --git a/backend/plugin/advisor/snowflake/rule_column_maximum_varchar_length.go b/backend/plugin/advisor/snowflake/rule_column_maximum_varchar_length.goindex d155f45f3f..676edd6bda 100644--- a/backend/plugin/advisor/snowflake/rule_column_maximum_varchar_length.go+++ b/backend/plugin/advisor/snowflake/rule_column_maximum_varchar_length.go@@ -8,10 +8,10 @@ import ("github.com/pkg/errors""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"omniast "github.com/bytebase/omni/snowflake/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"snowsqlparser "github.com/bytebase/bytebase/backend/plugin/parser/snowflake"@@ -124,7 +124,7 @@ func (r *ColumnMaximumVarcharLengthRule) checkTypeName(typeName *omniast.TypeNamCode: code.VarcharLengthExceedsLimit.Int32(),Title: r.title,Content: fmt.Sprintf("The maximum varchar length is %d.", r.maximum),- StartPosition: common.ConvertANTLRLineToPosition(r.baseLine + r.line(typeName.Loc.Start)),+ StartPosition: base.ConvertANTLRLineToPosition(r.baseLine + r.line(typeName.Loc.Start)),})}}diff --git a/backend/plugin/advisor/snowflake/rule_column_no_null.go b/backend/plugin/advisor/snowflake/rule_column_no_null.goindex d28455d28a..ca64702e7d 100644--- a/backend/plugin/advisor/snowflake/rule_column_no_null.go+++ b/backend/plugin/advisor/snowflake/rule_column_no_null.go@@ -7,10 +7,10 @@ import (omniast "github.com/bytebase/omni/snowflake/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"snowsqlparser "github.com/bytebase/bytebase/backend/plugin/parser/snowflake")@@ -164,7 +164,7 @@ func (r *ColumnNoNullRule) addNullableAdvice(columnNullable map[string]int) {Code: code.ColumnCannotNull.Int32(),Title: r.title,Content: fmt.Sprintf("Column %s is nullable, which is not allowed.", normalizedColumnName),- StartPosition: common.ConvertANTLRLineToPosition(r.baseLine + columnNullableLine),+ StartPosition: base.ConvertANTLRLineToPosition(r.baseLine + columnNullableLine),})}}diff --git a/backend/plugin/advisor/snowflake/rule_column_require.go b/backend/plugin/advisor/snowflake/rule_column_require.goindex 80ba628e65..76529d9eed 100644--- a/backend/plugin/advisor/snowflake/rule_column_require.go+++ b/backend/plugin/advisor/snowflake/rule_column_require.go@@ -10,10 +10,10 @@ import ("github.com/pkg/errors""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"omniast "github.com/bytebase/omni/snowflake/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"snowsqlparser "github.com/bytebase/bytebase/backend/plugin/parser/snowflake"@@ -179,7 +179,7 @@ func (r *ColumnRequireRule) addMissingColumnAdvice(missingColumns map[string]anyCode: code.NoRequiredColumn.Int32(),Title: r.title,Content: fmt.Sprintf("Table %s missing required column %q", originalTableName, column),- StartPosition: common.ConvertANTLRLineToPosition(r.baseLine + line),+ StartPosition: base.ConvertANTLRLineToPosition(r.baseLine + line),})}}diff --git a/backend/plugin/advisor/snowflake/rule_migration_compatibility.go b/backend/plugin/advisor/snowflake/rule_migration_compatibility.goindex 3f8f99cfa7..4fd0f6f85d 100644--- a/backend/plugin/advisor/snowflake/rule_migration_compatibility.go+++ b/backend/plugin/advisor/snowflake/rule_migration_compatibility.go@@ -8,10 +8,10 @@ import (omniast "github.com/bytebase/omni/snowflake/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"snowsqlparser "github.com/bytebase/bytebase/backend/plugin/parser/snowflake")@@ -103,7 +103,7 @@ func (c *migrationCompatibilityChecker) checkStmt(node omniast.Node, text stringCode: code.CompatibilityDropTable.Int32(),Title: c.title,Content: fmt.Sprintf("Drop table %q may cause incompatibility with the existing data and code", normalizedFullDropTableName),- StartPosition: common.ConvertANTLRLineToPosition(baseLine + statementLineForOffset(text, stmt.Loc.Start)),+ StartPosition: base.ConvertANTLRLineToPosition(baseLine + statementLineForOffset(text, stmt.Loc.Start)),})case *omniast.DropSchemaStmt:normalizedFullDropSchemaName := c.normalizeSchemaName(stmt.Name)@@ -120,7 +120,7 @@ func (c *migrationCompatibilityChecker) checkStmt(node omniast.Node, text stringCode: code.CompatibilityDropSchema.Int32(),Title: c.title,Content: fmt.Sprintf("Drop schema %q may cause incompatibility with the existing data and code", normalizedFullDropSchemaName),- StartPosition: common.ConvertANTLRLineToPosition(baseLine + statementLineForOffset(text, stmt.Loc.Start)),+ StartPosition: base.ConvertANTLRLineToPosition(baseLine + statementLineForOffset(text, stmt.Loc.Start)),})case *omniast.DropDatabaseStmt:normalizedFullDropDatabaseName := normalizeDatabaseName(stmt.Name)@@ -137,7 +137,7 @@ func (c *migrationCompatibilityChecker) checkStmt(node omniast.Node, text stringCode: code.CompatibilityDropDatabase.Int32(),Title: c.title,Content: fmt.Sprintf("Drop database %q may cause incompatibility with the existing data and code", normalizedFullDropDatabaseName),- StartPosition: common.ConvertANTLRLineToPosition(baseLine + statementLineForOffset(text, stmt.Loc.Start)),+ StartPosition: base.ConvertANTLRLineToPosition(baseLine + statementLineForOffset(text, stmt.Loc.Start)),})case *omniast.AlterTableStmt:for _, action := range stmt.Actions {@@ -156,7 +156,7 @@ func (c *migrationCompatibilityChecker) checkStmt(node omniast.Node, text stringCode: code.CompatibilityDropColumn.Int32(),Title: c.title,Content: fmt.Sprintf("Drop column %s may cause incompatibility with the existing data and code", strings.Join(normalizedAllColumnNames, ",")),- StartPosition: common.ConvertANTLRLineToPosition(baseLine + statementLineForOffset(text, stmt.Loc.Start)),+ StartPosition: base.ConvertANTLRLineToPosition(baseLine + statementLineForOffset(text, stmt.Loc.Start)),})}default:diff --git a/backend/plugin/advisor/snowflake/rule_naming_identifier_case.go b/backend/plugin/advisor/snowflake/rule_naming_identifier_case.goindex c2502c005a..5b5260a46b 100644--- a/backend/plugin/advisor/snowflake/rule_naming_identifier_case.go+++ b/backend/plugin/advisor/snowflake/rule_naming_identifier_case.go@@ -8,10 +8,10 @@ import (snowflakeast "github.com/bytebase/omni/snowflake/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"snowsqlparser "github.com/bytebase/bytebase/backend/plugin/parser/snowflake")@@ -156,5 +156,5 @@ func (c *namingIdentifierCaseChecker) positionAtOffset(offset int) *storepb.Posi}line += strings.Count(c.text[:offset], "\n")}- return common.ConvertANTLRLineToPosition(c.baseLine + line)+ return base.ConvertANTLRLineToPosition(c.baseLine + line)}diff --git a/backend/plugin/advisor/snowflake/rule_naming_identifier_no_keyword.go b/backend/plugin/advisor/snowflake/rule_naming_identifier_no_keyword.goindex 0c484b5175..96318f595c 100644--- a/backend/plugin/advisor/snowflake/rule_naming_identifier_no_keyword.go+++ b/backend/plugin/advisor/snowflake/rule_naming_identifier_no_keyword.go@@ -8,10 +8,10 @@ import (snowflakeast "github.com/bytebase/omni/snowflake/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"snowsqlparser "github.com/bytebase/bytebase/backend/plugin/parser/snowflake")@@ -153,5 +153,5 @@ func (c *namingIdentifierNoKeywordChecker) positionAtOffset(offset int) *storepb}line += strings.Count(c.text[:offset], "\n")}- return common.ConvertANTLRLineToPosition(c.baseLine + line)+ return base.ConvertANTLRLineToPosition(c.baseLine + line)}diff --git a/backend/plugin/advisor/snowflake/rule_naming_table.go b/backend/plugin/advisor/snowflake/rule_naming_table.goindex 7ddb2c4826..9717e09b7e 100644--- a/backend/plugin/advisor/snowflake/rule_naming_table.go+++ b/backend/plugin/advisor/snowflake/rule_naming_table.go@@ -10,10 +10,10 @@ import (snowflakeast "github.com/bytebase/omni/snowflake/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"snowsqlparser "github.com/bytebase/bytebase/backend/plugin/parser/snowflake")@@ -149,5 +149,5 @@ func (c *namingTableChecker) positionAtOffset(offset int) *storepb.Position {}line += strings.Count(c.text[:offset], "\n")}- return common.ConvertANTLRLineToPosition(c.baseLine + line)+ return base.ConvertANTLRLineToPosition(c.baseLine + line)}diff --git a/backend/plugin/advisor/snowflake/rule_select_no_select_all.go b/backend/plugin/advisor/snowflake/rule_select_no_select_all.goindex 58a212812a..79a8c245fc 100644--- a/backend/plugin/advisor/snowflake/rule_select_no_select_all.go+++ b/backend/plugin/advisor/snowflake/rule_select_no_select_all.go@@ -7,10 +7,10 @@ import (omniast "github.com/bytebase/omni/snowflake/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"snowsqlparser "github.com/bytebase/bytebase/backend/plugin/parser/snowflake")@@ -92,7 +92,7 @@ func (c *selectNoSelectAllChecker) checkStmt(node omniast.Node, text string, basCode: code.StatementSelectAll.Int32(),Title: c.title,Content: "Avoid using SELECT *.",- StartPosition: common.ConvertANTLRLineToPosition(baseLine + statementLineForOffset(text, offset)),+ StartPosition: base.ConvertANTLRLineToPosition(baseLine + statementLineForOffset(text, offset)),})}}diff --git a/backend/plugin/advisor/snowflake/rule_table_drop_naming_convention.go b/backend/plugin/advisor/snowflake/rule_table_drop_naming_convention.goindex 54456a0302..7975154038 100644--- a/backend/plugin/advisor/snowflake/rule_table_drop_naming_convention.go+++ b/backend/plugin/advisor/snowflake/rule_table_drop_naming_convention.go@@ -10,10 +10,10 @@ import (snowflakeast "github.com/bytebase/omni/snowflake/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"snowsqlparser "github.com/bytebase/bytebase/backend/plugin/parser/snowflake")@@ -110,5 +110,5 @@ func (c *tableDropNamingConventionChecker) positionAtOffset(offset int) *storepb}line += strings.Count(c.text[:offset], "\n")}- return common.ConvertANTLRLineToPosition(c.baseLine + line)+ return base.ConvertANTLRLineToPosition(c.baseLine + line)}diff --git a/backend/plugin/advisor/snowflake/rule_table_no_foreign_key.go b/backend/plugin/advisor/snowflake/rule_table_no_foreign_key.goindex 080c5b75e7..6c71d37db6 100644--- a/backend/plugin/advisor/snowflake/rule_table_no_foreign_key.go+++ b/backend/plugin/advisor/snowflake/rule_table_no_foreign_key.go@@ -8,10 +8,10 @@ import (omniast "github.com/bytebase/omni/snowflake/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"snowsqlparser "github.com/bytebase/bytebase/backend/plugin/parser/snowflake")@@ -96,7 +96,7 @@ func (r *TableNoForeignKeyRule) GetAdviceList() []*storepb.Advice {Code: code.TableHasFK.Int32(),Title: r.title,Content: fmt.Sprintf("FOREIGN KEY is not allowed in the table %s.", r.tableOriginalName[tableName]),- StartPosition: common.ConvertANTLRLineToPosition(r.tableLine[tableName]),+ StartPosition: base.ConvertANTLRLineToPosition(r.tableLine[tableName]),})}}diff --git a/backend/plugin/advisor/snowflake/rule_table_require_pk.go b/backend/plugin/advisor/snowflake/rule_table_require_pk.goindex a463fde451..db2f492ce2 100644--- a/backend/plugin/advisor/snowflake/rule_table_require_pk.go+++ b/backend/plugin/advisor/snowflake/rule_table_require_pk.go@@ -8,10 +8,10 @@ import (omniast "github.com/bytebase/omni/snowflake/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"snowsqlparser "github.com/bytebase/bytebase/backend/plugin/parser/snowflake")@@ -98,7 +98,7 @@ func (r *TableRequirePkRule) GetAdviceList() []*storepb.Advice {Code: code.TableNoPK.Int32(),Title: r.title,Content: fmt.Sprintf("Table %s requires PRIMARY KEY.", r.tableOriginalName[tableName]),- StartPosition: common.ConvertANTLRLineToPosition(r.tableLine[tableName]),+ StartPosition: base.ConvertANTLRLineToPosition(r.tableLine[tableName]),})}}diff --git a/backend/plugin/advisor/snowflake/rule_where_require_select.go b/backend/plugin/advisor/snowflake/rule_where_require_select.goindex 80c28f2a8c..f0d02e9192 100644--- a/backend/plugin/advisor/snowflake/rule_where_require_select.go+++ b/backend/plugin/advisor/snowflake/rule_where_require_select.go@@ -8,10 +8,10 @@ import (omniast "github.com/bytebase/omni/snowflake/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"snowsqlparser "github.com/bytebase/bytebase/backend/plugin/parser/snowflake")@@ -84,7 +84,7 @@ func (c *whereRequireForSelectChecker) checkStmt(node omniast.Node, text string,Code: code.StatementNoWhere.Int32(),Title: c.title,Content: "WHERE clause is required for SELECT statement.",- StartPosition: common.ConvertANTLRLineToPosition(baseLine + statementLineForOffset(text, offset)),+ StartPosition: base.ConvertANTLRLineToPosition(baseLine + statementLineForOffset(text, offset)),})}}diff --git a/backend/plugin/advisor/snowflake/rule_where_require_update_delete.go b/backend/plugin/advisor/snowflake/rule_where_require_update_delete.goindex 5fc5d30a17..7aace9598e 100644--- a/backend/plugin/advisor/snowflake/rule_where_require_update_delete.go+++ b/backend/plugin/advisor/snowflake/rule_where_require_update_delete.go@@ -7,10 +7,10 @@ import (omniast "github.com/bytebase/omni/snowflake/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"snowsqlparser "github.com/bytebase/bytebase/backend/plugin/parser/snowflake")@@ -83,6 +83,6 @@ func (c *whereRequireForUpdateDeleteChecker) addAdvice(statementType, text strinCode: code.StatementNoWhere.Int32(),Title: c.title,Content: fmt.Sprintf("WHERE clause is required for %s statement.", statementType),- StartPosition: common.ConvertANTLRLineToPosition(baseLine + statementLineForOffset(text, offset)),+ StartPosition: base.ConvertANTLRLineToPosition(baseLine + statementLineForOffset(text, offset)),})}diff --git a/backend/plugin/advisor/tidb/advisor_builtin_prior_backup_check.go b/backend/plugin/advisor/tidb/advisor_builtin_prior_backup_check.goindex 62d0b1b6e6..8d37305d02 100644--- a/backend/plugin/advisor/tidb/advisor_builtin_prior_backup_check.go+++ b/backend/plugin/advisor/tidb/advisor_builtin_prior_backup_check.go@@ -14,6 +14,7 @@ import (storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -130,7 +131,7 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx context.Context, checkCtx advTitle: title,Content: "Prior backup cannot deal with mixed DDL and DML statements",Code: code.BuiltinPriorBackupCheck.Int32(),- StartPosition: common.ConvertANTLRLineToPosition(p.OriginTextPosition()),+ StartPosition: base.ConvertANTLRLineToPosition(p.OriginTextPosition()),})}}diff --git a/backend/plugin/advisor/tidb/advisor_charset_allowlist.go b/backend/plugin/advisor/tidb/advisor_charset_allowlist.goindex 9f14166587..14fbb22f65 100644--- a/backend/plugin/advisor/tidb/advisor_charset_allowlist.go+++ b/backend/plugin/advisor/tidb/advisor_charset_allowlist.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"advisorcode "github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -54,7 +54,7 @@ func (*CharsetAllowlistAdvisor) Check(_ context.Context, checkCtx advisor.ContexCode: advisorcode.DisabledCharset.Int32(),Title: title,Content: fmt.Sprintf("\"%s\" used disabled charset '%s'", text, charset),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})}diff --git a/backend/plugin/advisor/tidb/advisor_collation_allowlist.go b/backend/plugin/advisor/tidb/advisor_collation_allowlist.goindex 4710be67bd..991edbd3fa 100644--- a/backend/plugin/advisor/tidb/advisor_collation_allowlist.go+++ b/backend/plugin/advisor/tidb/advisor_collation_allowlist.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"advisorcode "github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -53,7 +53,7 @@ func (*CollationAllowlistAdvisor) Check(_ context.Context, checkCtx advisor.ContCode: advisorcode.DisabledCollation.Int32(),Title: title,Content: fmt.Sprintf("\"%s\" used disabled collation '%s'", text, collation),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(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 7ca771e38a..013dd0ea7c 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@@ -9,10 +9,10 @@ import ("github.com/bytebase/omni/tidb/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -96,7 +96,7 @@ func (c *columnAutoIncrementInitialValueChecker) checkStmt(ostmt OmniStmt) {Code: code.AutoIncrementColumnInitialValueNotMatch.Int32(),Title: c.title,Content: fmt.Sprintf("The initial auto-increment value in table `%s` is %v, which doesn't equal %v", tableName, value, c.value),- StartPosition: common.ConvertANTLRLineToPosition(stmtLine),+ StartPosition: base.ConvertANTLRLineToPosition(stmtLine),})}}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 274247a19d..9c90ae9d91 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@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -72,7 +72,7 @@ func (c *columnAutoIncrementMustIntegerChecker) checkStmt(ostmt OmniStmt) {Code: code.AutoIncrementColumnNotInteger.Int32(),Title: c.title,Content: fmt.Sprintf("Auto-increment column `%s`.`%s` requires integer type", col.table, col.column),- StartPosition: common.ConvertANTLRLineToPosition(col.line),+ StartPosition: base.ConvertANTLRLineToPosition(col.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 669931f0d6..afeba3dc16 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@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -63,7 +63,7 @@ func (c *columnAutoIncrementMustUnsignedChecker) checkStmt(ostmt OmniStmt) {Code: code.AutoIncrementColumnSigned.Int32(),Title: c.title,Content: fmt.Sprintf("Auto-increment column `%s`.`%s` is not UNSIGNED type", col.table, col.column),- StartPosition: common.ConvertANTLRLineToPosition(col.line),+ StartPosition: base.ConvertANTLRLineToPosition(col.line),})}}diff --git a/backend/plugin/advisor/tidb/advisor_column_comment_convention.go b/backend/plugin/advisor/tidb/advisor_column_comment_convention.goindex 3f2a22ed24..dcb0bcdd0f 100644--- a/backend/plugin/advisor/tidb/advisor_column_comment_convention.go+++ b/backend/plugin/advisor/tidb/advisor_column_comment_convention.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -117,7 +117,7 @@ func (*ColumnCommentConventionAdvisor) Check(_ context.Context, checkCtx advisorCode: code.CommentEmpty.Int32(),Title: title,Content: fmt.Sprintf("Column `%s`.`%s` requires comments", r.table, r.column),- StartPosition: common.ConvertANTLRLineToPosition(r.line),+ StartPosition: base.ConvertANTLRLineToPosition(r.line),})}if payload.MaxLength >= 0 && int32(len(r.comment)) > payload.MaxLength {@@ -126,7 +126,7 @@ func (*ColumnCommentConventionAdvisor) Check(_ context.Context, checkCtx advisorCode: code.CommentTooLong.Int32(),Title: title,Content: fmt.Sprintf("The length of column `%s`.`%s` comment should be within %d characters", r.table, r.column, payload.MaxLength),- StartPosition: common.ConvertANTLRLineToPosition(r.line),+ StartPosition: base.ConvertANTLRLineToPosition(r.line),})}}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 cf6a342240..c9049de8f6 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@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")const (@@ -153,7 +153,7 @@ func generateCurrentTimeAdvice(tableSet map[string]currentTimeTableData, level sCode: code.DefaultCurrentTimeColumnCountExceedsLimit.Int32(),Title: title,Content: fmt.Sprintf("Table `%s` has %d DEFAULT CURRENT_TIMESTAMP() columns. The count greater than %d.", table.tableName, table.defaultCurrentTimeCount, maxDefaultCurrentTimeColumCount),- StartPosition: common.ConvertANTLRLineToPosition(table.line),+ StartPosition: base.ConvertANTLRLineToPosition(table.line),})}if table.onUpdateCurrentTimeCount > maxOnUpdateCurrentTimeColumnCount {@@ -162,7 +162,7 @@ func generateCurrentTimeAdvice(tableSet map[string]currentTimeTableData, level sCode: code.OnUpdateCurrentTimeColumnCountExceedsLimit.Int32(),Title: title,Content: fmt.Sprintf("Table `%s` has %d ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than %d.", table.tableName, table.onUpdateCurrentTimeCount, maxOnUpdateCurrentTimeColumnCount),- StartPosition: common.ConvertANTLRLineToPosition(table.line),+ StartPosition: base.ConvertANTLRLineToPosition(table.line),})}}diff --git a/backend/plugin/advisor/tidb/advisor_column_disallow_changing.go b/backend/plugin/advisor/tidb/advisor_column_disallow_changing.goindex 72d45a5a15..fc48efc39c 100644--- a/backend/plugin/advisor/tidb/advisor_column_disallow_changing.go+++ b/backend/plugin/advisor/tidb/advisor_column_disallow_changing.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -55,7 +55,7 @@ func (*ColumnDisallowChangingAdvisor) Check(_ context.Context, checkCtx advisor.Code: code.UseChangeColumnStatement.Int32(),Title: title,Content: fmt.Sprintf("\"%s\" contains CHANGE COLUMN statement", ostmt.TrimmedText()),- StartPosition: common.ConvertANTLRLineToPosition(ostmt.AbsoluteLine(alter.Loc.Start)),+ StartPosition: base.ConvertANTLRLineToPosition(ostmt.AbsoluteLine(alter.Loc.Start)),})}}diff --git a/backend/plugin/advisor/tidb/advisor_column_disallow_changing_order.go b/backend/plugin/advisor/tidb/advisor_column_disallow_changing_order.goindex 9c6ebe27ac..cd6b209f1d 100644--- a/backend/plugin/advisor/tidb/advisor_column_disallow_changing_order.go+++ b/backend/plugin/advisor/tidb/advisor_column_disallow_changing_order.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -53,7 +53,7 @@ func (*ColumnDisallowChangingOrderAdvisor) Check(_ context.Context, checkCtx advCode: code.ChangeColumnOrder.Int32(),Title: title,Content: fmt.Sprintf("\"%s\" changes column order", ostmt.TrimmedText()),- StartPosition: common.ConvertANTLRLineToPosition(ostmt.AbsoluteLine(alter.Loc.Start)),+ StartPosition: base.ConvertANTLRLineToPosition(ostmt.AbsoluteLine(alter.Loc.Start)),})}}diff --git a/backend/plugin/advisor/tidb/advisor_column_disallow_changing_type.go b/backend/plugin/advisor/tidb/advisor_column_disallow_changing_type.goindex 1f78134c82..8222617204 100644--- a/backend/plugin/advisor/tidb/advisor_column_disallow_changing_type.go+++ b/backend/plugin/advisor/tidb/advisor_column_disallow_changing_type.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -79,7 +79,7 @@ func (*ColumnDisallowChangingTypeAdvisor) Check(_ context.Context, checkCtx adviCode: code.ChangeColumnType.Int32(),Title: title,Content: fmt.Sprintf("\"%s\" changes column type", ostmt.TrimmedText()),- StartPosition: common.ConvertANTLRLineToPosition(ostmt.AbsoluteLine(alter.Loc.Start)),+ StartPosition: base.ConvertANTLRLineToPosition(ostmt.AbsoluteLine(alter.Loc.Start)),})}}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 4d245bad3c..40db749486 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@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -103,7 +103,7 @@ func (*ColumnDisallowDropInIndexAdvisor) Check(_ context.Context, checkCtx advisCode: code.DropIndexColumn.Int32(),Title: title,Content: fmt.Sprintf("`%s`.`%s` cannot drop index column", tableName, colName),- StartPosition: common.ConvertANTLRLineToPosition(stmtLine),+ StartPosition: base.ConvertANTLRLineToPosition(stmtLine),})}}diff --git a/backend/plugin/advisor/tidb/advisor_column_disallow_set_charset.go b/backend/plugin/advisor/tidb/advisor_column_disallow_set_charset.goindex 579254bbc1..873c392585 100644--- a/backend/plugin/advisor/tidb/advisor_column_disallow_set_charset.go+++ b/backend/plugin/advisor/tidb/advisor_column_disallow_set_charset.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"advisorcode "github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -101,7 +101,7 @@ func (*ColumnDisallowSetCharsetAdvisor) Check(_ context.Context, checkCtx advisoCode: advisorcode.SetColumnCharset.Int32(),Title: title,Content: fmt.Sprintf("Disallow set column charset but \"%s\" does", ostmt.TrimmedText()),- StartPosition: common.ConvertANTLRLineToPosition(ostmt.FirstTokenLine()),+ StartPosition: base.ConvertANTLRLineToPosition(ostmt.FirstTokenLine()),})}diff --git a/backend/plugin/advisor/tidb/advisor_column_maximum_character_length.go b/backend/plugin/advisor/tidb/advisor_column_maximum_character_length.goindex 0f809e8047..8cc383ae9a 100644--- a/backend/plugin/advisor/tidb/advisor_column_maximum_character_length.go+++ b/backend/plugin/advisor/tidb/advisor_column_maximum_character_length.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/tidb/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -140,6 +140,6 @@ func buildCharLengthAdvice(level storepb.Advice_Status, title, _, columnName strCode: code.CharLengthExceedsLimit.Int32(),Title: title,Content: fmt.Sprintf("The length of the CHAR column `%s` is %d, bigger than %d, please use VARCHAR instead", columnName, charLength, maximum),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),}}diff --git a/backend/plugin/advisor/tidb/advisor_column_no_null.go b/backend/plugin/advisor/tidb/advisor_column_no_null.goindex 1d6f664726..162760a449 100644--- a/backend/plugin/advisor/tidb/advisor_column_no_null.go+++ b/backend/plugin/advisor/tidb/advisor_column_no_null.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -174,7 +174,7 @@ func (c *columnNoNullChecker) generateAdvice() []*storepb.Advice {Code: code.ColumnCannotNull.Int32(),Title: c.title,Content: fmt.Sprintf("`%s`.`%s` cannot have NULL value", column.tableName, column.columnName),- StartPosition: common.ConvertANTLRLineToPosition(column.line),+ StartPosition: base.ConvertANTLRLineToPosition(column.line),})}}diff --git a/backend/plugin/advisor/tidb/advisor_column_require_default.go b/backend/plugin/advisor/tidb/advisor_column_require_default.goindex b263749b44..0f8d456288 100644--- a/backend/plugin/advisor/tidb/advisor_column_require_default.go+++ b/backend/plugin/advisor/tidb/advisor_column_require_default.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -128,7 +128,7 @@ func (c *columRequireDefaultChecker) checkStmt(ostmt OmniStmt) {Code: code.NoDefault.Int32(),Title: c.title,Content: fmt.Sprintf("Column `%s`.`%s` doesn't have DEFAULT.", col.table, col.column),- StartPosition: common.ConvertANTLRLineToPosition(col.line),+ StartPosition: base.ConvertANTLRLineToPosition(col.line),})}}diff --git a/backend/plugin/advisor/tidb/advisor_column_required.go b/backend/plugin/advisor/tidb/advisor_column_required.goindex d96a940235..d25e6104ad 100644--- a/backend/plugin/advisor/tidb/advisor_column_required.go+++ b/backend/plugin/advisor/tidb/advisor_column_required.go@@ -9,10 +9,10 @@ import ("github.com/bytebase/omni/tidb/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -190,7 +190,7 @@ func (v *columnRequirementState) generateAdviceList(level storepb.Advice_Status,Code: code.NoRequiredColumn.Int32(),Title: title,Content: fmt.Sprintf("Table `%s` requires columns: %s", tableName, strings.Join(missingColumns, ", ")),- StartPosition: common.ConvertANTLRLineToPosition(v.line[tableName]),+ StartPosition: base.ConvertANTLRLineToPosition(v.line[tableName]),})}}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 52be7f1a86..5525dc813a 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@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -123,7 +123,7 @@ func (*ColumnSetDefaultForNotNullAdvisor) Check(_ context.Context, checkCtx adviCode: code.NotNullColumnWithNoDefault.Int32(),Title: title,Content: fmt.Sprintf("Column `%s`.`%s` is NOT NULL but doesn't have DEFAULT", r.tableName, r.columnName),- StartPosition: common.ConvertANTLRLineToPosition(r.line),+ StartPosition: base.ConvertANTLRLineToPosition(r.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 96e85314b6..9ce9164a21 100644--- a/backend/plugin/advisor/tidb/advisor_column_type_disallow_list.go+++ b/backend/plugin/advisor/tidb/advisor_column_type_disallow_list.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -123,6 +123,6 @@ func checkColumnTypeDisallow(typeRestriction map[string]bool, level storepb.AdviCode: code.DisabledColumnType.Int32(),Title: title,Content: fmt.Sprintf("Disallow column type %s but column `%s`.`%s` is", columnType, tableName, col.Name),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(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 eb24036611..cb8b0830e6 100644--- a/backend/plugin/advisor/tidb/advisor_database_drop_empty_db.go+++ b/backend/plugin/advisor/tidb/advisor_database_drop_empty_db.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -69,7 +69,7 @@ func (c *allowDropEmptyDBChecker) checkStmt(ostmt OmniStmt) {Code: code.NotCurrentDatabase.Int32(),Title: c.title,Content: fmt.Sprintf("Database `%s` that is trying to be deleted is not the current database `%s`", node.Name, c.originalMetadata.DatabaseName()),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})} else if !c.originalMetadata.HasNoTable() {c.adviceList = append(c.adviceList, &storepb.Advice{@@ -77,7 +77,7 @@ func (c *allowDropEmptyDBChecker) checkStmt(ostmt OmniStmt) {Code: code.DatabaseNotEmpty.Int32(),Title: c.title,Content: fmt.Sprintf("Database `%s` is not allowed to drop if not empty", node.Name),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})}}diff --git a/backend/plugin/advisor/tidb/advisor_index_key_number_limit.go b/backend/plugin/advisor/tidb/advisor_index_key_number_limit.goindex d0c3b21128..11d7629724 100644--- a/backend/plugin/advisor/tidb/advisor_index_key_number_limit.go+++ b/backend/plugin/advisor/tidb/advisor_index_key_number_limit.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/tidb/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -132,7 +132,7 @@ func (*IndexKeyNumberLimitAdvisor) Check(_ context.Context, checkCtx advisor.ConCode: code.IndexKeyNumberExceedsLimit.Int32(),Title: title,Content: fmt.Sprintf("The number of index `%s` in table `%s` should be not greater than %d", h.index, h.table, maximum),- StartPosition: common.ConvertANTLRLineToPosition(h.line),+ StartPosition: base.ConvertANTLRLineToPosition(h.line),})}return adviceList, nildiff --git a/backend/plugin/advisor/tidb/advisor_index_no_duplicate_column.go b/backend/plugin/advisor/tidb/advisor_index_no_duplicate_column.goindex 2e00968f11..7aca056fb0 100644--- a/backend/plugin/advisor/tidb/advisor_index_no_duplicate_column.go+++ b/backend/plugin/advisor/tidb/advisor_index_no_duplicate_column.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -167,7 +167,7 @@ func (*IndexNoDuplicateColumnAdvisor) Check(_ context.Context, checkCtx advisor.Code: code.DuplicateColumnInIndex.Int32(),Title: title,Content: fmt.Sprintf("%s `%s` has duplicate column `%s`.`%s`", h.tp, h.index, h.table, h.column),- StartPosition: common.ConvertANTLRLineToPosition(h.line),+ StartPosition: base.ConvertANTLRLineToPosition(h.line),})}return adviceList, nildiff --git a/backend/plugin/advisor/tidb/advisor_index_pk_type.go b/backend/plugin/advisor/tidb/advisor_index_pk_type.goindex 5d0ffa227e..804b7f720f 100644--- a/backend/plugin/advisor/tidb/advisor_index_pk_type.go+++ b/backend/plugin/advisor/tidb/advisor_index_pk_type.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/tidb/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -123,7 +123,7 @@ func (c *indexPkTypeChecker) checkStmt(ostmt OmniStmt) {Code: code.IndexPKType.Int32(),Title: c.title,Content: fmt.Sprintf("Columns in primary key must be INT/BIGINT but `%s`.`%s` is %s", pd.table, pd.column, pd.columnType),- StartPosition: common.ConvertANTLRLineToPosition(pd.line),+ StartPosition: base.ConvertANTLRLineToPosition(pd.line),})}}diff --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 4c5d8d4fe6..98d014c5df 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@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/tidb/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -89,7 +89,7 @@ func (c *indexPrimaryKeyTypeAllowlistChecker) checkStmt(ostmt OmniStmt) {Code: code.IndexPKType.Int32(),Title: c.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),- StartPosition: common.ConvertANTLRLineToPosition(pd.line),+ StartPosition: base.ConvertANTLRLineToPosition(pd.line),})}}diff --git a/backend/plugin/advisor/tidb/advisor_index_total_number_limit.go b/backend/plugin/advisor/tidb/advisor_index_total_number_limit.goindex 8baa6a65ce..3469960be7 100644--- a/backend/plugin/advisor/tidb/advisor_index_total_number_limit.go+++ b/backend/plugin/advisor/tidb/advisor_index_total_number_limit.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/tidb/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -150,7 +150,7 @@ func (*IndexTotalNumberLimitAdvisor) Check(_ context.Context, checkCtx advisor.CCode: code.IndexCountExceedsLimit.Int32(),Title: title,Content: fmt.Sprintf("The count of index in table `%s` should be no more than %d, but found %d", t.name, maximum, count),- StartPosition: common.ConvertANTLRLineToPosition(t.line),+ StartPosition: base.ConvertANTLRLineToPosition(t.line),})}}diff --git a/backend/plugin/advisor/tidb/advisor_index_type_no_blob.go b/backend/plugin/advisor/tidb/advisor_index_type_no_blob.goindex c56fead0cd..6b4a7de9fe 100644--- a/backend/plugin/advisor/tidb/advisor_index_type_no_blob.go+++ b/backend/plugin/advisor/tidb/advisor_index_type_no_blob.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/tidb/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -84,7 +84,7 @@ func (c *indexTypeNoBlobChecker) checkStmt(ostmt OmniStmt) {Code: code.IndexTypeNoBlob.Int32(),Title: c.title,Content: fmt.Sprintf("Columns in index must not be BLOB but `%s`.`%s` is %s", pd.table, pd.column, pd.columnType),- StartPosition: common.ConvertANTLRLineToPosition(pd.line),+ StartPosition: base.ConvertANTLRLineToPosition(pd.line),})}}diff --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 3241f73176..e117bd4bf8 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@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"advisorcode "github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -88,7 +88,7 @@ func checkStmtForOrderByRand(ostmt OmniStmt, level storepb.Advice_Status, titleCode: advisorcode.InsertUseOrderByRand.Int32(),Title: title,Content: fmt.Sprintf("\"%s\" uses ORDER BY RAND in the INSERT statement", ostmt.TrimmedText()),- StartPosition: common.ConvertANTLRLineToPosition(ostmt.FirstTokenLine()),+ StartPosition: base.ConvertANTLRLineToPosition(ostmt.FirstTokenLine()),}}}diff --git a/backend/plugin/advisor/tidb/advisor_insert_must_specify_column.go b/backend/plugin/advisor/tidb/advisor_insert_must_specify_column.goindex cfa3004310..98058b3d24 100644--- a/backend/plugin/advisor/tidb/advisor_insert_must_specify_column.go+++ b/backend/plugin/advisor/tidb/advisor_insert_must_specify_column.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -79,6 +79,6 @@ func (c *insertMustSpecifyColumnChecker) checkStmt(ostmt OmniStmt) {Code: code.InsertNotSpecifyColumn.Int32(),Title: c.title,Content: fmt.Sprintf("The INSERT statement must specify columns but \"%s\" does not", ostmt.Text),- StartPosition: common.ConvertANTLRLineToPosition(ostmt.AbsoluteLine(node.Loc.Start)),+ StartPosition: base.ConvertANTLRLineToPosition(ostmt.AbsoluteLine(node.Loc.Start)),})}diff --git a/backend/plugin/advisor/tidb/advisor_migration_compatibility.go b/backend/plugin/advisor/tidb/advisor_migration_compatibility.goindex 9114dd5371..f3bac14cac 100644--- a/backend/plugin/advisor/tidb/advisor_migration_compatibility.go+++ b/backend/plugin/advisor/tidb/advisor_migration_compatibility.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"advisorcode "github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -92,7 +92,7 @@ func (c *compatibilityChecker) checkStmt(ostmt OmniStmt) {Code: code.Int32(),Title: c.title,Content: fmt.Sprintf("\"%s\" may cause incompatibility with the existing data and code", ostmt.Text),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})}}diff --git a/backend/plugin/advisor/tidb/advisor_naming_auto_increment_column.go b/backend/plugin/advisor/tidb/advisor_naming_auto_increment_column.goindex 6da4b330e0..3de982cbb6 100644--- a/backend/plugin/advisor/tidb/advisor_naming_auto_increment_column.go+++ b/backend/plugin/advisor/tidb/advisor_naming_auto_increment_column.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/tidb/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -66,7 +66,7 @@ func (*NamingAutoIncrementColumnAdvisor) Check(_ context.Context, checkCtx advisCode: code.NamingAutoIncrementColumnConventionMismatch.Int32(),Title: title,Content: fmt.Sprintf("`%s`.`%s` mismatches auto_increment column naming convention, naming format should be %q", col.table, col.column, format),- StartPosition: common.ConvertANTLRLineToPosition(col.line),+ StartPosition: base.ConvertANTLRLineToPosition(col.line),})}if maxLength > 0 && len(col.column) > maxLength {@@ -75,7 +75,7 @@ func (*NamingAutoIncrementColumnAdvisor) Check(_ context.Context, checkCtx advisCode: code.NamingAutoIncrementColumnConventionMismatch.Int32(),Title: title,Content: fmt.Sprintf("`%s`.`%s` mismatches auto_increment column naming convention, its length should be within %d characters", col.table, col.column, maxLength),- StartPosition: common.ConvertANTLRLineToPosition(col.line),+ StartPosition: base.ConvertANTLRLineToPosition(col.line),})}}diff --git a/backend/plugin/advisor/tidb/advisor_naming_column.go b/backend/plugin/advisor/tidb/advisor_naming_column.goindex fcd0d672e9..d914ac6616 100644--- a/backend/plugin/advisor/tidb/advisor_naming_column.go+++ b/backend/plugin/advisor/tidb/advisor_naming_column.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/tidb/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -158,7 +158,7 @@ func (c *namingColumnConventionChecker) checkStmt(ostmt OmniStmt) {Code: code.NamingColumnConventionMismatch.Int32(),Title: c.title,Content: fmt.Sprintf("`%s`.`%s` mismatches column naming convention, naming format should be %q", tableName, column.name, c.format),- StartPosition: common.ConvertANTLRLineToPosition(column.line),+ StartPosition: base.ConvertANTLRLineToPosition(column.line),})}if c.maxLength > 0 && len(column.name) > c.maxLength {@@ -167,7 +167,7 @@ func (c *namingColumnConventionChecker) checkStmt(ostmt OmniStmt) {Code: code.NamingColumnConventionMismatch.Int32(),Title: c.title,Content: fmt.Sprintf("`%s`.`%s` mismatches column naming convention, its length should be within %d characters", tableName, column.name, c.maxLength),- StartPosition: common.ConvertANTLRLineToPosition(column.line),+ StartPosition: base.ConvertANTLRLineToPosition(column.line),})}}diff --git a/backend/plugin/advisor/tidb/advisor_naming_table.go b/backend/plugin/advisor/tidb/advisor_naming_table.goindex 2a5840bc71..d90df90fff 100644--- a/backend/plugin/advisor/tidb/advisor_naming_table.go+++ b/backend/plugin/advisor/tidb/advisor_naming_table.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/tidb/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -112,7 +112,7 @@ func (c *namingTableConventionChecker) checkStmt(ostmt OmniStmt) {Code: code.NamingTableConventionMismatch.Int32(),Title: c.title,Content: fmt.Sprintf("`%s` mismatches table naming convention, naming format should be %q", tableName, c.format),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})}if c.maxLength > 0 && len(tableName) > c.maxLength {@@ -121,7 +121,7 @@ func (c *namingTableConventionChecker) checkStmt(ostmt OmniStmt) {Code: code.NamingTableConventionMismatch.Int32(),Title: c.title,Content: fmt.Sprintf("`%s` mismatches table naming convention, its length should be within %d characters", tableName, c.maxLength),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})}}diff --git a/backend/plugin/advisor/tidb/advisor_statement_dml_dry_run.go b/backend/plugin/advisor/tidb/advisor_statement_dml_dry_run.goindex 4bf5aac248..04cc99f26b 100644--- a/backend/plugin/advisor/tidb/advisor_statement_dml_dry_run.go+++ b/backend/plugin/advisor/tidb/advisor_statement_dml_dry_run.go@@ -12,6 +12,7 @@ import (storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -135,7 +136,7 @@ func (c *statementDmlDryRunChecker) appendFailure(ostmt OmniStmt, reason string)Code: code.StatementDMLDryRunFailed.Int32(),Title: c.title,Content: fmt.Sprintf("\"%s\" dry runs failed: %s", ostmt.TrimmedText(), reason),- StartPosition: common.ConvertANTLRLineToPosition(ostmt.FirstTokenLine()),+ StartPosition: base.ConvertANTLRLineToPosition(ostmt.FirstTokenLine()),})}diff --git a/backend/plugin/advisor/tidb/advisor_statement_merge_alter_table.go b/backend/plugin/advisor/tidb/advisor_statement_merge_alter_table.goindex f33a443b8b..66aa071290 100644--- a/backend/plugin/advisor/tidb/advisor_statement_merge_alter_table.go+++ b/backend/plugin/advisor/tidb/advisor_statement_merge_alter_table.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -113,7 +113,7 @@ func (*StatementMergeAlterTableAdvisor) Check(_ context.Context, checkCtx advisoCode: code.StatementRedundantAlterTable.Int32(),Title: title,Content: fmt.Sprintf("There are %d statements to modify table `%s`", t.count, t.name),- StartPosition: common.ConvertANTLRLineToPosition(t.lastLine),+ StartPosition: base.ConvertANTLRLineToPosition(t.lastLine),})}}diff --git a/backend/plugin/advisor/tidb/advisor_stmt_disallow_commit.go b/backend/plugin/advisor/tidb/advisor_stmt_disallow_commit.goindex 08bbef2af9..465c246ece 100644--- a/backend/plugin/advisor/tidb/advisor_stmt_disallow_commit.go+++ b/backend/plugin/advisor/tidb/advisor_stmt_disallow_commit.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -46,7 +46,7 @@ func (*StatementDisallowCommitAdvisor) Check(_ context.Context, checkCtx advisorCode: code.StatementDisallowCommit.Int32(),Title: checkCtx.Rule.Type.String(),Content: fmt.Sprintf("Commit is not allowed, related statement: \"%s\"", ostmt.TrimmedText()),- StartPosition: common.ConvertANTLRLineToPosition(ostmt.FirstTokenLine()),+ StartPosition: base.ConvertANTLRLineToPosition(ostmt.FirstTokenLine()),})}diff --git a/backend/plugin/advisor/tidb/advisor_stmt_disallow_limit.go b/backend/plugin/advisor/tidb/advisor_stmt_disallow_limit.goindex a2242ccc70..ab3bb53f55 100644--- a/backend/plugin/advisor/tidb/advisor_stmt_disallow_limit.go+++ b/backend/plugin/advisor/tidb/advisor_stmt_disallow_limit.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"advisorcode "github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -61,7 +61,7 @@ func (*StatementDisallowLimitAdvisor) Check(_ context.Context, checkCtx advisor.Code: code.Int32(),Title: checkCtx.Rule.Type.String(),Content: fmt.Sprintf("LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but \"%s\" uses", ostmt.TrimmedText()),- StartPosition: common.ConvertANTLRLineToPosition(ostmt.FirstTokenLine()),+ StartPosition: base.ConvertANTLRLineToPosition(ostmt.FirstTokenLine()),})}}diff --git a/backend/plugin/advisor/tidb/advisor_stmt_disallow_order_by.go b/backend/plugin/advisor/tidb/advisor_stmt_disallow_order_by.goindex fbc011e00e..696d177c3c 100644--- a/backend/plugin/advisor/tidb/advisor_stmt_disallow_order_by.go+++ b/backend/plugin/advisor/tidb/advisor_stmt_disallow_order_by.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"advisorcode "github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -57,7 +57,7 @@ func (*DisallowOrderByAdvisor) Check(_ context.Context, checkCtx advisor.ContextCode: code.Int32(),Title: checkCtx.Rule.Type.String(),Content: fmt.Sprintf("ORDER BY clause is forbidden in DELETE and UPDATE statements, but \"%s\" uses", ostmt.TrimmedText()),- StartPosition: common.ConvertANTLRLineToPosition(ostmt.FirstTokenLine()),+ StartPosition: base.ConvertANTLRLineToPosition(ostmt.FirstTokenLine()),})}}diff --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 0bf56455f5..40cff4b440 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@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")const (@@ -68,7 +68,7 @@ func (*NoLeadingWildcardLikeAdvisor) Check(_ context.Context, checkCtx advisor.CCode: code.StatementLeadingWildcardLike.Int32(),Title: title,Content: fmt.Sprintf("\"%s\" uses leading wildcard LIKE", ostmt.TrimmedText()),- StartPosition: common.ConvertANTLRLineToPosition(ostmt.FirstTokenLine()),+ StartPosition: base.ConvertANTLRLineToPosition(ostmt.FirstTokenLine()),})}return adviceList, nildiff --git a/backend/plugin/advisor/tidb/advisor_stmt_no_select_all.go b/backend/plugin/advisor/tidb/advisor_stmt_no_select_all.goindex 7f2b85fb54..9996482424 100644--- a/backend/plugin/advisor/tidb/advisor_stmt_no_select_all.go+++ b/backend/plugin/advisor/tidb/advisor_stmt_no_select_all.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -82,7 +82,7 @@ func (v *noSelectAllVisitor) Visit(node ast.Node) ast.Visitor {Code: code.StatementSelectAll.Int32(),Title: v.title,Content: fmt.Sprintf("\"%s\" uses SELECT all", v.text),- StartPosition: common.ConvertANTLRLineToPosition(v.line),+ StartPosition: base.ConvertANTLRLineToPosition(v.line),})return v}diff --git a/backend/plugin/advisor/tidb/advisor_stmt_where_required_for_select.go b/backend/plugin/advisor/tidb/advisor_stmt_where_required_for_select.goindex 0d8de07eb1..4f67b04ffa 100644--- a/backend/plugin/advisor/tidb/advisor_stmt_where_required_for_select.go+++ b/backend/plugin/advisor/tidb/advisor_stmt_where_required_for_select.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"advisorcode "github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -96,7 +96,7 @@ func (v *whereRequireSelectVisitor) Visit(node ast.Node) ast.Visitor {Code: advisorcode.StatementNoWhere.Int32(),Title: v.title,Content: fmt.Sprintf("\"%s\" requires WHERE clause", v.text),- StartPosition: common.ConvertANTLRLineToPosition(v.line),+ StartPosition: base.ConvertANTLRLineToPosition(v.line),})}return vdiff --git a/backend/plugin/advisor/tidb/advisor_stmt_where_required_for_update_delete.go b/backend/plugin/advisor/tidb/advisor_stmt_where_required_for_update_delete.goindex 8ed348224d..99be5fcb52 100644--- a/backend/plugin/advisor/tidb/advisor_stmt_where_required_for_update_delete.go+++ b/backend/plugin/advisor/tidb/advisor_stmt_where_required_for_update_delete.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"advisorcode "github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -101,7 +101,7 @@ func (v *whereRequireUpdateDeleteVisitor) Visit(node ast.Node) ast.Visitor {Code: advisorcode.StatementNoWhere.Int32(),Title: v.title,Content: fmt.Sprintf("\"%s\" requires WHERE clause", v.text),- StartPosition: common.ConvertANTLRLineToPosition(v.line),+ StartPosition: base.ConvertANTLRLineToPosition(v.line),})}return vdiff --git a/backend/plugin/advisor/tidb/advisor_table_comment_convention.go b/backend/plugin/advisor/tidb/advisor_table_comment_convention.goindex e1d8c36baa..e11aa7e95f 100644--- a/backend/plugin/advisor/tidb/advisor_table_comment_convention.go+++ b/backend/plugin/advisor/tidb/advisor_table_comment_convention.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -57,7 +57,7 @@ func (*TableCommentConventionAdvisor) Check(_ context.Context, checkCtx advisor.Code: code.CommentEmpty.Int32(),Title: title,Content: fmt.Sprintf("Table `%s` requires comments", n.Table.Name),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})}if payload.MaxLength >= 0 && int32(len(comment)) > payload.MaxLength {@@ -66,7 +66,7 @@ func (*TableCommentConventionAdvisor) Check(_ context.Context, checkCtx advisor.Code: code.CommentTooLong.Int32(),Title: title,Content: fmt.Sprintf("The length of table `%s` comment should be within %d characters", n.Table.Name, payload.MaxLength),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})}}diff --git a/backend/plugin/advisor/tidb/advisor_table_disallow_partition.go b/backend/plugin/advisor/tidb/advisor_table_disallow_partition.goindex c026d13927..98dd59fa11 100644--- a/backend/plugin/advisor/tidb/advisor_table_disallow_partition.go+++ b/backend/plugin/advisor/tidb/advisor_table_disallow_partition.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"advisorcode "github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -84,6 +84,6 @@ func buildPartitionAdvice(level storepb.Advice_Status, title, text string, lineCode: advisorcode.CreateTablePartition.Int32(),Title: title,Content: fmt.Sprintf("Table partition is forbidden, but \"%s\" creates", text),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(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 ad604fb4ab..1b2493723a 100644--- a/backend/plugin/advisor/tidb/advisor_table_drop_naming_convention.go+++ b/backend/plugin/advisor/tidb/advisor_table_drop_naming_convention.go@@ -8,10 +8,10 @@ import ("github.com/bytebase/omni/tidb/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -83,7 +83,7 @@ func (c *namingDropTableConventionChecker) checkStmt(ostmt OmniStmt) {Code: code.TableDropNamingConventionMismatch.Int32(),Title: c.title,Content: fmt.Sprintf("`%s` mismatches drop table naming convention, naming format should be %q", table.Name, c.format),- StartPosition: common.ConvertANTLRLineToPosition(line),+ StartPosition: base.ConvertANTLRLineToPosition(line),})}}diff --git a/backend/plugin/advisor/tidb/advisor_table_no_fk.go b/backend/plugin/advisor/tidb/advisor_table_no_fk.goindex 504fc6bb71..1d56c532a7 100644--- a/backend/plugin/advisor/tidb/advisor_table_no_fk.go+++ b/backend/plugin/advisor/tidb/advisor_table_no_fk.go@@ -6,10 +6,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base")var (@@ -67,7 +67,7 @@ func (c *tableNoFKChecker) checkStmt(ostmt OmniStmt) {Code: code.TableHasFK.Int32(),Title: c.title,Content: fmt.Sprintf("Foreign key is not allowed in the table `%s`", n.Table.Name),- StartPosition: common.ConvertANTLRLineToPosition(ostmt.AbsoluteLine(constraint.Loc.Start)),+ StartPosition: base.ConvertANTLRLineToPosition(ostmt.AbsoluteLine(constraint.Loc.Start)),})}case *ast.AlterTableStmt:@@ -90,7 +90,7 @@ func (c *tableNoFKChecker) checkStmt(ostmt OmniStmt) {Code: code.TableHasFK.Int32(),Title: c.title,Content: fmt.Sprintf("Foreign key is not allowed in the table `%s`", n.Table.Name),- StartPosition: common.ConvertANTLRLineToPosition(stmtLine),+ StartPosition: base.ConvertANTLRLineToPosition(stmtLine),})}default:diff --git a/backend/plugin/advisor/tidb/advisor_table_require_pk.go b/backend/plugin/advisor/tidb/advisor_table_require_pk.goindex 31396eada2..8d1c82d298 100644--- a/backend/plugin/advisor/tidb/advisor_table_require_pk.go+++ b/backend/plugin/advisor/tidb/advisor_table_require_pk.go@@ -7,10 +7,10 @@ import ("github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store/model")@@ -160,7 +160,7 @@ func (c *tableRequirePKChecker) generateAdviceList() []*storepb.Advice {Code: code.TableNoPK.Int32(),Title: c.title,Content: fmt.Sprintf("Table `%s` requires PRIMARY KEY", tableName),- StartPosition: common.ConvertANTLRLineToPosition(c.line[tableName]),+ StartPosition: base.ConvertANTLRLineToPosition(c.line[tableName]),})}}diff --git a/backend/plugin/advisor/tidb/utils.go b/backend/plugin/advisor/tidb/utils.goindex b779991dc5..11151274d3 100644--- a/backend/plugin/advisor/tidb/utils.go+++ b/backend/plugin/advisor/tidb/utils.go@@ -16,10 +16,10 @@ import (omniast "github.com/bytebase/omni/tidb/ast"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/code"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"tidbparser "github.com/bytebase/bytebase/backend/plugin/parser/tidb")@@ -879,7 +879,7 @@ func runNamingConventionRule(Code: cfg.mismatchCode.Int32(),Title: title,Content: fmt.Sprintf("%s in table `%s` mismatches the naming convention, expect %q but found `%s`", cfg.typeNoun, indexData.tableName, regex, indexData.indexName),- StartPosition: common.ConvertANTLRLineToPosition(indexData.line),+ StartPosition: base.ConvertANTLRLineToPosition(indexData.line),})}if maxLength > 0 && len(indexData.indexName) > maxLength {@@ -888,7 +888,7 @@ func runNamingConventionRule(Code: cfg.mismatchCode.Int32(),Title: title,Content: fmt.Sprintf("%s `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", cfg.typeNoun, indexData.indexName, indexData.tableName, maxLength),- StartPosition: common.ConvertANTLRLineToPosition(indexData.line),+ StartPosition: base.ConvertANTLRLineToPosition(indexData.line),})}}diff --git a/backend/plugin/parser/base/position.go b/backend/plugin/parser/base/position.goindex d9884409a6..736beb47a9 100644--- a/backend/plugin/parser/base/position.go+++ b/backend/plugin/parser/base/position.go@@ -1,6 +1,7 @@package baseimport (+ "math""unicode/utf8"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -84,3 +85,22 @@ func byteOffsetToRunePosition(sql string, byteOffset int) *storepb.Position {Column: runeCol + 1,}}++func safeIntToInt32(v int) int32 {+ if v > math.MaxInt32 {+ return math.MaxInt32+ }+ if v < math.MinInt32 {+ return math.MinInt32+ }+ return int32(v)+}++func ConvertANTLRLineToPosition(line int) *storepb.Position {+ // ANTLR line numbers are 1-based, and Position uses 1-based line numbering.+ // Just pass through the value, handling the 0 case for safety.+ positionLine := max(line, 1)+ return &storepb.Position{+ Line: safeIntToInt32(positionLine),+ }+}diff --git a/backend/plugin/parser/tidb/tidb.go b/backend/plugin/parser/tidb/tidb.goindex 58477d0980..e05b92d50f 100644--- a/backend/plugin/parser/tidb/tidb.go+++ b/backend/plugin/parser/tidb/tidb.go@@ -13,7 +13,6 @@ import (// The packege parser_driver has to be imported._ "github.com/pingcap/tidb/pkg/types/parser_driver"- "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/plugin/parser/tokenizer"@@ -144,7 +143,7 @@ func convertParserError(parserErr error) error {return parserErr}return &base.SyntaxError{- Position: common.ConvertTiDBParserErrorPositionToPosition(int32(line), int32(column)),+ Position: convertParserErrorPositionToPosition(int32(line), int32(column)),Message: parserErr.Error(),}}@@ -223,3 +222,10 @@ func TypeString(tp byte) string {return "unknown"}}++func convertParserErrorPositionToPosition(line, column int32) *storepb.Position {+ return &storepb.Position{+ Line: max(line, 1),+ Column: max(column, 1),+ }+}diff --git a/backend/plugin/parser/tidb/tidb_test.go b/backend/plugin/parser/tidb/tidb_test.goindex 581d20caf6..7ad1bb4d92 100644--- a/backend/plugin/parser/tidb/tidb_test.go+++ b/backend/plugin/parser/tidb/tidb_test.go@@ -258,3 +258,43 @@ select 3;`,})}}++func TestConvertTiDBParserErrorPositionToPosition(t *testing.T) {+ testCases := []struct {+ name string+ line int32+ column int32+ expectedLine int32+ expectedCol int32+ }{+ {+ name: "normal position",+ line: 2,+ column: 10,+ expectedLine: 2,+ expectedCol: 10,+ },+ {+ name: "line less than 1",+ line: 0,+ column: 5,+ expectedLine: 1,+ expectedCol: 5,+ },+ {+ name: "column less than 1",+ line: 3,+ column: 0,+ expectedLine: 3,+ expectedCol: 1,+ },+ }++ for _, tc := range testCases {+ t.Run(tc.name, func(t *testing.T) {+ pos := convertParserErrorPositionToPosition(tc.line, tc.column)+ require.Equal(t, tc.expectedLine, pos.Line, "line mismatch")+ require.Equal(t, tc.expectedCol, pos.Column, "column mismatch")+ })+ }+}diff --git a/backend/resources/postgres/embedded_instance.go b/backend/resources/postgres/embedded_instance.goindex 2db043fd73..0fa8a34fcb 100644--- a/backend/resources/postgres/embedded_instance.go+++ b/backend/resources/postgres/embedded_instance.go@@ -11,7 +11,6 @@ import ("github.com/jackc/pgx/v5""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log")@@ -66,7 +65,7 @@ func RemoveEmbeddedInstance(dataDir string) error {}func setupEmbeddedInstance(ctx context.Context, config EmbeddedInstanceConfig) error {- defaultDB, err := sql.Open("pgx", fmt.Sprintf("user=%s host=%s port=%d database=postgres", config.User, common.GetPostgresSocketDir(), config.Port))+ defaultDB, err := sql.Open("pgx", fmt.Sprintf("user=%s host=%s port=%d database=postgres", config.User, GetPostgresSocketDir(), config.Port))if err != nil {return err}@@ -83,7 +82,7 @@ func setupEmbeddedInstance(ctx context.Context, config EmbeddedInstanceConfig) ereturn errors.Wrap(err, "failed to create embedded PostgreSQL database")}- database, err := sql.Open("pgx", fmt.Sprintf("user=%s host=%s port=%d database=%s", config.User, common.GetPostgresSocketDir(), config.Port, config.DatabaseName))+ database, err := sql.Open("pgx", fmt.Sprintf("user=%s host=%s port=%d database=%s", config.User, GetPostgresSocketDir(), config.Port, config.DatabaseName))if err != nil {return err}diff --git a/backend/resources/postgres/meta_instance.go b/backend/resources/postgres/meta_instance.goindex 08254839d9..03efd74c4c 100644--- a/backend/resources/postgres/meta_instance.go+++ b/backend/resources/postgres/meta_instance.go@@ -21,7 +21,7 @@ func StartMetadataInstance(ctx context.Context, pgDataDir string, port int, modereturn nil, err}slog.Info("-----Embedded Postgres END-----")- db, err := sql.Open("pgx", fmt.Sprintf("host=%s port=%d user=bb database=postgres", common.GetPostgresSocketDir(), port))+ db, err := sql.Open("pgx", fmt.Sprintf("host=%s port=%d user=bb database=postgres", GetPostgresSocketDir(), port))if err != nil {return nil, err}diff --git a/backend/resources/postgres/postgres.go b/backend/resources/postgres/postgres.goindex d697211efd..3a29f9a259 100644--- a/backend/resources/postgres/postgres.go+++ b/backend/resources/postgres/postgres.go@@ -13,8 +13,6 @@ import ("syscall""github.com/pkg/errors"-- "github.com/bytebase/bytebase/backend/common")// start starts a postgres database instance.@@ -25,7 +23,7 @@ func start(port int, dataDir string, serverLog bool) (err error) {// We also set max_connections to 500 for tests.p := exec.Command("pg_ctl", "start", "-w","-D", dataDir,- "-o", fmt.Sprintf(`-p %d -k %s -N 500 -h "" -c log_checkpoints=off`, port, common.GetPostgresSocketDir()))+ "-o", fmt.Sprintf(`-p %d -k %s -N 500 -h "" -c log_checkpoints=off`, port, GetPostgresSocketDir()))uid, _, sameUser, err := shouldSwitchUser()if err != nil {@@ -179,3 +177,8 @@ func shouldSwitchUser() (uint32, uint32, bool, error) {}return uint32(uid), uint32(gid), sameUser, nil}++// GetPostgresSocketDir returns the postgres socket directory of Bytebase.+func GetPostgresSocketDir() string {+ return "/tmp"+}diff --git a/backend/server/prefix_test.go b/backend/server/prefix_test.gonew file mode 100644index 0000000000..37d83821a2--- /dev/null+++ b/backend/server/prefix_test.go@@ -0,0 +1,43 @@+package server++import (+ "testing"++ "github.com/stretchr/testify/assert"+)++func TestHasPrefixes(t *testing.T) {+ type args struct {+ src string+ prefixes []string+ }+ tests := []struct {+ name string+ args args+ want bool+ }{+ {+ name: "has prefixes",+ args: args{+ src: "abc",+ prefixes: []string{"a", "b", "c"},+ },+ want: true,+ },+ {+ name: "has no matching prefix",+ args: args{+ src: "this is a sentence",+ prefixes: []string{"that", "x", "y"},+ },+ want: false,+ },+ }+ for i := range tests {+ tt := tests[i]+ t.Run(tt.name, func(t *testing.T) {+ got := hasPrefixes(tt.args.src, tt.args.prefixes...)+ assert.Equal(t, got, tt.want)+ })+ }+}diff --git a/backend/server/server.go b/backend/server/server.goindex 3f811ded15..4d6035fc0f 100644--- a/backend/server/server.go+++ b/backend/server/server.go@@ -131,7 +131,7 @@ func NewServer(ctx context.Context, profile *config.Profile) (*Server, error) {return nil, err}s.stopper = append(s.stopper, stopper)- pgURL = fmt.Sprintf("host=%s port=%d user=bb database=bb", common.GetPostgresSocketDir(), profile.DatastorePort)+ pgURL = fmt.Sprintf("host=%s port=%d user=bb database=bb", postgres.GetPostgresSocketDir(), profile.DatastorePort)} else {pgURL = profile.PgURL}diff --git a/backend/server/server_frontend_routes.go b/backend/server/server_frontend_routes.goindex ecc9b4fb46..c3de219fe7 100644--- a/backend/server/server_frontend_routes.go+++ b/backend/server/server_frontend_routes.go@@ -9,8 +9,6 @@ import ("github.com/labstack/echo/v5""github.com/labstack/echo/v5/middleware"-- "github.com/bytebase/bytebase/backend/common")// registerFrontendRoutes wires up static file serving for the embedded frontend@@ -66,5 +64,14 @@ func registerFrontendRoutes(e *echo.Echo, distFS fs.FS) {// of falling through to the SPA's HTML5 fallback (which would return index.html).func defaultAPIRequestSkipper(c *echo.Context) bool {path := c.Request().URL.Path- return common.HasPrefixes(path, "/api", "/v1", "/bytebase.v1", "/.well-known", webhookAPIPrefix)+ return hasPrefixes(path, "/api", "/v1", "/bytebase.v1", "/.well-known", webhookAPIPrefix)+}++func hasPrefixes(src string, prefixes ...string) bool {+ for _, prefix := range prefixes {+ if strings.HasPrefix(src, prefix) {+ return true+ }+ }+ return false}diff --git a/docs/backend-common-audit.md b/docs/backend-common-audit.mdindex 31a45f8fb8..efbdaaede9 100644--- a/docs/backend-common-audit.md+++ b/docs/backend-common-audit.md@@ -3,7 +3,10 @@Audit scope: `backend/common`, including its subpackages, and their in-repositoryGo callers. The first migration implements `store/qb`, webhook retry and notificationtruncation, private store credential helpers, and private v1 audit callbacks.-The remaining entries are proposals.+The second migration moves the PostgreSQL socket-directory helper to+`resources/postgres`, prefix matching to a private server helper, ANTLR line+conversion to `plugin/parser/base`, and TiDB error-position conversion to a+private TiDB parser helper. The remaining entries are proposals.The root package mixes unrelated ownership: resource names, identity, requestcontext, audit transport, policy expressions, SQL execution, and generic helpers.