Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: correct position step 1 (#15646)

h3n4l5c7b28c43441
diff --git a/backend/common/position.go b/backend/common/position.go
new file mode 100644
index 0000000000..e528c619c0
--- /dev/null
+++ b/backend/common/position.go
@@ -0,0 +1,102 @@
+package common
+
+import (
+ "unicode/utf8"
+
+ storepb "github.com/bytebase/bytebase/proto/generated-go/store"
+)
+
+// 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 {
+ // Line position in a text (one-based).
+ Line int32
+ // Column position in a text (zero-based), equivalent to character offset.
+ Column int32
+}
+
+// ConvertPositionToANTLRPosition converts a Position to an ANTLRPosition in a given text.
+// Returns the end ANTLRPosition if the Position is out of the end of text,
+// returns the previous ANTLRPosition if the Position is in the middle of a character,
+// returns the previous ANTLRPosition if the Position is out of the end of a line.
+func ConvertPositionToANTLRPosition(p *storepb.Position, text string) *ANTLRPosition {
+ bs := []byte(text)
+ line := int32(0)
+ byteOffset := int32(0)
+ characterOffset := int32(0)
+
+ for bi := 0; bi < len(bs); {
+ if line < p.Line {
+ if bs[bi] == '\n' {
+ line++
+ }
+ bi++
+ continue
+ }
+
+ if byteOffset >= p.Column || bs[bi] == '\n' {
+ break
+ }
+
+ r, sz := utf8.DecodeRune(bs[bi:])
+ if r == utf8.RuneError {
+ break
+ }
+ // Avoid endless loop.
+ if sz == 0 {
+ break
+ }
+
+ byteOffset += int32(sz)
+ bi += sz
+ characterOffset++
+ }
+
+ return &ANTLRPosition{
+ Line: line + 1,
+ Column: characterOffset,
+ }
+}
+
+// ConvertANTLRPositionToPosition converts an ANTLRPosition to a Position in a given text.
+// Returns the end Position if the ANTLRPosition is out of the end of text,
+// returns the previous Position if the ANTLRPosition is in the middle of a character,
+// returns the previous Position if the ANTLRPosition is out of the end of a line.
+func ConvertANTLRPositionToPosition(a *ANTLRPosition, text string) *storepb.Position {
+ bs := []byte(text)
+ line := int32(0)
+ byteOffset := int32(0)
+ characterOffset := int32(0)
+
+ for bi := 0; bi < len(bs); {
+ if line < a.Line-1 {
+ if bs[bi] == '\n' {
+ line++
+ }
+ bi++
+ continue
+ }
+
+ if characterOffset >= a.Column || bs[bi] == '\n' {
+ break
+ }
+
+ r, sz := utf8.DecodeRune(bs[bi:])
+ if r == utf8.RuneError {
+ break
+ }
+ // Avoid endless loop.
+ if sz == 0 {
+ break
+ }
+
+ byteOffset += int32(sz)
+ bi += sz
+ characterOffset++
+ }
+
+ return &storepb.Position{
+ Line: line,
+ Column: byteOffset,
+ }
+}
diff --git a/backend/common/position_test.go b/backend/common/position_test.go
new file mode 100644
index 0000000000..5cebcc2ecf
--- /dev/null
+++ b/backend/common/position_test.go
@@ -0,0 +1,77 @@
+package common
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/require"
+
+ storepb "github.com/bytebase/bytebase/proto/generated-go/store"
+)
+
+func TestConvertPositionToANTLRPosition(t *testing.T) {
+ testCases := []struct {
+ description string
+ text string
+ position *storepb.Position
+ want *ANTLRPosition
+ }{
+ {
+ description: "empty text",
+ text: "",
+ position: &storepb.Position{Line: 0, Column: 0},
+ want: &ANTLRPosition{Line: 1, Column: 0},
+ },
+ {
+ description: "ascii",
+ text: "hello, world",
+ position: &storepb.Position{Line: 0, Column: 6},
+ want: &ANTLRPosition{Line: 1, Column: 6},
+ },
+ {
+ description: "multi-bytes characters",
+ text: "你好\n世界",
+ position: &storepb.Position{Line: 1, Column: 3},
+ want: &ANTLRPosition{Line: 2, Column: 1},
+ },
+ }
+
+ a := require.New(t)
+ for _, tc := range testCases {
+ got := ConvertPositionToANTLRPosition(tc.position, tc.text)
+ a.Equalf(tc.want, got, "Test case: %s", tc.description)
+ }
+}
+
+func TestConvertANTLRPositionToPosition(t *testing.T) {
+ testCases := []struct {
+ description string
+ text string
+ antlrPosition *ANTLRPosition
+ want *storepb.Position
+ }{
+ {
+ description: "empty text",
+ text: "",
+ antlrPosition: &ANTLRPosition{Line: 1, Column: 0},
+ want: &storepb.Position{Line: 0, Column: 0},
+ },
+ {
+ description: "ascii",
+ text: "hello, world",
+ antlrPosition: &ANTLRPosition{Line: 1, Column: 6},
+ want: &storepb.Position{Line: 0, Column: 6},
+ },
+ {
+ description: "multi-bytes characters",
+ text: "你好\n世界",
+ antlrPosition: &ANTLRPosition{Line: 2, Column: 1},
+ want: &storepb.Position{Line: 1, Column: 3},
+ },
+ }
+
+ a := require.New(t)
+ for _, tc := range testCases {
+ got := ConvertANTLRPositionToPosition(tc.antlrPosition, tc.text)
+ a.Equalf(tc.want, got, "Test case: %s", tc.description)
+ }
+}
diff --git a/backend/plugin/advisor/mssql/advisor_builtin_prior_backup_check.go b/backend/plugin/advisor/mssql/advisor_builtin_prior_backup_check.go
index 184e8c2779..47411ebe8e 100644
--- a/backend/plugin/advisor/mssql/advisor_builtin_prior_backup_check.go
+++ b/backend/plugin/advisor/mssql/advisor_builtin_prior_backup_check.go
@@ -52,26 +52,22 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx context.Context, checkCtx adv
if len(checkCtx.Statements) > common.MaxSheetCheckSize {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("The size of statements in the sheet exceeds the limit of %d", common.MaxSheetCheckSize),
- Code: advisor.BuiltinPriorBackupCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: 1,
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("The size of statements in the sheet exceeds the limit of %d", common.MaxSheetCheckSize),
+ Code: advisor.BuiltinPriorBackupCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(1),
})
}
databaseName := extractDatabaseName(checkCtx.PreUpdateBackupDetail.Database)
if !advisor.DatabaseExists(ctx, checkCtx, databaseName) {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Need database %q to do prior backup but it does not exist", checkCtx.PreUpdateBackupDetail.Database),
- Code: advisor.DatabaseNotExists.Int32(),
- StartPosition: &storepb.Position{
- Line: 1,
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Need database %q to do prior backup but it does not exist", checkCtx.PreUpdateBackupDetail.Database),
+ Code: advisor.DatabaseNotExists.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(1),
})
return adviceList, nil
}
@@ -81,13 +77,11 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx context.Context, checkCtx adv
if checker.hasDDL {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: "Prior backup cannot deal with mixed DDL and DML statements",
- Code: int32(advisor.BuiltinPriorBackupCheck),
- StartPosition: &storepb.Position{
- Line: 0,
- },
+ Status: level,
+ Title: title,
+ Content: "Prior backup cannot deal with mixed DDL and DML statements",
+ Code: int32(advisor.BuiltinPriorBackupCheck),
+ StartPosition: advisor.ConvertANTLRLineToPosition(1),
})
}
@@ -111,13 +105,11 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if statementType != item.table.StatementType {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("The statement type is not the same for all statements on the same table %q", key),
- Code: advisor.BuiltinPriorBackupCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: 1,
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("The statement type is not the same for all statements on the same table %q", key),
+ Code: advisor.BuiltinPriorBackupCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(1),
})
break
}
diff --git a/backend/plugin/advisor/mssql/advisor_column_maximum_varchar_length.go b/backend/plugin/advisor/mssql/advisor_column_maximum_varchar_length.go
index fbc5cc3ba5..ff49f22018 100644
--- a/backend/plugin/advisor/mssql/advisor_column_maximum_varchar_length.go
+++ b/backend/plugin/advisor/mssql/advisor_column_maximum_varchar_length.go
@@ -109,13 +109,11 @@ func (l *columnMaximumVarcharLengthChecker) EnterData_type(ctx *parser.Data_type
}
if currentLength > l.maximum {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.VarcharLengthExceedsLimit.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("The maximum varchar length is %d.", l.maximum),
- StartPosition: &storepb.Position{
- Line: int32(line),
- },
+ Status: l.level,
+ Code: advisor.VarcharLengthExceedsLimit.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("The maximum varchar length is %d.", l.maximum),
+ StartPosition: advisor.ConvertANTLRLineToPosition(line),
})
}
}
diff --git a/backend/plugin/advisor/mssql/advisor_column_no_null.go b/backend/plugin/advisor/mssql/advisor_column_no_null.go
index 274bf699f7..323d39f15e 100644
--- a/backend/plugin/advisor/mssql/advisor_column_no_null.go
+++ b/backend/plugin/advisor/mssql/advisor_column_no_null.go
@@ -92,13 +92,11 @@ func (l *columnNoNullChecker) ExitCreate_table(_ *parser.Create_tableContext) {
continue
}
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.ColumnCannotNull.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Column [%s] is nullable, which is not allowed.", columnName),
- StartPosition: &storepb.Position{
- Line: int32(l.currentTableColumnIsNullableLine[columnName]),
- },
+ Status: l.level,
+ Code: advisor.ColumnCannotNull.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Column [%s] is nullable, which is not allowed.", columnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(l.currentTableColumnIsNullableLine[columnName]),
})
}
@@ -170,13 +168,11 @@ func (l *columnNoNullChecker) ExitAlter_table(_ *parser.Alter_tableContext) {
continue
}
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.ColumnCannotNull.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Column [%s] is nullable, which is not allowed.", columnName),
- StartPosition: &storepb.Position{
- Line: int32(l.currentTableColumnIsNullableLine[columnName]),
- },
+ Status: l.level,
+ Code: advisor.ColumnCannotNull.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Column [%s] is nullable, which is not allowed.", columnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(l.currentTableColumnIsNullableLine[columnName]),
})
}
diff --git a/backend/plugin/advisor/mssql/advisor_column_require.go b/backend/plugin/advisor/mssql/advisor_column_require.go
index e74902b4df..bda44e2c74 100644
--- a/backend/plugin/advisor/mssql/advisor_column_require.go
+++ b/backend/plugin/advisor/mssql/advisor_column_require.go
@@ -115,13 +115,11 @@ func (l *columnRequireChecker) ExitCreate_table(ctx *parser.Create_tableContext)
})
for _, column := range columnNames {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NoRequiredColumn.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Table %s missing required column %q", l.currentOriginalTableName, column),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NoRequiredColumn.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Table %s missing required column %q", l.currentOriginalTableName, column),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
@@ -140,13 +138,11 @@ func (l *columnRequireChecker) EnterAlter_table(ctx *parser.Alter_tableContext)
_, normalizedColumnName := tsqlparser.NormalizeTSQLIdentifier(columnName)
if _, ok := l.requireColumns[normalizedColumnName]; ok {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NoRequiredColumn.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Table %s missing required column %q", tableName, normalizedColumnName),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NoRequiredColumn.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Table %s missing required column %q", tableName, normalizedColumnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mssql/advisor_column_type_disallow_list.go b/backend/plugin/advisor/mssql/advisor_column_type_disallow_list.go
index d15229e83f..60481b6855 100644
--- a/backend/plugin/advisor/mssql/advisor_column_type_disallow_list.go
+++ b/backend/plugin/advisor/mssql/advisor_column_type_disallow_list.go
@@ -68,13 +68,11 @@ func (checker *columnTypeDisallowListChecker) EnterData_type(ctx *parser.Data_ty
formatedDataType := strings.ToUpper(ctx.GetText())
if slices.Contains(checker.disallowTypes, formatedDataType) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DisabledColumnType.Int32(),
- Title: checker.title,
- Content: "Column type " + formatedDataType + " is disallowed",
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.DisabledColumnType.Int32(),
+ Title: checker.title,
+ Content: "Column type " + formatedDataType + " is disallowed",
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mssql/advisor_function_disallow_create_or_alter.go b/backend/plugin/advisor/mssql/advisor_function_disallow_create_or_alter.go
index 0db55846a7..c992f0c4ad 100644
--- a/backend/plugin/advisor/mssql/advisor_function_disallow_create_or_alter.go
+++ b/backend/plugin/advisor/mssql/advisor_function_disallow_create_or_alter.go
@@ -49,12 +49,10 @@ func (*FunctionDisallowCreateOrAlterAdvisor) Check(_ context.Context, checkCtx a
func (checker *FunctionDisallowCreateOrAlterChecker) EnterCreate_or_alter_function(ctx *parser.Create_or_alter_functionContext) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DisallowCreateFunction.Int32(),
- Title: checker.title,
- Content: "Creating or altering functions is prohibited",
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.DisallowCreateFunction.Int32(),
+ Title: checker.title,
+ Content: "Creating or altering functions is prohibited",
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
diff --git a/backend/plugin/advisor/mssql/advisor_index_not_redundant.go b/backend/plugin/advisor/mssql/advisor_index_not_redundant.go
index 28f16a4d6a..d305d0a5a5 100644
--- a/backend/plugin/advisor/mssql/advisor_index_not_redundant.go
+++ b/backend/plugin/advisor/mssql/advisor_index_not_redundant.go
@@ -97,12 +97,10 @@ func (checker *IndexNotRedundantChecker) EnterCreate_index(ctx *parser.Create_in
checker.adviceList = append(checker.adviceList, &storepb.Advice{
Status: checker.level,
Title: checker.title,
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
- Code: advisor.RedundantIndex.Int32(),
+ Code: advisor.RedundantIndex.Int32(),
Content: fmt.Sprintf("Redundant indexes with the same prefix ('%s' and '%s') in '%s.%s' is not allowed",
metaIdxName, statIdxName, findIdxKey.schemaName, findIdxKey.tblName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mssql/advisor_migration_compatibility.go b/backend/plugin/advisor/mssql/advisor_migration_compatibility.go
index db1dd509cf..a963a66e4f 100644
--- a/backend/plugin/advisor/mssql/advisor_migration_compatibility.go
+++ b/backend/plugin/advisor/mssql/advisor_migration_compatibility.go
@@ -113,13 +113,11 @@ func (l *migrationCompatibilityChecker) EnterDrop_table(ctx *parser.Drop_tableCo
normalizedTableName := tsqlparser.NormalizeTSQLTableName(tableName, l.currentDatabase, "dbo", false)
if _, ok := l.normalizedNewCreateTableNameMap[normalizedTableName]; !ok {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.CompatibilityDropSchema.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Drop table %s may cause incompatibility with the existing data and code", normalizedTableName),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.CompatibilityDropSchema.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Drop table %s may cause incompatibility with the existing data and code", normalizedTableName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
delete(l.normalizedNewCreateTableNameMap, normalizedTableName)
@@ -132,13 +130,11 @@ func (l *migrationCompatibilityChecker) EnterDrop_schema(ctx *parser.Drop_schema
normalizedSchemaName = fmt.Sprintf("%s.%s", l.currentDatabase, normalizedSchemaName)
if _, ok := l.normalizedNewCreateSchemaNameMap[normalizedSchemaName]; !ok {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.CompatibilityDropSchema.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Drop schema %s may cause incompatibility with the existing data and code", normalizedSchemaName),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.CompatibilityDropSchema.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Drop schema %s may cause incompatibility with the existing data and code", normalizedSchemaName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
delete(l.normalizedNewCreateSchemaNameMap, normalizedSchemaName)
@@ -149,13 +145,11 @@ func (l *migrationCompatibilityChecker) EnterDrop_database(ctx *parser.Drop_data
_, normalizedDatabaseName := tsqlparser.NormalizeTSQLIdentifier(databaseName)
if _, ok := l.normalizedNewCreateDatabaseNameMap[normalizedDatabaseName]; !ok {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.CompatibilityDropSchema.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Drop database %s may cause incompatibility with the existing data and code", normalizedDatabaseName),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.CompatibilityDropSchema.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Drop database %s may cause incompatibility with the existing data and code", normalizedDatabaseName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
delete(l.normalizedNewCreateDatabaseNameMap, normalizedDatabaseName)
@@ -177,13 +171,11 @@ func (l *migrationCompatibilityChecker) EnterAlter_table(ctx *parser.Alter_table
}
placeholder := strings.Join(allNormalizedDropColumnNames, ", ")
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.CompatibilityDropSchema.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Drop column %s may cause incompatibility with the existing data and code", placeholder),
- StartPosition: &storepb.Position{
- Line: int32(ctx.COLUMN().GetSymbol().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.CompatibilityDropSchema.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Drop column %s may cause incompatibility with the existing data and code", placeholder),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.COLUMN().GetSymbol().GetLine()),
})
return
}
@@ -196,13 +188,11 @@ func (l *migrationCompatibilityChecker) EnterAlter_table(ctx *parser.Alter_table
}
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.CompatibilityAlterColumn.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Alter COLUMN %s may cause incompatibility with the existing data and code", normalizedColumnName),
- StartPosition: &storepb.Position{
- Line: int32(ctx.COLUMN().GetSymbol().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.CompatibilityAlterColumn.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Alter COLUMN %s may cause incompatibility with the existing data and code", normalizedColumnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.COLUMN().GetSymbol().GetLine()),
})
return
}
@@ -228,13 +218,11 @@ func (l *migrationCompatibilityChecker) EnterAlter_table(ctx *parser.Alter_table
operation = "Add CHECK"
}
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: code.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("%s may cause incompatibility with the existing data and code", operation),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: code.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("%s may cause incompatibility with the existing data and code", operation),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
return
@@ -242,25 +230,21 @@ func (l *migrationCompatibilityChecker) EnterAlter_table(ctx *parser.Alter_table
if ctx.WITH() != nil && ctx.NOCHECK() != nil {
if ctx.FOREIGN() != nil {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.CompatibilityAddForeignKey.Int32(),
- Title: l.title,
- Content: "Add FOREIGN KEY WITH NO CHECK may cause incompatibility with the existing data and code",
- StartPosition: &storepb.Position{
- Line: int32(ctx.FOREIGN().GetSymbol().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.CompatibilityAddForeignKey.Int32(),
+ Title: l.title,
+ Content: "Add FOREIGN KEY WITH NO CHECK may cause incompatibility with the existing data and code",
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.FOREIGN().GetSymbol().GetLine()),
})
return
}
if len(ctx.AllCHECK()) == 1 {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.CompatibilityAddForeignKey.Int32(),
- Title: l.title,
- Content: "Add CHECK WITH NO CHECK may cause incompatibility with the existing data and code",
- StartPosition: &storepb.Position{
- Line: int32(ctx.CHECK(0).GetSymbol().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.CompatibilityAddForeignKey.Int32(),
+ Title: l.title,
+ Content: "Add CHECK WITH NO CHECK may cause incompatibility with the existing data and code",
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.CHECK(0).GetSymbol().GetLine()),
})
return
}
@@ -304,12 +288,10 @@ func (l *migrationCompatibilityChecker) EnterExecute_body(ctx *parser.Execute_bo
return
}
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.CompatibilityRenameTable.Int32(),
- Title: l.title,
- Content: "sp_rename may cause incompatibility with the existing data and code, and break scripts and stored procedures.",
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.CompatibilityRenameTable.Int32(),
+ Title: l.title,
+ Content: "sp_rename may cause incompatibility with the existing data and code, and break scripts and stored procedures.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
diff --git a/backend/plugin/advisor/mssql/advisor_naming_identifier_no_keyword.go b/backend/plugin/advisor/mssql/advisor_naming_identifier_no_keyword.go
index 89b6badacb..cee1c0be4b 100644
--- a/backend/plugin/advisor/mssql/advisor_naming_identifier_no_keyword.go
+++ b/backend/plugin/advisor/mssql/advisor_naming_identifier_no_keyword.go
@@ -87,13 +87,11 @@ func (l *namingIdentifierNoKeywordChecker) EnterId_(ctx *parser.Id_Context) {
_, normalizedID := tsqlparser.NormalizeTSQLIdentifier(ctx)
if tsqlparser.IsTSQLReservedKeyword(normalizedID, false) {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NameIsKeywordIdentifier.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Identifier [%s] is a keyword identifier and should be avoided.", normalizedID),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NameIsKeywordIdentifier.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Identifier [%s] is a keyword identifier and should be avoided.", normalizedID),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mssql/advisor_naming_table.go b/backend/plugin/advisor/mssql/advisor_naming_table.go
index 89e7fde9e3..4c43a05f98 100644
--- a/backend/plugin/advisor/mssql/advisor_naming_table.go
+++ b/backend/plugin/advisor/mssql/advisor_naming_table.go
@@ -81,24 +81,20 @@ func (l *namingTableListener) EnterCreate_table(ctx *parser.Create_tableContext)
if !l.format.MatchString(tableName) {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NamingTableConventionMismatch.Int32(),
- Title: l.title,
- Content: fmt.Sprintf(`%s mismatches table naming convention, naming format should be %q`, tableName, l.format),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NamingTableConventionMismatch.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf(`%s mismatches table naming convention, naming format should be %q`, tableName, l.format),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
if l.maxLength > 0 && len(tableName) > l.maxLength {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NamingTableConventionMismatch.Int32(),
- Title: l.title,
- Content: fmt.Sprintf(`%s mismatches table naming convention, its length should be within %d characters`, tableName, l.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NamingTableConventionMismatch.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf(`%s mismatches table naming convention, its length should be within %d characters`, tableName, l.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
@@ -168,24 +164,20 @@ func (l *namingTableListener) EnterExecute_body(ctx *parser.Execute_bodyContext)
if !l.format.MatchString(newTableName) {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NamingTableConventionMismatch.Int32(),
- Title: l.title,
- Content: fmt.Sprintf(`%s mismatches table naming convention, naming format should be %q`, newTableName, l.format),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NamingTableConventionMismatch.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf(`%s mismatches table naming convention, naming format should be %q`, newTableName, l.format),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
if l.maxLength > 0 && len(newTableName) > l.maxLength {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NamingTableConventionMismatch.Int32(),
- Title: l.title,
- Content: fmt.Sprintf(`%s mismatches table naming convention, its length should be within %d characters`, newTableName, l.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NamingTableConventionMismatch.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf(`%s mismatches table naming convention, its length should be within %d characters`, newTableName, l.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mssql/advisor_naming_table_no_keyword.go b/backend/plugin/advisor/mssql/advisor_naming_table_no_keyword.go
index b959865526..b9b733cbac 100644
--- a/backend/plugin/advisor/mssql/advisor_naming_table_no_keyword.go
+++ b/backend/plugin/advisor/mssql/advisor_naming_table_no_keyword.go
@@ -69,13 +69,11 @@ func (l *namingTableNoKeywordChecker) EnterCreate_table(ctx *parser.Create_table
_, normalizedTableName := tsqlparser.NormalizeTSQLIdentifier(tableName)
if tsqlparser.IsTSQLReservedKeyword(normalizedTableName, false) {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NameIsKeywordIdentifier.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Table name [%s] is a reserved keyword and should be avoided.", normalizedTableName),
- StartPosition: &storepb.Position{
- Line: int32(tableName.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NameIsKeywordIdentifier.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Table name [%s] is a reserved keyword and should be avoided.", normalizedTableName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(tableName.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mssql/advisor_procedure_disallow_create_or_alter.go b/backend/plugin/advisor/mssql/advisor_procedure_disallow_create_or_alter.go
index 5079a45bdc..2fe8edd9d5 100644
--- a/backend/plugin/advisor/mssql/advisor_procedure_disallow_create_or_alter.go
+++ b/backend/plugin/advisor/mssql/advisor_procedure_disallow_create_or_alter.go
@@ -48,12 +48,10 @@ func (*ProcedureDisallowCreateOrAlterAdvisor) Check(_ context.Context, checkCtx
func (checker *ProcedureDisallowCreateOrAlterChecker) EnterCreate_or_alter_procedure(ctx *parser.Create_or_alter_procedureContext) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DisallowCreateProcedure.Int32(),
- Title: checker.title,
- Content: "Creating or altering procedures is prohibited",
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.DisallowCreateProcedure.Int32(),
+ Title: checker.title,
+ Content: "Creating or altering procedures is prohibited",
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
diff --git a/backend/plugin/advisor/mssql/advisor_select_no_select_all.go b/backend/plugin/advisor/mssql/advisor_select_no_select_all.go
index 0a1b0de54a..8f12b12e13 100644
--- a/backend/plugin/advisor/mssql/advisor_select_no_select_all.go
+++ b/backend/plugin/advisor/mssql/advisor_select_no_select_all.go
@@ -66,13 +66,11 @@ func (l *selectNoSelectAllChecker) EnterSelect_list_elem(ctx *parser.Select_list
if v := ctx.Asterisk(); v != nil {
if v.STAR() != nil {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.StatementSelectAll.Int32(),
- Title: l.title,
- Content: "Avoid using SELECT *.",
- StartPosition: &storepb.Position{
- Line: int32(v.STAR().GetSymbol().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.StatementSelectAll.Int32(),
+ Title: l.title,
+ Content: "Avoid using SELECT *.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(v.STAR().GetSymbol().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mssql/advisor_statement_disallow_cross_db_queries.go b/backend/plugin/advisor/mssql/advisor_statement_disallow_cross_db_queries.go
index 4678ca15df..31ecef60ec 100644
--- a/backend/plugin/advisor/mssql/advisor_statement_disallow_cross_db_queries.go
+++ b/backend/plugin/advisor/mssql/advisor_statement_disallow_cross_db_queries.go
@@ -55,13 +55,11 @@ func (checker *DisallowCrossDBQueriesChecker) EnterTable_source_item(ctx *parser
// Case insensitive.
if fullTblName, err := tsql.NormalizeFullTableName(fullTblnameCtx); err == nil && fullTblName.Database != "" && !strings.EqualFold(fullTblName.Database, checker.curDB) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementDisallowCrossDBQueries.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Cross database queries (target databse: '%s', current database: '%s') are prohibited", fullTblName.Database, checker.curDB),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementDisallowCrossDBQueries.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Cross database queries (target databse: '%s', current database: '%s') are prohibited", fullTblName.Database, checker.curDB),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
// Ignore internal error...
diff --git a/backend/plugin/advisor/mssql/advisor_statement_disallow_mix_in_ddl.go b/backend/plugin/advisor/mssql/advisor_statement_disallow_mix_in_ddl.go
index 1321080fc6..afe2f7a48e 100644
--- a/backend/plugin/advisor/mssql/advisor_statement_disallow_mix_in_ddl.go
+++ b/backend/plugin/advisor/mssql/advisor_statement_disallow_mix_in_ddl.go
@@ -73,13 +73,11 @@ func (c *statementDisallowMixInDDLChecker) EnterSql_clauses(ctx *parser.Sql_clau
if isDML {
c.adviceList = append(c.adviceList, &storepb.Advice{
- Status: c.level,
- Title: c.title,
- Content: "Alter schema can only run DDL",
- Code: advisor.StatementDisallowMixDDLDML.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: c.level,
+ Title: c.title,
+ Content: "Alter schema can only run DDL",
+ Code: advisor.StatementDisallowMixDDLDML.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mssql/advisor_statement_disallow_mix_in_dml.go b/backend/plugin/advisor/mssql/advisor_statement_disallow_mix_in_dml.go
index 25e53b8247..bf1ddd03cb 100644
--- a/backend/plugin/advisor/mssql/advisor_statement_disallow_mix_in_dml.go
+++ b/backend/plugin/advisor/mssql/advisor_statement_disallow_mix_in_dml.go
@@ -73,13 +73,11 @@ func (c *statementDisallowMixInDMLChecker) EnterSql_clauses(ctx *parser.Sql_clau
if !isDML {
c.adviceList = append(c.adviceList, &storepb.Advice{
- Status: c.level,
- Title: c.title,
- Content: "Data change can only run DML",
- Code: advisor.StatementDisallowMixDDLDML.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: c.level,
+ Title: c.title,
+ Content: "Data change can only run DML",
+ Code: advisor.StatementDisallowMixDDLDML.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mssql/advisor_statement_where_disallow_functions_and_calculations.go b/backend/plugin/advisor/mssql/advisor_statement_where_disallow_functions_and_calculations.go
index 59a310b4cb..ca21e0653a 100644
--- a/backend/plugin/advisor/mssql/advisor_statement_where_disallow_functions_and_calculations.go
+++ b/backend/plugin/advisor/mssql/advisor_statement_where_disallow_functions_and_calculations.go
@@ -66,13 +66,11 @@ func generateAdviceOnFunctionUsing(c *DisallowFuncAndCalculationsChecker, ctx an
}
c.hasTriggeredRule = true
return &storepb.Advice{
- Status: c.level,
- Code: advisor.StatementDisallowFunctionsAndCalculations.Int32(),
- Title: c.title,
- Content: fmt.Sprintf("Calling function '%s' in 'WHERE' clause is not allowed", ctx.GetText()),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: c.level,
+ Code: advisor.StatementDisallowFunctionsAndCalculations.Int32(),
+ Title: c.title,
+ Content: fmt.Sprintf("Calling function '%s' in 'WHERE' clause is not allowed", ctx.GetText()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
}
}
@@ -82,13 +80,11 @@ func generateAdviceOnPerformingCalculations(c *DisallowFuncAndCalculationsChecke
}
c.hasTriggeredRule = true
return &storepb.Advice{
- Status: c.level,
- Code: advisor.StatementDisallowFunctionsAndCalculations.Int32(),
- Title: c.title,
- Content: "Performing calculations in 'WHERE' clause is not allowed",
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: c.level,
+ Code: advisor.StatementDisallowFunctionsAndCalculations.Int32(),
+ Title: c.title,
+ Content: "Performing calculations in 'WHERE' clause is not allowed",
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
}
}
diff --git a/backend/plugin/advisor/mssql/advisor_statement_where_requirement_for_select.go b/backend/plugin/advisor/mssql/advisor_statement_where_requirement_for_select.go
index 043d67f2eb..fe19797291 100644
--- a/backend/plugin/advisor/mssql/advisor_statement_where_requirement_for_select.go
+++ b/backend/plugin/advisor/mssql/advisor_statement_where_requirement_for_select.go
@@ -66,13 +66,11 @@ func (l *whereRequirementForSelectChecker) EnterQuery_specification(ctx *parser.
// Allow SELECT queries without a FROM clause to proceed, e.g. SELECT 1.
if ctx.WHERE() == nil && ctx.From_table_sources() != nil {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.StatementNoWhere.Int32(),
- Title: l.title,
- Content: "WHERE clause is required for SELETE statement.",
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.StatementNoWhere.Int32(),
+ Title: l.title,
+ Content: "WHERE clause is required for SELETE statement.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mssql/advisor_statement_where_requirement_for_update_delete.go b/backend/plugin/advisor/mssql/advisor_statement_where_requirement_for_update_delete.go
index 3186b3ae0a..fade47ea03 100644
--- a/backend/plugin/advisor/mssql/advisor_statement_where_requirement_for_update_delete.go
+++ b/backend/plugin/advisor/mssql/advisor_statement_where_requirement_for_update_delete.go
@@ -65,13 +65,11 @@ func (l *whereRequirementForUpdateDeleteChecker) generateAdvice() ([]*storepb.Ad
func (l *whereRequirementForUpdateDeleteChecker) EnterDelete_statement(ctx *parser.Delete_statementContext) {
if ctx.WHERE() == nil {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.StatementNoWhere.Int32(),
- Title: l.title,
- Content: "WHERE clause is required for DELETE statement.",
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.StatementNoWhere.Int32(),
+ Title: l.title,
+ Content: "WHERE clause is required for DELETE statement.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
@@ -80,13 +78,11 @@ func (l *whereRequirementForUpdateDeleteChecker) EnterDelete_statement(ctx *pars
func (l *whereRequirementForUpdateDeleteChecker) EnterUpdate_statement(ctx *parser.Update_statementContext) {
if ctx.WHERE() == nil {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.StatementNoWhere.Int32(),
- Title: l.title,
- Content: "WHERE clause is required for UPDATE statement.",
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.StatementNoWhere.Int32(),
+ Title: l.title,
+ Content: "WHERE clause is required for UPDATE statement.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mssql/advisor_table_disallow_ddl.go b/backend/plugin/advisor/mssql/advisor_table_disallow_ddl.go
index b2e7ce9160..0b402c1723 100644
--- a/backend/plugin/advisor/mssql/advisor_table_disallow_ddl.go
+++ b/backend/plugin/advisor/mssql/advisor_table_disallow_ddl.go
@@ -102,13 +102,11 @@ func (checker *tableDisallowDDLChecker) checkTableName(normalizedTableName strin
for _, disallow := range checker.disallowList {
if normalizedTableName == disallow {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.TableDisallowDDL.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("DDL is disallowed on table %s.", normalizedTableName),
- StartPosition: &storepb.Position{
- Line: int32(line),
- },
+ Status: checker.level,
+ Code: advisor.TableDisallowDDL.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("DDL is disallowed on table %s.", normalizedTableName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(line),
})
return
}
diff --git a/backend/plugin/advisor/mssql/advisor_table_disallow_dml.go b/backend/plugin/advisor/mssql/advisor_table_disallow_dml.go
index 9fd86886e9..f260bc8bdb 100644
--- a/backend/plugin/advisor/mssql/advisor_table_disallow_dml.go
+++ b/backend/plugin/advisor/mssql/advisor_table_disallow_dml.go
@@ -109,13 +109,11 @@ func (checker *tableDisallowDMLChecker) checkTableName(normalizedTableName strin
for _, disallow := range checker.disallowList {
if normalizedTableName == disallow {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.TableDisallowDML.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("DML is disallowed on table %s.", normalizedTableName),
- StartPosition: &storepb.Position{
- Line: int32(line),
- },
+ Status: checker.level,
+ Code: advisor.TableDisallowDML.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("DML is disallowed on table %s.", normalizedTableName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(line),
})
return
}
diff --git a/backend/plugin/advisor/mssql/advisor_table_drop_naming_convention.go b/backend/plugin/advisor/mssql/advisor_table_drop_naming_convention.go
index 47367104f4..3727b070de 100644
--- a/backend/plugin/advisor/mssql/advisor_table_drop_naming_convention.go
+++ b/backend/plugin/advisor/mssql/advisor_table_drop_naming_convention.go
@@ -81,13 +81,11 @@ func (l *tableDropNamingConventionChecker) EnterDrop_table(ctx *parser.Drop_tabl
_, normalizedTableName := tsqlparser.NormalizeTSQLIdentifier(table)
if !l.format.MatchString(normalizedTableName) {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.TableDropNamingConventionMismatch.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("[%s] mismatches drop table naming convention, naming format should be %q", normalizedTableName, l.format),
- StartPosition: &storepb.Position{
- Line: int32(table.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.TableDropNamingConventionMismatch.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("[%s] mismatches drop table naming convention, naming format should be %q", normalizedTableName, l.format),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mssql/advisor_table_no_foreign_key.go b/backend/plugin/advisor/mssql/advisor_table_no_foreign_key.go
index be8349591d..1b9038a744 100644
--- a/backend/plugin/advisor/mssql/advisor_table_no_foreign_key.go
+++ b/backend/plugin/advisor/mssql/advisor_table_no_foreign_key.go
@@ -78,13 +78,11 @@ func (l *tableNoForeignKeyChecker) generateAdvice() ([]*storepb.Advice, error) {
for tableName, hasForeignKey := range l.tableHasForeignKey {
if hasForeignKey {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.TableHasFK.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("FOREIGN KEY is not allowed in the table %s.", l.tableOriginalName[tableName]),
- StartPosition: &storepb.Position{
- Line: int32(l.tableLine[tableName]),
- },
+ Status: l.level,
+ Code: advisor.TableHasFK.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("FOREIGN KEY is not allowed in the table %s.", l.tableOriginalName[tableName]),
+ StartPosition: advisor.ConvertANTLRLineToPosition(l.tableLine[tableName]),
})
}
}
diff --git a/backend/plugin/advisor/mssql/advisor_table_require_pk.go b/backend/plugin/advisor/mssql/advisor_table_require_pk.go
index c59143e50c..9f1bf5e540 100644
--- a/backend/plugin/advisor/mssql/advisor_table_require_pk.go
+++ b/backend/plugin/advisor/mssql/advisor_table_require_pk.go
@@ -78,13 +78,11 @@ func (l *tableRequirePkChecker) generateAdvice() ([]*storepb.Advice, error) {
for tableName, hasPK := range l.tableHasPrimaryKey {
if !hasPK {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.TableNoPK.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Table %s requires PRIMARY KEY.", l.tableOriginalName[tableName]),
- StartPosition: &storepb.Position{
- Line: int32(l.tableLine[tableName]),
- },
+ Status: l.level,
+ Code: advisor.TableNoPK.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Table %s requires PRIMARY KEY.", l.tableOriginalName[tableName]),
+ StartPosition: advisor.ConvertANTLRLineToPosition(l.tableLine[tableName]),
})
}
}
diff --git a/backend/plugin/advisor/mssql/test/column_maximum_varchar_length.yaml b/backend/plugin/advisor/mssql/test/column_maximum_varchar_length.yaml
index d8b29472ff..4cd33af86d 100644
--- a/backend/plugin/advisor/mssql/test/column_maximum_varchar_length.yaml
+++ b/backend/plugin/advisor/mssql/test/column_maximum_varchar_length.yaml
@@ -8,7 +8,7 @@
title: column.maximum-varchar-length
content: The maximum varchar length is 2560.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE MyTable ALTER COLUMN a VARCHAR(MAX);
@@ -19,7 +19,7 @@
title: column.maximum-varchar-length
content: The maximum varchar length is 2560.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE MyTable ALTER COLUMN a NVARCHAR(MAX);
@@ -30,6 +30,6 @@
title: column.maximum-varchar-length
content: The maximum varchar length is 2560.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mssql/test/column_no_null.yaml b/backend/plugin/advisor/mssql/test/column_no_null.yaml
index f27972f7b8..5b78e23366 100644
--- a/backend/plugin/advisor/mssql/test/column_no_null.yaml
+++ b/backend/plugin/advisor/mssql/test/column_no_null.yaml
@@ -12,7 +12,7 @@
title: column.no-null
content: Column [age] is nullable, which is not allowed.
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- status: 2
@@ -20,7 +20,7 @@
title: column.no-null
content: Column [address] is nullable, which is not allowed.
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- statement: |-
@@ -38,7 +38,7 @@
title: column.no-null
content: Column [address] is nullable, which is not allowed.
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- statement: ALTER TABLE MyTable ALTER COLUMN Name VARCHAR(100) NULL;
@@ -49,7 +49,7 @@
title: column.no-null
content: Column [name] is nullable, which is not allowed.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE MyTable ALTER COLUMN Name VARCHAR(100) NOT NULL;
@@ -62,7 +62,7 @@
title: column.no-null
content: Column [age] is nullable, which is not allowed.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE MyTable ADD Age INT NULL;
@@ -73,7 +73,7 @@
title: column.no-null
content: Column [age] is nullable, which is not allowed.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE MyTable ADD Age INT NOT NULL;
diff --git a/backend/plugin/advisor/mssql/test/column_required.yaml b/backend/plugin/advisor/mssql/test/column_required.yaml
index 540cfb56c3..7f4ef3626f 100644
--- a/backend/plugin/advisor/mssql/test/column_required.yaml
+++ b/backend/plugin/advisor/mssql/test/column_required.yaml
@@ -19,7 +19,7 @@
title: column.required
content: Table t missing required column "created_ts"
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
@@ -27,7 +27,7 @@
title: column.required
content: Table t missing required column "creator_id"
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
@@ -35,7 +35,7 @@
title: column.required
content: Table t missing required column "id"
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
@@ -43,7 +43,7 @@
title: column.required
content: Table t missing required column "updated_ts"
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
@@ -51,7 +51,7 @@
title: column.required
content: Table t missing required column "updater_id"
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -68,7 +68,7 @@
title: column.required
content: Table t missing required column "updated_ts"
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE t DROP COLUMN created_ts;
@@ -79,7 +79,7 @@
title: column.required
content: Table t missing required column "created_ts"
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE t DROP COLUMN creator_id;
@@ -90,6 +90,6 @@
title: column.required
content: Table t missing required column "creator_id"
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mssql/test/column_type_disallow_list.yaml b/backend/plugin/advisor/mssql/test/column_type_disallow_list.yaml
index 7f03c6b56f..824e96ade7 100644
--- a/backend/plugin/advisor/mssql/test/column_type_disallow_list.yaml
+++ b/backend/plugin/advisor/mssql/test/column_type_disallow_list.yaml
@@ -11,6 +11,6 @@
title: column.type-disallow-list
content: Column type JSON is disallowed
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mssql/test/index_not_redundant.yaml b/backend/plugin/advisor/mssql/test/index_not_redundant.yaml
index 3e217c8945..4ac646266f 100644
--- a/backend/plugin/advisor/mssql/test/index_not_redundant.yaml
+++ b/backend/plugin/advisor/mssql/test/index_not_redundant.yaml
@@ -6,7 +6,7 @@
title: index.not-redundant
content: Redundant indexes with the same prefix ('idx_0' and 'test_index') in 'dbo.pokes' is not allowed
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE INDEX test_index ON dbo.pokes (c100, c200);
@@ -19,6 +19,6 @@
title: index.not-redundant
content: Redundant indexes with the same prefix ('idx_0' and 'test_index') in 'dbo.pokes' is not allowed
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mssql/test/naming_identifier_no_keyword.yaml b/backend/plugin/advisor/mssql/test/naming_identifier_no_keyword.yaml
index 444cf7168b..604930ae94 100644
--- a/backend/plugin/advisor/mssql/test/naming_identifier_no_keyword.yaml
+++ b/backend/plugin/advisor/mssql/test/naming_identifier_no_keyword.yaml
@@ -8,7 +8,7 @@
title: naming.identifier.no-keyword
content: Identifier [exec] is a keyword identifier and should be avoided.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
@@ -16,7 +16,7 @@
title: naming.identifier.no-keyword
content: Identifier [fillfactor] is a keyword identifier and should be avoided.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
@@ -24,7 +24,7 @@
title: naming.identifier.no-keyword
content: Identifier [add] is a keyword identifier and should be avoided.
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
@@ -32,6 +32,6 @@
title: naming.identifier.no-keyword
content: Identifier [fillfactor] is a keyword identifier and should be avoided.
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mssql/test/naming_table.yaml b/backend/plugin/advisor/mssql/test/naming_table.yaml
index 3751f755a1..065de3086d 100644
--- a/backend/plugin/advisor/mssql/test/naming_table.yaml
+++ b/backend/plugin/advisor/mssql/test/naming_table.yaml
@@ -8,7 +8,7 @@
title: naming.table
content: '[\\] mismatches table naming convention, naming format should be "^[A-Z]([_A-Za-z])*$"'
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE all_lowercase(ID INT);
@@ -19,7 +19,7 @@
title: naming.table
content: all_lowercase mismatches table naming convention, naming format should be "^[A-Z]([_A-Za-z])*$"
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE PascalCase(ID INT);
@@ -34,6 +34,6 @@
title: naming.table
content: salesTerr mismatches table naming convention, naming format should be "^[A-Z]([_A-Za-z])*$"
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mssql/test/naming_table_no_keyword.yaml b/backend/plugin/advisor/mssql/test/naming_table_no_keyword.yaml
index c2f7b7b653..313e323052 100644
--- a/backend/plugin/advisor/mssql/test/naming_table_no_keyword.yaml
+++ b/backend/plugin/advisor/mssql/test/naming_table_no_keyword.yaml
@@ -6,7 +6,7 @@
title: naming.table.no-keyword
content: Table name [fillfactor] is a reserved keyword and should be avoided.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE MyDB.MySchema.[fillfactor] (id INT);
@@ -17,7 +17,7 @@
title: naming.table.no-keyword
content: Table name [fillfactor] is a reserved keyword and should be avoided.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE Person(id INT);
diff --git a/backend/plugin/advisor/mssql/test/schema_backward_compatibility.yaml b/backend/plugin/advisor/mssql/test/schema_backward_compatibility.yaml
index 3d73bf4d99..e4e27a944c 100644
--- a/backend/plugin/advisor/mssql/test/schema_backward_compatibility.yaml
+++ b/backend/plugin/advisor/mssql/test/schema_backward_compatibility.yaml
@@ -6,7 +6,7 @@
title: schema.backward-compatibility
content: sp_rename may cause incompatibility with the existing data and code, and break scripts and stored procedures.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: DROP TABLE MyTable;
@@ -17,7 +17,7 @@
title: schema.backward-compatibility
content: Drop table master.dbo.MyTable may cause incompatibility with the existing data and code
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -32,7 +32,7 @@
title: schema.backward-compatibility
content: Drop schema master.myschema may cause incompatibility with the existing data and code
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -47,7 +47,7 @@
title: schema.backward-compatibility
content: Drop database mydb may cause incompatibility with the existing data and code
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -71,7 +71,7 @@
title: schema.backward-compatibility
content: Drop column mycolumnone, mycolumntwo may cause incompatibility with the existing data and code
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
@@ -79,7 +79,7 @@
title: schema.backward-compatibility
content: Alter COLUMN mycolumnone may cause incompatibility with the existing data and code
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
@@ -87,7 +87,7 @@
title: schema.backward-compatibility
content: Add PRIMARY KEY may cause incompatibility with the existing data and code
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
@@ -95,7 +95,7 @@
title: schema.backward-compatibility
content: Add UNIQUE KEY may cause incompatibility with the existing data and code
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- status: 2
@@ -103,7 +103,7 @@
title: schema.backward-compatibility
content: Add CHECK may cause incompatibility with the existing data and code
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- status: 2
@@ -111,7 +111,7 @@
title: schema.backward-compatibility
content: Add CHECK WITH NO CHECK may cause incompatibility with the existing data and code
startposition:
- line: 6
+ line: 5
column: 0
endposition: null
- status: 2
@@ -119,7 +119,7 @@
title: schema.backward-compatibility
content: Add FOREIGN KEY WITH NO CHECK may cause incompatibility with the existing data and code
startposition:
- line: 8
+ line: 7
column: 0
endposition: null
- statement: EXEC sp_rename 'Sales.SalesTerritory', 'SalesTerr';
@@ -130,7 +130,7 @@
title: schema.backward-compatibility
content: sp_rename may cause incompatibility with the existing data and code, and break scripts and stored procedures.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: EXEC sp_rename 'dbo.ErrorLog.ErrorTime', 'ErrorDateTime', 'COLUMN';
@@ -141,6 +141,6 @@
title: schema.backward-compatibility
content: sp_rename may cause incompatibility with the existing data and code, and break scripts and stored procedures.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mssql/test/statement_disallow_cross_db_queries.yaml b/backend/plugin/advisor/mssql/test/statement_disallow_cross_db_queries.yaml
index 68d04ea013..82a6175d44 100644
--- a/backend/plugin/advisor/mssql/test/statement_disallow_cross_db_queries.yaml
+++ b/backend/plugin/advisor/mssql/test/statement_disallow_cross_db_queries.yaml
@@ -11,7 +11,7 @@
title: statement.disallow-cross-db-queries
content: 'Cross database queries (target databse: ''master2'', current database: ''master'') are prohibited'
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -24,6 +24,6 @@
title: statement.disallow-cross-db-queries
content: 'Cross database queries (target databse: ''master'', current database: ''master2'') are prohibited'
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mssql/test/statement_disallow_mix_in_ddl.yaml b/backend/plugin/advisor/mssql/test/statement_disallow_mix_in_ddl.yaml
index 1faca79076..26a7315af8 100644
--- a/backend/plugin/advisor/mssql/test/statement_disallow_mix_in_ddl.yaml
+++ b/backend/plugin/advisor/mssql/test/statement_disallow_mix_in_ddl.yaml
@@ -6,7 +6,7 @@
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: UPDATE tech_book SET id = 1;
@@ -17,7 +17,7 @@
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD author TEXT; UPDATE tech_book SET id = 1;DELETE FROM tech_book WHERE a > 1;
@@ -28,7 +28,7 @@
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
@@ -36,6 +36,6 @@
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mssql/test/statement_disallow_mix_in_dml.yaml b/backend/plugin/advisor/mssql/test/statement_disallow_mix_in_dml.yaml
index f48c4bddf2..4e8c901134 100644
--- a/backend/plugin/advisor/mssql/test/statement_disallow_mix_in_dml.yaml
+++ b/backend/plugin/advisor/mssql/test/statement_disallow_mix_in_dml.yaml
@@ -10,6 +10,6 @@
title: statement.disallow-mix-in-dml
content: Data change can only run DML
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mssql/test/statement_select_no_select_all.yaml b/backend/plugin/advisor/mssql/test/statement_select_no_select_all.yaml
index d9bc264725..2ff05e6e09 100644
--- a/backend/plugin/advisor/mssql/test/statement_select_no_select_all.yaml
+++ b/backend/plugin/advisor/mssql/test/statement_select_no_select_all.yaml
@@ -6,7 +6,7 @@
title: statement.select.no-select-all
content: Avoid using SELECT *.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT a, b FROM t
@@ -19,7 +19,7 @@
title: statement.select.no-select-all
content: Avoid using SELECT *.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: INSERT INTO t SELECT * FROM t1
@@ -30,6 +30,6 @@
title: statement.select.no-select-all
content: Avoid using SELECT *.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mssql/test/statement_where_disallow_functions_and_calculations.yaml b/backend/plugin/advisor/mssql/test/statement_where_disallow_functions_and_calculations.yaml
index ca25d7c0c6..bcd55d9dfe 100644
--- a/backend/plugin/advisor/mssql/test/statement_where_disallow_functions_and_calculations.yaml
+++ b/backend/plugin/advisor/mssql/test/statement_where_disallow_functions_and_calculations.yaml
@@ -10,7 +10,7 @@
title: statement.where.disallow-functions-and-calculations
content: Performing calculations in 'WHERE' clause is not allowed
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
@@ -18,7 +18,7 @@
title: statement.where.disallow-functions-and-calculations
content: Performing calculations in 'WHERE' clause is not allowed
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- statement: |-
@@ -31,7 +31,7 @@
title: statement.where.disallow-functions-and-calculations
content: Performing calculations in 'WHERE' clause is not allowed
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
@@ -39,7 +39,7 @@
title: statement.where.disallow-functions-and-calculations
content: Calling function 'AVG(bar)' in 'WHERE' clause is not allowed
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: SELECT bar FROM pokes WHERE bar > 1;
@@ -58,6 +58,6 @@
title: statement.where.disallow-functions-and-calculations
content: Calling function 'AVG(a)' in 'WHERE' clause is not allowed
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mssql/test/statement_where_require_select.yaml b/backend/plugin/advisor/mssql/test/statement_where_require_select.yaml
index 0021236256..c93a8a07d1 100644
--- a/backend/plugin/advisor/mssql/test/statement_where_require_select.yaml
+++ b/backend/plugin/advisor/mssql/test/statement_where_require_select.yaml
@@ -6,7 +6,7 @@
title: statement.where.require.select
content: WHERE clause is required for SELETE statement.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT * FROM MyTable WHERE a = 1;
@@ -22,7 +22,7 @@
title: statement.where.require.select
content: WHERE clause is required for SELETE statement.
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
@@ -30,7 +30,7 @@
title: statement.where.require.select
content: WHERE clause is required for SELETE statement.
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: SELECT 1;
diff --git a/backend/plugin/advisor/mssql/test/statement_where_require_update_delete.yaml b/backend/plugin/advisor/mssql/test/statement_where_require_update_delete.yaml
index 47dafb33c7..10867be611 100644
--- a/backend/plugin/advisor/mssql/test/statement_where_require_update_delete.yaml
+++ b/backend/plugin/advisor/mssql/test/statement_where_require_update_delete.yaml
@@ -6,7 +6,7 @@
title: statement.where.require.update-delete
content: WHERE clause is required for UPDATE statement.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: UPDATE MyTable SET a = 1 WHERE a = 1;
@@ -19,7 +19,7 @@
title: statement.where.require.update-delete
content: WHERE clause is required for DELETE statement.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: DELETE FROM MyTable WHERE a = 1;
diff --git a/backend/plugin/advisor/mssql/test/system_function_disallow_create.yaml b/backend/plugin/advisor/mssql/test/system_function_disallow_create.yaml
index d720349df3..cbf03b707c 100644
--- a/backend/plugin/advisor/mssql/test/system_function_disallow_create.yaml
+++ b/backend/plugin/advisor/mssql/test/system_function_disallow_create.yaml
@@ -20,6 +20,6 @@
title: system.function.disallow-create
content: Creating or altering functions is prohibited
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mssql/test/system_procedure_disallow_create.yaml b/backend/plugin/advisor/mssql/test/system_procedure_disallow_create.yaml
index cfc91b9909..5973cdf8fb 100644
--- a/backend/plugin/advisor/mssql/test/system_procedure_disallow_create.yaml
+++ b/backend/plugin/advisor/mssql/test/system_procedure_disallow_create.yaml
@@ -24,6 +24,6 @@
title: system.procedure.disallow-create
content: Creating or altering procedures is prohibited
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mssql/test/table_disallow_ddl.yaml b/backend/plugin/advisor/mssql/test/table_disallow_ddl.yaml
index ccab9b0a88..09e59ae4ff 100644
--- a/backend/plugin/advisor/mssql/test/table_disallow_ddl.yaml
+++ b/backend/plugin/advisor/mssql/test/table_disallow_ddl.yaml
@@ -14,6 +14,6 @@
title: table.disallow-ddl
content: DDL is disallowed on table MySchema.Identifier.
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mssql/test/table_disallow_dml.yaml b/backend/plugin/advisor/mssql/test/table_disallow_dml.yaml
index 5f09ec71e3..55665fa7ee 100644
--- a/backend/plugin/advisor/mssql/test/table_disallow_dml.yaml
+++ b/backend/plugin/advisor/mssql/test/table_disallow_dml.yaml
@@ -9,7 +9,7 @@
title: table.disallow-dml
content: DML is disallowed on table MySchema.Identifier.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -22,7 +22,7 @@
title: table.disallow-dml
content: DML is disallowed on table MySchema.Identifier.
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: DELETE FROM MySchema.Identifier WHERE Id = 1;
@@ -33,7 +33,7 @@
title: table.disallow-dml
content: DML is disallowed on table MySchema.Identifier.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: UPDATE MySchema.Identifier SET Name = 'Bob' WHERE Id = 1;
@@ -44,7 +44,7 @@
title: table.disallow-dml
content: DML is disallowed on table MySchema.Identifier.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT * INTO MySchema.Identifier FROM MySchema.MyTable;
@@ -55,6 +55,6 @@
title: table.disallow-dml
content: DML is disallowed on table MySchema.Identifier.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mssql/test/table_drop_naming_convention.yaml b/backend/plugin/advisor/mssql/test/table_drop_naming_convention.yaml
index 14e58ca54e..e9643091cf 100644
--- a/backend/plugin/advisor/mssql/test/table_drop_naming_convention.yaml
+++ b/backend/plugin/advisor/mssql/test/table_drop_naming_convention.yaml
@@ -8,7 +8,7 @@
title: table.drop-naming-convention
content: '[foo] mismatches drop table naming convention, naming format should be "_delete$"'
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: DROP TABLE [Foo], [Bar_delete];
@@ -19,6 +19,6 @@
title: table.drop-naming-convention
content: '[foo] mismatches drop table naming convention, naming format should be "_delete$"'
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mssql/test/table_no_foreign_key.yaml b/backend/plugin/advisor/mssql/test/table_no_foreign_key.yaml
index f526d0084f..f625f62ccb 100644
--- a/backend/plugin/advisor/mssql/test/table_no_foreign_key.yaml
+++ b/backend/plugin/advisor/mssql/test/table_no_foreign_key.yaml
@@ -12,7 +12,7 @@
title: table.no-foreign-key
content: FOREIGN KEY is not allowed in the table MyTable.
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -30,7 +30,7 @@
title: table.no-foreign-key
content: FOREIGN KEY is not allowed in the table Customer.
startposition:
- line: 6
+ line: 5
column: 0
endposition: null
- statement: |-
@@ -48,7 +48,7 @@
title: table.no-foreign-key
content: FOREIGN KEY is not allowed in the table Customer.
startposition:
- line: 7
+ line: 6
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/mssql/test/table_require_pk.yaml b/backend/plugin/advisor/mssql/test/table_require_pk.yaml
index 597b87e809..29618d6792 100644
--- a/backend/plugin/advisor/mssql/test/table_require_pk.yaml
+++ b/backend/plugin/advisor/mssql/test/table_require_pk.yaml
@@ -10,7 +10,7 @@
title: table.require-pk
content: Table MySchema.MyTable requires PRIMARY KEY.
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/mysql/advisor_builtin_prior_backup_check.go b/backend/plugin/advisor/mysql/advisor_builtin_prior_backup_check.go
index 094748257b..a3a0940549 100644
--- a/backend/plugin/advisor/mysql/advisor_builtin_prior_backup_check.go
+++ b/backend/plugin/advisor/mysql/advisor_builtin_prior_backup_check.go
@@ -60,13 +60,11 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx context.Context, checkCtx adv
if checker.IsDDL {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: "Prior backup cannot deal with mixed DDL and DML statements",
- Code: advisor.BuiltinPriorBackupCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.BaseLine) + 1,
- },
+ Status: level,
+ Title: title,
+ Content: "Prior backup cannot deal with mixed DDL and DML statements",
+ Code: advisor.BuiltinPriorBackupCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.BaseLine),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_charset_allowlist.go b/backend/plugin/advisor/mysql/advisor_charset_allowlist.go
index efbc9a2c92..c17c609b5e 100644
--- a/backend/plugin/advisor/mysql/advisor_charset_allowlist.go
+++ b/backend/plugin/advisor/mysql/advisor_charset_allowlist.go
@@ -92,13 +92,11 @@ func (checker *charsetAllowlistChecker) EnterCreateDatabase(ctx *mysql.CreateDat
func (checker *charsetAllowlistChecker) checkCharset(charset string, lineNumber int) {
if _, exists := checker.allowList[charset]; charset != "" && !exists {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DisabledCharset.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" used disabled charset '%s'", checker.text, charset),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + lineNumber),
- },
+ Status: checker.level,
+ Code: advisor.DisabledCharset.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" used disabled charset '%s'", checker.text, charset),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + lineNumber),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_collation_allowlist.go b/backend/plugin/advisor/mysql/advisor_collation_allowlist.go
index f410f411df..41d58702de 100644
--- a/backend/plugin/advisor/mysql/advisor_collation_allowlist.go
+++ b/backend/plugin/advisor/mysql/advisor_collation_allowlist.go
@@ -92,13 +92,11 @@ func (checker *collationAllowlistChecker) checkCollation(collation string, lineN
collation = strings.ToLower(collation)
if _, exists := checker.allowList[collation]; collation != "" && !exists {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DisabledCollation.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" used disabled collation '%s'", checker.text, collation),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + lineNumber),
- },
+ Status: checker.level,
+ Code: advisor.DisabledCollation.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" used disabled collation '%s'", checker.text, collation),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + lineNumber),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_colum_require_default.go b/backend/plugin/advisor/mysql/advisor_colum_require_default.go
index 8fcbfbaf6c..256b532bb7 100644
--- a/backend/plugin/advisor/mysql/advisor_colum_require_default.go
+++ b/backend/plugin/advisor/mysql/advisor_colum_require_default.go
@@ -145,13 +145,11 @@ func (checker *columnRequireDefaultChecker) EnterAlterTable(ctx *mysql.AlterTabl
func (checker *columnRequireDefaultChecker) checkFieldDefinition(tableName, columnName string, ctx mysql.IFieldDefinitionContext) {
if !checker.hasDefault(ctx) && checker.needDefault(ctx) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NoDefault.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Column `%s`.`%s` doesn't have DEFAULT.", tableName, columnName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.NoDefault.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Column `%s`.`%s` doesn't have DEFAULT.", tableName, columnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_column_auto_increment_initial_value.go b/backend/plugin/advisor/mysql/advisor_column_auto_increment_initial_value.go
index 02e17c1952..d8c56f01b4 100644
--- a/backend/plugin/advisor/mysql/advisor_column_auto_increment_initial_value.go
+++ b/backend/plugin/advisor/mysql/advisor_column_auto_increment_initial_value.go
@@ -92,13 +92,11 @@ func (checker *columnAutoIncrementInitialValueChecker) EnterCreateTable(ctx *mys
}
if value != uint64(checker.value) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.AutoIncrementColumnInitialValueNotMatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The initial auto-increment value in table `%s` is %v, which doesn't equal %v", tableName, value, checker.value),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.AutoIncrementColumnInitialValueNotMatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The initial auto-increment value in table `%s` is %v, which doesn't equal %v", tableName, value, checker.value),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
@@ -141,13 +139,11 @@ func (checker *columnAutoIncrementInitialValueChecker) EnterAlterTable(ctx *mysq
}
if value != uint64(checker.value) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.AutoIncrementColumnInitialValueNotMatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The initial auto-increment value in table `%s` is %v, which doesn't equal %v", tableName, value, checker.value),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.AutoIncrementColumnInitialValueNotMatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The initial auto-increment value in table `%s` is %v, which doesn't equal %v", tableName, value, checker.value),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_column_auto_increment_must_integer.go b/backend/plugin/advisor/mysql/advisor_column_auto_increment_must_integer.go
index 92ec93c9fa..fb61387701 100644
--- a/backend/plugin/advisor/mysql/advisor_column_auto_increment_must_integer.go
+++ b/backend/plugin/advisor/mysql/advisor_column_auto_increment_must_integer.go
@@ -144,13 +144,11 @@ func (checker *columnAutoIncrementMustIntegerChecker) EnterAlterTable(ctx *mysql
func (checker *columnAutoIncrementMustIntegerChecker) checkFieldDefinition(tableName, columnName string, ctx mysql.IFieldDefinitionContext) {
if !checker.isAutoIncrementColumnIsInteger(ctx) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.AutoIncrementColumnNotInteger.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Auto-increment column `%s`.`%s` requires integer type", tableName, columnName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.AutoIncrementColumnNotInteger.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Auto-increment column `%s`.`%s` requires integer type", tableName, columnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_column_auto_increment_must_unsigned.go b/backend/plugin/advisor/mysql/advisor_column_auto_increment_must_unsigned.go
index 92855e65c8..a4fce2c251 100644
--- a/backend/plugin/advisor/mysql/advisor_column_auto_increment_must_unsigned.go
+++ b/backend/plugin/advisor/mysql/advisor_column_auto_increment_must_unsigned.go
@@ -146,13 +146,11 @@ func (checker *columnAutoIncrementMustUnsignedChecker) EnterAlterTable(ctx *mysq
func (checker *columnAutoIncrementMustUnsignedChecker) checkFieldDefinition(tableName, columnName string, ctx mysql.IFieldDefinitionContext) {
if !checker.isAutoIncrementColumnIsInteger(ctx) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.AutoIncrementColumnSigned.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Auto-increment column `%s`.`%s` is not UNSIGNED type", tableName, columnName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.AutoIncrementColumnSigned.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Auto-increment column `%s`.`%s` is not UNSIGNED type", tableName, columnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_column_comment_convention.go b/backend/plugin/advisor/mysql/advisor_column_comment_convention.go
index c99cb410df..5c8336bc40 100644
--- a/backend/plugin/advisor/mysql/advisor_column_comment_convention.go
+++ b/backend/plugin/advisor/mysql/advisor_column_comment_convention.go
@@ -165,26 +165,22 @@ func (checker *columnCommentConventionChecker) checkFieldDefinition(tableName, c
comment = mysqlparser.NormalizeMySQLTextLiteral(attribute.TextLiteral())
if checker.payload.MaxLength >= 0 && len(comment) > checker.payload.MaxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CommentTooLong.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The length of column `%s`.`%s` comment should be within %d characters", tableName, columnName, checker.payload.MaxLength),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.CommentTooLong.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The length of column `%s`.`%s` comment should be within %d characters", tableName, columnName, checker.payload.MaxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
if checker.payload.RequiredClassification {
if classification, _ := common.GetClassificationAndUserComment(comment, checker.classificationConfig); classification == "" {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CommentMissingClassification.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Column `%s`.`%s` comment requires classification", tableName, columnName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.CommentMissingClassification.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Column `%s`.`%s` comment requires classification", tableName, columnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
@@ -194,13 +190,11 @@ func (checker *columnCommentConventionChecker) checkFieldDefinition(tableName, c
if len(comment) == 0 && checker.payload.Required {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CommentEmpty.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Column `%s`.`%s` requires comments", tableName, columnName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.CommentEmpty.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Column `%s`.`%s` requires comments", tableName, columnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_column_current_time_count_limit.go b/backend/plugin/advisor/mysql/advisor_column_current_time_count_limit.go
index 6133b59c61..de0032c4c7 100644
--- a/backend/plugin/advisor/mysql/advisor_column_current_time_count_limit.go
+++ b/backend/plugin/advisor/mysql/advisor_column_current_time_count_limit.go
@@ -218,24 +218,20 @@ func (checker *columnCurrentTimeCountLimitChecker) generateAdvice() []*storepb.A
for _, table := range tableList {
if table.defaultCurrentTimeCount > maxDefaultCurrentTimeColumCount {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DefaultCurrentTimeColumnCountExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table `%s` has %d DEFAULT CURRENT_TIMESTAMP() columns. The count greater than %d.", table.tableName, table.defaultCurrentTimeCount, maxDefaultCurrentTimeColumCount),
- StartPosition: &storepb.Position{
- Line: int32(table.line),
- },
+ Status: checker.level,
+ Code: advisor.DefaultCurrentTimeColumnCountExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table `%s` has %d DEFAULT CURRENT_TIMESTAMP() columns. The count greater than %d.", table.tableName, table.defaultCurrentTimeCount, maxDefaultCurrentTimeColumCount),
+ StartPosition: advisor.ConvertANTLRLineToPosition(table.line),
})
}
if table.onUpdateCurrentTimeCount > maxOnUpdateCurrentTimeColumnCount {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.OnUpdateCurrentTimeColumnCountExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table `%s` has %d ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than %d.", table.tableName, table.onUpdateCurrentTimeCount, maxOnUpdateCurrentTimeColumnCount),
- StartPosition: &storepb.Position{
- Line: int32(table.line),
- },
+ Status: checker.level,
+ Code: advisor.OnUpdateCurrentTimeColumnCountExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table `%s` has %d ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than %d.", table.tableName, table.onUpdateCurrentTimeCount, maxOnUpdateCurrentTimeColumnCount),
+ StartPosition: advisor.ConvertANTLRLineToPosition(table.line),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_column_disallow_changing.go b/backend/plugin/advisor/mysql/advisor_column_disallow_changing.go
index e2ec310d33..cb7ce6fcfa 100644
--- a/backend/plugin/advisor/mysql/advisor_column_disallow_changing.go
+++ b/backend/plugin/advisor/mysql/advisor_column_disallow_changing.go
@@ -90,13 +90,11 @@ func (checker *columnDisallowChangingChecker) EnterAlterTable(ctx *mysql.AlterTa
// change column
if item.CHANGE_SYMBOL() != nil && item.ColumnInternalRef() != nil && item.Identifier() != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.UseChangeColumnStatement.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" contains CHANGE COLUMN statement", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.UseChangeColumnStatement.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" contains CHANGE COLUMN statement", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_column_disallow_changing_order.go b/backend/plugin/advisor/mysql/advisor_column_disallow_changing_order.go
index 37d123c503..67ccd93f3a 100644
--- a/backend/plugin/advisor/mysql/advisor_column_disallow_changing_order.go
+++ b/backend/plugin/advisor/mysql/advisor_column_disallow_changing_order.go
@@ -100,13 +100,11 @@ func (checker *columnDisallowChangingOrderChecker) EnterAlterTable(ctx *mysql.Al
if item.Place() != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.ChangeColumnOrder.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" changes column order", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.ChangeColumnOrder.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" changes column order", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_column_disallow_changing_type.go b/backend/plugin/advisor/mysql/advisor_column_disallow_changing_type.go
index 86049c5074..17813466c7 100644
--- a/backend/plugin/advisor/mysql/advisor_column_disallow_changing_type.go
+++ b/backend/plugin/advisor/mysql/advisor_column_disallow_changing_type.go
@@ -150,13 +150,11 @@ func (checker *columnDisallowChangingTypeChecker) changeColumnType(tableName, co
if normalizeColumnType(column.Type()) != normalizeColumnType(tp) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.ChangeColumnType.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" changes column type", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + dataType.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.ChangeColumnType.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" changes column type", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + dataType.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_column_disallow_drop.go b/backend/plugin/advisor/mysql/advisor_column_disallow_drop.go
index a95543a784..db783d7c17 100644
--- a/backend/plugin/advisor/mysql/advisor_column_disallow_drop.go
+++ b/backend/plugin/advisor/mysql/advisor_column_disallow_drop.go
@@ -84,13 +84,11 @@ func (checker *columnDisallowDropChecker) EnterAlterTable(ctx *mysql.AlterTableC
columnName := mysqlparser.NormalizeMySQLColumnInternalRef(item.ColumnInternalRef())
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DropColumn.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("drops column \"%s\" of table \"%s\"", columnName, tableName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + item.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.DropColumn.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("drops column \"%s\" of table \"%s\"", columnName, tableName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + item.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_column_disallow_drop_in_index.go b/backend/plugin/advisor/mysql/advisor_column_disallow_drop_in_index.go
index 055679d23c..06db09e818 100644
--- a/backend/plugin/advisor/mysql/advisor_column_disallow_drop_in_index.go
+++ b/backend/plugin/advisor/mysql/advisor_column_disallow_drop_in_index.go
@@ -148,13 +148,11 @@ func (checker *columnDisallowDropInIndexChecker) EnterAlterTable(ctx *mysql.Alte
columnName := mysqlparser.NormalizeMySQLColumnInternalRef(item.ColumnInternalRef())
if !checker.canDrop(tableName, columnName) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DropIndexColumn.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("`%s`.`%s` cannot drop index column", tableName, columnName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + item.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.DropIndexColumn.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("`%s`.`%s` cannot drop index column", tableName, columnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + item.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_column_disallow_set_charset.go b/backend/plugin/advisor/mysql/advisor_column_disallow_set_charset.go
index 6a16d27bd9..01489ddfb1 100644
--- a/backend/plugin/advisor/mysql/advisor_column_disallow_set_charset.go
+++ b/backend/plugin/advisor/mysql/advisor_column_disallow_set_charset.go
@@ -89,13 +89,11 @@ func (checker *columnDisallowSetCharsetChecker) EnterCreateTable(ctx *mysql.Crea
charset := checker.getCharSet(tableElement.ColumnDefinition().FieldDefinition().DataType())
if !checker.checkCharset(charset) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.SetColumnCharset.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Disallow set column charset but \"%s\" does", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.SetColumnCharset.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Disallow set column charset but \"%s\" does", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
@@ -168,13 +166,11 @@ func (checker *columnDisallowSetCharsetChecker) EnterAlterTable(ctx *mysql.Alter
for _, charsetName := range charsetList {
if !checker.checkCharset(charsetName) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.SetColumnCharset.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Disallow set column charset but \"%s\" does", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.SetColumnCharset.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Disallow set column charset but \"%s\" does", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_column_maximum_character_length.go b/backend/plugin/advisor/mysql/advisor_column_maximum_character_length.go
index 6f9f1ffff5..b388dc4e22 100644
--- a/backend/plugin/advisor/mysql/advisor_column_maximum_character_length.go
+++ b/backend/plugin/advisor/mysql/advisor_column_maximum_character_length.go
@@ -94,13 +94,11 @@ func (checker *columnMaximumCharacterLengthChecker) EnterCreateTable(ctx *mysql.
charLength := checker.getCharLength(tableElement.ColumnDefinition().FieldDefinition().DataType())
if checker.maximum > 0 && charLength > checker.maximum {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CharLengthExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The length of the CHAR column `%s.%s` is bigger than %d, please use VARCHAR instead", tableName, columnName, checker.maximum),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + tableElement.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.CharLengthExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The length of the CHAR column `%s.%s` is bigger than %d, please use VARCHAR instead", tableName, columnName, checker.maximum),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + tableElement.GetStart().GetLine()),
})
}
}
@@ -182,13 +180,11 @@ func (checker *columnMaximumCharacterLengthChecker) EnterAlterTable(ctx *mysql.A
for _, columnName := range columnList {
if charLength, ok := charLengthMap[columnName]; ok && checker.maximum > 0 && charLength > checker.maximum {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CharLengthExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The length of the CHAR column `%s.%s` is bigger than %d, please use VARCHAR instead", tableName, columnName, checker.maximum),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.CharLengthExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The length of the CHAR column `%s.%s` is bigger than %d, please use VARCHAR instead", tableName, columnName, checker.maximum),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_column_maximum_varchar_length.go b/backend/plugin/advisor/mysql/advisor_column_maximum_varchar_length.go
index 931ee340ea..63912055e8 100644
--- a/backend/plugin/advisor/mysql/advisor_column_maximum_varchar_length.go
+++ b/backend/plugin/advisor/mysql/advisor_column_maximum_varchar_length.go
@@ -94,13 +94,11 @@ func (checker *columnMaximumVarcharLengthChecker) EnterCreateTable(ctx *mysql.Cr
length := getVarcharLength(tableElement.ColumnDefinition().FieldDefinition().DataType())
if checker.maximum > 0 && length > checker.maximum {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.VarcharLengthExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The length of the VARCHAR column `%s.%s` is bigger than %d", tableName, columnName, checker.maximum),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + tableElement.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.VarcharLengthExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The length of the VARCHAR column `%s.%s` is bigger than %d", tableName, columnName, checker.maximum),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + tableElement.GetStart().GetLine()),
})
}
}
@@ -181,13 +179,11 @@ func (checker *columnMaximumVarcharLengthChecker) EnterAlterTable(ctx *mysql.Alt
for _, columnName := range columnList {
if length, ok := varcharLengthMap[columnName]; ok && checker.maximum > 0 && length > checker.maximum {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.VarcharLengthExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The length of the VARCHAR column `%s.%s` is bigger than %d", tableName, columnName, checker.maximum),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.VarcharLengthExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The length of the VARCHAR column `%s.%s` is bigger than %d", tableName, columnName, checker.maximum),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_column_no_null.go b/backend/plugin/advisor/mysql/advisor_column_no_null.go
index 46080a6706..66b8418b3c 100644
--- a/backend/plugin/advisor/mysql/advisor_column_no_null.go
+++ b/backend/plugin/advisor/mysql/advisor_column_no_null.go
@@ -95,13 +95,11 @@ func (checker *columnNoNullChecker) generateAdvice() []*storepb.Advice {
})
if col != nil && col.Nullable() {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.ColumnCannotNull.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("`%s`.`%s` cannot have NULL value", column.tableName, column.columnName),
- StartPosition: &storepb.Position{
- Line: int32(column.line),
- },
+ Status: checker.level,
+ Code: advisor.ColumnCannotNull.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("`%s`.`%s` cannot have NULL value", column.tableName, column.columnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.line),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_column_require_charset.go b/backend/plugin/advisor/mysql/advisor_column_require_charset.go
index 7283b7f12c..501563a109 100644
--- a/backend/plugin/advisor/mysql/advisor_column_require_charset.go
+++ b/backend/plugin/advisor/mysql/advisor_column_require_charset.go
@@ -81,13 +81,11 @@ func (checker *columnRequireCharsetChecker) EnterCreateTable(ctx *mysql.CreateTa
if isCharsetDataType(dataType) {
if dataType.CharsetWithOptBinary() == nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NoCharset.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Column %s does not have a character set specified", columnName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + columnDefinition.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.NoCharset.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Column %s does not have a character set specified", columnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + columnDefinition.GetStart().GetLine()),
})
}
}
@@ -109,13 +107,11 @@ func (checker *columnRequireCharsetChecker) EnterAlterTable(ctx *mysql.AlterTabl
if isCharsetDataType(dataType) {
if dataType.CharsetWithOptBinary() == nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NoCharset.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Column %s does not have a character set specified", columnName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + alterListItem.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.NoCharset.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Column %s does not have a character set specified", columnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + alterListItem.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_column_require_collation.go b/backend/plugin/advisor/mysql/advisor_column_require_collation.go
index 0806474c07..4f93b84169 100644
--- a/backend/plugin/advisor/mysql/advisor_column_require_collation.go
+++ b/backend/plugin/advisor/mysql/advisor_column_require_collation.go
@@ -81,13 +81,11 @@ func (checker *columnRequireCollationChecker) EnterCreateTable(ctx *mysql.Create
if isCharsetDataType(dataType) {
if columnDefinition.FieldDefinition().Collate() == nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NoCollation.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Column %s does not have a collation specified", columnName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + columnDefinition.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.NoCollation.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Column %s does not have a collation specified", columnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + columnDefinition.GetStart().GetLine()),
})
}
}
@@ -109,13 +107,11 @@ func (checker *columnRequireCollationChecker) EnterAlterTable(ctx *mysql.AlterTa
if isCharsetDataType(dataType) {
if alterListItem.FieldDefinition().Collate() == nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NoCollation.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Column %s does not have a collation specified", columnName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + alterListItem.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.NoCollation.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Column %s does not have a collation specified", columnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + alterListItem.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_column_required.go b/backend/plugin/advisor/mysql/advisor_column_required.go
index cf0501fa90..125059ed2d 100644
--- a/backend/plugin/advisor/mysql/advisor_column_required.go
+++ b/backend/plugin/advisor/mysql/advisor_column_required.go
@@ -179,13 +179,11 @@ func (checker *columnRequirementChecker) generateAdviceList() []*storepb.Advice
// Order it cause the random iteration order in Go, see https://go.dev/blog/maps
sort.Strings(missingColumns)
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NoRequiredColumn.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table `%s` requires columns: %s", tableName, strings.Join(missingColumns, ", ")),
- StartPosition: &storepb.Position{
- Line: int32(checker.line[tableName]),
- },
+ Status: checker.level,
+ Code: advisor.NoRequiredColumn.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table `%s` requires columns: %s", tableName, strings.Join(missingColumns, ", ")),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line[tableName]),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_column_set_default_for_not_null.go b/backend/plugin/advisor/mysql/advisor_column_set_default_for_not_null.go
index 1ea3cef731..f9f2a816dd 100644
--- a/backend/plugin/advisor/mysql/advisor_column_set_default_for_not_null.go
+++ b/backend/plugin/advisor/mysql/advisor_column_set_default_for_not_null.go
@@ -119,13 +119,11 @@ func (checker *columnSetDefaultForNotNullChecker) EnterCreateTable(ctx *mysql.Cr
}
if !checker.canNull(field) && !checker.hasDefault(field) && checker.needDefault(field) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NotNullColumnWithNoDefault.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Column `%s`.`%s` is NOT NULL but doesn't have DEFAULT", tableName, columnName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + tableElement.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.NotNullColumnWithNoDefault.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Column `%s`.`%s` is NOT NULL but doesn't have DEFAULT", tableName, columnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + tableElement.GetStart().GetLine()),
})
}
}
@@ -134,13 +132,11 @@ func (checker *columnSetDefaultForNotNullChecker) EnterCreateTable(ctx *mysql.Cr
func (checker *columnSetDefaultForNotNullChecker) checkFieldDefinition(tableName, columnName string, ctx mysql.IFieldDefinitionContext) {
if !checker.canNull(ctx) && checker.needDefault(ctx) && !checker.hasDefault(ctx) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NotNullColumnWithNoDefault.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Column `%s`.`%s` is NOT NULL but doesn't have DEFAULT", tableName, columnName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.NotNullColumnWithNoDefault.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Column `%s`.`%s` is NOT NULL but doesn't have DEFAULT", tableName, columnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_column_type_disallow_list.go b/backend/plugin/advisor/mysql/advisor_column_type_disallow_list.go
index 6f0fceb0cc..8547c15b97 100644
--- a/backend/plugin/advisor/mysql/advisor_column_type_disallow_list.go
+++ b/backend/plugin/advisor/mysql/advisor_column_type_disallow_list.go
@@ -109,13 +109,11 @@ func (checker *columnTypeDisallowListChecker) checkFieldDefinition(tableName, co
columnType = strings.ToUpper(columnType)
if _, exists := checker.typeRestriction[columnType]; exists {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DisabledColumnType.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Disallow column type %s but column `%s`.`%s` is", columnType, tableName, columnName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.DisabledColumnType.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Disallow column type %s but column `%s`.`%s` is", columnType, tableName, columnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_database_drop_empty_db.go b/backend/plugin/advisor/mysql/advisor_database_drop_empty_db.go
index f827d9f715..3d9033f40d 100644
--- a/backend/plugin/advisor/mysql/advisor_database_drop_empty_db.go
+++ b/backend/plugin/advisor/mysql/advisor_database_drop_empty_db.go
@@ -76,23 +76,19 @@ func (checker *allowDropEmptyDBChecker) EnterDropDatabase(ctx *mysql.DropDatabas
dbName := mysqlparser.NormalizeMySQLSchemaRef(ctx.SchemaRef())
if checker.catalog.Origin.DatabaseName() != dbName {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NotCurrentDatabase.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Database `%s` that is trying to be deleted is not the current database `%s`", dbName, checker.catalog.Origin.DatabaseName()),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.NotCurrentDatabase.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Database `%s` that is trying to be deleted is not the current database `%s`", dbName, checker.catalog.Origin.DatabaseName()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
} else if !checker.catalog.Origin.HasNoTable() {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DatabaseNotEmpty.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Database `%s` is not allowed to drop if not empty", dbName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.DatabaseNotEmpty.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Database `%s` is not allowed to drop if not empty", dbName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_disallow_procedure.go b/backend/plugin/advisor/mysql/advisor_disallow_procedure.go
index 959da7f9a0..1532f7088a 100644
--- a/backend/plugin/advisor/mysql/advisor_disallow_procedure.go
+++ b/backend/plugin/advisor/mysql/advisor_disallow_procedure.go
@@ -76,13 +76,11 @@ func (checker *procedureDisallowCreateChecker) EnterCreateProcedure(ctx *mysql.C
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Procedure is forbidden, but \"%s\" creates", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Procedure is forbidden, but \"%s\" creates", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_event_disallow_create.go b/backend/plugin/advisor/mysql/advisor_event_disallow_create.go
index c953ec045a..666cb2963e 100644
--- a/backend/plugin/advisor/mysql/advisor_event_disallow_create.go
+++ b/backend/plugin/advisor/mysql/advisor_event_disallow_create.go
@@ -75,13 +75,11 @@ func (checker *eventDisallowCreateChecker) EnterCreateEvent(ctx *mysql.CreateEve
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Event is forbidden, but \"%s\" creates", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Event is forbidden, but \"%s\" creates", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_function_disallow_create.go b/backend/plugin/advisor/mysql/advisor_function_disallow_create.go
index c7bc809b66..641233e89c 100644
--- a/backend/plugin/advisor/mysql/advisor_function_disallow_create.go
+++ b/backend/plugin/advisor/mysql/advisor_function_disallow_create.go
@@ -75,13 +75,11 @@ func (checker *functionDisallowCreateChecker) EnterCreateFunction(ctx *mysql.Cre
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Function is forbidden, but \"%s\" creates", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Function is forbidden, but \"%s\" creates", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_function_disallowed_list.go b/backend/plugin/advisor/mysql/advisor_function_disallowed_list.go
index a937e2a0b5..8bd35810b9 100644
--- a/backend/plugin/advisor/mysql/advisor_function_disallowed_list.go
+++ b/backend/plugin/advisor/mysql/advisor_function_disallowed_list.go
@@ -79,13 +79,11 @@ func (checker *functionDisallowedListChecker) EnterFunctionCall(ctx *mysql.Funct
functionName := mysqlparser.NormalizeMySQLPureIdentifier(pi)
if slices.Contains(checker.disallowList, strings.ToUpper(functionName)) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DisabledFunction.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Function \"%s\" is disallowed, but \"%s\" uses", functionName, checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.DisabledFunction.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Function \"%s\" is disallowed, but \"%s\" uses", functionName, checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_index_key_number_limit.go b/backend/plugin/advisor/mysql/advisor_index_key_number_limit.go
index bb84f4c080..6c21150a79 100644
--- a/backend/plugin/advisor/mysql/advisor_index_key_number_limit.go
+++ b/backend/plugin/advisor/mysql/advisor_index_key_number_limit.go
@@ -119,13 +119,11 @@ func (checker *indexKeyNumberLimitChecker) handleConstraintDef(tableName string,
if checker.max > 0 && len(columnList) > checker.max {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.IndexKeyNumberExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The number of index `%s` in table `%s` should be not greater than %d", indexName, tableName, checker.max),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.IndexKeyNumberExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The number of index `%s` in table `%s` should be not greater than %d", indexName, tableName, checker.max),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
@@ -154,13 +152,11 @@ func (checker *indexKeyNumberLimitChecker) EnterCreateIndex(ctx *mysql.CreateInd
columnList := mysqlparser.NormalizeKeyListVariants(ctx.CreateIndexTarget().KeyListVariants())
if checker.max > 0 && len(columnList) > checker.max {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.IndexKeyNumberExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The number of index `%s` in table `%s` should be not greater than %d", indexName, tableName, checker.max),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.IndexKeyNumberExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The number of index `%s` in table `%s` should be not greater than %d", indexName, tableName, checker.max),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_index_no_duplicate_column.go b/backend/plugin/advisor/mysql/advisor_index_no_duplicate_column.go
index f1777e8391..b8389b94e9 100644
--- a/backend/plugin/advisor/mysql/advisor_index_no_duplicate_column.go
+++ b/backend/plugin/advisor/mysql/advisor_index_no_duplicate_column.go
@@ -155,13 +155,11 @@ func (checker *indexNoDuplicateColumnChecker) EnterCreateIndex(ctx *mysql.Create
columnList := mysqlparser.NormalizeKeyListVariants(ctx.CreateIndexTarget().KeyListVariants())
if column, duplicate := checker.hasDuplicateColumn(columnList); duplicate {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DuplicateColumnInIndex.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("%s`%s` has duplicate column `%s`.`%s`", indexType, indexName, tableName, column),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.DuplicateColumnInIndex.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("%s`%s` has duplicate column `%s`.`%s`", indexType, indexName, tableName, column),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
@@ -209,13 +207,11 @@ func (checker *indexNoDuplicateColumnChecker) handleConstraintDef(tableName stri
}
if column, duplicate := checker.hasDuplicateColumn(columnList); duplicate {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DuplicateColumnInIndex.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("%s`%s` has duplicate column `%s`.`%s`", indexType, indexName, tableName, column),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.DuplicateColumnInIndex.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("%s`%s` has duplicate column `%s`.`%s`", indexType, indexName, tableName, column),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_index_pk_type.go b/backend/plugin/advisor/mysql/advisor_index_pk_type.go
index 117fb36f0e..356ed9a5e7 100644
--- a/backend/plugin/advisor/mysql/advisor_index_pk_type.go
+++ b/backend/plugin/advisor/mysql/advisor_index_pk_type.go
@@ -190,13 +190,11 @@ func (checker *indexPkTypeChecker) checkConstraintDef(tableName string, ctx mysq
func (checker *indexPkTypeChecker) addAdvice(tableName, columnName, columnType string, lineNumber int) {
if !strings.EqualFold(columnType, "INT") && !strings.EqualFold(columnType, "BIGINT") {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.IndexPKType.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Columns in primary key must be INT/BIGINT but `%s`.`%s` is %s", tableName, columnName, columnType),
- StartPosition: &storepb.Position{
- Line: int32(lineNumber),
- },
+ Status: checker.level,
+ Code: advisor.IndexPKType.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Columns in primary key must be INT/BIGINT but `%s`.`%s` is %s", tableName, columnName, columnType),
+ StartPosition: advisor.ConvertANTLRLineToPosition(lineNumber),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_index_primary_key_type_allowlist.go b/backend/plugin/advisor/mysql/advisor_index_primary_key_type_allowlist.go
index 24b9d73633..71c94db391 100644
--- a/backend/plugin/advisor/mysql/advisor_index_primary_key_type_allowlist.go
+++ b/backend/plugin/advisor/mysql/advisor_index_primary_key_type_allowlist.go
@@ -174,13 +174,11 @@ func (checker *indexPrimaryKeyTypeAllowlistChecker) checkFieldDefinition(tableNa
if attribute.PRIMARY_SYMBOL() != nil {
if _, exists := checker.allowlist[columnType]; !exists {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.IndexPKType.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The column `%s` in table `%s` is one of the primary key, but its type \"%s\" is not in allowlist", columnName, tableName, columnType),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.IndexPKType.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The column `%s` in table `%s` is one of the primary key, but its type \"%s\" is not in allowlist", columnName, tableName, columnType),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
@@ -205,13 +203,11 @@ func (checker *indexPrimaryKeyTypeAllowlistChecker) checkConstraintDef(tableName
columnType = strings.ToLower(columnType)
if _, exists := checker.allowlist[columnType]; !exists {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.IndexPKType.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The column `%s` in table `%s` is one of the primary key, but its type \"%s\" is not in allowlist", columnName, tableName, columnType),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.IndexPKType.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The column `%s` in table `%s` is one of the primary key, but its type \"%s\" is not in allowlist", columnName, tableName, columnType),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_index_total_number_limit.go b/backend/plugin/advisor/mysql/advisor_index_total_number_limit.go
index 67e990e289..e2e847087a 100644
--- a/backend/plugin/advisor/mysql/advisor_index_total_number_limit.go
+++ b/backend/plugin/advisor/mysql/advisor_index_total_number_limit.go
@@ -96,13 +96,11 @@ func (checker *indexTotalNumberLimitChecker) generateAdvice() []*storepb.Advice
tableInfo := checker.catalog.Final.FindTable(&catalog.TableFind{TableName: table.name})
if tableInfo != nil && tableInfo.CountIndex() > checker.max {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.IndexCountExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The count of index in table `%s` should be no more than %d, but found %d", table.name, checker.max, tableInfo.CountIndex()),
- StartPosition: &storepb.Position{
- Line: int32(table.line),
- },
+ Status: checker.level,
+ Code: advisor.IndexCountExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The count of index in table `%s` should be no more than %d, but found %d", table.name, checker.max, tableInfo.CountIndex()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(table.line),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_index_type_allow_list.go b/backend/plugin/advisor/mysql/advisor_index_type_allow_list.go
index d5f804bc3d..1f14196c61 100644
--- a/backend/plugin/advisor/mysql/advisor_index_type_allow_list.go
+++ b/backend/plugin/advisor/mysql/advisor_index_type_allow_list.go
@@ -156,12 +156,10 @@ func (checker *indexTypeAllowListChecker) validateIndexType(indexType string, li
}
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.IndexTypeNotAllowed.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Index type `%s` is not allowed", indexType),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + line),
- },
+ Status: checker.level,
+ Code: advisor.IndexTypeNotAllowed.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Index type `%s` is not allowed", indexType),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + line),
})
}
diff --git a/backend/plugin/advisor/mysql/advisor_index_type_no_blob.go b/backend/plugin/advisor/mysql/advisor_index_type_no_blob.go
index b17c8717ae..2a7f9992fd 100644
--- a/backend/plugin/advisor/mysql/advisor_index_type_no_blob.go
+++ b/backend/plugin/advisor/mysql/advisor_index_type_no_blob.go
@@ -236,13 +236,11 @@ func (checker *indexTypeNoBlobChecker) checkConstraintDef(tableName string, ctx
func (checker *indexTypeNoBlobChecker) addAdvice(tableName, columnName, columnType string, lineNumber int) {
if checker.isBlob(columnType) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.IndexTypeNoBlob.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Columns in index must not be BLOB but `%s`.`%s` is %s", tableName, columnName, columnType),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + lineNumber),
- },
+ Status: checker.level,
+ Code: advisor.IndexTypeNoBlob.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Columns in index must not be BLOB but `%s`.`%s` is %s", tableName, columnName, columnType),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + lineNumber),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_insert_disallow_order_by_rand.go b/backend/plugin/advisor/mysql/advisor_insert_disallow_order_by_rand.go
index c0019b4bfa..29a8227555 100644
--- a/backend/plugin/advisor/mysql/advisor_insert_disallow_order_by_rand.go
+++ b/backend/plugin/advisor/mysql/advisor_insert_disallow_order_by_rand.go
@@ -101,13 +101,11 @@ func (checker *insertDisallowOrderByRandChecker) EnterQueryExpression(ctx *mysql
text := expr.GetText()
if strings.EqualFold(text, RandFn) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.InsertUseOrderByRand.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" uses ORDER BY RAND in the INSERT statement", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.InsertUseOrderByRand.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" uses ORDER BY RAND in the INSERT statement", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_insert_must_specify_column.go b/backend/plugin/advisor/mysql/advisor_insert_must_specify_column.go
index b99b0d734d..cf0478450f 100644
--- a/backend/plugin/advisor/mysql/advisor_insert_must_specify_column.go
+++ b/backend/plugin/advisor/mysql/advisor_insert_must_specify_column.go
@@ -87,26 +87,22 @@ func (checker *insertMustSpecifyColumnChecker) EnterInsertStatement(ctx *mysql.I
return
}
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.InsertNotSpecifyColumn.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The INSERT statement must specify columns but \"%s\" does not", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.InsertNotSpecifyColumn.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The INSERT statement must specify columns but \"%s\" does not", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
func (checker *insertMustSpecifyColumnChecker) EnterSelectItemList(ctx *mysql.SelectItemListContext) {
if checker.hasSelect && ctx.MULT_OPERATOR() != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.InsertNotSpecifyColumn.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The INSERT statement must specify columns but \"%s\" does not", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.InsertNotSpecifyColumn.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The INSERT statement must specify columns but \"%s\" does not", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_insert_row_limit.go b/backend/plugin/advisor/mysql/advisor_insert_row_limit.go
index 1fbf9a4ff8..f2e3ea2762 100644
--- a/backend/plugin/advisor/mysql/advisor_insert_row_limit.go
+++ b/backend/plugin/advisor/mysql/advisor_insert_row_limit.go
@@ -109,36 +109,30 @@ func (checker *insertRowLimitChecker) handleInsertQueryExpression(ctx mysql.IIns
res, err := advisor.Query(checker.ctx, advisor.QueryContext{}, checker.driver, storepb.Engine_MYSQL, fmt.Sprintf("EXPLAIN %s", checker.text))
if err != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.InsertTooManyRows.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" dry runs failed: %s", checker.text, err.Error()),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.InsertTooManyRows.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" dry runs failed: %s", checker.text, err.Error()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
return
}
rowCount, err := getInsertRows(res)
if err != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.Internal.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("failed to get row count for \"%s\": %s", checker.text, err.Error()),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.Internal.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("failed to get row count for \"%s\": %s", checker.text, err.Error()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
} else if rowCount > int64(checker.maxRow) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.InsertTooManyRows.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" inserts %d rows. The count exceeds %d.", checker.text, rowCount, checker.maxRow),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.InsertTooManyRows.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" inserts %d rows. The count exceeds %d.", checker.text, rowCount, checker.maxRow),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
}
@@ -157,13 +151,11 @@ func (checker *insertRowLimitChecker) handleNoInsertQueryExpression(ctx mysql.II
allValues := ctx.InsertFromConstructor().InsertValues().ValueList().AllValues()
if len(allValues) > checker.maxRow {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.InsertTooManyRows.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" inserts %d rows. The count exceeds %d.", checker.text, len(allValues), checker.maxRow),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.InsertTooManyRows.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" inserts %d rows. The count exceeds %d.", checker.text, len(allValues), checker.maxRow),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_migration_compatibility.go b/backend/plugin/advisor/mysql/advisor_migration_compatibility.go
index c9ef498750..ee6849711d 100644
--- a/backend/plugin/advisor/mysql/advisor_migration_compatibility.go
+++ b/backend/plugin/advisor/mysql/advisor_migration_compatibility.go
@@ -73,13 +73,11 @@ func (checker *compatibilityChecker) ExitQuery(ctx *mysql.QueryContext) {
if checker.code != advisor.Ok {
text := ctx.GetParser().GetTokenStream().GetTextFromRuleContext(ctx)
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: checker.code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" may cause incompatibility with the existing data and code", text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: checker.code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" may cause incompatibility with the existing data and code", text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_naming_auto_increment_column.go b/backend/plugin/advisor/mysql/advisor_naming_auto_increment_column.go
index b9e239f01e..fd234ff31f 100644
--- a/backend/plugin/advisor/mysql/advisor_naming_auto_increment_column.go
+++ b/backend/plugin/advisor/mysql/advisor_naming_auto_increment_column.go
@@ -163,24 +163,20 @@ func (checker *namingAutoIncrementColumnChecker) checkFieldDefinition(tableName,
if !checker.format.MatchString(columnName) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingAutoIncrementColumnConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("`%s`.`%s` mismatches auto_increment column naming convention, naming format should be %q", tableName, columnName, checker.format),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.NamingAutoIncrementColumnConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("`%s`.`%s` mismatches auto_increment column naming convention, naming format should be %q", tableName, columnName, checker.format),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
if checker.maxLength > 0 && len(columnName) > checker.maxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingAutoIncrementColumnConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("`%s`.`%s` mismatches auto_increment column naming convention, its length should be within %d characters", tableName, columnName, checker.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.NamingAutoIncrementColumnConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("`%s`.`%s` mismatches auto_increment column naming convention, its length should be within %d characters", tableName, columnName, checker.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_naming_column.go b/backend/plugin/advisor/mysql/advisor_naming_column.go
index 075694930f..f99cb0e2f8 100644
--- a/backend/plugin/advisor/mysql/advisor_naming_column.go
+++ b/backend/plugin/advisor/mysql/advisor_naming_column.go
@@ -157,24 +157,20 @@ func (checker *namingColumnConventionChecker) handleColumn(tableName string, col
lineNumber += checker.baseLine
if !checker.format.MatchString(columnName) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingColumnConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("`%s`.`%s` mismatches column naming convention, naming format should be %q", tableName, columnName, checker.format),
- StartPosition: &storepb.Position{
- Line: int32(lineNumber),
- },
+ Status: checker.level,
+ Code: advisor.NamingColumnConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("`%s`.`%s` mismatches column naming convention, naming format should be %q", tableName, columnName, checker.format),
+ StartPosition: advisor.ConvertANTLRLineToPosition(lineNumber),
})
}
if checker.maxLength > 0 && len(columnName) > checker.maxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingColumnConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("`%s`.`%s` mismatches column naming convention, its length should be within %d characters", tableName, columnName, checker.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(lineNumber),
- },
+ Status: checker.level,
+ Code: advisor.NamingColumnConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("`%s`.`%s` mismatches column naming convention, its length should be within %d characters", tableName, columnName, checker.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(lineNumber),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_naming_foreign_key_convention.go b/backend/plugin/advisor/mysql/advisor_naming_foreign_key_convention.go
index 89de299f62..894a55646f 100644
--- a/backend/plugin/advisor/mysql/advisor_naming_foreign_key_convention.go
+++ b/backend/plugin/advisor/mysql/advisor_naming_foreign_key_convention.go
@@ -153,24 +153,20 @@ func (checker *namingFKConventionChecker) handleIndexList(indexDataList []*index
}
if !regex.MatchString(indexData.indexName) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingFKConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Foreign key in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),
- StartPosition: &storepb.Position{
- Line: int32(indexData.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingFKConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Foreign key in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(indexData.line),
})
}
if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingFKConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Foreign key `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(indexData.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingFKConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Foreign key `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(indexData.line),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_naming_index_convention.go b/backend/plugin/advisor/mysql/advisor_naming_index_convention.go
index c729881617..a5200481cc 100644
--- a/backend/plugin/advisor/mysql/advisor_naming_index_convention.go
+++ b/backend/plugin/advisor/mysql/advisor_naming_index_convention.go
@@ -232,24 +232,20 @@ func (checker *namingIndexConventionChecker) handleIndexList(indexDataList []*in
}
if !regex.MatchString(indexData.indexName) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingIndexConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Index in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),
- StartPosition: &storepb.Position{
- Line: int32(indexData.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingIndexConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Index in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(indexData.line),
})
}
if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingIndexConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Index `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(indexData.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingIndexConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Index `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(indexData.line),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_naming_table.go b/backend/plugin/advisor/mysql/advisor_naming_table.go
index 5bb9b92130..679857be5b 100644
--- a/backend/plugin/advisor/mysql/advisor_naming_table.go
+++ b/backend/plugin/advisor/mysql/advisor_naming_table.go
@@ -131,24 +131,20 @@ func (checker *namingTableConventionChecker) handleTableName(tableName string, l
lineNumber += checker.baseLine
if !checker.format.MatchString(tableName) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingTableConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("`%s` mismatches table naming convention, naming format should be %q", tableName, checker.format),
- StartPosition: &storepb.Position{
- Line: int32(lineNumber),
- },
+ Status: checker.level,
+ Code: advisor.NamingTableConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("`%s` mismatches table naming convention, naming format should be %q", tableName, checker.format),
+ StartPosition: advisor.ConvertANTLRLineToPosition(lineNumber),
})
}
if checker.maxLength > 0 && len(tableName) > checker.maxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingTableConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("`%s` mismatches table naming convention, its length should be within %d characters", tableName, checker.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(lineNumber),
- },
+ Status: checker.level,
+ Code: advisor.NamingTableConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("`%s` mismatches table naming convention, its length should be within %d characters", tableName, checker.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(lineNumber),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_naming_unique_key_convention.go b/backend/plugin/advisor/mysql/advisor_naming_unique_key_convention.go
index 7604f0ec2a..58e86d9add 100644
--- a/backend/plugin/advisor/mysql/advisor_naming_unique_key_convention.go
+++ b/backend/plugin/advisor/mysql/advisor_naming_unique_key_convention.go
@@ -221,24 +221,20 @@ func (checker *namingUKConventionChecker) handleIndexList(indexDataList []*index
}
if !regex.MatchString(indexData.indexName) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingUKConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Unique key in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),
- StartPosition: &storepb.Position{
- Line: int32(indexData.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingUKConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Unique key in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(indexData.line),
})
}
if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingUKConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Unique key `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(indexData.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingUKConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Unique key `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(indexData.line),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_online_migration.go b/backend/plugin/advisor/mysql/advisor_online_migration.go
index 48e4dd2655..02b4963832 100644
--- a/backend/plugin/advisor/mysql/advisor_online_migration.go
+++ b/backend/plugin/advisor/mysql/advisor_online_migration.go
@@ -11,6 +11,7 @@ import (
mysql "github.com/bytebase/mysql-parser"
+ "github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/plugin/advisor"
"github.com/bytebase/bytebase/backend/plugin/parser/base"
mysqlparser "github.com/bytebase/bytebase/backend/plugin/parser/mysql"
@@ -79,6 +80,7 @@ func (*OnlineMigrationAdvisor) Check(ctx context.Context, checkCtx advisor.Conte
currentDatabase: checkCtx.CurrentDatabase,
changedResources: make(map[string]base.SchemaResource),
baseline: int32(stmt.BaseLine),
+ checkCtx: checkCtx,
}
antlr.ParseTreeWalkerDefault.Walk(checker, stmt.Tree)
@@ -148,6 +150,7 @@ func (*OnlineMigrationAdvisor) Check(ctx context.Context, checkCtx advisor.Conte
type useGhostChecker struct {
*mysql.BaseMySQLParserListener
+ checkCtx advisor.Context
currentDatabase string
changedResources map[string]base.SchemaResource
@@ -159,17 +162,23 @@ type useGhostChecker struct {
}
func (c *useGhostChecker) EnterAlterStatement(ctx *mysql.AlterStatementContext) {
- c.start = &storepb.Position{
- Line: c.baseline + int32(ctx.GetStart().GetLine()),
- Column: int32(ctx.GetStart().GetColumn()) + 1, // convert to 1-based
- }
+ c.start = common.ConvertANTLRPositionToPosition(
+ &common.ANTLRPosition{
+ Line: int32(ctx.GetStart().GetLine()),
+ Column: int32(ctx.GetStart().GetColumn()),
+ },
+ c.checkCtx.Statements,
+ )
}
func (c *useGhostChecker) ExitAlterStatement(ctx *mysql.AlterStatementContext) {
- c.end = &storepb.Position{
- Line: c.baseline + int32(ctx.GetStop().GetLine()),
- Column: int32(ctx.GetStop().GetColumn()+len([]rune(ctx.GetStop().GetText()))) + 1, // convert to 1-based
- }
+ c.end = common.ConvertANTLRPositionToPosition(
+ &common.ANTLRPosition{
+ Line: c.baseline + int32(ctx.GetStop().GetLine()),
+ Column: int32(ctx.GetStop().GetColumn() + len([]rune(ctx.GetStop().GetText()))),
+ },
+ c.checkCtx.Statements,
+ )
}
func (c *useGhostChecker) EnterAlterTable(ctx *mysql.AlterTableContext) {
diff --git a/backend/plugin/advisor/mysql/advisor_statement_add_column_without_position.go b/backend/plugin/advisor/mysql/advisor_statement_add_column_without_position.go
index 8468ec3168..359aea8cc2 100644
--- a/backend/plugin/advisor/mysql/advisor_statement_add_column_without_position.go
+++ b/backend/plugin/advisor/mysql/advisor_statement_add_column_without_position.go
@@ -111,13 +111,11 @@ func (checker *statementAddColumnWithoutPositionChecker) EnterAlterTable(ctx *my
if len(position) != 0 {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementAddColumnWithPosition.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("add column with position \"%s\"", position),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementAddColumnWithPosition.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("add column with position \"%s\"", position),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_statement_affected_row_limit.go b/backend/plugin/advisor/mysql/advisor_statement_affected_row_limit.go
index 8fb7fad4d7..f386d6a401 100644
--- a/backend/plugin/advisor/mysql/advisor_statement_affected_row_limit.go
+++ b/backend/plugin/advisor/mysql/advisor_statement_affected_row_limit.go
@@ -107,35 +107,29 @@ func (checker *statementAffectedRowLimitChecker) handleStmt(lineNumber int) {
res, err := advisor.Query(checker.ctx, advisor.QueryContext{}, checker.driver, storepb.Engine_MYSQL, fmt.Sprintf("EXPLAIN %s", checker.text))
if err != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementAffectedRowExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" dry runs failed: %s", checker.text, err.Error()),
- StartPosition: &storepb.Position{
- Line: int32(lineNumber),
- },
+ Status: checker.level,
+ Code: advisor.StatementAffectedRowExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" dry runs failed: %s", checker.text, err.Error()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(lineNumber),
})
} else {
rowCount, err := getRows(res)
if err != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.Internal.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("failed to get row count for \"%s\": %s", checker.text, err.Error()),
- StartPosition: &storepb.Position{
- Line: int32(lineNumber),
- },
+ Status: checker.level,
+ Code: advisor.Internal.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("failed to get row count for \"%s\": %s", checker.text, err.Error()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(lineNumber),
})
} else if rowCount > int64(checker.maxRow) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementAffectedRowExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" affected %d rows (estimated). The count exceeds %d.", checker.text, rowCount, checker.maxRow),
- StartPosition: &storepb.Position{
- Line: int32(lineNumber),
- },
+ Status: checker.level,
+ Code: advisor.StatementAffectedRowExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" affected %d rows (estimated). The count exceeds %d.", checker.text, rowCount, checker.maxRow),
+ StartPosition: advisor.ConvertANTLRLineToPosition(lineNumber),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_in_ddl.go b/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_in_ddl.go
index 68c6048fbc..b49f08ea21 100644
--- a/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_in_ddl.go
+++ b/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_in_ddl.go
@@ -48,13 +48,11 @@ func (*StatementDisallowMixInDDLAdvisor) Check(_ context.Context, checkCtx advis
if checker.IsDML {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Alter schema can only run DDL, \"%s\" is not DDL", checker.Text),
- Code: advisor.StatementDisallowMixDDLDML.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.BaseLine) + 1,
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Alter schema can only run DDL, \"%s\" is not DDL", checker.Text),
+ Code: advisor.StatementDisallowMixDDLDML.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.BaseLine),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_in_dml.go b/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_in_dml.go
index c2be199c45..dcf72ee3ce 100644
--- a/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_in_dml.go
+++ b/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_in_dml.go
@@ -48,13 +48,11 @@ func (*StatementDisallowMixInDMLAdvisor) Check(_ context.Context, checkCtx advis
if checker.IsDDL {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Data change can only run DML, \"%s\" is not DML", checker.Text),
- Code: advisor.StatementDisallowMixDDLDML.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.BaseLine) + 1,
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Data change can only run DML, \"%s\" is not DML", checker.Text),
+ Code: advisor.StatementDisallowMixDDLDML.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.BaseLine),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_statement_disallow_using_filesort.go b/backend/plugin/advisor/mysql/advisor_statement_disallow_using_filesort.go
index 04f4d1c090..cccf96c104 100644
--- a/backend/plugin/advisor/mysql/advisor_statement_disallow_using_filesort.go
+++ b/backend/plugin/advisor/mysql/advisor_statement_disallow_using_filesort.go
@@ -84,35 +84,29 @@ func (checker *disallowUsingFilesortChecker) EnterSelectStatement(ctx *mysql.Sel
res, err := advisor.Query(checker.ctx, advisor.QueryContext{}, checker.driver, storepb.Engine_MYSQL, fmt.Sprintf("EXPLAIN %s", query))
if err != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementExplainQueryFailed.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Failed to explain query: %s, with error: %s", query, err),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementExplainQueryFailed.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Failed to explain query: %s, with error: %s", query, err),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
} else {
hasUsingFilesort, tables, err := hasUsingFilesortInExtraColumn(res)
if err != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.Internal.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Failed to check extra column: %s, with error: %s", query, err),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.Internal.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Failed to check extra column: %s, with error: %s", query, err),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
} else if hasUsingFilesort {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementHasUsingFilesort.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Using filesort detected on table(s): %s", tables),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementHasUsingFilesort.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Using filesort detected on table(s): %s", tables),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_statement_disallow_using_temporary.go b/backend/plugin/advisor/mysql/advisor_statement_disallow_using_temporary.go
index 12fc3cc517..e09ff29f36 100644
--- a/backend/plugin/advisor/mysql/advisor_statement_disallow_using_temporary.go
+++ b/backend/plugin/advisor/mysql/advisor_statement_disallow_using_temporary.go
@@ -84,35 +84,29 @@ func (checker *disallowUsingTemporaryChecker) EnterSelectStatement(ctx *mysql.Se
res, err := advisor.Query(checker.ctx, advisor.QueryContext{}, checker.driver, storepb.Engine_MYSQL, fmt.Sprintf("EXPLAIN %s", query))
if err != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementExplainQueryFailed.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Failed to explain query: %s, with error: %s", query, err),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementExplainQueryFailed.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Failed to explain query: %s, with error: %s", query, err),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
} else {
hasUsingTemporary, tables, err := hasUsingTemporaryInExtraColumn(res)
if err != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.Internal.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Failed to check extra column: %s, with error: %s", query, err),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.Internal.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Failed to check extra column: %s, with error: %s", query, err),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
} else if hasUsingTemporary {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementHasUsingTemporary.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Using temporary detected on table(s): %s", tables),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementHasUsingTemporary.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Using temporary detected on table(s): %s", tables),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_statement_dml_dry_run.go b/backend/plugin/advisor/mysql/advisor_statement_dml_dry_run.go
index e8e70a909d..d2a233be4a 100644
--- a/backend/plugin/advisor/mysql/advisor_statement_dml_dry_run.go
+++ b/backend/plugin/advisor/mysql/advisor_statement_dml_dry_run.go
@@ -105,13 +105,11 @@ func (checker *statementDmlDryRunChecker) handleStmt(text string, lineNumber int
checker.explainCount++
if _, err := advisor.Query(checker.ctx, advisor.QueryContext{}, checker.driver, storepb.Engine_MYSQL, fmt.Sprintf("EXPLAIN %s", text)); err != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementDMLDryRunFailed.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" dry runs failed: %s", text, err.Error()),
- StartPosition: &storepb.Position{
- Line: int32(checker.line + lineNumber),
- },
+ Status: checker.level,
+ Code: advisor.StatementDMLDryRunFailed.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" dry runs failed: %s", text, err.Error()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line + lineNumber),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_statement_join_strict_column_attrs.go b/backend/plugin/advisor/mysql/advisor_statement_join_strict_column_attrs.go
index 717907f34d..b5b4a61ae9 100644
--- a/backend/plugin/advisor/mysql/advisor_statement_join_strict_column_attrs.go
+++ b/backend/plugin/advisor/mysql/advisor_statement_join_strict_column_attrs.go
@@ -200,13 +200,11 @@ func (checker *statementJoinStrictColumnAttrsChecker) checkColumnAttrs(leftColum
}
if leftColumn.Type != rightColumn.Type || leftColumn.CharacterSet != rightColumn.CharacterSet || leftColumn.Collation != rightColumn.Collation {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementJoinColumnAttrsNotMatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("%s.%s and %s.%s column fields do not match", leftColumnAttr.Table, leftColumnAttr.Column, rightColumnAttr.Table, rightColumnAttr.Column),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine) + 1,
- },
+ Status: checker.level,
+ Code: advisor.StatementJoinColumnAttrsNotMatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("%s.%s and %s.%s column fields do not match", leftColumnAttr.Table, leftColumnAttr.Column, rightColumnAttr.Table, rightColumnAttr.Column),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_statement_maximum_join_table_count.go b/backend/plugin/advisor/mysql/advisor_statement_maximum_join_table_count.go
index ae85c3f60f..d58d5de81f 100644
--- a/backend/plugin/advisor/mysql/advisor_statement_maximum_join_table_count.go
+++ b/backend/plugin/advisor/mysql/advisor_statement_maximum_join_table_count.go
@@ -74,13 +74,11 @@ func (checker *statementMaximumJoinTableCountChecker) EnterJoinedTable(ctx *mysq
// The count starts from 0. We count the number of tables in the joins.
if checker.count == checker.limitMaxValue {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementMaximumJoinTableCount.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" exceeds the maximum number of joins %d.", checker.text, checker.limitMaxValue),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementMaximumJoinTableCount.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" exceeds the maximum number of joins %d.", checker.text, checker.limitMaxValue),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_statement_maximum_limit_value.go b/backend/plugin/advisor/mysql/advisor_statement_maximum_limit_value.go
index 94c1b21fe8..3273181093 100644
--- a/backend/plugin/advisor/mysql/advisor_statement_maximum_limit_value.go
+++ b/backend/plugin/advisor/mysql/advisor_statement_maximum_limit_value.go
@@ -104,13 +104,11 @@ func (checker *statementMaximumLimitValueChecker) EnterLimitClause(ctx *mysql.Li
if limitValue > checker.limitMaxValue {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementExceedMaximumLimitValue.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The limit value %d exceeds the maximum allowed value %d", limitValue, checker.limitMaxValue),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementExceedMaximumLimitValue.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The limit value %d exceeds the maximum allowed value %d", limitValue, checker.limitMaxValue),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_statement_merge_alter_table.go b/backend/plugin/advisor/mysql/advisor_statement_merge_alter_table.go
index f16a2ae0c6..a8a22e189a 100644
--- a/backend/plugin/advisor/mysql/advisor_statement_merge_alter_table.go
+++ b/backend/plugin/advisor/mysql/advisor_statement_merge_alter_table.go
@@ -127,13 +127,11 @@ func (checker *statementMergeAlterTableChecker) generateAdvice() []*storepb.Advi
for _, table := range tableList {
if table.count > 1 {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementRedundantAlterTable.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("There are %d statements to modify table `%s`", table.count, table.name),
- StartPosition: &storepb.Position{
- Line: int32(table.lastLine),
- },
+ Status: checker.level,
+ Code: advisor.StatementRedundantAlterTable.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("There are %d statements to modify table `%s`", table.count, table.name),
+ StartPosition: advisor.ConvertANTLRLineToPosition(table.lastLine),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_statement_query_minumum_plan_level.go b/backend/plugin/advisor/mysql/advisor_statement_query_minumum_plan_level.go
index 0d6c940643..8cb1cc7287 100644
--- a/backend/plugin/advisor/mysql/advisor_statement_query_minumum_plan_level.go
+++ b/backend/plugin/advisor/mysql/advisor_statement_query_minumum_plan_level.go
@@ -145,25 +145,21 @@ func (checker *statementQueryMinumumPlanLevelChecker) EnterSelectStatement(ctx *
res, err := advisor.Query(checker.ctx, advisor.QueryContext{}, checker.driver, storepb.Engine_MYSQL, fmt.Sprintf("EXPLAIN %s", query))
if err != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementExplainQueryFailed.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Failed to explain query: %s, with error: %s", query, err),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementExplainQueryFailed.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Failed to explain query: %s, with error: %s", query, err),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
} else {
explainTypes, err := getQueryExplainTypes(res)
if err != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.Internal.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Failed to check explain type column: %s, with error: %s", query, err),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.Internal.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Failed to check explain type column: %s, with error: %s", query, err),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
} else if len(explainTypes) > 0 {
overused, overusedType := false, ExplainTypeAll
@@ -176,13 +172,11 @@ func (checker *statementQueryMinumumPlanLevelChecker) EnterSelectStatement(ctx *
}
if overused {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementUnwantedQueryPlanLevel.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Overused query plan level detected %s, minimum plan level: %s", overusedType.String(), checker.explainType.String()),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementUnwantedQueryPlanLevel.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Overused query plan level detected %s, minimum plan level: %s", overusedType.String(), checker.explainType.String()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_statement_select_full_table_scan.go b/backend/plugin/advisor/mysql/advisor_statement_select_full_table_scan.go
index 9758ede287..f79f4cbbf1 100644
--- a/backend/plugin/advisor/mysql/advisor_statement_select_full_table_scan.go
+++ b/backend/plugin/advisor/mysql/advisor_statement_select_full_table_scan.go
@@ -85,35 +85,29 @@ func (checker *statementSelectFullTableScanChecker) EnterSelectStatement(ctx *my
res, err := advisor.Query(checker.ctx, advisor.QueryContext{}, checker.driver, storepb.Engine_MYSQL, fmt.Sprintf("EXPLAIN %s", query))
if err != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementCheckSelectFullTableScanFailed.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Failed to check full table scan: %s, with error: %s", query, err),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementCheckSelectFullTableScanFailed.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Failed to check full table scan: %s, with error: %s", query, err),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
} else {
hasFullScan, tables, err := hasTableFullScan(res)
if err != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.Internal.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Failed to check full table scan: %s, with error: %s", query, err),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.Internal.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Failed to check full table scan: %s, with error: %s", query, err),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
} else if hasFullScan {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementHasTableFullScan.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Full table scan detected on table(s): %s", tables),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementHasTableFullScan.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Full table scan detected on table(s): %s", tables),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_statement_where_disallow_using_function.go b/backend/plugin/advisor/mysql/advisor_statement_where_disallow_using_function.go
index 3ee53f8211..540a4823c8 100644
--- a/backend/plugin/advisor/mysql/advisor_statement_where_disallow_using_function.go
+++ b/backend/plugin/advisor/mysql/advisor_statement_where_disallow_using_function.go
@@ -88,13 +88,11 @@ func (checker *statementWhereDisallowUsingFunctionChecker) EnterFunctionCall(ctx
pi := ctx.PureIdentifier()
if pi != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DisabledFunction.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Function is disallowed in where clause, but \"%s\" uses", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.DisabledFunction.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Function is disallowed in where clause, but \"%s\" uses", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_statement_where_maximum_logical_operator_count.go b/backend/plugin/advisor/mysql/advisor_statement_where_maximum_logical_operator_count.go
index 27cb7c2119..635087e762 100644
--- a/backend/plugin/advisor/mysql/advisor_statement_where_maximum_logical_operator_count.go
+++ b/backend/plugin/advisor/mysql/advisor_statement_where_maximum_logical_operator_count.go
@@ -51,13 +51,11 @@ func (*StatementWhereMaximumLogicalOperatorCountAdvisor) Check(_ context.Context
antlr.ParseTreeWalkerDefault.Walk(checker, stmt.Tree)
if checker.maxOrCount > checker.maximum {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementWhereMaximumLogicalOperatorCount.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Number of tokens (%d) in the OR predicate operation exceeds limit (%d) in statement %q.", checker.maxOrCount, checker.maximum, checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.maxOrCountLine),
- },
+ Status: checker.level,
+ Code: advisor.StatementWhereMaximumLogicalOperatorCount.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Number of tokens (%d) in the OR predicate operation exceeds limit (%d) in statement %q.", checker.maxOrCount, checker.maximum, checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.maxOrCountLine),
})
}
}
@@ -104,13 +102,11 @@ func (checker *statementWhereMaximumLogicalOperatorCountChecker) EnterExprList(c
count := len(ctx.AllExpr())
if count > checker.maximum {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementWhereMaximumLogicalOperatorCount.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Number of tokens (%d) in IN predicate operation exceeds limit (%d) in statement %q.", count, checker.maximum, checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementWhereMaximumLogicalOperatorCount.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Number of tokens (%d) in IN predicate operation exceeds limit (%d) in statement %q.", count, checker.maximum, checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_statement_where_no_equal_null.go b/backend/plugin/advisor/mysql/advisor_statement_where_no_equal_null.go
index 5c0a511981..d7f56a6a07 100644
--- a/backend/plugin/advisor/mysql/advisor_statement_where_no_equal_null.go
+++ b/backend/plugin/advisor/mysql/advisor_statement_where_no_equal_null.go
@@ -83,13 +83,11 @@ func (checker *statementWhereNoEqualNullChecker) EnterPrimaryExprCompare(ctx *my
}
if ctx.Predicate() != nil && ctx.Predicate().GetText() == "NULL" {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementWhereNoEqualNull.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("WHERE clause contains equal null: %s", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementWhereNoEqualNull.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("WHERE clause contains equal null: %s", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_stmt_disallow_commit.go b/backend/plugin/advisor/mysql/advisor_stmt_disallow_commit.go
index 55344f8af4..0b47376f52 100644
--- a/backend/plugin/advisor/mysql/advisor_stmt_disallow_commit.go
+++ b/backend/plugin/advisor/mysql/advisor_stmt_disallow_commit.go
@@ -77,12 +77,10 @@ func (checker *statementDisallowCommitChecker) EnterTransactionStatement(ctx *my
}
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementDisallowCommit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Commit is not allowed, related statement: \"%s\"", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementDisallowCommit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Commit is not allowed, related statement: \"%s\"", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
diff --git a/backend/plugin/advisor/mysql/advisor_stmt_disallow_limit.go b/backend/plugin/advisor/mysql/advisor_stmt_disallow_limit.go
index 54c7c1536d..6e128f6bfe 100644
--- a/backend/plugin/advisor/mysql/advisor_stmt_disallow_limit.go
+++ b/backend/plugin/advisor/mysql/advisor_stmt_disallow_limit.go
@@ -105,12 +105,10 @@ func (checker *statementDisallowLimitChecker) EnterQueryExpression(ctx *mysql.Qu
func (checker *statementDisallowLimitChecker) handleLimitClause(code advisor.Code, lineNumber int) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but \"%s\" uses", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.line + lineNumber),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but \"%s\" uses", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line + lineNumber),
})
}
diff --git a/backend/plugin/advisor/mysql/advisor_stmt_disallow_order_by.go b/backend/plugin/advisor/mysql/advisor_stmt_disallow_order_by.go
index d8c8bd9c1c..40940410a3 100644
--- a/backend/plugin/advisor/mysql/advisor_stmt_disallow_order_by.go
+++ b/backend/plugin/advisor/mysql/advisor_stmt_disallow_order_by.go
@@ -85,12 +85,10 @@ func (checker *disallowOrderByChecker) EnterUpdateStatement(ctx *mysql.UpdateSta
func (checker *disallowOrderByChecker) handleOrderByClause(code advisor.Code, lineNumber int) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("ORDER BY clause is forbidden in DELETE and UPDATE statements, but \"%s\" uses", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.line + lineNumber),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("ORDER BY clause is forbidden in DELETE and UPDATE statements, but \"%s\" uses", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line + lineNumber),
})
}
diff --git a/backend/plugin/advisor/mysql/advisor_stmt_no_leading_wildcard_like.go b/backend/plugin/advisor/mysql/advisor_stmt_no_leading_wildcard_like.go
index 49e4c902dc..1253145a5b 100644
--- a/backend/plugin/advisor/mysql/advisor_stmt_no_leading_wildcard_like.go
+++ b/backend/plugin/advisor/mysql/advisor_stmt_no_leading_wildcard_like.go
@@ -77,13 +77,11 @@ func (checker *noLeadingWildcardLikeChecker) EnterPredicateExprLike(ctx *mysql.P
pattern := expr.GetText()
if (strings.HasPrefix(pattern, "'%") && strings.HasSuffix(pattern, "'")) || (strings.HasPrefix(pattern, "\"%") && strings.HasSuffix(pattern, "\"")) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementLeadingWildcardLike.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" uses leading wildcard LIKE", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementLeadingWildcardLike.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" uses leading wildcard LIKE", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_stmt_no_select_all.go b/backend/plugin/advisor/mysql/advisor_stmt_no_select_all.go
index bef55ecf05..7fd545220a 100644
--- a/backend/plugin/advisor/mysql/advisor_stmt_no_select_all.go
+++ b/backend/plugin/advisor/mysql/advisor_stmt_no_select_all.go
@@ -67,13 +67,11 @@ func (checker *noSelectAllChecker) EnterQuery(ctx *mysql.QueryContext) {
func (checker *noSelectAllChecker) EnterSelectItemList(ctx *mysql.SelectItemListContext) {
if ctx.MULT_OPERATOR() != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementSelectAll.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" uses SELECT all", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementSelectAll.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" uses SELECT all", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_stmt_require_algorithm_or_lock_options.go b/backend/plugin/advisor/mysql/advisor_stmt_require_algorithm_or_lock_options.go
index cefce6408f..aabeecb141 100644
--- a/backend/plugin/advisor/mysql/advisor_stmt_require_algorithm_or_lock_options.go
+++ b/backend/plugin/advisor/mysql/advisor_stmt_require_algorithm_or_lock_options.go
@@ -82,13 +82,11 @@ func (checker *RequireAlgorithmOptionChecker) EnterAlterTable(ctx *mysql.AlterTa
func (checker *RequireAlgorithmOptionChecker) ExitAlterTable(*mysql.AlterTableContext) {
if !checker.hasOption {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: int32(checker.errorCode),
- Title: checker.title,
- Content: "ALTER TABLE statement should include " + checker.requiredOption + " option",
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + checker.line),
- },
+ Status: checker.level,
+ Code: int32(checker.errorCode),
+ Title: checker.title,
+ Content: "ALTER TABLE statement should include " + checker.requiredOption + " option",
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + checker.line),
})
}
checker.inAlterTableStatement = false
diff --git a/backend/plugin/advisor/mysql/advisor_stmt_where_required.go b/backend/plugin/advisor/mysql/advisor_stmt_where_required.go
index 5fe1b99982..87bcc72583 100644
--- a/backend/plugin/advisor/mysql/advisor_stmt_where_required.go
+++ b/backend/plugin/advisor/mysql/advisor_stmt_where_required.go
@@ -96,12 +96,10 @@ func (checker *whereRequirementChecker) EnterQuerySpecification(ctx *mysql.Query
func (checker *whereRequirementChecker) handleWhereClause(lineNumber int) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementNoWhere.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" requires WHERE clause", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + lineNumber),
- },
+ Status: checker.level,
+ Code: advisor.StatementNoWhere.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" requires WHERE clause", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + lineNumber),
})
}
diff --git a/backend/plugin/advisor/mysql/advisor_stmt_where_requirement_for_select.go b/backend/plugin/advisor/mysql/advisor_stmt_where_requirement_for_select.go
index e71daf44f4..90e404ca92 100644
--- a/backend/plugin/advisor/mysql/advisor_stmt_where_requirement_for_select.go
+++ b/backend/plugin/advisor/mysql/advisor_stmt_where_requirement_for_select.go
@@ -76,12 +76,10 @@ func (checker *whereRequirementForSelectChecker) EnterQuerySpecification(ctx *my
func (checker *whereRequirementForSelectChecker) handleWhereClause(lineNumber int) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementNoWhere.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" requires WHERE clause", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + lineNumber),
- },
+ Status: checker.level,
+ Code: advisor.StatementNoWhere.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" requires WHERE clause", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + lineNumber),
})
}
diff --git a/backend/plugin/advisor/mysql/advisor_stmt_where_requirement_for_update_delete.go b/backend/plugin/advisor/mysql/advisor_stmt_where_requirement_for_update_delete.go
index b227c61f49..a5cb8464a9 100644
--- a/backend/plugin/advisor/mysql/advisor_stmt_where_requirement_for_update_delete.go
+++ b/backend/plugin/advisor/mysql/advisor_stmt_where_requirement_for_update_delete.go
@@ -86,12 +86,10 @@ func (checker *whereRequirementForUpdateDeleteChecker) EnterUpdateStatement(ctx
func (checker *whereRequirementForUpdateDeleteChecker) handleWhereClause(lineNumber int) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementNoWhere.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" requires WHERE clause", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + lineNumber),
- },
+ Status: checker.level,
+ Code: advisor.StatementNoWhere.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" requires WHERE clause", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + lineNumber),
})
}
diff --git a/backend/plugin/advisor/mysql/advisor_table_comment_convention.go b/backend/plugin/advisor/mysql/advisor_table_comment_convention.go
index 6863196822..5bdeb778a8 100644
--- a/backend/plugin/advisor/mysql/advisor_table_comment_convention.go
+++ b/backend/plugin/advisor/mysql/advisor_table_comment_convention.go
@@ -85,36 +85,30 @@ func (checker *tableCommentConventionChecker) EnterCreateTable(ctx *mysql.Create
if checker.payload.Required && !exists {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CommentEmpty.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table `%s` requires comments", tableName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.CommentEmpty.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table `%s` requires comments", tableName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
if checker.payload.MaxLength >= 0 && len(comment) > checker.payload.MaxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CommentTooLong.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The length of table `%s` comment should be within %d characters", tableName, checker.payload.MaxLength),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.CommentTooLong.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The length of table `%s` comment should be within %d characters", tableName, checker.payload.MaxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
if checker.payload.RequiredClassification {
if classification, _ := common.GetClassificationAndUserComment(comment, checker.classificationConfig); classification == "" {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CommentMissingClassification.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table `%s` comment requires classification", tableName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.CommentMissingClassification.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table `%s` comment requires classification", tableName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_table_disallow_ddl.go b/backend/plugin/advisor/mysql/advisor_table_disallow_ddl.go
index 61215dbc7a..97fa5ad367 100644
--- a/backend/plugin/advisor/mysql/advisor_table_disallow_ddl.go
+++ b/backend/plugin/advisor/mysql/advisor_table_disallow_ddl.go
@@ -111,13 +111,11 @@ func (checker *tableDisallowDDLChecker) checkTableName(tableName string, line in
for _, disallow := range checker.disallowList {
if tableName == disallow {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.TableDisallowDDL.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("DDL is disallowed on table %s.", tableName),
- StartPosition: &storepb.Position{
- Line: int32(line),
- },
+ Status: checker.level,
+ Code: advisor.TableDisallowDDL.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("DDL is disallowed on table %s.", tableName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(line),
})
return
}
diff --git a/backend/plugin/advisor/mysql/advisor_table_disallow_dml.go b/backend/plugin/advisor/mysql/advisor_table_disallow_dml.go
index 59388475fe..b1f0f80da5 100644
--- a/backend/plugin/advisor/mysql/advisor_table_disallow_dml.go
+++ b/backend/plugin/advisor/mysql/advisor_table_disallow_dml.go
@@ -105,13 +105,11 @@ func (checker *tableDisallowDMLChecker) checkTableName(tableName string, line in
for _, disallow := range checker.disallowList {
if tableName == disallow {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.TableDisallowDML.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("DML is disallowed on table %s.", tableName),
- StartPosition: &storepb.Position{
- Line: int32(line),
- },
+ Status: checker.level,
+ Code: advisor.TableDisallowDML.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("DML is disallowed on table %s.", tableName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(line),
})
return
}
diff --git a/backend/plugin/advisor/mysql/advisor_table_disallow_partition.go b/backend/plugin/advisor/mysql/advisor_table_disallow_partition.go
index 95dde10c7c..1581af9e67 100644
--- a/backend/plugin/advisor/mysql/advisor_table_disallow_partition.go
+++ b/backend/plugin/advisor/mysql/advisor_table_disallow_partition.go
@@ -78,13 +78,11 @@ func (checker *tableDisallowPartitionChecker) EnterCreateTable(ctx *mysql.Create
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table partition is forbidden, but \"%s\" creates", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table partition is forbidden, but \"%s\" creates", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
@@ -100,13 +98,11 @@ func (checker *tableDisallowPartitionChecker) EnterAlterTable(ctx *mysql.AlterTa
}
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table partition is forbidden, but \"%s\" creates", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table partition is forbidden, but \"%s\" creates", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_table_disallow_set_charset.go b/backend/plugin/advisor/mysql/advisor_table_disallow_set_charset.go
index 1058ba5147..04ae7515e9 100644
--- a/backend/plugin/advisor/mysql/advisor_table_disallow_set_charset.go
+++ b/backend/plugin/advisor/mysql/advisor_table_disallow_set_charset.go
@@ -70,13 +70,11 @@ func (checker *tableDisallowSetCharsetChecker) EnterCreateTable(ctx *mysql.Creat
for _, option := range ctx.CreateTableOptions().AllCreateTableOption() {
if option.DefaultCharset() != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DisallowSetCharset.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Set charset on tables is disallowed, but \"%s\" uses", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.DisallowSetCharset.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Set charset on tables is disallowed, but \"%s\" uses", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
@@ -102,13 +100,11 @@ func (checker *tableDisallowSetCharsetChecker) EnterAlterTable(ctx *mysql.AlterT
if alterListItem.Charset() != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DisallowSetCharset.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Set charset on tables is disallowed, but \"%s\" uses", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.DisallowSetCharset.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Set charset on tables is disallowed, but \"%s\" uses", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_table_disallow_trigger.go b/backend/plugin/advisor/mysql/advisor_table_disallow_trigger.go
index 536c6e0f12..a5ba5720cc 100644
--- a/backend/plugin/advisor/mysql/advisor_table_disallow_trigger.go
+++ b/backend/plugin/advisor/mysql/advisor_table_disallow_trigger.go
@@ -76,13 +76,11 @@ func (checker *tableDisallowTriggerChecker) EnterCreateTrigger(ctx *mysql.Create
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Trigger is forbidden, but \"%s\" creates", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Trigger is forbidden, but \"%s\" creates", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_table_drop_naming_convention.go b/backend/plugin/advisor/mysql/advisor_table_drop_naming_convention.go
index 456c366e4d..3f5501f08a 100644
--- a/backend/plugin/advisor/mysql/advisor_table_drop_naming_convention.go
+++ b/backend/plugin/advisor/mysql/advisor_table_drop_naming_convention.go
@@ -80,13 +80,11 @@ func (checker *namingDropTableConventionChecker) EnterDropTable(ctx *mysql.DropT
_, tableName := mysqlparser.NormalizeMySQLTableRef(tableRef)
if !checker.format.MatchString(tableName) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.TableDropNamingConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("`%s` mismatches drop table naming convention, naming format should be %q", tableName, checker.format),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.TableDropNamingConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("`%s` mismatches drop table naming convention, naming format should be %q", tableName, checker.format),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_table_limit_size.go b/backend/plugin/advisor/mysql/advisor_table_limit_size.go
index d86acda88f..70df95a7d6 100644
--- a/backend/plugin/advisor/mysql/advisor_table_limit_size.go
+++ b/backend/plugin/advisor/mysql/advisor_table_limit_size.go
@@ -67,13 +67,11 @@ func (*MaximumTableSizeAdvisor) Check(_ context.Context, checkCtx advisor.Contex
tableRows := getTabRowsByName(tabName, checkCtx.DBSchema.Schemas[0].Tables)
if tableRows >= int64(payload.Number) {
adviceList = append(adviceList, &storepb.Advice{
- Status: status,
- Code: advisor.TableExceedLimitSize.Int32(),
- Title: checkCtx.Rule.Type,
- Content: fmt.Sprintf("Apply DDL on large table '%s' ( %d rows ) will lock table for a long time", tabName, tableRows),
- StartPosition: &storepb.Position{
- Line: int32(statementBaseLine + tableSizeChecker.baseLine),
- },
+ Status: status,
+ Code: advisor.TableExceedLimitSize.Int32(),
+ Title: checkCtx.Rule.Type,
+ Content: fmt.Sprintf("Apply DDL on large table '%s' ( %d rows ) will lock table for a long time", tabName, tableRows),
+ StartPosition: advisor.ConvertANTLRLineToPosition(statementBaseLine + tableSizeChecker.baseLine),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_table_no_duplicate_index.go b/backend/plugin/advisor/mysql/advisor_table_no_duplicate_index.go
index b53abe535e..4207a04636 100644
--- a/backend/plugin/advisor/mysql/advisor_table_no_duplicate_index.go
+++ b/backend/plugin/advisor/mysql/advisor_table_no_duplicate_index.go
@@ -99,13 +99,11 @@ func (checker *tableNoDuplicateIndexChecker) EnterCreateTable(ctx *mysql.CreateT
// Check for duplicate index.
if index := hasDuplicateIndexes(checker.indexList); index != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DuplicateIndexInTable.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("`%s` has duplicate index `%s`", tableName, index.indexName),
- StartPosition: &storepb.Position{
- Line: int32(index.line),
- },
+ Status: checker.level,
+ Code: advisor.DuplicateIndexInTable.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("`%s` has duplicate index `%s`", tableName, index.indexName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(index.line),
})
}
}
@@ -132,13 +130,11 @@ func (checker *tableNoDuplicateIndexChecker) EnterAlterTable(ctx *mysql.AlterTab
}
if index := hasDuplicateIndexes(checker.indexList); index != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DuplicateIndexInTable.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("`%s` has duplicate index `%s`", tableName, index.indexName),
- StartPosition: &storepb.Position{
- Line: int32(index.line),
- },
+ Status: checker.level,
+ Code: advisor.DuplicateIndexInTable.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("`%s` has duplicate index `%s`", tableName, index.indexName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(index.line),
})
}
}
@@ -216,13 +212,11 @@ func (checker *tableNoDuplicateIndexChecker) EnterCreateIndex(ctx *mysql.CreateI
checker.indexList = append(checker.indexList, index)
if index := hasDuplicateIndexes(checker.indexList); index != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DuplicateIndexInTable.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("`%s` has duplicate index `%s`", tableName, index.indexName),
- StartPosition: &storepb.Position{
- Line: int32(index.line),
- },
+ Status: checker.level,
+ Code: advisor.DuplicateIndexInTable.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("`%s` has duplicate index `%s`", tableName, index.indexName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(index.line),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_table_no_fk.go b/backend/plugin/advisor/mysql/advisor_table_no_fk.go
index 8c83dd900e..d7cae6a69d 100644
--- a/backend/plugin/advisor/mysql/advisor_table_no_fk.go
+++ b/backend/plugin/advisor/mysql/advisor_table_no_fk.go
@@ -111,13 +111,11 @@ func (checker *tableNoFKChecker) handleTableConstraintDef(tableName string, ctx
switch strings.ToUpper(ctx.GetType_().GetText()) {
case "FOREIGN":
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.TableHasFK.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Foreign key is not allowed in the table `%s`", tableName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.TableHasFK.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Foreign key is not allowed in the table `%s`", tableName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
default:
}
diff --git a/backend/plugin/advisor/mysql/advisor_table_require_charset.go b/backend/plugin/advisor/mysql/advisor_table_require_charset.go
index ee287d7132..188a442257 100644
--- a/backend/plugin/advisor/mysql/advisor_table_require_charset.go
+++ b/backend/plugin/advisor/mysql/advisor_table_require_charset.go
@@ -78,13 +78,11 @@ func (checker *tableRequireCharsetChecker) EnterCreateTable(ctx *mysql.CreateTab
}
if !hasCharset {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NoCharset.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table %s does not have a character set specified", tableName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.NoCharset.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table %s does not have a character set specified", tableName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_table_require_collation.go b/backend/plugin/advisor/mysql/advisor_table_require_collation.go
index 8a3bc15c17..ae7d173584 100644
--- a/backend/plugin/advisor/mysql/advisor_table_require_collation.go
+++ b/backend/plugin/advisor/mysql/advisor_table_require_collation.go
@@ -78,13 +78,11 @@ func (checker *tableRequireCollationChecker) EnterCreateTable(ctx *mysql.CreateT
}
if !hasCollation {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NoCollation.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table %s does not have a collation specified", tableName),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.NoCollation.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table %s does not have a collation specified", tableName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_table_require_pk.go b/backend/plugin/advisor/mysql/advisor_table_require_pk.go
index 84eed4ddcc..fa6818ef82 100644
--- a/backend/plugin/advisor/mysql/advisor_table_require_pk.go
+++ b/backend/plugin/advisor/mysql/advisor_table_require_pk.go
@@ -202,13 +202,11 @@ func (checker *tableRequirePKChecker) generateAdviceList() []*storepb.Advice {
for _, tableName := range tableList {
if len(checker.tables[tableName]) == 0 {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.TableNoPK.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table `%s` requires PRIMARY KEY", tableName),
- StartPosition: &storepb.Position{
- Line: int32(checker.line[tableName]),
- },
+ Status: checker.level,
+ Code: advisor.TableNoPK.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table `%s` requires PRIMARY KEY", tableName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line[tableName]),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_table_text_fields_total_length.go b/backend/plugin/advisor/mysql/advisor_table_text_fields_total_length.go
index 9ec663a977..bd23542598 100644
--- a/backend/plugin/advisor/mysql/advisor_table_text_fields_total_length.go
+++ b/backend/plugin/advisor/mysql/advisor_table_text_fields_total_length.go
@@ -88,13 +88,11 @@ func (checker *tableFieldsMaximumVarcharLengthChecker) EnterCreateTable(ctx *mys
total := getTotalTextLength(tableInfo)
if total > int64(checker.maximum) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.IndexCountExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table %q total text column length (%d) exceeds the limit (%d).", tableName, total, checker.maximum),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.IndexCountExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table %q total text column length (%d) exceeds the limit (%d).", tableName, total, checker.maximum),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
@@ -124,13 +122,11 @@ func (checker *tableFieldsMaximumVarcharLengthChecker) EnterAlterTable(ctx *mysq
total := getTotalTextLength(tableInfo)
if total > int64(checker.maximum) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.TotalTextLengthExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table %q total text column length (%d) exceeds the limit (%d).", tableName, total, checker.maximum),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.TotalTextLengthExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table %q total text column length (%d) exceeds the limit (%d).", tableName, total, checker.maximum),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/advisor_use_innodb.go b/backend/plugin/advisor/mysql/advisor_use_innodb.go
index 9598e439bd..62a2d78b74 100644
--- a/backend/plugin/advisor/mysql/advisor_use_innodb.go
+++ b/backend/plugin/advisor/mysql/advisor_use_innodb.go
@@ -160,12 +160,10 @@ func (c *useInnoDBChecker) EnterSetStatement(ctx *mysql.SetStatementContext) {
func (c *useInnoDBChecker) addAdvice(content string, lineNumber int) {
lineNumber += c.baseLine
c.adviceList = append(c.adviceList, &storepb.Advice{
- Status: c.level,
- Code: advisor.NotInnoDBEngine.Int32(),
- Title: c.title,
- Content: fmt.Sprintf("\"%s;\" doesn't use InnoDB engine", content),
- StartPosition: &storepb.Position{
- Line: int32(lineNumber),
- },
+ Status: c.level,
+ Code: advisor.NotInnoDBEngine.Int32(),
+ Title: c.title,
+ Content: fmt.Sprintf("\"%s;\" doesn't use InnoDB engine", content),
+ StartPosition: advisor.ConvertANTLRLineToPosition(lineNumber),
})
}
diff --git a/backend/plugin/advisor/mysql/advisor_view_disallow_create.go b/backend/plugin/advisor/mysql/advisor_view_disallow_create.go
index 62f22dd771..e0b62e97f8 100644
--- a/backend/plugin/advisor/mysql/advisor_view_disallow_create.go
+++ b/backend/plugin/advisor/mysql/advisor_view_disallow_create.go
@@ -75,13 +75,11 @@ func (checker *viewDisallowCreateChecker) EnterCreateView(ctx *mysql.CreateViewC
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("View is forbidden, but \"%s\" creates", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("View is forbidden, but \"%s\" creates", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/mysql/test/column_auto_increment_initial_value.yaml b/backend/plugin/advisor/mysql/test/column_auto_increment_initial_value.yaml
index 891c17d14e..301f2a2c12 100644
--- a/backend/plugin/advisor/mysql/test/column_auto_increment_initial_value.yaml
+++ b/backend/plugin/advisor/mysql/test/column_auto_increment_initial_value.yaml
@@ -11,9 +11,8 @@
code: 416
title: column.auto-increment-initial-value
content: The initial auto-increment value in table `t2` is 2, which doesn't equal 20
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -27,8 +26,7 @@
code: 416
title: column.auto-increment-initial-value
content: The initial auto-increment value in table `t` is 100, which doesn't equal 20
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/column_auto_increment_must_integer.yaml b/backend/plugin/advisor/mysql/test/column_auto_increment_must_integer.yaml
index f15439e95c..f90cb29572 100644
--- a/backend/plugin/advisor/mysql/test/column_auto_increment_must_integer.yaml
+++ b/backend/plugin/advisor/mysql/test/column_auto_increment_must_integer.yaml
@@ -19,9 +19,8 @@
code: 410
title: column.auto-increment-must-integer
content: Auto-increment column `t2`.`a` requires integer type
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -33,9 +32,8 @@
code: 410
title: column.auto-increment-must-integer
content: Auto-increment column `t`.`a` requires integer type
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -47,9 +45,8 @@
code: 410
title: column.auto-increment-must-integer
content: Auto-increment column `t`.`a` requires integer type
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -61,9 +58,8 @@
code: 410
title: column.auto-increment-must-integer
content: Auto-increment column `t`.`a` requires integer type
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -76,9 +72,8 @@
code: 410
title: column.auto-increment-must-integer
content: Auto-increment column `t`.`a` requires integer type
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -90,8 +85,7 @@
code: 410
title: column.auto-increment-must-integer
content: Auto-increment column `t`.`a` requires integer type
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/column_auto_increment_must_unsigned.yaml b/backend/plugin/advisor/mysql/test/column_auto_increment_must_unsigned.yaml
index 4d00468643..19ce2f7356 100644
--- a/backend/plugin/advisor/mysql/test/column_auto_increment_must_unsigned.yaml
+++ b/backend/plugin/advisor/mysql/test/column_auto_increment_must_unsigned.yaml
@@ -7,9 +7,8 @@
code: 417
title: column.auto-increment-must-unsigned
content: Auto-increment column `t`.`a` is not UNSIGNED type
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(a INT SIGNED AUTO_INCREMENT);
@@ -19,9 +18,8 @@
code: 417
title: column.auto-increment-must-unsigned
content: Auto-increment column `t`.`a` is not UNSIGNED type
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(a INT ZEROFILL AUTO_INCREMENT);
@@ -35,9 +33,8 @@
code: 417
title: column.auto-increment-must-unsigned
content: Auto-increment column `t`.`a` is not UNSIGNED type
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -50,9 +47,8 @@
code: 417
title: column.auto-increment-must-unsigned
content: Auto-increment column `t`.`a` is not UNSIGNED type
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -65,8 +61,7 @@
code: 417
title: column.auto-increment-must-unsigned
content: Auto-increment column `t`.`a` is not UNSIGNED type
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/column_comment.yaml b/backend/plugin/advisor/mysql/test/column_comment.yaml
index acc7ea83a5..e2f315fa79 100644
--- a/backend/plugin/advisor/mysql/test/column_comment.yaml
+++ b/backend/plugin/advisor/mysql/test/column_comment.yaml
@@ -17,27 +17,24 @@
code: 1032
title: column.comment
content: Column `userTable`.`id` requires comments
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 1032
title: column.comment
content: Column `userTable`.`name` requires comments
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 1032
title: column.comment
content: Column `userTable`.`roomId` requires comments
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- statement: |
@@ -67,27 +64,24 @@
code: 1301
title: column.comment
content: The length of column `t`.`a` comment should be within 10 characters
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 1032
title: column.comment
content: Column `t`.`b` requires comments
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 1032
title: column.comment
content: Column `t`.`c` requires comments
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- statement: |-
@@ -99,9 +93,8 @@
code: 1032
title: column.comment
content: Column `t`.`b` requires comments
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -113,18 +106,16 @@
code: 1032
title: column.comment
content: Column `t`.`b` requires comments
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 1032
title: column.comment
content: Column `t`.`c` requires comments
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -136,18 +127,16 @@
code: 1301
title: column.comment
content: The length of column `t`.`a` comment should be within 10 characters
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 1032
title: column.comment
content: Column `t`.`b` requires comments
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -159,18 +148,16 @@
code: 1301
title: column.comment
content: The length of column `t`.`b` comment should be within 10 characters
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 1032
title: column.comment
content: Column `t`.`b` requires comments
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -182,17 +169,15 @@
code: 1301
title: column.comment
content: The length of column `t`.`b` comment should be within 10 characters
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 1301
title: column.comment
content: The length of column `t`.`b` comment should be within 10 characters
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/column_current_time_count_limit.yaml b/backend/plugin/advisor/mysql/test/column_current_time_count_limit.yaml
index 597813e2bd..c99ca69ad5 100644
--- a/backend/plugin/advisor/mysql/test/column_current_time_count_limit.yaml
+++ b/backend/plugin/advisor/mysql/test/column_current_time_count_limit.yaml
@@ -17,9 +17,8 @@
code: 419
title: column.current-time-count-limit
content: Table `userTable` has 2 ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than 1.
- detail: ""
startposition:
- line: 6
+ line: 5
column: 0
endposition: null
- statement: |
@@ -49,9 +48,8 @@
code: 418
title: column.current-time-count-limit
content: Table `t` has 3 DEFAULT CURRENT_TIMESTAMP() columns. The count greater than 2.
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- statement: |-
@@ -65,9 +63,8 @@
code: 419
title: column.current-time-count-limit
content: Table `t` has 2 ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than 1.
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -79,8 +76,7 @@
code: 419
title: column.current-time-count-limit
content: Table `tech_book` has 2 ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than 1.
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/column_disallow_change.yaml b/backend/plugin/advisor/mysql/test/column_disallow_change.yaml
index 4d0fd92649..f09c34d59f 100644
--- a/backend/plugin/advisor/mysql/test/column_disallow_change.yaml
+++ b/backend/plugin/advisor/mysql/test/column_disallow_change.yaml
@@ -11,8 +11,7 @@
code: 406
title: column.disallow-change
content: '"ALTER TABLE t CHANGE COLUMN b a int;" contains CHANGE COLUMN statement'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/column_disallow_change_type.yaml b/backend/plugin/advisor/mysql/test/column_disallow_change_type.yaml
index 4081dd9ae6..e292659455 100644
--- a/backend/plugin/advisor/mysql/test/column_disallow_change_type.yaml
+++ b/backend/plugin/advisor/mysql/test/column_disallow_change_type.yaml
@@ -9,18 +9,16 @@
code: 403
title: column.disallow-change-type
content: '"ALTER TABLE tech_book MODIFY id INTEGER;" changes column type'
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 403
title: column.disallow-change-type
content: '"ALTER TABLE tech_book MODIFY id INTEGER UNSIGNED;" changes column type'
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- statement: |-
@@ -32,9 +30,8 @@
code: 403
title: column.disallow-change-type
content: '"ALTER TABLE tech_book MODIFY id int(4);" changes column type'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -46,18 +43,16 @@
code: 403
title: column.disallow-change-type
content: '"ALTER TABLE tech_book MODIFY id bigint;" changes column type'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 403
title: column.disallow-change-type
content: '"ALTER TABLE tech_book MODIFY id smallint;" changes column type'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: ALTER TABLE tech_book CHANGE name uname varchar(20);
@@ -67,8 +62,7 @@
code: 403
title: column.disallow-change-type
content: '"ALTER TABLE tech_book CHANGE name uname varchar(20);" changes column type'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/column_disallow_changing_order.yaml b/backend/plugin/advisor/mysql/test/column_disallow_changing_order.yaml
index 38df94b43a..52f8b7f38f 100644
--- a/backend/plugin/advisor/mysql/test/column_disallow_changing_order.yaml
+++ b/backend/plugin/advisor/mysql/test/column_disallow_changing_order.yaml
@@ -11,9 +11,8 @@
code: 407
title: column.disallow-changing-order
content: '"ALTER TABLE t MODIFY COLUMN a int FIRST;" changes column order'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -25,9 +24,8 @@
code: 407
title: column.disallow-changing-order
content: '"ALTER TABLE t CHANGE COLUMN a1 a int FIRST;" changes column order'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -39,9 +37,8 @@
code: 407
title: column.disallow-changing-order
content: '"ALTER TABLE t MODIFY COLUMN a int AFTER b;" changes column order'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -53,8 +50,7 @@
code: 407
title: column.disallow-changing-order
content: '"ALTER TABLE t CHANGE COLUMN a1 a int AFTER b;" changes column order'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/column_disallow_drop_in_index.yaml b/backend/plugin/advisor/mysql/test/column_disallow_drop_in_index.yaml
index 33130658a7..3423953509 100644
--- a/backend/plugin/advisor/mysql/test/column_disallow_drop_in_index.yaml
+++ b/backend/plugin/advisor/mysql/test/column_disallow_drop_in_index.yaml
@@ -38,9 +38,8 @@
code: 424
title: column.disallow-drop-in-index
content: '`t`.`b` cannot drop index column'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -52,9 +51,8 @@
code: 424
title: column.disallow-drop-in-index
content: '`t`.`c` cannot drop index column'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -72,17 +70,15 @@
code: 424
title: column.disallow-drop-in-index
content: '`t`.`a` cannot drop index column'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 424
title: column.disallow-drop-in-index
content: '`t`.`c` cannot drop index column'
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/column_disallow_set_charset.yaml b/backend/plugin/advisor/mysql/test/column_disallow_set_charset.yaml
index 795562352b..bdcdc9a7f3 100644
--- a/backend/plugin/advisor/mysql/test/column_disallow_set_charset.yaml
+++ b/backend/plugin/advisor/mysql/test/column_disallow_set_charset.yaml
@@ -13,18 +13,16 @@
code: 414
title: column.disallow-set-charset
content: Disallow set column charset but "CREATE TABLE t1(a varchar(20) CHARSET ascii);" does
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 414
title: column.disallow-set-charset
content: Disallow set column charset but "CREATE TABLE t2(a varchar(20) CHARSET ascii);" does
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -36,9 +34,8 @@
code: 414
title: column.disallow-set-charset
content: Disallow set column charset but "ALTER TABLE tech_book ADD COLUMN b varchar(20) CHARSET ascii;" does
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -51,27 +48,24 @@
code: 414
title: column.disallow-set-charset
content: Disallow set column charset but "ALTER TABLE tech_book ADD COLUMN (c varchar(20) CHARSET ascii, d varchar(20) CHARSET ascii);" does
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 414
title: column.disallow-set-charset
content: Disallow set column charset but "ALTER TABLE tech_book ADD COLUMN (c varchar(20) CHARSET ascii, d varchar(20) CHARSET ascii);" does
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 414
title: column.disallow-set-charset
content: Disallow set column charset but "ALTER TABLE tech_book ADD COLUMN e varchar(20) CHARSET ascii;" does
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -83,9 +77,8 @@
code: 414
title: column.disallow-set-charset
content: Disallow set column charset but "ALTER TABLE tech_book MODIFY COLUMN id varchar(20) CHARSET ascii;" does
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -97,8 +90,7 @@
code: 414
title: column.disallow-set-charset
content: Disallow set column charset but "ALTER TABLE tech_book CHANGE COLUMN name name varchar(20) CHARSET ascii;" does
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/column_maximum_character_length.yaml b/backend/plugin/advisor/mysql/test/column_maximum_character_length.yaml
index 3cd2c98b34..284540a68c 100644
--- a/backend/plugin/advisor/mysql/test/column_maximum_character_length.yaml
+++ b/backend/plugin/advisor/mysql/test/column_maximum_character_length.yaml
@@ -13,9 +13,8 @@
code: 415
title: column.maximum-character-length
content: The length of the CHAR column `t2.name` is bigger than 20, please use VARCHAR instead
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -27,9 +26,8 @@
code: 415
title: column.maximum-character-length
content: The length of the CHAR column `tech_book.name_2` is bigger than 20, please use VARCHAR instead
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -41,9 +39,8 @@
code: 415
title: column.maximum-character-length
content: The length of the CHAR column `tech_book.name` is bigger than 20, please use VARCHAR instead
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -55,8 +52,7 @@
code: 415
title: column.maximum-character-length
content: The length of the CHAR column `tech_book.name` is bigger than 20, please use VARCHAR instead
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/column_maximum_varchar_length.yaml b/backend/plugin/advisor/mysql/test/column_maximum_varchar_length.yaml
index d93dd37de6..d2fd67498f 100644
--- a/backend/plugin/advisor/mysql/test/column_maximum_varchar_length.yaml
+++ b/backend/plugin/advisor/mysql/test/column_maximum_varchar_length.yaml
@@ -7,9 +7,8 @@
code: 422
title: column.maximum-varchar-length
content: The length of the VARCHAR column `t1.name` is bigger than 2560
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -21,8 +20,7 @@
code: 422
title: column.maximum-varchar-length
content: The length of the VARCHAR column `tech_book.name_2` is bigger than 2560
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/column_no_null.yaml b/backend/plugin/advisor/mysql/test/column_no_null.yaml
index 46c7366f86..0d45cbe07c 100644
--- a/backend/plugin/advisor/mysql/test/column_no_null.yaml
+++ b/backend/plugin/advisor/mysql/test/column_no_null.yaml
@@ -9,18 +9,16 @@
code: 402
title: column.no-null
content: '`book`.`id` cannot have NULL value'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 402
title: column.no-null
content: '`book`.`name` cannot have NULL value'
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255));
@@ -30,9 +28,8 @@
code: 402
title: column.no-null
content: '`book`.`name` cannot have NULL value'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id int NOT NULL, name varchar(255));
@@ -42,9 +39,8 @@
code: 402
title: column.no-null
content: '`book`.`name` cannot have NULL value'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255) NOT NULL);
@@ -58,9 +54,8 @@
code: 402
title: column.no-null
content: '`book`.`id` cannot have NULL value'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -72,9 +67,8 @@
code: 402
title: column.no-null
content: '`book`.`id` cannot have NULL value'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -94,9 +88,8 @@
code: 402
title: column.no-null
content: '`book`.`name` cannot have NULL value'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/mysql/test/column_require_default.yaml b/backend/plugin/advisor/mysql/test/column_require_default.yaml
index b6adb0ddee..489b9181d9 100644
--- a/backend/plugin/advisor/mysql/test/column_require_default.yaml
+++ b/backend/plugin/advisor/mysql/test/column_require_default.yaml
@@ -39,9 +39,8 @@
code: 420
title: column.require-default
content: Column `t`.`a` doesn't have DEFAULT.
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -54,18 +53,16 @@
code: 420
title: column.require-default
content: Column `tech_book`.`b` doesn't have DEFAULT.
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 420
title: column.require-default
content: Column `tech_book`.`a` doesn't have DEFAULT.
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD COLUMN (a BLOB, b timestamp);
@@ -75,9 +72,8 @@
code: 420
title: column.require-default
content: Column `tech_book`.`b` doesn't have DEFAULT.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -90,9 +86,8 @@
code: 420
title: column.require-default
content: Column `tech_book`.`b` doesn't have DEFAULT.
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/mysql/test/column_required.yaml b/backend/plugin/advisor/mysql/test/column_required.yaml
index 976ae0a463..b2975f3e8e 100644
--- a/backend/plugin/advisor/mysql/test/column_required.yaml
+++ b/backend/plugin/advisor/mysql/test/column_required.yaml
@@ -11,45 +11,40 @@
code: 401
title: column.required
content: 'Table `t1` requires columns: created_ts, creator_id, id, updated_ts, updater_id'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 401
title: column.required
content: 'Table `book` requires columns: created_ts, creator_id, updated_ts, updater_id'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 401
title: column.required
content: 'Table `t2` requires columns: created_ts, updated_ts, updater_id'
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 401
title: column.required
content: 'Table `t3` requires columns: updated_ts, updater_id'
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- status: 2
code: 401
title: column.required
content: 'Table `t4` requires columns: updated_ts'
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- statement: |-
@@ -76,9 +71,8 @@
code: 401
title: column.required
content: 'Table `book` requires columns: creator_id'
- detail: ""
startposition:
- line: 8
+ line: 7
column: 0
endposition: null
- statement: |-
@@ -106,9 +100,8 @@
code: 401
title: column.required
content: 'Table `book` requires columns: creator_id'
- detail: ""
startposition:
- line: 8
+ line: 7
column: 0
endposition: null
- statement: |-
@@ -136,9 +129,8 @@
code: 401
title: column.required
content: 'Table `book` requires columns: creator_id'
- detail: ""
startposition:
- line: 8
+ line: 7
column: 0
endposition: null
- statement: |-
@@ -166,9 +158,8 @@
code: 401
title: column.required
content: 'Table `book` requires columns: updater_id'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -199,18 +190,16 @@
code: 401
title: column.required
content: 'Table `book` requires columns: creator_id'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 401
title: column.required
content: 'Table `student` requires columns: creator_id, updater_id'
- detail: ""
startposition:
- line: 7
+ line: 6
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/mysql/test/column_set_default_for_not_null.yaml b/backend/plugin/advisor/mysql/test/column_set_default_for_not_null.yaml
index 82beac2865..ade35aa0f7 100644
--- a/backend/plugin/advisor/mysql/test/column_set_default_for_not_null.yaml
+++ b/backend/plugin/advisor/mysql/test/column_set_default_for_not_null.yaml
@@ -18,9 +18,8 @@
code: 404
title: column.set-default-for-not-null
content: Column `book`.`id` is NOT NULL but doesn't have DEFAULT
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -42,9 +41,8 @@
code: 404
title: column.set-default-for-not-null
content: Column `book`.`id` is NOT NULL but doesn't have DEFAULT
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -56,18 +54,16 @@
code: 404
title: column.set-default-for-not-null
content: Column `book`.`b` is NOT NULL but doesn't have DEFAULT
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 404
title: column.set-default-for-not-null
content: Column `book`.`c` is NOT NULL but doesn't have DEFAULT
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -79,9 +75,8 @@
code: 404
title: column.set-default-for-not-null
content: Column `book`.`id` is NOT NULL but doesn't have DEFAULT
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -101,9 +96,8 @@
code: 404
title: column.set-default-for-not-null
content: Column `book`.`id` is NOT NULL but doesn't have DEFAULT
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/mysql/test/column_type_disallow_list.yaml b/backend/plugin/advisor/mysql/test/column_type_disallow_list.yaml
index ff944d162c..8f1f04baf5 100644
--- a/backend/plugin/advisor/mysql/test/column_type_disallow_list.yaml
+++ b/backend/plugin/advisor/mysql/test/column_type_disallow_list.yaml
@@ -7,9 +7,8 @@
code: 411
title: column.type-disallow-list
content: Disallow column type JSON but column `t`.`a` is
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -21,9 +20,8 @@
code: 411
title: column.type-disallow-list
content: Disallow column type JSON but column `t`.`a` is
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -35,18 +33,16 @@
code: 411
title: column.type-disallow-list
content: Disallow column type JSON but column `t`.`a` is
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 411
title: column.type-disallow-list
content: Disallow column type JSON but column `t`.`b` is
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -58,9 +54,8 @@
code: 411
title: column.type-disallow-list
content: Disallow column type JSON but column `t`.`a` is
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -72,8 +67,7 @@
code: 411
title: column.type-disallow-list
content: Disallow column type JSON but column `t`.`c` is
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/database_drop_empty_database.yaml b/backend/plugin/advisor/mysql/test/database_drop_empty_database.yaml
index 8ed8638145..128f4b56b2 100644
--- a/backend/plugin/advisor/mysql/test/database_drop_empty_database.yaml
+++ b/backend/plugin/advisor/mysql/test/database_drop_empty_database.yaml
@@ -5,8 +5,7 @@
code: 701
title: database.drop-empty-database
content: Database `test` is not allowed to drop if not empty
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/engine_mysql_use_innodb.yaml b/backend/plugin/advisor/mysql/test/engine_mysql_use_innodb.yaml
index 9e2a2f608d..0d47d6812d 100644
--- a/backend/plugin/advisor/mysql/test/engine_mysql_use_innodb.yaml
+++ b/backend/plugin/advisor/mysql/test/engine_mysql_use_innodb.yaml
@@ -29,9 +29,8 @@
UNIQUE KEY uk1(id, name),
FOREIGN KEY fk1(roomId) REFERENCES room(id),
INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin;" doesn't use InnoDB engine
- detail: ""
startposition:
- line: 12
+ line: 11
column: 0
endposition: null
- statement: |
@@ -66,9 +65,8 @@
id INT,
price INT
) ENGINE = CSV;" doesn't use InnoDB engine
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- statement: |
@@ -87,9 +85,8 @@
id INT,
price INT
) ENGINE = CSV;" doesn't use InnoDB engine
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- statement: ALTER TABLE tech_book ENGINE = INNODB;
@@ -104,9 +101,8 @@
code: 501
title: engine.mysql.use-innodb
content: '"ALTER TABLE tech_book ENGINE = CSV;" doesn''t use InnoDB engine'
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: SET default_storage_engine=INNODB;
@@ -120,9 +116,8 @@
code: 501
title: engine.mysql.use-innodb
content: '"SET default_storage_engine=CSV;" doesn''t use InnoDB engine'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |
diff --git a/backend/plugin/advisor/mysql/test/index_key_number_limit.yaml b/backend/plugin/advisor/mysql/test/index_key_number_limit.yaml
index b8ec5172aa..c5b7a77b0f 100644
--- a/backend/plugin/advisor/mysql/test/index_key_number_limit.yaml
+++ b/backend/plugin/advisor/mysql/test/index_key_number_limit.yaml
@@ -14,27 +14,24 @@
code: 802
title: index.key-number-limit
content: The number of index `pk` in table `t` should be not greater than 5
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- status: 2
code: 802
title: index.key-number-limit
content: The number of index `uk` in table `t` should be not greater than 5
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- status: 2
code: 802
title: index.key-number-limit
content: The number of index `fk` in table `t` should be not greater than 5
- detail: ""
startposition:
- line: 6
+ line: 5
column: 0
endposition: null
- statement: |-
@@ -47,18 +44,16 @@
code: 802
title: index.key-number-limit
content: The number of index `idx` in table `t` should be not greater than 5
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 802
title: index.key-number-limit
content: The number of index `uk` in table `t` should be not greater than 5
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -71,18 +66,16 @@
code: 802
title: index.key-number-limit
content: The number of index `pk` in table `t` should be not greater than 5
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 802
title: index.key-number-limit
content: The number of index `uk` in table `t` should be not greater than 5
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -94,9 +87,8 @@
code: 802
title: index.key-number-limit
content: The number of index `uk` in table `t` should be not greater than 5
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/mysql/test/index_no_duplicate_column.yaml b/backend/plugin/advisor/mysql/test/index_no_duplicate_column.yaml
index 764e56dc13..789fa37b59 100644
--- a/backend/plugin/advisor/mysql/test/index_no_duplicate_column.yaml
+++ b/backend/plugin/advisor/mysql/test/index_no_duplicate_column.yaml
@@ -11,9 +11,8 @@
code: 812
title: index.no-duplicate-column
content: PRIMARY KEY `` has duplicate column `t`.`a`
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -35,9 +34,8 @@
code: 812
title: index.no-duplicate-column
content: FOREIGN KEY `fk1` has duplicate column `t3`.`a`
- detail: ""
startposition:
- line: 11
+ line: 10
column: 0
endposition: null
- statement: |-
@@ -51,9 +49,8 @@
code: 812
title: index.no-duplicate-column
content: INDEX `idx_a` has duplicate column `t`.`a`
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -66,9 +63,8 @@
code: 812
title: index.no-duplicate-column
content: INDEX `idx_a` has duplicate column `t`.`a`
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -81,9 +77,8 @@
code: 812
title: index.no-duplicate-column
content: UNIQUE INDEX `idx_a` has duplicate column `t`.`a`
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -96,9 +91,8 @@
code: 812
title: index.no-duplicate-column
content: INDEX `idx_a` has duplicate column `t`.`a`
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -110,9 +104,8 @@
code: 812
title: index.no-duplicate-column
content: PRIMARY KEY `pk_a` has duplicate column `t`.`a`
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -129,9 +122,8 @@
code: 812
title: index.no-duplicate-column
content: UNIQUE KEY `uk_a` has duplicate column `t`.`a`
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -144,8 +136,7 @@
code: 812
title: index.no-duplicate-column
content: FOREIGN KEY `fk_a` has duplicate column `t`.`a`
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/index_pk_type_limit.yaml b/backend/plugin/advisor/mysql/test/index_pk_type_limit.yaml
index 35fd1c4b68..1aafead339 100644
--- a/backend/plugin/advisor/mysql/test/index_pk_type_limit.yaml
+++ b/backend/plugin/advisor/mysql/test/index_pk_type_limit.yaml
@@ -5,9 +5,8 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(id INT PRIMARY KEY);
@@ -19,9 +18,8 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(id INT, id2 VARCHAR(5), id3 VARCHAR(5), PRIMARY KEY(id, id2, id3));
@@ -31,18 +29,16 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id3` is varchar(5)
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(id INT, id2 BIGINT, PRIMARY KEY(id, id2));
@@ -58,9 +54,8 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -76,9 +71,8 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -90,18 +84,16 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id3` is varchar(5)
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -121,9 +113,8 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -135,18 +126,16 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id3` is varchar(5)
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -166,9 +155,8 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -184,9 +172,8 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/mysql/test/index_primary_key_type_allowlist.yaml b/backend/plugin/advisor/mysql/test/index_primary_key_type_allowlist.yaml
index 6785ec5ff0..8e6c6e5f93 100644
--- a/backend/plugin/advisor/mysql/test/index_primary_key_type_allowlist.yaml
+++ b/backend/plugin/advisor/mysql/test/index_primary_key_type_allowlist.yaml
@@ -5,9 +5,8 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(id INT PRIMARY KEY);
@@ -19,9 +18,8 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(id INT, id2 VARCHAR(5), id3 VARCHAR(5), PRIMARY KEY(id, id2, id3));
@@ -31,18 +29,16 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id2` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 803
title: index.primary-key-type-allowlist
content: The column `id3` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(id INT, id2 BIGINT, PRIMARY KEY(id, id2));
@@ -58,9 +54,8 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -76,9 +71,8 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -90,18 +84,16 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id2` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 803
title: index.primary-key-type-allowlist
content: The column `id3` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -121,9 +113,8 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -135,18 +126,16 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id2` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 803
title: index.primary-key-type-allowlist
content: The column `id3` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -166,9 +155,8 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -184,9 +172,8 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id2` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/mysql/test/index_total_number_limit.yaml b/backend/plugin/advisor/mysql/test/index_total_number_limit.yaml
index 7239cc0d68..03e1ccae2d 100644
--- a/backend/plugin/advisor/mysql/test/index_total_number_limit.yaml
+++ b/backend/plugin/advisor/mysql/test/index_total_number_limit.yaml
@@ -14,9 +14,8 @@
code: 813
title: index.total-number-limit
content: The count of index in table `tech_book` should be no more than 5, but found 8
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- statement: |-
@@ -32,9 +31,8 @@
code: 813
title: index.total-number-limit
content: The count of index in table `t` should be no more than 5, but found 6
- detail: ""
startposition:
- line: 6
+ line: 5
column: 0
endposition: null
- statement: |-
@@ -53,9 +51,8 @@
code: 813
title: index.total-number-limit
content: The count of index in table `t` should be no more than 5, but found 6
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -75,8 +72,7 @@
code: 813
title: index.total-number-limit
content: The count of index in table `t` should be no more than 5, but found 6
- detail: ""
startposition:
- line: 10
+ line: 9
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/index_type_allow_list.yaml b/backend/plugin/advisor/mysql/test/index_type_allow_list.yaml
index 28509b0c84..80cc604e67 100644
--- a/backend/plugin/advisor/mysql/test/index_type_allow_list.yaml
+++ b/backend/plugin/advisor/mysql/test/index_type_allow_list.yaml
@@ -26,9 +26,8 @@
code: 816
title: index.type-allow-list
content: Index type `SPATIAL` is not allowed
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- statement: |-
@@ -43,8 +42,7 @@
code: 816
title: index.type-allow-list
content: Index type `FULLTEXT` is not allowed
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/index_type_no_blob.yaml b/backend/plugin/advisor/mysql/test/index_type_no_blob.yaml
index 91e4323b24..9e16396bb9 100644
--- a/backend/plugin/advisor/mysql/test/index_type_no_blob.yaml
+++ b/backend/plugin/advisor/mysql/test/index_type_no_blob.yaml
@@ -17,9 +17,8 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `userTable`.`content` is blob
- detail: ""
startposition:
- line: 12
+ line: 11
column: 0
endposition: null
- statement: |
@@ -42,9 +41,8 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(b BLOB, mb MEDIUMBLOB, lb LONGBLOB, id INT, PRIMARY KEY(b(1), mb(2), lb(3), id));
@@ -54,27 +52,24 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(b BLOB, mb MEDIUMBLOB, lb LONGBLOB, id INT, UNIQUE INDEX(b(1), mb(2), lb(3), id))
@@ -84,27 +79,24 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(b BLOB, mb MEDIUMBLOB, lb LONGBLOB, id iNT, INDEX(b(1), mb(2), lb(3), id))
@@ -114,27 +106,24 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(id INT, PRIMARY KEY(id))
@@ -148,9 +137,8 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -162,27 +150,24 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -194,27 +179,24 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -233,27 +215,24 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- statement: |-
@@ -270,9 +249,8 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -285,8 +263,7 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`d` is blob
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/naming_column.yaml b/backend/plugin/advisor/mysql/test/naming_column.yaml
index 5bf8e9ff6a..6dd467cca1 100644
--- a/backend/plugin/advisor/mysql/test/naming_column.yaml
+++ b/backend/plugin/advisor/mysql/test/naming_column.yaml
@@ -5,9 +5,8 @@
code: 302
title: naming.column
content: '`book`.`creatorId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id int, gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx int);
@@ -17,9 +16,8 @@
code: 302
title: naming.column
content: '`book`.`gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx` mismatches column naming convention, its length should be within 64 characters'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id int, creator_id int);
@@ -34,18 +32,16 @@
code: 302
title: naming.column
content: '`book`.`creatorId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 302
title: naming.column
content: '`book`.`gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx` mismatches column naming convention, its length should be within 64 characters'
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |
@@ -57,9 +53,8 @@
code: 302
title: naming.column
content: '`tech_book`.`gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx` mismatches column naming convention, its length should be within 64 characters'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -76,9 +71,8 @@
code: 302
title: naming.column
content: '`book`.`creatorId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 7
+ line: 6
column: 0
endposition: null
- statement: |-
@@ -100,9 +94,8 @@
code: 302
title: naming.column
content: '`book`.`contentString` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 6
+ line: 5
column: 0
endposition: null
- statement: |-
@@ -118,18 +111,16 @@
code: 302
title: naming.column
content: '`book`.`contentString` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 6
+ line: 5
column: 0
endposition: null
- status: 2
code: 302
title: naming.column
content: '`book`.`personAge` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 6
+ line: 5
column: 0
endposition: null
- statement: |-
@@ -148,35 +139,31 @@
code: 302
title: naming.column
content: '`book`.`createdTs` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 302
title: naming.column
content: '`book`.`updaterId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- status: 2
code: 302
title: naming.column
content: '`student`.`createdTs` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 8
+ line: 7
column: 0
endposition: null
- status: 2
code: 302
title: naming.column
content: '`student`.`updatedTs` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 9
+ line: 8
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/naming_column_auto_increment.yaml b/backend/plugin/advisor/mysql/test/naming_column_auto_increment.yaml
index b1b90a9eff..5bb651445c 100644
--- a/backend/plugin/advisor/mysql/test/naming_column_auto_increment.yaml
+++ b/backend/plugin/advisor/mysql/test/naming_column_auto_increment.yaml
@@ -7,9 +7,8 @@
code: 307
title: naming.column.auto-increment
content: '`book`.`a` mismatches auto_increment column naming convention, naming format should be "^id$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD COLUMN a int AUTO_INCREMENT;
@@ -19,9 +18,8 @@
code: 307
title: naming.column.auto-increment
content: '`tech_book`.`a` mismatches auto_increment column naming convention, naming format should be "^id$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book CHANGE COLUMN id a int AUTO_INCREMENT;
@@ -31,9 +29,8 @@
code: 307
title: naming.column.auto-increment
content: '`tech_book`.`a` mismatches auto_increment column naming convention, naming format should be "^id$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book MODIFY COLUMN name int AUTO_INCREMENT;
@@ -43,9 +40,8 @@
code: 307
title: naming.column.auto-increment
content: '`tech_book`.`name` mismatches auto_increment column naming convention, naming format should be "^id$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |
diff --git a/backend/plugin/advisor/mysql/test/naming_identifier_no_keyword.yaml b/backend/plugin/advisor/mysql/test/naming_identifier_no_keyword.yaml
index 26854605b2..b75a309249 100644
--- a/backend/plugin/advisor/mysql/test/naming_identifier_no_keyword.yaml
+++ b/backend/plugin/advisor/mysql/test/naming_identifier_no_keyword.yaml
@@ -7,7 +7,6 @@
code: 201
title: Syntax error
content: "Syntax error at line 1:13 \nrelated text: CREATE TABLE interval"
- detail: ""
startposition:
line: 1
column: 13
@@ -19,7 +18,6 @@
code: 308
title: naming.identifier.no-keyword
content: Identifier "execute" is a keyword and should be avoided
- detail: ""
startposition:
line: 1
column: 0
@@ -31,7 +29,6 @@
code: 308
title: naming.identifier.no-keyword
content: Identifier "execute" is a keyword and should be avoided
- detail: ""
startposition:
line: 1
column: 0
@@ -43,7 +40,6 @@
code: 308
title: naming.identifier.no-keyword
content: Identifier "interval" is a keyword and should be avoided
- detail: ""
startposition:
line: 1
column: 0
@@ -55,7 +51,6 @@
code: 308
title: naming.identifier.no-keyword
content: Identifier "current_timestamp" is a keyword and should be avoided
- detail: ""
startposition:
line: 3
column: 0
@@ -67,7 +62,6 @@
code: 308
title: naming.identifier.no-keyword
content: Identifier "interval" is a keyword and should be avoided
- detail: ""
startposition:
line: 1
column: 0
diff --git a/backend/plugin/advisor/mysql/test/naming_index_fk.yaml b/backend/plugin/advisor/mysql/test/naming_index_fk.yaml
index 9fdeb37fe1..4869b9a5a8 100644
--- a/backend/plugin/advisor/mysql/test/naming_index_fk.yaml
+++ b/backend/plugin/advisor/mysql/test/naming_index_fk.yaml
@@ -5,9 +5,8 @@
code: 305
title: naming.index.fk
content: Foreign key in table `userTable` mismatches the naming convention, expect "^$|^fk_userTable_roomId_room_id$" but found `fk1`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD CONSTRAINT fk_tech_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id);
@@ -19,9 +18,8 @@
code: 305
title: naming.index.fk
content: Foreign key in table `tech_book` mismatches the naming convention, expect "^$|^fk_tech_book_author_id_author_id$" but found `fk_author_id`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD CONSTRAINT rvemempmcmmhutaskvcidmwaldtfjdgmcpkhmibtadfydtkexpuzczrrneucthfwk FOREIGN KEY (author_id) REFERENCES author (id);
@@ -31,18 +29,16 @@
code: 305
title: naming.index.fk
content: Foreign key `rvemempmcmmhutaskvcidmwaldtfjdgmcpkhmibtadfydtkexpuzczrrneucthfwk` in table `tech_book` mismatches the naming convention, its length should be within 64 characters
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 305
title: naming.index.fk
content: Foreign key in table `tech_book` mismatches the naming convention, expect "^$|^fk_tech_book_author_id_author_id$" but found `rvemempmcmmhutaskvcidmwaldtfjdgmcpkhmibtadfydtkexpuzczrrneucthfwk`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |
@@ -71,8 +67,7 @@
code: 305
title: naming.index.fk
content: Foreign key in table `book` mismatches the naming convention, expect "^$|^fk_book_author_id_author_id$" but found `fk_book_author_id`
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/naming_index_idx.yaml b/backend/plugin/advisor/mysql/test/naming_index_idx.yaml
index d0f12c0925..f5d100758d 100644
--- a/backend/plugin/advisor/mysql/test/naming_index_idx.yaml
+++ b/backend/plugin/advisor/mysql/test/naming_index_idx.yaml
@@ -7,9 +7,8 @@
code: 303
title: naming.index.idx
content: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `tech_book_id_name`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE INDEX afvjwsgrbgqzjfrkmbcoxzstznuypasijbbcdykoboredqovetzfcmmqliaelyavw ON tech_book(id, name);
@@ -19,18 +18,16 @@
code: 303
title: naming.index.idx
content: Index `afvjwsgrbgqzjfrkmbcoxzstznuypasijbbcdykoboredqovetzfcmmqliaelyavw` in table `tech_book` mismatches the naming convention, its length should be within 64 characters
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 303
title: naming.index.idx
content: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `afvjwsgrbgqzjfrkmbcoxzstznuypasijbbcdykoboredqovetzfcmmqliaelyavw`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book RENAME INDEX old_index TO idx_tech_book_id_name;
@@ -42,9 +39,8 @@
code: 303
title: naming.index.idx
content: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `idx_tech_book`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD INDEX idx_tech_book_id_name (id, name);
@@ -56,9 +52,8 @@
code: 303
title: naming.index.idx
content: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `tech_book_id_name`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE tech_book_copy(id INT PRIMARY KEY, name VARCHAR(20), INDEX idx_tech_book_copy_name (name));
diff --git a/backend/plugin/advisor/mysql/test/naming_index_uk.yaml b/backend/plugin/advisor/mysql/test/naming_index_uk.yaml
index 0a18a5c4e6..a6652d623d 100644
--- a/backend/plugin/advisor/mysql/test/naming_index_uk.yaml
+++ b/backend/plugin/advisor/mysql/test/naming_index_uk.yaml
@@ -9,9 +9,8 @@
code: 304
title: naming.index.uk
content: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `tech_book_id_name`
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |
@@ -23,18 +22,16 @@
code: 304
title: naming.index.uk
content: Unique key `qtzmquwvlnttctfluoouxelxeliltcfzzstrtyocogwwyiyrflmrkbhbfasynlacy` in table `tech_book` mismatches the naming convention, its length should be within 64 characters
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 304
title: naming.index.uk
content: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `qtzmquwvlnttctfluoouxelxeliltcfzzstrtyocogwwyiyrflmrkbhbfasynlacy`
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD UNIQUE uk_tech_book_id_name (id, name);
@@ -48,9 +45,8 @@
code: 304
title: naming.index.uk
content: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `tech_book_id_name`
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: ALTER TABLE tech_book RENAME INDEX old_uk TO uk_tech_book_id_name;
@@ -64,9 +60,8 @@
code: 304
title: naming.index.uk
content: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `uk_tech_book`
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: CREATE TABLE book(id INT PRIMARY KEY, name VARCHAR(20), UNIQUE INDEX uk_book_name (name));
diff --git a/backend/plugin/advisor/mysql/test/naming_table.yaml b/backend/plugin/advisor/mysql/test/naming_table.yaml
index 6dc0a9fc0d..76d4d93ecf 100644
--- a/backend/plugin/advisor/mysql/test/naming_table.yaml
+++ b/backend/plugin/advisor/mysql/test/naming_table.yaml
@@ -5,9 +5,8 @@
code: 301
title: naming.table
content: '`techBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE tech_book_copy(id int, name varchar(255));
@@ -19,9 +18,8 @@
code: 301
title: naming.table
content: '`cjnubexocfhqoogdmihudyahmmghviqkzvpixnwvxtxumvuannpwdcbtsgwrvzpde` mismatches table naming convention, its length should be within 64 characters'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |
@@ -33,9 +31,8 @@
code: 301
title: naming.table
content: '`TechBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |
@@ -51,9 +48,8 @@
code: 301
title: naming.table
content: '`LiteraryBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |
@@ -66,18 +62,16 @@
code: 301
title: naming.table
content: '`LiteraryBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 301
title: naming.table
content: '`TechBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |
diff --git a/backend/plugin/advisor/mysql/test/schema_backward_compatibility.yaml b/backend/plugin/advisor/mysql/test/schema_backward_compatibility.yaml
index 8d1e4e206d..b98168eea3 100644
--- a/backend/plugin/advisor/mysql/test/schema_backward_compatibility.yaml
+++ b/backend/plugin/advisor/mysql/test/schema_backward_compatibility.yaml
@@ -5,9 +5,8 @@
code: 111
title: schema.backward-compatibility
content: '"ALTER TABLE tech_book CHANGE name f2 TEXT;" may cause incompatibility with the existing data and code'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book MODIFY name TEXT;
@@ -17,9 +16,8 @@
code: 111
title: schema.backward-compatibility
content: '"ALTER TABLE tech_book MODIFY name TEXT;" may cause incompatibility with the existing data and code'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book MODIFY name TEXT NULL;
@@ -29,9 +27,8 @@
code: 111
title: schema.backward-compatibility
content: '"ALTER TABLE tech_book MODIFY name TEXT NULL;" may cause incompatibility with the existing data and code'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book MODIFY name TEXT NOT NULL;
@@ -41,9 +38,8 @@
code: 111
title: schema.backward-compatibility
content: '"ALTER TABLE tech_book MODIFY name TEXT NOT NULL;" may cause incompatibility with the existing data and code'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book MODIFY name TEXT COMMENT 'bla';
@@ -53,8 +49,7 @@
code: 111
title: schema.backward-compatibility
content: '"ALTER TABLE tech_book MODIFY name TEXT COMMENT ''bla'';" may cause incompatibility with the existing data and code'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/statement_disallow_commit.yaml b/backend/plugin/advisor/mysql/test/statement_disallow_commit.yaml
index 806ff53e06..10735b4545 100644
--- a/backend/plugin/advisor/mysql/test/statement_disallow_commit.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_disallow_commit.yaml
@@ -8,9 +8,8 @@
code: 206
title: statement.disallow-commit
content: 'Commit is not allowed, related statement: "COMMIT;"'
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -27,17 +26,15 @@
code: 206
title: statement.disallow-commit
content: 'Commit is not allowed, related statement: "COMMIT;"'
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 206
title: statement.disallow-commit
content: 'Commit is not allowed, related statement: "COMMIT;"'
- detail: ""
startposition:
- line: 7
+ line: 6
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/statement_disallow_limit.yaml b/backend/plugin/advisor/mysql/test/statement_disallow_limit.yaml
index 2bf925ec71..d75a8cf313 100644
--- a/backend/plugin/advisor/mysql/test/statement_disallow_limit.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_disallow_limit.yaml
@@ -9,9 +9,8 @@
code: 1103
title: statement.disallow-limit
content: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO tech_book SELECT * FROM tech_book LIMIT 1;" uses
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |
@@ -23,9 +22,8 @@
code: 1103
title: statement.disallow-limit
content: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO tech_book SELECT * FROM tech_book UNION SELECT * FROM tech_book LIMIT 1;" uses
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |
@@ -37,9 +35,8 @@
code: 1103
title: statement.disallow-limit
content: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO tech_book SELECT * FROM tech_book UNION SELECT * FROM tech_book LIMIT 1;" uses
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |
@@ -51,9 +48,8 @@
code: 1102
title: statement.disallow-limit
content: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "UPDATE tech_book SET name = 'my name' LIMIT 10;" uses
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |
@@ -65,8 +61,7 @@
code: 1106
title: statement.disallow-limit
content: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "DELETE FROM tech_book LIMIT 10;" uses
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/statement_disallow_mix_in_ddl.yaml b/backend/plugin/advisor/mysql/test/statement_disallow_mix_in_ddl.yaml
index c3fd0f30ad..2455aa3b98 100644
--- a/backend/plugin/advisor/mysql/test/statement_disallow_mix_in_ddl.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_disallow_mix_in_ddl.yaml
@@ -5,9 +5,8 @@
code: 227
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL, "DELETE FROM tech_book WHERE a > 1;" is not DDL
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: UPDATE tech_book SET id = 1;
@@ -17,9 +16,8 @@
code: 227
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL, "UPDATE tech_book SET id = 1;" is not DDL
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD COLUMN author TEXT; UPDATE tech_book SET id = 1;DELETE FROM tech_book WHERE a > 1;
@@ -29,17 +27,15 @@
code: 227
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL, "DELETE FROM tech_book WHERE a > 1;" is not DDL
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 227
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL, "UPDATE tech_book SET id = 1;" is not DDL
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/statement_disallow_mix_in_dml.yaml b/backend/plugin/advisor/mysql/test/statement_disallow_mix_in_dml.yaml
index 51ccbeb2e8..58503bd9b5 100644
--- a/backend/plugin/advisor/mysql/test/statement_disallow_mix_in_dml.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_disallow_mix_in_dml.yaml
@@ -9,8 +9,7 @@
code: 227
title: statement.disallow-mix-in-dml
content: Data change can only run DML, "ALTER TABLE tech_book ADD COLUMN author TEXT;" is not DML
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/statement_disallow_order_by.yaml b/backend/plugin/advisor/mysql/test/statement_disallow_order_by.yaml
index ebe5ce321f..0a662ac6cc 100644
--- a/backend/plugin/advisor/mysql/test/statement_disallow_order_by.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_disallow_order_by.yaml
@@ -9,9 +9,8 @@
code: 1104
title: statement.disallow-order-by
content: ORDER BY clause is forbidden in DELETE and UPDATE statements, but "UPDATE tech_book SET name = 'my name' ORDER BY id;" uses
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -23,8 +22,7 @@
code: 1105
title: statement.disallow-order-by
content: ORDER BY clause is forbidden in DELETE and UPDATE statements, but "DELETE FROM tech_book ORDER BY id;" uses
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/statement_insert_disallow_order_by_rand.yaml b/backend/plugin/advisor/mysql/test/statement_insert_disallow_order_by_rand.yaml
index 6420e96bca..e493e9f0a5 100644
--- a/backend/plugin/advisor/mysql/test/statement_insert_disallow_order_by_rand.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_insert_disallow_order_by_rand.yaml
@@ -9,9 +9,8 @@
code: 1108
title: statement.insert.disallow-order-by-rand
content: '"INSERT INTO tech_book SELECT * FROM tech_book ORDER BY rand();" uses ORDER BY RAND in the INSERT statement'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -23,8 +22,7 @@
code: 1108
title: statement.insert.disallow-order-by-rand
content: '"INSERT INTO tech_book SELECT * FROM tech_book ORDER BY RAND() LIMIT 1;" uses ORDER BY RAND in the INSERT statement'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/statement_insert_must_specify_column.yaml b/backend/plugin/advisor/mysql/test/statement_insert_must_specify_column.yaml
index 5994ade7c9..aec6059ac1 100644
--- a/backend/plugin/advisor/mysql/test/statement_insert_must_specify_column.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_insert_must_specify_column.yaml
@@ -5,9 +5,8 @@
code: 1107
title: statement.insert.must-specify-column
content: The INSERT statement must specify columns but "INSERT INTO t_copy SELECT * FROM t;" does not
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: INSERT INTO tech_book(id, name) VALUES (1, '1');
@@ -19,8 +18,7 @@
code: 1107
title: statement.insert.must-specify-column
content: The INSERT statement must specify columns but "INSERT INTO tech_book VALUES (1, '1');" does not
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/statement_insert_row_limit.yaml b/backend/plugin/advisor/mysql/test/statement_insert_row_limit.yaml
index 2d9a409d63..fc71314f83 100644
--- a/backend/plugin/advisor/mysql/test/statement_insert_row_limit.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_insert_row_limit.yaml
@@ -9,9 +9,8 @@
code: 1101
title: statement.insert.row-limit
content: '"INSERT INTO tech_book values(1, ''a''), (2, ''b''), (3, ''c''), (4, ''d''), (5, ''e''), (6, ''f'');" inserts 6 rows. The count exceeds 5.'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: INSERT INTO tech_book SELECT * FROM tech_book;
diff --git a/backend/plugin/advisor/mysql/test/statement_max_execution_time.yaml b/backend/plugin/advisor/mysql/test/statement_max_execution_time.yaml
index e229cf34af..41a4f08aa1 100644
--- a/backend/plugin/advisor/mysql/test/statement_max_execution_time.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_max_execution_time.yaml
@@ -9,7 +9,6 @@
code: 235
title: statement.max-execution-time
content: The max_execution_time is not set
- detail: ""
startposition: null
endposition: null
- statement: SELECT * FROM t;
@@ -19,6 +18,5 @@
code: 235
title: statement.max-execution-time
content: The max_execution_time is not set
- detail: ""
startposition: null
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/statement_maximum_join_table_count.yaml b/backend/plugin/advisor/mysql/test/statement_maximum_join_table_count.yaml
index 53366055a8..0584bedb9e 100644
--- a/backend/plugin/advisor/mysql/test/statement_maximum_join_table_count.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_maximum_join_table_count.yaml
@@ -7,8 +7,7 @@
code: 223
title: statement.maximum-join-table-count
content: '"select name from hello join world on hello.id = world.id join baby on world.id = baby.id;" exceeds the maximum number of joins 2.'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/statement_maximum_limit_value.yaml b/backend/plugin/advisor/mysql/test/statement_maximum_limit_value.yaml
index 341261a746..2a5837919e 100644
--- a/backend/plugin/advisor/mysql/test/statement_maximum_limit_value.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_maximum_limit_value.yaml
@@ -6,8 +6,7 @@
code: 222
title: statement.maximum-limit-value
content: The limit value 1000000 exceeds the maximum allowed value 1000
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/statement_merge_alter_table.yaml b/backend/plugin/advisor/mysql/test/statement_merge_alter_table.yaml
index 7a26d00b46..22f1f823b5 100644
--- a/backend/plugin/advisor/mysql/test/statement_merge_alter_table.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_merge_alter_table.yaml
@@ -9,9 +9,8 @@
code: 207
title: statement.merge-alter-table
content: There are 2 statements to modify table `tech_book`
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -25,18 +24,16 @@
code: 207
title: statement.merge-alter-table
content: There are 2 statements to modify table `t`
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 207
title: statement.merge-alter-table
content: There are 2 statements to modify table `tech_book`
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- statement: |-
@@ -50,17 +47,15 @@
code: 207
title: statement.merge-alter-table
content: There are 2 statements to modify table `tech_book`
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 207
title: statement.merge-alter-table
content: There are 2 statements to modify table `t`
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/statement_require_algorithm_option.yaml b/backend/plugin/advisor/mysql/test/statement_require_algorithm_option.yaml
index f3d6a5eb61..91ff3cf5d3 100644
--- a/backend/plugin/advisor/mysql/test/statement_require_algorithm_option.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_require_algorithm_option.yaml
@@ -11,8 +11,7 @@
code: 236
title: statement.require-algorithm-option
content: ALTER TABLE statement should include ALGORITHM option
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/statement_require_lock_option.yaml b/backend/plugin/advisor/mysql/test/statement_require_lock_option.yaml
index 643162b872..78593a9e3b 100644
--- a/backend/plugin/advisor/mysql/test/statement_require_lock_option.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_require_lock_option.yaml
@@ -11,9 +11,8 @@
code: 237
title: statement.require-lock-option
content: ALTER TABLE statement should include LOCK option
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |
@@ -26,8 +25,7 @@
code: 237
title: statement.require-lock-option
content: ALTER TABLE statement should include LOCK option
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/statement_select_no_select_all.yaml b/backend/plugin/advisor/mysql/test/statement_select_no_select_all.yaml
index 366ba12614..899ce92940 100644
--- a/backend/plugin/advisor/mysql/test/statement_select_no_select_all.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_select_no_select_all.yaml
@@ -5,9 +5,8 @@
code: 203
title: statement.select.no-select-all
content: '"SELECT * FROM t;" uses SELECT all'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT a, b FROM t;
@@ -22,18 +21,16 @@
code: 203
title: statement.select.no-select-all
content: '"SELECT * FROM t;" uses SELECT all'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 203
title: statement.select.no-select-all
content: '"SELECT a, b FROM (SELECT * from t1 JOIN t2) t;" uses SELECT all'
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -50,9 +47,8 @@
"SELECT * FROM t1
UNION
SELECT * FROM t2;" uses SELECT all
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
@@ -62,9 +58,8 @@
"SELECT * FROM t1
UNION
SELECT * FROM t2;" uses SELECT all
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- statement: |-
@@ -81,9 +76,8 @@
"WITH cte AS (
SELECT * FROM a
) SELECT * FROM cte;" uses SELECT all
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
@@ -93,9 +87,8 @@
"WITH cte AS (
SELECT * FROM a
) SELECT * FROM cte;" uses SELECT all
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- statement: |-
@@ -112,8 +105,7 @@
"SELECT *
FROM a
INNER JOIN b USING(id);" uses SELECT all
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/statement_where_disallow_functions_and_calculations.yaml b/backend/plugin/advisor/mysql/test/statement_where_disallow_functions_and_calculations.yaml
index 159bdcb1ef..26519d1435 100644
--- a/backend/plugin/advisor/mysql/test/statement_where_disallow_functions_and_calculations.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_where_disallow_functions_and_calculations.yaml
@@ -5,8 +5,7 @@
code: 1702
title: statement.where.disallow-functions-and-calculations
content: Function is disallowed in where clause, but "SELECT * FROM employee WHERE id = RAND();" uses
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/statement_where_maximum_logical_operator_count.yaml b/backend/plugin/advisor/mysql/test/statement_where_maximum_logical_operator_count.yaml
index 6d15fd681d..df77aa9281 100644
--- a/backend/plugin/advisor/mysql/test/statement_where_maximum_logical_operator_count.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_where_maximum_logical_operator_count.yaml
@@ -5,9 +5,8 @@
code: 225
title: statement.where.maximum-logical-operator-count
content: Number of tokens (5) in IN predicate operation exceeds limit (2) in statement "SELECT * FROM employee WHERE id IN (1, 2, 3, 4, 5);".
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT * FROM employee WHERE id = 1 OR id = 2 OR id = 3 OR id = 4 OR id = 5;
@@ -17,8 +16,7 @@
code: 225
title: statement.where.maximum-logical-operator-count
content: Number of tokens (5) in the OR predicate operation exceeds limit (2) in statement "SELECT * FROM employee WHERE id = 1 OR id = 2 OR id = 3 OR id = 4 OR id = 5;".
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/statement_where_no_equal_null.yaml b/backend/plugin/advisor/mysql/test/statement_where_no_equal_null.yaml
index bc819eb5b0..4cc571dbd2 100644
--- a/backend/plugin/advisor/mysql/test/statement_where_no_equal_null.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_where_no_equal_null.yaml
@@ -12,8 +12,7 @@
code: 221
title: statement.where.no-equal-null
content: 'WHERE clause contains equal null: SELECT * FROM t WHERE name = ''test'' AND id = NULL;'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/statement_where_no_leading_wildcard_like.yaml b/backend/plugin/advisor/mysql/test/statement_where_no_leading_wildcard_like.yaml
index a6caf98225..b6aeb93089 100644
--- a/backend/plugin/advisor/mysql/test/statement_where_no_leading_wildcard_like.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_where_no_leading_wildcard_like.yaml
@@ -6,9 +6,8 @@
code: 204
title: statement.where.no-leading-wildcard-like
content: '"DELETE FROM tech_book WHERE name like "%abc";" uses leading wildcard LIKE'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |
@@ -24,9 +23,8 @@
code: 204
title: statement.where.no-leading-wildcard-like
content: '"SELECT * FROM t WHERE a LIKE ''%abc'';" uses leading wildcard LIKE'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |
@@ -38,9 +36,8 @@
code: 204
title: statement.where.no-leading-wildcard-like
content: '"SELECT * FROM t WHERE a LIKE ''abc'' OR a LIKE ''%abc'';" uses leading wildcard LIKE'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |
@@ -59,9 +56,8 @@
FROM t
WHERE a LIKE '%acc'
OR a LIKE '%abc';" uses leading wildcard LIKE
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- status: 2
@@ -72,9 +68,8 @@
FROM t
WHERE a LIKE '%acc'
OR a LIKE '%abc';" uses leading wildcard LIKE
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- statement: |
@@ -97,9 +92,8 @@
WHERE a LIKE '%acc'
OR a LIKE '%abc'
) t1;" uses leading wildcard LIKE
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- status: 2
@@ -112,8 +106,7 @@
WHERE a LIKE '%acc'
OR a LIKE '%abc'
) t1;" uses leading wildcard LIKE
- detail: ""
startposition:
- line: 6
+ line: 5
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/statement_where_require_select.yaml b/backend/plugin/advisor/mysql/test/statement_where_require_select.yaml
index 89f2e559a2..e1f572551a 100644
--- a/backend/plugin/advisor/mysql/test/statement_where_require_select.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_where_require_select.yaml
@@ -11,9 +11,8 @@
code: 202
title: statement.where.require.select
content: '"SELECT id FROM book;" requires WHERE clause'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |
@@ -40,9 +39,8 @@
SELECT max(id)
FROM book
);" requires WHERE clause
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- statement: |
diff --git a/backend/plugin/advisor/mysql/test/statement_where_require_update_delete.yaml b/backend/plugin/advisor/mysql/test/statement_where_require_update_delete.yaml
index 800a4a2c27..89839d0d3d 100644
--- a/backend/plugin/advisor/mysql/test/statement_where_require_update_delete.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_where_require_update_delete.yaml
@@ -11,9 +11,8 @@
code: 202
title: statement.where.require.update-delete
content: '"DELETE FROM book;" requires WHERE clause'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |
@@ -25,9 +24,8 @@
code: 202
title: statement.where.require.update-delete
content: '"UPDATE book SET id = 1;" requires WHERE clause'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |
diff --git a/backend/plugin/advisor/mysql/test/system_charset_allowlist.yaml b/backend/plugin/advisor/mysql/test/system_charset_allowlist.yaml
index f655fe2ea0..d1dbb6b51a 100644
--- a/backend/plugin/advisor/mysql/test/system_charset_allowlist.yaml
+++ b/backend/plugin/advisor/mysql/test/system_charset_allowlist.yaml
@@ -9,9 +9,8 @@
code: 1001
title: system.charset.allowlist
content: '"CREATE TABLE t(a int) CHARSET ascii;" used disabled charset ''ascii'''
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -23,9 +22,8 @@
code: 1001
title: system.charset.allowlist
content: '"ALTER TABLE t CHARSET ascii;" used disabled charset ''ascii'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: ALTER DATABASE test CHARSET ascii;
@@ -35,9 +33,8 @@
code: 1001
title: system.charset.allowlist
content: '"ALTER DATABASE test CHARSET ascii;" used disabled charset ''ascii'''
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(a varchar(255) CHARSET ascii);
@@ -47,9 +44,8 @@
code: 1001
title: system.charset.allowlist
content: '"CREATE TABLE t(a varchar(255) CHARSET ascii);" used disabled charset ''ascii'''
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -61,9 +57,8 @@
code: 1001
title: system.charset.allowlist
content: '"ALTER TABLE t ADD COLUMN a varchar(255) CHARSET ascii;" used disabled charset ''ascii'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -75,9 +70,8 @@
code: 1001
title: system.charset.allowlist
content: '"ALTER TABLE t MODIFY COLUMN a varchar(255) CHARSET ascii;" used disabled charset ''ascii'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -89,9 +83,8 @@
code: 1001
title: system.charset.allowlist
content: '"ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARSET ascii;" used disabled charset ''ascii'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: /* this is a comment */
diff --git a/backend/plugin/advisor/mysql/test/system_collation_allowlist.yaml b/backend/plugin/advisor/mysql/test/system_collation_allowlist.yaml
index d0d59ca175..e6a339ca19 100644
--- a/backend/plugin/advisor/mysql/test/system_collation_allowlist.yaml
+++ b/backend/plugin/advisor/mysql/test/system_collation_allowlist.yaml
@@ -31,9 +31,8 @@
UNIQUE KEY uk1(id, name),
FOREIGN KEY fk1(roomId) REFERENCES room(id),
INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin;" used disabled collation 'latin1_bin'
- detail: ""
startposition:
- line: 12
+ line: 11
column: 0
endposition: null
- statement: |
@@ -56,9 +55,8 @@
code: 1201
title: system.collation.allowlist
content: '"CREATE TABLE t(a int) COLLATE utf8mb4_polish_ci;" used disabled collation ''utf8mb4_polish_ci'''
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(a varchar(255));
@@ -70,9 +68,8 @@
code: 1201
title: system.collation.allowlist
content: '"CREATE TABLE t(a int) COLLATE latin1_bin;" used disabled collation ''latin1_bin'''
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -84,9 +81,8 @@
code: 1201
title: system.collation.allowlist
content: '"ALTER TABLE t COLLATE latin1_bin;" used disabled collation ''latin1_bin'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: ALTER DATABASE test COLLATE latin1_bin;
@@ -96,9 +92,8 @@
code: 1201
title: system.collation.allowlist
content: '"ALTER DATABASE test COLLATE latin1_bin;" used disabled collation ''latin1_bin'''
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin);
@@ -108,9 +103,8 @@
code: 1201
title: system.collation.allowlist
content: '"CREATE TABLE t(a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin);" used disabled collation ''latin1_bin'''
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -122,9 +116,8 @@
code: 1201
title: system.collation.allowlist
content: '"ALTER TABLE t ADD COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin;" used disabled collation ''latin1_bin'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -136,9 +129,8 @@
code: 1201
title: system.collation.allowlist
content: '"ALTER TABLE t MODIFY COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin;" used disabled collation ''latin1_bin'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -150,8 +142,7 @@
code: 1201
title: system.collation.allowlist
content: '"ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin;" used disabled collation ''latin1_bin'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/system_event_disallow_create.yaml b/backend/plugin/advisor/mysql/test/system_event_disallow_create.yaml
index dbee7403a5..a103b3a251 100644
--- a/backend/plugin/advisor/mysql/test/system_event_disallow_create.yaml
+++ b/backend/plugin/advisor/mysql/test/system_event_disallow_create.yaml
@@ -23,8 +23,7 @@
INSERT INTO backup_table (backup_date, data)
SELECT NOW(), data
FROM main_table;" creates
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/system_function_disallow_create.yaml b/backend/plugin/advisor/mysql/test/system_function_disallow_create.yaml
index 6390ac705b..a3fc6d37e1 100644
--- a/backend/plugin/advisor/mysql/test/system_function_disallow_create.yaml
+++ b/backend/plugin/advisor/mysql/test/system_function_disallow_create.yaml
@@ -21,8 +21,7 @@
SET result = a + b;
RETURN result;
END;" creates
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/system_function_disallowed_list.yaml b/backend/plugin/advisor/mysql/test/system_function_disallowed_list.yaml
index f2a5583b2d..ed90f94447 100644
--- a/backend/plugin/advisor/mysql/test/system_function_disallowed_list.yaml
+++ b/backend/plugin/advisor/mysql/test/system_function_disallowed_list.yaml
@@ -7,9 +7,8 @@
code: 1702
title: system.function.disallowed-list
content: Function "RAND" is disallowed, but "SELECT RAND();" uses
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -29,9 +28,8 @@
name VARCHAR(255),
age INT
);" uses
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: SELECT SLEEP(5);
@@ -41,8 +39,7 @@
code: 1702
title: system.function.disallowed-list
content: Function "SLEEP" is disallowed, but "SELECT SLEEP(5);" uses
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/system_procedure_disallow_create.yaml b/backend/plugin/advisor/mysql/test/system_procedure_disallow_create.yaml
index 2a6f5bf0d2..aead0d2a5a 100644
--- a/backend/plugin/advisor/mysql/test/system_procedure_disallow_create.yaml
+++ b/backend/plugin/advisor/mysql/test/system_procedure_disallow_create.yaml
@@ -15,8 +15,7 @@
BEGIN
SELECT 'Hello, World!' AS Message;
END;" creates
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/system_view_disallow_create.yaml b/backend/plugin/advisor/mysql/test/system_view_disallow_create.yaml
index 42c7893918..7a34cd0043 100644
--- a/backend/plugin/advisor/mysql/test/system_view_disallow_create.yaml
+++ b/backend/plugin/advisor/mysql/test/system_view_disallow_create.yaml
@@ -7,8 +7,7 @@
code: 1601
title: system.view.disallow-create
content: View is forbidden, but "CREATE VIEW get_one AS SELECT 1;" creates
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/table_comment.yaml b/backend/plugin/advisor/mysql/test/table_comment.yaml
index cad625a9d4..c98b725457 100644
--- a/backend/plugin/advisor/mysql/test/table_comment.yaml
+++ b/backend/plugin/advisor/mysql/test/table_comment.yaml
@@ -7,9 +7,8 @@
code: 1301
title: table.comment
content: The length of table `t` comment should be within 10 characters
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -21,9 +20,8 @@
code: 1032
title: table.comment
content: Table `t` requires comments
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -35,8 +33,7 @@
code: 1301
title: table.comment
content: The length of table `t` comment should be within 10 characters
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/table_disallow_partition.yaml b/backend/plugin/advisor/mysql/test/table_disallow_partition.yaml
index ca8ac66078..18e65485f8 100644
--- a/backend/plugin/advisor/mysql/test/table_disallow_partition.yaml
+++ b/backend/plugin/advisor/mysql/test/table_disallow_partition.yaml
@@ -16,9 +16,8 @@
PARTITION p0 VALUES LESS THAN (6),
PARTITION p1 VALUES LESS THAN (11)
);" creates
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -36,9 +35,8 @@
PARTITION p0 VALUES LESS THAN (6),
PARTITION p1 VALUES LESS THAN (11)
);" creates
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -60,9 +58,8 @@
PARTITION p0 VALUES LESS THAN (6),
PARTITION p1 VALUES LESS THAN (11)
);" creates
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
@@ -73,8 +70,7 @@
PARTITION p0 VALUES LESS THAN (6),
PARTITION p1 VALUES LESS THAN (11)
);" creates
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/table_disallow_set_charset.yaml b/backend/plugin/advisor/mysql/test/table_disallow_set_charset.yaml
index 5dab5b7278..eb8206be68 100644
--- a/backend/plugin/advisor/mysql/test/table_disallow_set_charset.yaml
+++ b/backend/plugin/advisor/mysql/test/table_disallow_set_charset.yaml
@@ -13,9 +13,8 @@
id INT PRIMARY KEY,
name VARCHAR(50)
) CHARSET=utf8;" uses
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -30,8 +29,7 @@
code: 612
title: table.disallow-set-charset
content: Set charset on tables is disallowed, but "ALTER TABLE employee CONVERT TO CHARACTER SET utf8;" uses
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/table_disallow_trigger.yaml b/backend/plugin/advisor/mysql/test/table_disallow_trigger.yaml
index 1c304e6f32..553fecbd09 100644
--- a/backend/plugin/advisor/mysql/test/table_disallow_trigger.yaml
+++ b/backend/plugin/advisor/mysql/test/table_disallow_trigger.yaml
@@ -12,8 +12,7 @@
content: |-
Trigger is forbidden, but "CREATE TRIGGER ins_sum BEFORE INSERT ON account
FOR EACH ROW SET @sum = @sum + NEW.amount;" creates
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/table_drop_naming_convention.yaml b/backend/plugin/advisor/mysql/test/table_drop_naming_convention.yaml
index fe65f00c92..f356a448a8 100644
--- a/backend/plugin/advisor/mysql/test/table_drop_naming_convention.yaml
+++ b/backend/plugin/advisor/mysql/test/table_drop_naming_convention.yaml
@@ -12,9 +12,8 @@
code: 603
title: table.drop-naming-convention
content: '`foo` mismatches drop table naming convention, naming format should be "_delete$"'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -28,8 +27,7 @@
code: 603
title: table.drop-naming-convention
content: '`bar` mismatches drop table naming convention, naming format should be "_delete$"'
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/table_no_duplicate_index.yaml b/backend/plugin/advisor/mysql/test/table_no_duplicate_index.yaml
index 125daff966..59cd7d7f7a 100644
--- a/backend/plugin/advisor/mysql/test/table_no_duplicate_index.yaml
+++ b/backend/plugin/advisor/mysql/test/table_no_duplicate_index.yaml
@@ -33,9 +33,8 @@
code: 815
title: table.no-duplicate-index
content: '`users` has duplicate index `idx_username_duplicate`'
- detail: ""
startposition:
- line: 7
+ line: 6
column: 0
endposition: null
- statement: |-
@@ -53,9 +52,8 @@
code: 815
title: table.no-duplicate-index
content: '`orders` has duplicate index ``'
- detail: ""
startposition:
- line: 7
+ line: 6
column: 0
endposition: null
- statement: |-
@@ -74,9 +72,8 @@
code: 815
title: table.no-duplicate-index
content: '`orders` has duplicate index `idx_duplicate`'
- detail: ""
startposition:
- line: 9
+ line: 8
column: 0
endposition: null
- statement: |-
@@ -93,9 +90,8 @@
code: 815
title: table.no-duplicate-index
content: '`orders` has duplicate index `idx_customer_id_duplicate`'
- detail: ""
startposition:
- line: 7
+ line: 6
column: 0
endposition: null
- statement: |-
@@ -112,9 +108,8 @@
code: 815
title: table.no-duplicate-index
content: '`orders` has duplicate index `idx_customer_duplicate`'
- detail: ""
startposition:
- line: 7
+ line: 6
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/mysql/test/table_no_foreign_key.yaml b/backend/plugin/advisor/mysql/test/table_no_foreign_key.yaml
index 3604783977..c75a8a6b91 100644
--- a/backend/plugin/advisor/mysql/test/table_no_foreign_key.yaml
+++ b/backend/plugin/advisor/mysql/test/table_no_foreign_key.yaml
@@ -7,9 +7,8 @@
code: 602
title: table.no-foreign-key
content: Foreign key is not allowed in the table `tech_book`
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -21,8 +20,7 @@
code: 602
title: table.no-foreign-key
content: Foreign key is not allowed in the table `book`
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/mysql/test/table_require_pk.yaml b/backend/plugin/advisor/mysql/test/table_require_pk.yaml
index 1a7199e263..3901475871 100644
--- a/backend/plugin/advisor/mysql/test/table_require_pk.yaml
+++ b/backend/plugin/advisor/mysql/test/table_require_pk.yaml
@@ -17,9 +17,8 @@
code: 601
title: table.require-pk
content: Table `userTable` requires PRIMARY KEY
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |
@@ -45,9 +44,8 @@
code: 601
title: table.require-pk
content: Table `t2` requires PRIMARY KEY
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -60,9 +58,8 @@
code: 601
title: table.require-pk
content: Table `t2` requires PRIMARY KEY
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -79,9 +76,8 @@
code: 601
title: table.require-pk
content: Table `t2` requires PRIMARY KEY
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -103,9 +99,8 @@
code: 601
title: table.require-pk
content: Table `t` requires PRIMARY KEY
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -117,9 +112,8 @@
code: 601
title: table.require-pk
content: Table `t` requires PRIMARY KEY
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -152,9 +146,8 @@
code: 601
title: table.require-pk
content: Table `t` requires PRIMARY KEY
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -166,9 +159,8 @@
code: 601
title: table.require-pk
content: Table `tech_book` requires PRIMARY KEY
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: ALTER TABLE tech_book DROP COLUMN name;
@@ -182,9 +174,8 @@
code: 601
title: table.require-pk
content: Table `tech_book` requires PRIMARY KEY
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -196,8 +187,7 @@
code: 601
title: table.require-pk
content: Table `tech_book` requires PRIMARY KEY
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/oceanbase/advisor_disallow_offline_ddl.go b/backend/plugin/advisor/oceanbase/advisor_disallow_offline_ddl.go
index 4c8b76c85b..2f217d0e6e 100644
--- a/backend/plugin/advisor/oceanbase/advisor_disallow_offline_ddl.go
+++ b/backend/plugin/advisor/oceanbase/advisor_disallow_offline_ddl.go
@@ -242,12 +242,10 @@ func (*disallowOfflineDdlChecker) isPrimaryKeyColumn(ctx mysql.IFieldDefinitionC
func (checker *disallowOfflineDdlChecker) advice(ctx antlr.ParserRuleContext, operation string) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementOfflineDDL.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("%s is an offline DDL operation.", operation),
- StartPosition: &storepb.Position{
- Line: int32(checker.baseLine + ctx.GetStart().GetLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementOfflineDDL.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("%s is an offline DDL operation.", operation),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.baseLine + ctx.GetStart().GetLine()),
})
}
diff --git a/backend/plugin/advisor/oracle/advisor_column_add_not_null_column_require_default.go b/backend/plugin/advisor/oracle/advisor_column_add_not_null_column_require_default.go
index bf995de4ff..3ac52e416c 100644
--- a/backend/plugin/advisor/oracle/advisor_column_add_not_null_column_require_default.go
+++ b/backend/plugin/advisor/oracle/advisor_column_add_not_null_column_require_default.go
@@ -96,13 +96,11 @@ func (l *columnAddNotNullColumnRequireDefaultListener) ExitColumn_definition(ctx
if ctx.DEFAULT() == nil {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NotNullColumnWithNoDefault.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Adding not null column %q requires default.", normalizeIdentifier(ctx.Column_name(), l.currentDatabase)),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NotNullColumnWithNoDefault.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Adding not null column %q requires default.", normalizeIdentifier(ctx.Column_name(), l.currentDatabase)),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/oracle/advisor_column_comment_convention.go b/backend/plugin/advisor/oracle/advisor_column_comment_convention.go
index 29944dba14..8cea56f5b6 100644
--- a/backend/plugin/advisor/oracle/advisor_column_comment_convention.go
+++ b/backend/plugin/advisor/oracle/advisor_column_comment_convention.go
@@ -120,37 +120,31 @@ func (l *columnCommentConventionListener) generateAdvices() ([]*storepb.Advice,
if !ok || comment == "" {
if l.payload.Required {
advices = append(advices, &storepb.Advice{
- Status: l.level,
- Code: advisor.CommentEmpty.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Comment is required for column %s", normalizeIdentifierName(columnName)),
- StartPosition: &storepb.Position{
- Line: int32(l.columnLine[columnName]),
- },
+ Status: l.level,
+ Code: advisor.CommentEmpty.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Comment is required for column %s", normalizeIdentifierName(columnName)),
+ StartPosition: advisor.ConvertANTLRLineToPosition(l.columnLine[columnName]),
})
}
} else {
if l.payload.MaxLength > 0 && len(comment) > l.payload.MaxLength {
advices = append(advices, &storepb.Advice{
- Status: l.level,
- Code: advisor.CommentTooLong.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Column %s comment is too long. The length of comment should be within %d characters", normalizeIdentifierName(columnName), l.payload.MaxLength),
- StartPosition: &storepb.Position{
- Line: int32(l.columnLine[columnName]),
- },
+ Status: l.level,
+ Code: advisor.CommentTooLong.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Column %s comment is too long. The length of comment should be within %d characters", normalizeIdentifierName(columnName), l.payload.MaxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(l.columnLine[columnName]),
})
}
if l.payload.RequiredClassification {
if classification, _ := common.GetClassificationAndUserComment(comment, l.classificationConfig); classification == "" {
advices = append(advices, &storepb.Advice{
- Status: l.level,
- Code: advisor.CommentMissingClassification.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Column %s comment requires classification", normalizeIdentifierName(columnName)),
- StartPosition: &storepb.Position{
- Line: int32(l.columnLine[columnName]),
- },
+ Status: l.level,
+ Code: advisor.CommentMissingClassification.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Column %s comment requires classification", normalizeIdentifierName(columnName)),
+ StartPosition: advisor.ConvertANTLRLineToPosition(l.columnLine[columnName]),
})
}
}
diff --git a/backend/plugin/advisor/oracle/advisor_column_maximum_character_length.go b/backend/plugin/advisor/oracle/advisor_column_maximum_character_length.go
index 7f24f158d6..02415fd6ea 100644
--- a/backend/plugin/advisor/oracle/advisor_column_maximum_character_length.go
+++ b/backend/plugin/advisor/oracle/advisor_column_maximum_character_length.go
@@ -94,12 +94,10 @@ func (l *columnMaximumCharacterLengthListener) EnterDatatype(ctx *parser.Datatyp
}
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.CharLengthExceedsLimit.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("The maximum character length is %d.", l.maximum),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.CharLengthExceedsLimit.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("The maximum character length is %d.", l.maximum),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
diff --git a/backend/plugin/advisor/oracle/advisor_column_maximum_varchar_length.go b/backend/plugin/advisor/oracle/advisor_column_maximum_varchar_length.go
index c5e965f1b5..1c555ec1b5 100644
--- a/backend/plugin/advisor/oracle/advisor_column_maximum_varchar_length.go
+++ b/backend/plugin/advisor/oracle/advisor_column_maximum_varchar_length.go
@@ -94,12 +94,10 @@ func (l *columnMaximumVarcharLengthListener) EnterDatatype(ctx *parser.DatatypeC
}
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.VarcharLengthExceedsLimit.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("The maximum varchar length is %d.", l.maximum),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.VarcharLengthExceedsLimit.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("The maximum varchar length is %d.", l.maximum),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
diff --git a/backend/plugin/advisor/oracle/advisor_column_no_null.go b/backend/plugin/advisor/oracle/advisor_column_no_null.go
index 5367a67095..0ac7fd64b8 100644
--- a/backend/plugin/advisor/oracle/advisor_column_no_null.go
+++ b/backend/plugin/advisor/oracle/advisor_column_no_null.go
@@ -77,13 +77,11 @@ func (l *columnNoNullListener) generateAdvice() ([]*storepb.Advice, error) {
for _, columnID := range columnIDs {
line := l.nullableColumns[columnID]
advice = append(advice, &storepb.Advice{
- Status: l.level,
- Code: advisor.ColumnCannotNull.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Column %q is nullable, which is not allowed.", lastIdentifier(columnID)),
- StartPosition: &storepb.Position{
- Line: int32(line),
- },
+ Status: l.level,
+ Code: advisor.ColumnCannotNull.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Column %q is nullable, which is not allowed.", lastIdentifier(columnID)),
+ StartPosition: advisor.ConvertANTLRLineToPosition(line),
})
}
diff --git a/backend/plugin/advisor/oracle/advisor_column_require.go b/backend/plugin/advisor/oracle/advisor_column_require.go
index b13ceef310..8a797f80c1 100644
--- a/backend/plugin/advisor/oracle/advisor_column_require.go
+++ b/backend/plugin/advisor/oracle/advisor_column_require.go
@@ -102,13 +102,11 @@ func (l *columnRequireListener) ExitCreate_table(ctx *parser.Create_tableContext
sort.Strings(missingColumns)
tableName := normalizeIdentifier(ctx.Table_name(), l.currentDatabase)
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NoRequiredColumn.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Table %q requires columns: %s", tableName, strings.Join(missingColumns, ", ")),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStop().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NoRequiredColumn.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Table %q requires columns: %s", tableName, strings.Join(missingColumns, ", ")),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStop().GetLine()),
})
}
@@ -141,13 +139,11 @@ func (l *columnRequireListener) ExitAlter_table(ctx *parser.Alter_tableContext)
sort.Strings(missingColumns)
tableName := lastIdentifier(normalizeIdentifier(ctx.Tableview_name(), l.currentDatabase))
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NoRequiredColumn.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Table %q requires columns: %s", tableName, strings.Join(missingColumns, ", ")),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStop().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NoRequiredColumn.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Table %q requires columns: %s", tableName, strings.Join(missingColumns, ", ")),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStop().GetLine()),
})
}
diff --git a/backend/plugin/advisor/oracle/advisor_column_require_default.go b/backend/plugin/advisor/oracle/advisor_column_require_default.go
index 566e50edae..0457af706a 100644
--- a/backend/plugin/advisor/oracle/advisor_column_require_default.go
+++ b/backend/plugin/advisor/oracle/advisor_column_require_default.go
@@ -74,13 +74,11 @@ func (l *columnRequireDefaultListener) generateAdvice() ([]*storepb.Advice, erro
for _, columnID := range columnIDs {
line := l.noDefaultColumns[columnID]
advice = append(advice, &storepb.Advice{
- Status: l.level,
- Code: advisor.NoDefault.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Column %q doesn't have default value", lastIdentifier(columnID)),
- StartPosition: &storepb.Position{
- Line: int32(line),
- },
+ Status: l.level,
+ Code: advisor.NoDefault.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Column %q doesn't have default value", lastIdentifier(columnID)),
+ StartPosition: advisor.ConvertANTLRLineToPosition(line),
})
}
diff --git a/backend/plugin/advisor/oracle/advisor_column_type_disallow_list.go b/backend/plugin/advisor/oracle/advisor_column_type_disallow_list.go
index 4bb2ae02f2..b7eb4084b9 100644
--- a/backend/plugin/advisor/oracle/advisor_column_type_disallow_list.go
+++ b/backend/plugin/advisor/oracle/advisor_column_type_disallow_list.go
@@ -87,26 +87,22 @@ func (l *columnTypeDisallowListListener) isDisallowType(tp parser.IDatatypeConte
func (l *columnTypeDisallowListListener) EnterColumn_definition(ctx *parser.Column_definitionContext) {
if l.isDisallowType(ctx.Datatype()) {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.DisabledColumnType.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Disallow column type %s but column \"%s\" is", ctx.Datatype().GetText(), normalizeIdentifier(ctx.Column_name(), l.currentDatabase)),
- StartPosition: &storepb.Position{
- Line: int32(ctx.Datatype().GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.DisabledColumnType.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Disallow column type %s but column \"%s\" is", ctx.Datatype().GetText(), normalizeIdentifier(ctx.Column_name(), l.currentDatabase)),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.Datatype().GetStart().GetLine()),
})
}
if ctx.Regular_id() != nil {
for _, tp := range l.disallowList {
if ctx.Regular_id().GetText() == tp {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.DisabledColumnType.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Disallow column type %s but column \"%s\" is", ctx.Regular_id().GetText(), normalizeIdentifier(ctx.Column_name(), l.currentDatabase)),
- StartPosition: &storepb.Position{
- Line: int32(ctx.Regular_id().GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.DisabledColumnType.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Disallow column type %s but column \"%s\" is", ctx.Regular_id().GetText(), normalizeIdentifier(ctx.Column_name(), l.currentDatabase)),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.Regular_id().GetStart().GetLine()),
})
break
}
@@ -118,13 +114,11 @@ func (l *columnTypeDisallowListListener) EnterColumn_definition(ctx *parser.Colu
func (l *columnTypeDisallowListListener) EnterModify_col_properties(ctx *parser.Modify_col_propertiesContext) {
if l.isDisallowType(ctx.Datatype()) {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.DisabledColumnType.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Disallow column type %s but column \"%s\" is", ctx.Datatype().GetText(), normalizeIdentifier(ctx.Column_name(), l.currentDatabase)),
- StartPosition: &storepb.Position{
- Line: int32(ctx.Datatype().GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.DisabledColumnType.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Disallow column type %s but column \"%s\" is", ctx.Datatype().GetText(), normalizeIdentifier(ctx.Column_name(), l.currentDatabase)),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.Datatype().GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/oracle/advisor_index_key_number_limit.go b/backend/plugin/advisor/oracle/advisor_index_key_number_limit.go
index 13efc26cd3..43de56cc06 100644
--- a/backend/plugin/advisor/oracle/advisor_index_key_number_limit.go
+++ b/backend/plugin/advisor/oracle/advisor_index_key_number_limit.go
@@ -77,13 +77,11 @@ func (l *indexKeyNumberLimitListener) EnterTable_index_clause(ctx *parser.Table_
keys := len(ctx.AllIndex_expr_option())
if keys > l.max {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.IndexKeyNumberExceedsLimit.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Index key number should be less than or equal to %d", l.max),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.IndexKeyNumberExceedsLimit.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Index key number should be less than or equal to %d", l.max),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
@@ -93,13 +91,11 @@ func (l *indexKeyNumberLimitListener) EnterOut_of_line_constraint(ctx *parser.Ou
keys := len(ctx.AllColumn_name())
if keys > l.max {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.IndexKeyNumberExceedsLimit.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Index key number should be less than or equal to %d", l.max),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.IndexKeyNumberExceedsLimit.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Index key number should be less than or equal to %d", l.max),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/oracle/advisor_insert_must_specify_column.go b/backend/plugin/advisor/oracle/advisor_insert_must_specify_column.go
index d8c1f16e84..f97ed2509c 100644
--- a/backend/plugin/advisor/oracle/advisor_insert_must_specify_column.go
+++ b/backend/plugin/advisor/oracle/advisor_insert_must_specify_column.go
@@ -67,13 +67,11 @@ func (l *insertMustSpecifyColumnListener) generateAdvice() ([]*storepb.Advice, e
func (l *insertMustSpecifyColumnListener) EnterInsert_into_clause(ctx *parser.Insert_into_clauseContext) {
if ctx.Paren_column_list() == nil {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.InsertNotSpecifyColumn.Int32(),
- Title: l.title,
- Content: "INSERT statement should specify column name.",
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.InsertNotSpecifyColumn.Int32(),
+ Title: l.title,
+ Content: "INSERT statement should specify column name.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/oracle/advisor_naming_identifier_case.go b/backend/plugin/advisor/oracle/advisor_naming_identifier_case.go
index 31099b3031..a2a6fd60f3 100644
--- a/backend/plugin/advisor/oracle/advisor_naming_identifier_case.go
+++ b/backend/plugin/advisor/oracle/advisor_naming_identifier_case.go
@@ -77,25 +77,21 @@ func (l *namingIdentifierCaseListener) EnterId_expression(ctx *parser.Id_express
if l.upper {
if identifier != strings.ToUpper(identifier) {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NamingCaseMismatch.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Identifier %q should be upper case", identifier),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NamingCaseMismatch.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Identifier %q should be upper case", identifier),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
} else {
if identifier != strings.ToLower(identifier) {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NamingCaseMismatch.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Identifier %q should be lower case", identifier),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NamingCaseMismatch.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Identifier %q should be lower case", identifier),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/oracle/advisor_naming_identifier_no_keyword.go b/backend/plugin/advisor/oracle/advisor_naming_identifier_no_keyword.go
index 02bd67cb1e..4dab539400 100644
--- a/backend/plugin/advisor/oracle/advisor_naming_identifier_no_keyword.go
+++ b/backend/plugin/advisor/oracle/advisor_naming_identifier_no_keyword.go
@@ -70,13 +70,11 @@ func (l *namingIdentifierNoKeywordListener) EnterId_expression(ctx *parser.Id_ex
identifier := normalizeIDExpression(ctx)
if plsqlparser.IsOracleKeyword(identifier) {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NameIsKeywordIdentifier.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Identifier %q is a keyword and should be avoided", identifier),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NameIsKeywordIdentifier.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Identifier %q is a keyword and should be avoided", identifier),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/oracle/advisor_naming_table.go b/backend/plugin/advisor/oracle/advisor_naming_table.go
index 82b858ddc6..037d51eee7 100644
--- a/backend/plugin/advisor/oracle/advisor_naming_table.go
+++ b/backend/plugin/advisor/oracle/advisor_naming_table.go
@@ -79,24 +79,20 @@ func (l *namingTableListener) EnterCreate_table(ctx *parser.Create_tableContext)
tableName := normalizeIdentifier(ctx.Table_name(), l.currentDatabase)
if !l.format.MatchString(tableName) {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NamingTableConventionMismatch.Int32(),
- Title: l.title,
- Content: fmt.Sprintf(`"%s" mismatches table naming convention, naming format should be %q`, tableName, l.format),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NamingTableConventionMismatch.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf(`"%s" mismatches table naming convention, naming format should be %q`, tableName, l.format),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
if l.maxLength > 0 && len(tableName) > l.maxLength {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NamingTableConventionMismatch.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("\"%s\" mismatches table naming convention, its length should be within %d characters", tableName, l.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NamingTableConventionMismatch.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("\"%s\" mismatches table naming convention, its length should be within %d characters", tableName, l.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
@@ -112,24 +108,20 @@ func (l *namingTableListener) EnterAlter_table_properties(ctx *parser.Alter_tabl
}
if !l.format.MatchString(tableName) {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NamingTableConventionMismatch.Int32(),
- Title: l.title,
- Content: fmt.Sprintf(`"%s" mismatches table naming convention, naming format should be %q`, tableName, l.format),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NamingTableConventionMismatch.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf(`"%s" mismatches table naming convention, naming format should be %q`, tableName, l.format),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
if l.maxLength > 0 && len(tableName) > l.maxLength {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NamingTableConventionMismatch.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("\"%s\" mismatches table naming convention, its length should be within %d characters", tableName, l.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NamingTableConventionMismatch.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("\"%s\" mismatches table naming convention, its length should be within %d characters", tableName, l.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/oracle/advisor_naming_table_no_keyword.go b/backend/plugin/advisor/oracle/advisor_naming_table_no_keyword.go
index d89796f5b8..43c10483c7 100644
--- a/backend/plugin/advisor/oracle/advisor_naming_table_no_keyword.go
+++ b/backend/plugin/advisor/oracle/advisor_naming_table_no_keyword.go
@@ -70,13 +70,11 @@ func (l *namingTableNoKeywordListener) EnterCreate_table(ctx *parser.Create_tabl
tableName := normalizeIdentifier(ctx.Table_name(), l.currentDatabase)
if plsqlparser.IsOracleKeyword(tableName) {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NameIsKeywordIdentifier.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Table name %q is a keyword identifier and should be avoided.", tableName),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NameIsKeywordIdentifier.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Table name %q is a keyword identifier and should be avoided.", tableName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
@@ -89,13 +87,11 @@ func (l *namingTableNoKeywordListener) EnterAlter_table_properties(ctx *parser.A
tableName := lastIdentifier(normalizeIdentifier(ctx.Tableview_name(), l.currentDatabase))
if plsqlparser.IsOracleKeyword(tableName) {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NameIsKeywordIdentifier.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Table name %q is a keyword identifier and should be avoided.", tableName),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NameIsKeywordIdentifier.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Table name %q is a keyword identifier and should be avoided.", tableName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/oracle/advisor_select_no_select_all.go b/backend/plugin/advisor/oracle/advisor_select_no_select_all.go
index 1bbee35c78..f14b6cce66 100644
--- a/backend/plugin/advisor/oracle/advisor_select_no_select_all.go
+++ b/backend/plugin/advisor/oracle/advisor_select_no_select_all.go
@@ -67,13 +67,11 @@ func (l *selectNoSelectAllListener) generateAdvice() ([]*storepb.Advice, error)
func (l *selectNoSelectAllListener) EnterSelected_list(ctx *parser.Selected_listContext) {
if ctx.ASTERISK() != nil {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.StatementSelectAll.Int32(),
- Title: l.title,
- Content: "Avoid using SELECT *.",
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.StatementSelectAll.Int32(),
+ Title: l.title,
+ Content: "Avoid using SELECT *.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/oracle/advisor_statement_disallow_mix_in_ddl.go b/backend/plugin/advisor/oracle/advisor_statement_disallow_mix_in_ddl.go
index ac751e28c6..61b01e3fc9 100644
--- a/backend/plugin/advisor/oracle/advisor_statement_disallow_mix_in_ddl.go
+++ b/backend/plugin/advisor/oracle/advisor_statement_disallow_mix_in_ddl.go
@@ -47,13 +47,11 @@ func (*StatementDisallowMixInDDLAdvisor) Check(_ context.Context, checkCtx advis
if stmt, ok := item.(parser.IUnit_statementContext); ok {
if stmt.Data_manipulation_language_statements() != nil {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: "Alter schema can only run DDL",
- Code: advisor.StatementDisallowMixDDLDML.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.GetStart().GetLine()),
- },
+ Status: level,
+ Title: title,
+ Content: "Alter schema can only run DDL",
+ Code: advisor.StatementDisallowMixDDLDML.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/oracle/advisor_statement_disallow_mix_in_dml.go b/backend/plugin/advisor/oracle/advisor_statement_disallow_mix_in_dml.go
index c685e96f54..2648002c0e 100644
--- a/backend/plugin/advisor/oracle/advisor_statement_disallow_mix_in_dml.go
+++ b/backend/plugin/advisor/oracle/advisor_statement_disallow_mix_in_dml.go
@@ -48,13 +48,11 @@ func (*StatementDisallowMixInDMLAdvisor) Check(_ context.Context, checkCtx advis
if stmt, ok := item.(parser.IUnit_statementContext); ok {
if stmt.Data_manipulation_language_statements() == nil {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: "Data change can only run DML",
- Code: advisor.StatementDisallowMixDDLDML.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.GetStart().GetLine()),
- },
+ Status: level,
+ Title: title,
+ Content: "Data change can only run DML",
+ Code: advisor.StatementDisallowMixDDLDML.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/oracle/advisor_statement_dml_dry_run.go b/backend/plugin/advisor/oracle/advisor_statement_dml_dry_run.go
index 1599269002..3317663e9a 100644
--- a/backend/plugin/advisor/oracle/advisor_statement_dml_dry_run.go
+++ b/backend/plugin/advisor/oracle/advisor_statement_dml_dry_run.go
@@ -94,13 +94,11 @@ func (s *statementDmlDryRunChecker) handleStmt(text string, lineNumber int) {
s.explainCount++
if _, err := advisor.Query(s.ctx, advisor.QueryContext{}, s.driver, storepb.Engine_ORACLE, fmt.Sprintf("EXPLAIN PLAN FOR %s", text)); err != nil {
s.adviceList = append(s.adviceList, &storepb.Advice{
- Status: s.level,
- Code: advisor.StatementDMLDryRunFailed.Int32(),
- Title: s.title,
- Content: fmt.Sprintf("Failed to dry run statement at line %d: %v", lineNumber, err),
- StartPosition: &storepb.Position{
- Line: int32(lineNumber),
- },
+ Status: s.level,
+ Code: advisor.StatementDMLDryRunFailed.Int32(),
+ Title: s.title,
+ Content: fmt.Sprintf("Failed to dry run statement at line %d: %v", lineNumber, err),
+ StartPosition: advisor.ConvertANTLRLineToPosition(lineNumber),
})
}
}
diff --git a/backend/plugin/advisor/oracle/advisor_table_comment_convention.go b/backend/plugin/advisor/oracle/advisor_table_comment_convention.go
index f3412b5fe7..4f45159e5f 100644
--- a/backend/plugin/advisor/oracle/advisor_table_comment_convention.go
+++ b/backend/plugin/advisor/oracle/advisor_table_comment_convention.go
@@ -101,37 +101,31 @@ func (l *tableCommentConventionListener) generateAdvices() ([]*storepb.Advice, e
if !ok || comment == "" {
if l.payload.Required {
advices = append(advices, &storepb.Advice{
- Status: l.level,
- Code: advisor.CommentEmpty.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Comment is required for table %s", normalizeIdentifierName(tableName)),
- StartPosition: &storepb.Position{
- Line: int32(l.tableLine[tableName]),
- },
+ Status: l.level,
+ Code: advisor.CommentEmpty.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Comment is required for table %s", normalizeIdentifierName(tableName)),
+ StartPosition: advisor.ConvertANTLRLineToPosition(l.tableLine[tableName]),
})
}
} else {
if l.payload.MaxLength > 0 && len(comment) > l.payload.MaxLength {
advices = append(advices, &storepb.Advice{
- Status: l.level,
- Code: advisor.CommentTooLong.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Table %s comment is too long. The length of comment should be within %d characters", normalizeIdentifierName(tableName), l.payload.MaxLength),
- StartPosition: &storepb.Position{
- Line: int32(l.tableLine[tableName]),
- },
+ Status: l.level,
+ Code: advisor.CommentTooLong.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Table %s comment is too long. The length of comment should be within %d characters", normalizeIdentifierName(tableName), l.payload.MaxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(l.tableLine[tableName]),
})
}
if l.payload.RequiredClassification {
if classification, _ := common.GetClassificationAndUserComment(comment, l.classificationConfig); classification == "" {
advices = append(advices, &storepb.Advice{
- Status: l.level,
- Code: advisor.CommentMissingClassification.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Table %s comment requires classification", normalizeIdentifierName(tableName)),
- StartPosition: &storepb.Position{
- Line: int32(l.tableLine[tableName]),
- },
+ Status: l.level,
+ Code: advisor.CommentMissingClassification.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Table %s comment requires classification", normalizeIdentifierName(tableName)),
+ StartPosition: advisor.ConvertANTLRLineToPosition(l.tableLine[tableName]),
})
}
}
diff --git a/backend/plugin/advisor/oracle/advisor_table_no_foreign_key.go b/backend/plugin/advisor/oracle/advisor_table_no_foreign_key.go
index 66b1abdd17..0ff070af3e 100644
--- a/backend/plugin/advisor/oracle/advisor_table_no_foreign_key.go
+++ b/backend/plugin/advisor/oracle/advisor_table_no_foreign_key.go
@@ -69,13 +69,11 @@ func (l *tableNoForeignKeyListener) generateAdvice() ([]*storepb.Advice, error)
for tableName, hasFK := range l.tableWithFK {
if hasFK {
advice = append(advice, &storepb.Advice{
- Status: l.level,
- Code: advisor.TableHasFK.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Foreign key is not allowed in the table %s.", normalizeIdentifierName(tableName)),
- StartPosition: &storepb.Position{
- Line: int32(l.tableLine[tableName]),
- },
+ Status: l.level,
+ Code: advisor.TableHasFK.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Foreign key is not allowed in the table %s.", normalizeIdentifierName(tableName)),
+ StartPosition: advisor.ConvertANTLRLineToPosition(l.tableLine[tableName]),
})
}
}
diff --git a/backend/plugin/advisor/oracle/advisor_table_require_pk.go b/backend/plugin/advisor/oracle/advisor_table_require_pk.go
index 66d2a52eb6..965826a0cc 100644
--- a/backend/plugin/advisor/oracle/advisor_table_require_pk.go
+++ b/backend/plugin/advisor/oracle/advisor_table_require_pk.go
@@ -69,13 +69,11 @@ func (l *TableRequirePKListener) generateAdvice() ([]*storepb.Advice, error) {
for tableName, hasPK := range l.tableWitPK {
if !hasPK {
advice = append(advice, &storepb.Advice{
- Status: l.level,
- Code: advisor.TableNoPK.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Table %s requires PRIMARY KEY.", normalizeIdentifierName(tableName)),
- StartPosition: &storepb.Position{
- Line: int32(l.tableLine[tableName]),
- },
+ Status: l.level,
+ Code: advisor.TableNoPK.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Table %s requires PRIMARY KEY.", normalizeIdentifierName(tableName)),
+ StartPosition: advisor.ConvertANTLRLineToPosition(l.tableLine[tableName]),
})
}
}
diff --git a/backend/plugin/advisor/oracle/advisor_where_no_leading_wildcard_like.go b/backend/plugin/advisor/oracle/advisor_where_no_leading_wildcard_like.go
index 7fc09e5dea..85049d336e 100644
--- a/backend/plugin/advisor/oracle/advisor_where_no_leading_wildcard_like.go
+++ b/backend/plugin/advisor/oracle/advisor_where_no_leading_wildcard_like.go
@@ -77,13 +77,11 @@ func (l *whereNoLeadingWildcardLikeListener) EnterCompound_expression(ctx *parse
text := ctx.Concatenation(1).GetText()
if strings.HasPrefix(text, "'%") && strings.HasSuffix(text, "'") {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.StatementLeadingWildcardLike.Int32(),
- Title: l.title,
- Content: "Avoid using leading wildcard LIKE.",
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.StatementLeadingWildcardLike.Int32(),
+ Title: l.title,
+ Content: "Avoid using leading wildcard LIKE.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/oracle/advisor_where_require_for_select.go b/backend/plugin/advisor/oracle/advisor_where_require_for_select.go
index 5f92ac2019..a0f2fc5241 100644
--- a/backend/plugin/advisor/oracle/advisor_where_require_for_select.go
+++ b/backend/plugin/advisor/oracle/advisor_where_require_for_select.go
@@ -75,13 +75,11 @@ func (l *whereRequireForSelectListener) EnterQuery_block(ctx *parser.Query_block
}
if ctx.Where_clause() == nil {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.StatementNoWhere.Int32(),
- Title: l.title,
- Content: "WHERE clause is required for SELECT statement.",
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStop().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.StatementNoWhere.Int32(),
+ Title: l.title,
+ Content: "WHERE clause is required for SELECT statement.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStop().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/oracle/advisor_where_require_for_update_delete.go b/backend/plugin/advisor/oracle/advisor_where_require_for_update_delete.go
index 4802aa1c1e..a0cc394189 100644
--- a/backend/plugin/advisor/oracle/advisor_where_require_for_update_delete.go
+++ b/backend/plugin/advisor/oracle/advisor_where_require_for_update_delete.go
@@ -67,13 +67,11 @@ func (l *whereRequireForUpdateDeleteListener) generateAdvice() ([]*storepb.Advic
func (l *whereRequireForUpdateDeleteListener) EnterUpdate_statement(ctx *parser.Update_statementContext) {
if ctx.Where_clause() == nil {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.StatementNoWhere.Int32(),
- Title: l.title,
- Content: "WHERE clause is required for UPDATE statement.",
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStop().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.StatementNoWhere.Int32(),
+ Title: l.title,
+ Content: "WHERE clause is required for UPDATE statement.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStop().GetLine()),
})
}
}
@@ -82,13 +80,11 @@ func (l *whereRequireForUpdateDeleteListener) EnterUpdate_statement(ctx *parser.
func (l *whereRequireForUpdateDeleteListener) EnterDelete_statement(ctx *parser.Delete_statementContext) {
if ctx.Where_clause() == nil {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.StatementNoWhere.Int32(),
- Title: l.title,
- Content: "WHERE clause is required for DELETE statement.",
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStop().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.StatementNoWhere.Int32(),
+ Title: l.title,
+ Content: "WHERE clause is required for DELETE statement.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStop().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/oracle/test/column_add_not_null_require_default.yaml b/backend/plugin/advisor/oracle/test/column_add_not_null_require_default.yaml
index ae39bd0bdf..76351123c9 100644
--- a/backend/plugin/advisor/oracle/test/column_add_not_null_require_default.yaml
+++ b/backend/plugin/advisor/oracle/test/column_add_not_null_require_default.yaml
@@ -5,9 +5,8 @@
code: 404
title: column.add-not-null-require-default
content: Adding not null column "READER" requires default.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD reader int DEFAULT 0 NOT NULL
diff --git a/backend/plugin/advisor/oracle/test/column_comment.yaml b/backend/plugin/advisor/oracle/test/column_comment.yaml
index 931af3e302..a4372930fd 100644
--- a/backend/plugin/advisor/oracle/test/column_comment.yaml
+++ b/backend/plugin/advisor/oracle/test/column_comment.yaml
@@ -3,37 +3,47 @@
id int
);
COMMENT ON COLUMN book.id IS 'comments';
+ changeType: 0
- statement: |-
ALTER TABLE t ADD (d int, a int);
COMMENT ON COLUMN t.d IS 'comments';
COMMENT ON COLUMN t.a IS 'comments';
-- statement: |-
- CREATE TABLE t(a int);
+ changeType: 0
+- statement: CREATE TABLE t(a int);
+ changeType: 0
want:
- status: 2
code: 1032
title: column.comment
content: Comment is required for column "TEST_DB"."T"."A"
startposition:
- line: 1
+ line: 0
+ column: 0
+ endposition: null
- statement: |-
ALTER TABLE t ADD (d int, a int);
COMMENT ON COLUMN t.a IS 'comments';
+ changeType: 0
want:
- status: 2
code: 1032
title: column.comment
content: Comment is required for column "TEST_DB"."T"."D"
startposition:
- line: 1
+ line: 0
+ column: 0
+ endposition: null
- statement: |-
CREATE TABLE t(a int);
COMMENT ON COLUMN t.a IS 'comments';
COMMENT ON COLUMN t.a IS '';
+ changeType: 0
want:
- status: 2
code: 1032
title: column.comment
content: Comment is required for column "TEST_DB"."T"."A"
startposition:
- line: 1
+ line: 0
+ column: 0
+ endposition: null
diff --git a/backend/plugin/advisor/oracle/test/column_maximum_character_length.yaml b/backend/plugin/advisor/oracle/test/column_maximum_character_length.yaml
index e1ee40b3fe..071169f7b0 100644
--- a/backend/plugin/advisor/oracle/test/column_maximum_character_length.yaml
+++ b/backend/plugin/advisor/oracle/test/column_maximum_character_length.yaml
@@ -9,9 +9,8 @@
code: 415
title: column.maximum-character-length
content: The maximum character length is 20.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE public.tech_book ADD name_2 char(225)
@@ -21,9 +20,8 @@
code: 415
title: column.maximum-character-length
content: The maximum character length is 20.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book MODIFY name char(225)
@@ -33,8 +31,7 @@
code: 415
title: column.maximum-character-length
content: The maximum character length is 20.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/oracle/test/column_maximum_varchar_length.yaml b/backend/plugin/advisor/oracle/test/column_maximum_varchar_length.yaml
index 9e48ff611e..b94eabcb65 100644
--- a/backend/plugin/advisor/oracle/test/column_maximum_varchar_length.yaml
+++ b/backend/plugin/advisor/oracle/test/column_maximum_varchar_length.yaml
@@ -7,9 +7,8 @@
code: 422
title: column.maximum-varchar-length
content: The maximum varchar length is 2560.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(name varchar(225));
@@ -21,9 +20,8 @@
code: 422
title: column.maximum-varchar-length
content: The maximum varchar length is 2560.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book MODIFY name varchar(22225)
@@ -33,8 +31,7 @@
code: 422
title: column.maximum-varchar-length
content: The maximum varchar length is 2560.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/oracle/test/column_no_null.yaml b/backend/plugin/advisor/oracle/test/column_no_null.yaml
index 4cca81a174..2110713b33 100644
--- a/backend/plugin/advisor/oracle/test/column_no_null.yaml
+++ b/backend/plugin/advisor/oracle/test/column_no_null.yaml
@@ -9,18 +9,16 @@
code: 402
title: column.no-null
content: Column "ID" is nullable, which is not allowed.
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 402
title: column.no-null
content: Column "NAME" is nullable, which is not allowed.
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: CREATE TABLE book(id int, name varchar(255), PRIMARY KEY (id))
@@ -30,9 +28,8 @@
code: 402
title: column.no-null
content: Column "NAME" is nullable, which is not allowed.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255))
@@ -42,9 +39,8 @@
code: 402
title: column.no-null
content: Column "NAME" is nullable, which is not allowed.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id int NOT NULL, name varchar(255))
@@ -54,9 +50,8 @@
code: 402
title: column.no-null
content: Column "NAME" is nullable, which is not allowed.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255) NOT NULL)
@@ -68,9 +63,8 @@
code: 402
title: column.no-null
content: Column "READER" is nullable, which is not allowed.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -88,9 +82,8 @@
code: 402
title: column.no-null
content: Column "NAME" is nullable, which is not allowed.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: -- this is a comment
diff --git a/backend/plugin/advisor/oracle/test/column_require_default.yaml b/backend/plugin/advisor/oracle/test/column_require_default.yaml
index c1c3bbb591..80abfc4f92 100644
--- a/backend/plugin/advisor/oracle/test/column_require_default.yaml
+++ b/backend/plugin/advisor/oracle/test/column_require_default.yaml
@@ -5,9 +5,8 @@
code: 420
title: column.require-default
content: Column "A" doesn't have default value
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -21,8 +20,7 @@
code: 420
title: column.require-default
content: Column "A" doesn't have default value
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/oracle/test/column_required.yaml b/backend/plugin/advisor/oracle/test/column_required.yaml
index 4a4f95aab2..a71c4d33b6 100644
--- a/backend/plugin/advisor/oracle/test/column_required.yaml
+++ b/backend/plugin/advisor/oracle/test/column_required.yaml
@@ -5,9 +5,8 @@
code: 401
title: column.required
content: 'Table "BOOK" requires columns: "created_ts", "creator_id", "updated_ts", "updater_id"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -27,9 +26,8 @@
code: 401
title: column.required
content: 'Table "TECH_BOOK" requires columns: "creator_id"'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -41,8 +39,7 @@
code: 401
title: column.required
content: 'Table "TECH_BOOK" requires columns: "creator_id"'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/oracle/test/column_type_disallow_list.yaml b/backend/plugin/advisor/oracle/test/column_type_disallow_list.yaml
index b4501ebce4..9066a62b6b 100644
--- a/backend/plugin/advisor/oracle/test/column_type_disallow_list.yaml
+++ b/backend/plugin/advisor/oracle/test/column_type_disallow_list.yaml
@@ -7,9 +7,8 @@
code: 411
title: column.type-disallow-list
content: Disallow column type JSON but column "B" is
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -21,9 +20,8 @@
code: 411
title: column.type-disallow-list
content: Disallow column type JSON but column "A" is
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -35,9 +33,8 @@
code: 411
title: column.type-disallow-list
content: Disallow column type BINARY_FLOAT but column "D" is
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: CREATE TABLE t(a int, b BINARY_FLOAT);
@@ -47,9 +44,8 @@
code: 411
title: column.type-disallow-list
content: Disallow column type BINARY_FLOAT but column "B" is
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -61,8 +57,7 @@
code: 411
title: column.type-disallow-list
content: Disallow column type BINARY_FLOAT but column "A" is
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/oracle/test/index_key_number_limit.yaml b/backend/plugin/advisor/oracle/test/index_key_number_limit.yaml
index e552d39e84..c9051e5159 100644
--- a/backend/plugin/advisor/oracle/test/index_key_number_limit.yaml
+++ b/backend/plugin/advisor/oracle/test/index_key_number_limit.yaml
@@ -11,9 +11,8 @@
code: 802
title: index.key-number-limit
content: Index key number should be less than or equal to 5
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(id int, name char(225), c1 int, c2 int, c3 int, c4 int, CONSTRAINT t_id_name UNIQUE (id, name, c1, c2, c3, c4));
@@ -23,9 +22,8 @@
code: 802
title: index.key-number-limit
content: Index key number should be less than or equal to 5
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -37,9 +35,8 @@
code: 802
title: index.key-number-limit
content: Index key number should be less than or equal to 5
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -51,9 +48,8 @@
code: 802
title: index.key-number-limit
content: Index key number should be less than or equal to 5
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -65,8 +61,7 @@
code: 802
title: index.key-number-limit
content: Index key number should be less than or equal to 5
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/oracle/test/naming_identifier_case.yaml b/backend/plugin/advisor/oracle/test/naming_identifier_case.yaml
index 9f0ce69711..487b0dd656 100644
--- a/backend/plugin/advisor/oracle/test/naming_identifier_case.yaml
+++ b/backend/plugin/advisor/oracle/test/naming_identifier_case.yaml
@@ -5,9 +5,8 @@
code: 309
title: naming.identifier.case
content: Identifier "table" should be upper case
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE tt(id int, name varchar(255))
@@ -19,9 +18,8 @@
code: 309
title: naming.identifier.case
content: Identifier "Tt" should be upper case
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book RENAME TO analyze
diff --git a/backend/plugin/advisor/oracle/test/naming_identifier_no_keyword.yaml b/backend/plugin/advisor/oracle/test/naming_identifier_no_keyword.yaml
index c5000aefb2..0881fd76a8 100644
--- a/backend/plugin/advisor/oracle/test/naming_identifier_no_keyword.yaml
+++ b/backend/plugin/advisor/oracle/test/naming_identifier_no_keyword.yaml
@@ -5,18 +5,16 @@
code: 308
title: naming.identifier.no-keyword
content: Identifier "NAME" is a keyword and should be avoided
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 308
title: naming.identifier.no-keyword
content: Identifier "table" is a keyword and should be avoided
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE "rlcmidzlevbivwvcntihenpoibtsdfasdfasdfiutqeb"(id int, name varchar(255))
@@ -26,9 +24,8 @@
code: 308
title: naming.identifier.no-keyword
content: Identifier "NAME" is a keyword and should be avoided
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE analyze(id int, name varchar(255))
@@ -38,9 +35,8 @@
code: 308
title: naming.identifier.no-keyword
content: Identifier "NAME" is a keyword and should be avoided
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book RENAME TO analyze
diff --git a/backend/plugin/advisor/oracle/test/naming_table.yaml b/backend/plugin/advisor/oracle/test/naming_table.yaml
index 88476e1977..bb9349c546 100644
--- a/backend/plugin/advisor/oracle/test/naming_table.yaml
+++ b/backend/plugin/advisor/oracle/test/naming_table.yaml
@@ -5,9 +5,8 @@
code: 301
title: naming.table
content: '"techBook" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE "rlcmidzlevbivwvcntihenpoibtsdfasdfasdfiutqeb"(id int, name varchar(255))
@@ -19,9 +18,8 @@
code: 301
title: naming.table
content: '"TECH_BOOK" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE techBook(id int, name varchar(255))
@@ -31,9 +29,8 @@
code: 301
title: naming.table
content: '"TECHBOOK" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id int, name varchar(255))
@@ -43,9 +40,8 @@
code: 301
title: naming.table
content: '"BOOK" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book RENAME TO "TechBook"
@@ -55,9 +51,8 @@
code: 301
title: naming.table
content: '"TechBook" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -69,18 +64,16 @@
code: 301
title: naming.table
content: '"TECHBOOK" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 301
title: naming.table
content: '"TECH_BOOK_TMP" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -92,8 +85,7 @@
code: 301
title: naming.table
content: '"TECH_BOOK" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/oracle/test/naming_table_no_keyword.yaml b/backend/plugin/advisor/oracle/test/naming_table_no_keyword.yaml
index 3a4dc4e2e3..76f483bb48 100644
--- a/backend/plugin/advisor/oracle/test/naming_table_no_keyword.yaml
+++ b/backend/plugin/advisor/oracle/test/naming_table_no_keyword.yaml
@@ -5,9 +5,8 @@
code: 308
title: naming.table.no-keyword
content: Table name "table" is a keyword identifier and should be avoided.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE "rlcmidzlevbivwvcntihenpoibtsdfasdfasdfiutqeb"(id int, name varchar(255))
@@ -19,9 +18,8 @@
code: 308
title: naming.table.no-keyword
content: Table name "AVG" is a keyword identifier and should be avoided.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book RENAME TO avg
@@ -31,9 +29,8 @@
code: 308
title: naming.table.no-keyword
content: Table name "AVG" is a keyword identifier and should be avoided.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/oracle/test/statement_disallow_mix_in_ddl.yaml b/backend/plugin/advisor/oracle/test/statement_disallow_mix_in_ddl.yaml
index d669b3532f..ac6eea75ef 100644
--- a/backend/plugin/advisor/oracle/test/statement_disallow_mix_in_ddl.yaml
+++ b/backend/plugin/advisor/oracle/test/statement_disallow_mix_in_ddl.yaml
@@ -5,9 +5,8 @@
code: 227
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: UPDATE tech_book SET id = 1;
@@ -17,9 +16,8 @@
code: 227
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD author VARCHAR2(250); UPDATE tech_book SET id = 1;DELETE FROM tech_book WHERE a > 1;
@@ -29,17 +27,15 @@
code: 227
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 227
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/oracle/test/statement_disallow_mix_in_dml.yaml b/backend/plugin/advisor/oracle/test/statement_disallow_mix_in_dml.yaml
index 65953a0022..f0d00cc47f 100644
--- a/backend/plugin/advisor/oracle/test/statement_disallow_mix_in_dml.yaml
+++ b/backend/plugin/advisor/oracle/test/statement_disallow_mix_in_dml.yaml
@@ -9,8 +9,7 @@
code: 227
title: statement.disallow-mix-in-dml
content: Data change can only run DML
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/oracle/test/statement_insert_must_specify_column.yaml b/backend/plugin/advisor/oracle/test/statement_insert_must_specify_column.yaml
index d9000bc8ef..4bc3f0e81e 100644
--- a/backend/plugin/advisor/oracle/test/statement_insert_must_specify_column.yaml
+++ b/backend/plugin/advisor/oracle/test/statement_insert_must_specify_column.yaml
@@ -7,8 +7,7 @@
code: 1107
title: statement.insert.must-specify-column
content: INSERT statement should specify column name.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/oracle/test/statement_select_no_select_all.yaml b/backend/plugin/advisor/oracle/test/statement_select_no_select_all.yaml
index 0548a580f9..2ff05e6e09 100644
--- a/backend/plugin/advisor/oracle/test/statement_select_no_select_all.yaml
+++ b/backend/plugin/advisor/oracle/test/statement_select_no_select_all.yaml
@@ -5,9 +5,8 @@
code: 203
title: statement.select.no-select-all
content: Avoid using SELECT *.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT a, b FROM t
@@ -19,9 +18,8 @@
code: 203
title: statement.select.no-select-all
content: Avoid using SELECT *.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: INSERT INTO t SELECT * FROM t1
@@ -31,8 +29,7 @@
code: 203
title: statement.select.no-select-all
content: Avoid using SELECT *.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/oracle/test/statement_where_no_leading_wildcard_like.yaml b/backend/plugin/advisor/oracle/test/statement_where_no_leading_wildcard_like.yaml
index 8a449b9cec..2da180aa84 100644
--- a/backend/plugin/advisor/oracle/test/statement_where_no_leading_wildcard_like.yaml
+++ b/backend/plugin/advisor/oracle/test/statement_where_no_leading_wildcard_like.yaml
@@ -7,9 +7,8 @@
code: 204
title: statement.where.no-leading-wildcard-like
content: Avoid using leading wildcard LIKE.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT * FROM t WHERE a LIKE 'abc' OR a LIKE '%abc'
@@ -19,9 +18,8 @@
code: 204
title: statement.where.no-leading-wildcard-like
content: Avoid using leading wildcard LIKE.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc'
@@ -31,18 +29,16 @@
code: 204
title: statement.where.no-leading-wildcard-like
content: Avoid using leading wildcard LIKE.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 204
title: statement.where.no-leading-wildcard-like
content: Avoid using leading wildcard LIKE.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT * FROM (SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc') t1
@@ -52,17 +48,15 @@
code: 204
title: statement.where.no-leading-wildcard-like
content: Avoid using leading wildcard LIKE.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 204
title: statement.where.no-leading-wildcard-like
content: Avoid using leading wildcard LIKE.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/oracle/test/statement_where_require_select.yaml b/backend/plugin/advisor/oracle/test/statement_where_require_select.yaml
index fd60f00afd..48afbe8b06 100644
--- a/backend/plugin/advisor/oracle/test/statement_where_require_select.yaml
+++ b/backend/plugin/advisor/oracle/test/statement_where_require_select.yaml
@@ -5,9 +5,8 @@
code: 202
title: statement.where.require.select
content: WHERE clause is required for SELECT statement.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT a FROM t WHERE a > 0
@@ -19,9 +18,8 @@
code: 202
title: statement.where.require.select
content: WHERE clause is required for SELECT statement.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT 1 FROM dual
diff --git a/backend/plugin/advisor/oracle/test/statement_where_require_update_delete.yaml b/backend/plugin/advisor/oracle/test/statement_where_require_update_delete.yaml
index 6fcff0a25c..e7b492f675 100644
--- a/backend/plugin/advisor/oracle/test/statement_where_require_update_delete.yaml
+++ b/backend/plugin/advisor/oracle/test/statement_where_require_update_delete.yaml
@@ -5,9 +5,8 @@
code: 202
title: statement.where.require.update-delete
content: WHERE clause is required for DELETE statement.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: UPDATE t1 SET a = 1
@@ -17,9 +16,8 @@
code: 202
title: statement.where.require.update-delete
content: WHERE clause is required for UPDATE statement.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: DELETE FROM t1 WHERE a > 0
diff --git a/backend/plugin/advisor/oracle/test/table_comment.yaml b/backend/plugin/advisor/oracle/test/table_comment.yaml
index ba2801a790..7922d7da7d 100644
--- a/backend/plugin/advisor/oracle/test/table_comment.yaml
+++ b/backend/plugin/advisor/oracle/test/table_comment.yaml
@@ -4,44 +4,56 @@
name varchar(255)
);
COMMENT ON TABLE book IS 'comments';
-- statement: |-
- CREATE TABLE t(a int);
+ changeType: 0
+- statement: CREATE TABLE t(a int);
+ changeType: 0
want:
- status: 2
code: 1032
title: table.comment
content: Comment is required for table "TEST_DB"."T"
startposition:
- line: 1
+ line: 0
+ column: 0
+ endposition: null
- statement: |-
CREATE TABLE t(a int);
CREATE TABLE d(a int);
COMMENT ON TABLE t IS 'comments';
+ changeType: 0
want:
- status: 2
code: 1032
title: table.comment
content: Comment is required for table "TEST_DB"."D"
startposition:
- line: 2
+ line: 1
+ column: 0
+ endposition: null
- statement: |-
CREATE TABLE t(a int);
COMMENT ON TABLE t IS 'comments';
COMMENT ON TABLE t IS '';
+ changeType: 0
want:
- status: 2
code: 1032
title: table.comment
content: Comment is required for table "TEST_DB"."T"
startposition:
- line: 1
+ line: 0
+ column: 0
+ endposition: null
- statement: |-
CREATE TABLE t(a int);
COMMENT ON TABLE t IS 'looooooong comments';
+ changeType: 0
want:
- status: 2
code: 1301
title: table.comment
content: Table "TEST_DB"."T" comment is too long. The length of comment should be within 10 characters
startposition:
- line: 1
+ line: 0
+ column: 0
+ endposition: null
diff --git a/backend/plugin/advisor/oracle/test/table_no_foreign_key.yaml b/backend/plugin/advisor/oracle/test/table_no_foreign_key.yaml
index b7c575561b..e118a70ccc 100644
--- a/backend/plugin/advisor/oracle/test/table_no_foreign_key.yaml
+++ b/backend/plugin/advisor/oracle/test/table_no_foreign_key.yaml
@@ -5,9 +5,8 @@
code: 602
title: table.no-foreign-key
content: Foreign key is not allowed in the table "TEST_DB"."TECH_BOOK".
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id INT, author_id INT, CONSTRAINT fk_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id))
@@ -17,8 +16,7 @@
code: 602
title: table.no-foreign-key
content: Foreign key is not allowed in the table "TEST_DB"."BOOK".
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/oracle/test/table_require_pk.yaml b/backend/plugin/advisor/oracle/test/table_require_pk.yaml
index aaf8b6db78..e9438c5ad5 100644
--- a/backend/plugin/advisor/oracle/test/table_require_pk.yaml
+++ b/backend/plugin/advisor/oracle/test/table_require_pk.yaml
@@ -9,9 +9,8 @@
code: 601
title: table.require-pk
content: Table "TEST_DB"."T" requires PRIMARY KEY.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -31,8 +30,7 @@
code: 601
title: table.require-pk
content: Table "TEST_DB"."T" requires PRIMARY KEY.
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/advisor_builtin_prior_backup_check.go b/backend/plugin/advisor/pg/advisor_builtin_prior_backup_check.go
index 35f1069e18..4abb85fbd5 100644
--- a/backend/plugin/advisor/pg/advisor_builtin_prior_backup_check.go
+++ b/backend/plugin/advisor/pg/advisor_builtin_prior_backup_check.go
@@ -56,13 +56,11 @@ func (*BuiltinPriorBackupCheckAdvisor) Check(_ context.Context, checkCtx advisor
for _, stmt := range stmtList {
if _, ok := stmt.(ast.DDLNode); ok {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Data change can only run DML, \"%s\" is not DML", stmt.Text()),
- Code: advisor.BuiltinPriorBackupCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Data change can only run DML, \"%s\" is not DML", stmt.Text()),
+ Code: advisor.BuiltinPriorBackupCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_collation_allowlist.go b/backend/plugin/advisor/pg/advisor_collation_allowlist.go
index 2ef603bd0d..5eb434c19c 100644
--- a/backend/plugin/advisor/pg/advisor_collation_allowlist.go
+++ b/backend/plugin/advisor/pg/advisor_collation_allowlist.go
@@ -116,13 +116,11 @@ func (checker *collationAllowlistChecker) Visit(in ast.Node) ast.Visitor {
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Use disabled collation \"%s\", related statement \"%s\"", disabledCollation, checker.text),
- StartPosition: &storepb.Position{
- Line: int32(line),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Use disabled collation \"%s\", related statement \"%s\"", disabledCollation, checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(line),
})
}
diff --git a/backend/plugin/advisor/pg/advisor_column_comment_convention.go b/backend/plugin/advisor/pg/advisor_column_comment_convention.go
index fe9f7eaade..24ffef6a13 100644
--- a/backend/plugin/advisor/pg/advisor_column_comment_convention.go
+++ b/backend/plugin/advisor/pg/advisor_column_comment_convention.go
@@ -65,38 +65,32 @@ func (*ColumnCommentConventionAdvisor) Check(_ context.Context, checkCtx advisor
if commentStmt == nil || commentStmt.Comment == "" {
if checker.payload.Required {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CommentEmpty.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Comment is required for column `%s`", stringifyColumnNameDef(columnName)),
- StartPosition: &storepb.Position{
- Line: int32(columnName.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.CommentEmpty.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Comment is required for column `%s`", stringifyColumnNameDef(columnName)),
+ StartPosition: advisor.ConvertANTLRLineToPosition(columnName.LastLine()),
})
}
} else {
comment := commentStmt.Comment
if checker.payload.MaxLength > 0 && len(comment) > checker.payload.MaxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CommentTooLong.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Column `%s` comment is too long. The length of comment should be within %d characters", stringifyColumnNameDef(columnName), checker.payload.MaxLength),
- StartPosition: &storepb.Position{
- Line: int32(commentStmt.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.CommentTooLong.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Column `%s` comment is too long. The length of comment should be within %d characters", stringifyColumnNameDef(columnName), checker.payload.MaxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(commentStmt.LastLine()),
})
}
if checker.payload.RequiredClassification {
if classification, _ := common.GetClassificationAndUserComment(comment, checker.classificationConfig); classification == "" {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CommentMissingClassification.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Column `%s` comment requires classification", stringifyColumnNameDef(columnName)),
- StartPosition: &storepb.Position{
- Line: int32(commentStmt.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.CommentMissingClassification.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Column `%s` comment requires classification", stringifyColumnNameDef(columnName)),
+ StartPosition: advisor.ConvertANTLRLineToPosition(commentStmt.LastLine()),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_column_default_disallow_volatile.go b/backend/plugin/advisor/pg/advisor_column_default_disallow_volatile.go
index c9f6abc603..71b3f3dadf 100644
--- a/backend/plugin/advisor/pg/advisor_column_default_disallow_volatile.go
+++ b/backend/plugin/advisor/pg/advisor_column_default_disallow_volatile.go
@@ -74,13 +74,11 @@ func (checker *columnDefaultDisallowVolatileChecker) generateAdvice() []*storepb
for _, column := range columnList {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NoDefault.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Column %q.%q in schema %q has volatile DEFAULT", column.table, column.name, column.schema),
- StartPosition: &storepb.Position{
- Line: int32(column.line),
- },
+ Status: checker.level,
+ Code: advisor.NoDefault.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Column %q.%q in schema %q has volatile DEFAULT", column.table, column.name, column.schema),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.line),
})
}
diff --git a/backend/plugin/advisor/pg/advisor_column_disallow_changing_type.go b/backend/plugin/advisor/pg/advisor_column_disallow_changing_type.go
index ca5be441f0..133fb94a37 100644
--- a/backend/plugin/advisor/pg/advisor_column_disallow_changing_type.go
+++ b/backend/plugin/advisor/pg/advisor_column_disallow_changing_type.go
@@ -68,13 +68,11 @@ func (checker *columnDisallowChangingTypeChecker) Visit(in ast.Node) ast.Visitor
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The statement \"%s\" changes column type", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The statement \"%s\" changes column type", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
diff --git a/backend/plugin/advisor/pg/advisor_column_maximum_character_length.go b/backend/plugin/advisor/pg/advisor_column_maximum_character_length.go
index 9a8c011fdb..b1eacaa62a 100644
--- a/backend/plugin/advisor/pg/advisor_column_maximum_character_length.go
+++ b/backend/plugin/advisor/pg/advisor_column_maximum_character_length.go
@@ -107,13 +107,11 @@ func (checker *columnMaximumCharacterLengthChecker) Visit(in ast.Node) ast.Visit
if tableName != "" {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CharLengthExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf(`The length of the CHAR column %q in table %s is bigger than %d, please use VARCHAR instead`, columnName, tableName, checker.maximum),
- StartPosition: &storepb.Position{
- Line: int32(line),
- },
+ Status: checker.level,
+ Code: advisor.CharLengthExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf(`The length of the CHAR column %q in table %s is bigger than %d, please use VARCHAR instead`, columnName, tableName, checker.maximum),
+ StartPosition: advisor.ConvertANTLRLineToPosition(line),
})
}
diff --git a/backend/plugin/advisor/pg/advisor_column_no_null.go b/backend/plugin/advisor/pg/advisor_column_no_null.go
index cfe6a4eda0..d706e39012 100644
--- a/backend/plugin/advisor/pg/advisor_column_no_null.go
+++ b/backend/plugin/advisor/pg/advisor_column_no_null.go
@@ -79,13 +79,11 @@ func (checker *columnNoNullChecker) generateAdviceList() []*storepb.Advice {
}
for _, column := range columnList {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.ColumnCannotNull.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf(`Column "%s" in %s cannot have NULL value`, column.column, column.normalizeTableName()),
- StartPosition: &storepb.Position{
- Line: int32(checker.nullableColumns[column]),
- },
+ Status: checker.level,
+ Code: advisor.ColumnCannotNull.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf(`Column "%s" in %s cannot have NULL value`, column.column, column.normalizeTableName()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.nullableColumns[column]),
})
}
diff --git a/backend/plugin/advisor/pg/advisor_column_require_default.go b/backend/plugin/advisor/pg/advisor_column_require_default.go
index 611fb99338..1d7f513d1c 100644
--- a/backend/plugin/advisor/pg/advisor_column_require_default.go
+++ b/backend/plugin/advisor/pg/advisor_column_require_default.go
@@ -87,13 +87,11 @@ func (checker *columnRequireDefaultChecker) generateAdvice() []*storepb.Advice {
})
if columnInfo != nil && !columnInfo.HasDefault() {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NoDefault.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Column %q.%q in schema %q doesn't have DEFAULT", column.table, column.name, column.schema),
- StartPosition: &storepb.Position{
- Line: int32(column.line),
- },
+ Status: checker.level,
+ Code: advisor.NoDefault.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Column %q.%q in schema %q doesn't have DEFAULT", column.table, column.name, column.schema),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.line),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_column_required.go b/backend/plugin/advisor/pg/advisor_column_required.go
index 4f1e41968a..883b9a70d6 100644
--- a/backend/plugin/advisor/pg/advisor_column_required.go
+++ b/backend/plugin/advisor/pg/advisor_column_required.go
@@ -102,13 +102,11 @@ func (checker *columnRequirementChecker) Visit(node ast.Node) ast.Visitor {
// Order it cause the random iteration order in Go, see https://go.dev/blog/maps
sort.Strings(missingColumns)
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NoRequiredColumn.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table %q requires columns: %s", table.Name, strings.Join(missingColumns, ", ")),
- StartPosition: &storepb.Position{
- Line: int32(node.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.NoRequiredColumn.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table %q requires columns: %s", table.Name, strings.Join(missingColumns, ", ")),
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.LastLine()),
})
}
diff --git a/backend/plugin/advisor/pg/advisor_column_type_disallow_list.go b/backend/plugin/advisor/pg/advisor_column_type_disallow_list.go
index 4b3368edef..7cad696442 100644
--- a/backend/plugin/advisor/pg/advisor_column_type_disallow_list.go
+++ b/backend/plugin/advisor/pg/advisor_column_type_disallow_list.go
@@ -137,13 +137,11 @@ func (checker *columnTypeDisallowListChecker) Visit(in ast.Node) ast.Visitor {
for _, column := range columnList {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DisabledColumnType.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Disallow column type %s but column \"%s\".\"%s\" is", column.tp, column.table, column.column),
- StartPosition: &storepb.Position{
- Line: int32(column.line),
- },
+ Status: checker.level,
+ Code: advisor.DisabledColumnType.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Disallow column type %s but column \"%s\".\"%s\" is", column.tp, column.table, column.column),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.line),
})
}
return checker
diff --git a/backend/plugin/advisor/pg/advisor_comment_convention.go b/backend/plugin/advisor/pg/advisor_comment_convention.go
index 81e8803f80..426f9c1cbd 100644
--- a/backend/plugin/advisor/pg/advisor_comment_convention.go
+++ b/backend/plugin/advisor/pg/advisor_comment_convention.go
@@ -78,13 +78,11 @@ func (checker *commentConventionChecker) Visit(node ast.Node) ast.Visitor {
if checker.maxLength > 0 && len(comment.comment) > checker.maxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CommentTooLong.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The length of comment should be within %d characters", checker.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(comment.line),
- },
+ Status: checker.level,
+ Code: advisor.CommentTooLong.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The length of comment should be within %d characters", checker.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(comment.line),
})
}
diff --git a/backend/plugin/advisor/pg/advisor_encoding_allowlist.go b/backend/plugin/advisor/pg/advisor_encoding_allowlist.go
index 00afc0b392..0a17292007 100644
--- a/backend/plugin/advisor/pg/advisor_encoding_allowlist.go
+++ b/backend/plugin/advisor/pg/advisor_encoding_allowlist.go
@@ -85,13 +85,11 @@ func (checker *encodingAllowlistChecker) Visit(in ast.Node) ast.Visitor {
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" used disabled encoding '%s'", checker.text, disabledEncoding),
- StartPosition: &storepb.Position{
- Line: int32(line),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" used disabled encoding '%s'", checker.text, disabledEncoding),
+ StartPosition: advisor.ConvertANTLRLineToPosition(line),
})
}
diff --git a/backend/plugin/advisor/pg/advisor_index_create_concurrently.go b/backend/plugin/advisor/pg/advisor_index_create_concurrently.go
index 7ffe11f6b7..39b3c2e3dd 100644
--- a/backend/plugin/advisor/pg/advisor_index_create_concurrently.go
+++ b/backend/plugin/advisor/pg/advisor_index_create_concurrently.go
@@ -60,25 +60,21 @@ func (checker *indexCreateConcurrentlyChecker) Visit(in ast.Node) ast.Visitor {
case *ast.CreateIndexStmt:
if !node.Concurrently {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CreateIndexUnconcurrently.Int32(),
- Title: checker.title,
- Content: "Creating indexes will block writes on the table, unless use CONCURRENTLY",
- StartPosition: &storepb.Position{
- Line: int32(in.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.CreateIndexUnconcurrently.Int32(),
+ Title: checker.title,
+ Content: "Creating indexes will block writes on the table, unless use CONCURRENTLY",
+ StartPosition: advisor.ConvertANTLRLineToPosition(in.LastLine()),
})
}
case *ast.DropIndexStmt:
if !node.Concurrently {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DropIndexUnconcurrently.Int32(),
- Title: checker.title,
- Content: "Droping indexes will block writes on the table, unless use CONCURRENTLY",
- StartPosition: &storepb.Position{
- Line: int32(in.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.DropIndexUnconcurrently.Int32(),
+ Title: checker.title,
+ Content: "Droping indexes will block writes on the table, unless use CONCURRENTLY",
+ StartPosition: advisor.ConvertANTLRLineToPosition(in.LastLine()),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_index_key_number_limit.go b/backend/plugin/advisor/pg/advisor_index_key_number_limit.go
index 0624952bf6..edf3e950c9 100644
--- a/backend/plugin/advisor/pg/advisor_index_key_number_limit.go
+++ b/backend/plugin/advisor/pg/advisor_index_key_number_limit.go
@@ -100,13 +100,11 @@ func (checker *indexKeyNumberLimitChecker) Visit(node ast.Node) ast.Visitor {
for _, index := range indexDataList {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.IndexKeyNumberExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The number of keys of index %q in table %q should be not greater than %d", index.indexName, index.tableName, checker.max),
- StartPosition: &storepb.Position{
- Line: int32(index.line),
- },
+ Status: checker.level,
+ Code: advisor.IndexKeyNumberExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The number of keys of index %q in table %q should be not greater than %d", index.indexName, index.tableName, checker.max),
+ StartPosition: advisor.ConvertANTLRLineToPosition(index.line),
})
}
return checker
diff --git a/backend/plugin/advisor/pg/advisor_index_no_duplicate_column.go b/backend/plugin/advisor/pg/advisor_index_no_duplicate_column.go
index 38f9e6d31b..3f81e87b68 100644
--- a/backend/plugin/advisor/pg/advisor_index_no_duplicate_column.go
+++ b/backend/plugin/advisor/pg/advisor_index_no_duplicate_column.go
@@ -120,13 +120,11 @@ func (checker *indexNoDuplicateColumnChecker) Visit(node ast.Node) ast.Visitor {
for _, column := range columnList {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DuplicateColumnInIndex.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("%s \"%s\" has duplicate column \"%s\".\"%s\"", column.constraintType, column.index, column.table, column.column),
- StartPosition: &storepb.Position{
- Line: int32(column.line),
- },
+ Status: checker.level,
+ Code: advisor.DuplicateColumnInIndex.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("%s \"%s\" has duplicate column \"%s\".\"%s\"", column.constraintType, column.index, column.table, column.column),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.line),
})
}
diff --git a/backend/plugin/advisor/pg/advisor_index_primary_key_type_allowlist.go b/backend/plugin/advisor/pg/advisor_index_primary_key_type_allowlist.go
index de2f803c50..d90fd75079 100644
--- a/backend/plugin/advisor/pg/advisor_index_primary_key_type_allowlist.go
+++ b/backend/plugin/advisor/pg/advisor_index_primary_key_type_allowlist.go
@@ -95,13 +95,11 @@ func (checker *indexPrimaryKeyTypeAllowlistChecker) Visit(in ast.Node) ast.Visit
typeText = ""
}
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.IndexPKType.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf(`The column "%s" is one of the primary key, but its type "%s" is not in allowlist`, column.ColumnName, typeText),
- StartPosition: &storepb.Position{
- Line: int32(column.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.IndexPKType.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf(`The column "%s" is one of the primary key, but its type "%s" is not in allowlist`, column.ColumnName, typeText),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.LastLine()),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_index_total_number_limit.go b/backend/plugin/advisor/pg/advisor_index_total_number_limit.go
index 0535af0abc..32998a5f5e 100644
--- a/backend/plugin/advisor/pg/advisor_index_total_number_limit.go
+++ b/backend/plugin/advisor/pg/advisor_index_total_number_limit.go
@@ -104,13 +104,11 @@ func (checker *indexTotalNumberLimitChecker) generateAdvice() []*storepb.Advice
})
if tableInfo != nil && tableInfo.CountIndex() > checker.max {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.IndexCountExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The count of index in table %q.%q should be no more than %d, but found %d", table.schema, table.table, checker.max, tableInfo.CountIndex()),
- StartPosition: &storepb.Position{
- Line: int32(table.line),
- },
+ Status: checker.level,
+ Code: advisor.IndexCountExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The count of index in table %q.%q should be no more than %d, but found %d", table.schema, table.table, checker.max, tableInfo.CountIndex()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(table.line),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_insert_disallow_order_by_rand.go b/backend/plugin/advisor/pg/advisor_insert_disallow_order_by_rand.go
index 7128b09165..10fe545f5f 100644
--- a/backend/plugin/advisor/pg/advisor_insert_disallow_order_by_rand.go
+++ b/backend/plugin/advisor/pg/advisor_insert_disallow_order_by_rand.go
@@ -73,13 +73,11 @@ func (checker *insertDisallowOrderByRandChecker) Visit(in ast.Node) ast.Visitor
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The INSERT statement uses ORDER BY random() or random_between(), related statement \"%s\"", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(in.LastLine()),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The INSERT statement uses ORDER BY random() or random_between(), related statement \"%s\"", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(in.LastLine()),
})
}
diff --git a/backend/plugin/advisor/pg/advisor_insert_must_specify_column.go b/backend/plugin/advisor/pg/advisor_insert_must_specify_column.go
index b2ef515d25..b35511babb 100644
--- a/backend/plugin/advisor/pg/advisor_insert_must_specify_column.go
+++ b/backend/plugin/advisor/pg/advisor_insert_must_specify_column.go
@@ -61,13 +61,11 @@ type insertMustSpecifyColumnChecker struct {
func (checker *insertMustSpecifyColumnChecker) Visit(in ast.Node) ast.Visitor {
if node, ok := in.(*ast.InsertStmt); ok && len(node.ColumnList) == 0 {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.InsertNotSpecifyColumn.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The INSERT statement must specify columns but \"%s\" does not", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(node.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.InsertNotSpecifyColumn.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The INSERT statement must specify columns but \"%s\" does not", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.LastLine()),
})
}
diff --git a/backend/plugin/advisor/pg/advisor_insert_row_limit.go b/backend/plugin/advisor/pg/advisor_insert_row_limit.go
index 98accc6165..ea3e3cb867 100644
--- a/backend/plugin/advisor/pg/advisor_insert_row_limit.go
+++ b/backend/plugin/advisor/pg/advisor_insert_row_limit.go
@@ -106,25 +106,21 @@ func (checker *insertRowLimitChecker) Visit(node ast.Node) ast.Visitor {
}, checker.driver, storepb.Engine_POSTGRES, fmt.Sprintf("EXPLAIN %s", node.Text()))
if err != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.InsertTooManyRows.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" dry runs failed: %s", checker.text, err.Error()),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.InsertTooManyRows.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" dry runs failed: %s", checker.text, err.Error()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
} else {
rowCount, err := getAffectedRows(res)
if err != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.Internal.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("failed to get row count for \"%s\": %s", checker.text, err.Error()),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.Internal.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("failed to get row count for \"%s\": %s", checker.text, err.Error()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
} else if rowCount > int64(checker.maxRow) {
code = advisor.InsertTooManyRows
@@ -136,13 +132,11 @@ func (checker *insertRowLimitChecker) Visit(node ast.Node) ast.Visitor {
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The statement \"%s\" inserts %d rows. The count exceeds %d.", checker.text, rows, checker.maxRow),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The statement \"%s\" inserts %d rows. The count exceeds %d.", checker.text, rows, checker.maxRow),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
return checker
diff --git a/backend/plugin/advisor/pg/advisor_migration_compatibility.go b/backend/plugin/advisor/pg/advisor_migration_compatibility.go
index f3520d0578..873917a696 100644
--- a/backend/plugin/advisor/pg/advisor_migration_compatibility.go
+++ b/backend/plugin/advisor/pg/advisor_migration_compatibility.go
@@ -117,13 +117,11 @@ func (checker *compatibilityChecker) Visit(node ast.Node) ast.Visitor {
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" may cause incompatibility with the existing data and code", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(node.LastLine()),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" may cause incompatibility with the existing data and code", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.LastLine()),
})
}
return checker
diff --git a/backend/plugin/advisor/pg/advisor_naming_column.go b/backend/plugin/advisor/pg/advisor_naming_column.go
index 7972c4b467..1aaa72be82 100644
--- a/backend/plugin/advisor/pg/advisor_naming_column.go
+++ b/backend/plugin/advisor/pg/advisor_naming_column.go
@@ -103,25 +103,21 @@ func (checker *namingColumnConventionChecker) Visit(node ast.Node) ast.Visitor {
for _, column := range columnList {
if !checker.format.MatchString(column.name) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingColumnConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\".\"%s\" mismatches column naming convention, naming format should be %q", tableName, column.name, checker.format),
- StartPosition: &storepb.Position{
- Line: int32(column.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingColumnConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\".\"%s\" mismatches column naming convention, naming format should be %q", tableName, column.name, checker.format),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.line),
})
}
if checker.maxLength > 0 && len(column.name) > checker.maxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingColumnConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\".\"%s\" mismatches column naming convention, its length should be within %d characters", tableName, column.name, checker.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(column.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingColumnConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\".\"%s\" mismatches column naming convention, its length should be within %d characters", tableName, column.name, checker.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.line),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_naming_foreign_key_convention.go b/backend/plugin/advisor/pg/advisor_naming_foreign_key_convention.go
index 487e250421..ec92743996 100644
--- a/backend/plugin/advisor/pg/advisor_naming_foreign_key_convention.go
+++ b/backend/plugin/advisor/pg/advisor_naming_foreign_key_convention.go
@@ -91,24 +91,20 @@ func (checker *namingFKConventionChecker) Visit(in ast.Node) ast.Visitor {
}
if !regex.MatchString(indexData.indexName) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingFKConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf(`Foreign key in table "%s" mismatches the naming convention, expect %q but found "%s"`, indexData.tableName, regex, indexData.indexName),
- StartPosition: &storepb.Position{
- Line: int32(indexData.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingFKConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf(`Foreign key in table "%s" mismatches the naming convention, expect %q but found "%s"`, indexData.tableName, regex, indexData.indexName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(indexData.line),
})
}
if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingFKConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf(`Foreign key "%s" in table "%s" mismatches the naming convention, its length should be within %d characters`, indexData.indexName, indexData.tableName, checker.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(indexData.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingFKConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf(`Foreign key "%s" in table "%s" mismatches the naming convention, its length should be within %d characters`, indexData.indexName, indexData.tableName, checker.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(indexData.line),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_naming_fully_qualified.go b/backend/plugin/advisor/pg/advisor_naming_fully_qualified.go
index 7310ed8570..5cde0ce6e4 100644
--- a/backend/plugin/advisor/pg/advisor_naming_fully_qualified.go
+++ b/backend/plugin/advisor/pg/advisor_naming_fully_qualified.go
@@ -165,13 +165,11 @@ func (checker *FullyQualifiedObjectNameChecker) appendAdviceByObjName(objName st
re := regexp.MustCompile(`.+\..+`)
if !re.MatchString(objName) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.status,
- Code: advisor.NamingNotFullyQualifiedName,
- Title: checker.title,
- Content: fmt.Sprintf("unqualified object name: '%s'", objName),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.status,
+ Code: advisor.NamingNotFullyQualifiedName,
+ Title: checker.title,
+ Content: fmt.Sprintf("unqualified object name: '%s'", objName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_naming_index_convention.go b/backend/plugin/advisor/pg/advisor_naming_index_convention.go
index dbad6d6792..0f24daf3db 100644
--- a/backend/plugin/advisor/pg/advisor_naming_index_convention.go
+++ b/backend/plugin/advisor/pg/advisor_naming_index_convention.go
@@ -85,24 +85,20 @@ func (checker *namingIndexConventionChecker) Visit(node ast.Node) ast.Visitor {
}
if !regex.MatchString(indexData.indexName) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingIndexConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Index in table %q mismatches the naming convention, expect %q but found %q", indexData.tableName, regex, indexData.indexName),
- StartPosition: &storepb.Position{
- Line: int32(node.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.NamingIndexConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Index in table %q mismatches the naming convention, expect %q but found %q", indexData.tableName, regex, indexData.indexName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.LastLine()),
})
}
if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingIndexConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Index %q in table %q mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(node.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.NamingIndexConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Index %q in table %q mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.LastLine()),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_naming_primary_key_convention.go b/backend/plugin/advisor/pg/advisor_naming_primary_key_convention.go
index 7164a6a6b4..ed07bb5f84 100644
--- a/backend/plugin/advisor/pg/advisor_naming_primary_key_convention.go
+++ b/backend/plugin/advisor/pg/advisor_naming_primary_key_convention.go
@@ -86,24 +86,20 @@ func (checker *namingPKConventionChecker) Visit(in ast.Node) ast.Visitor {
}
if !regex.MatchString(indexData.indexName) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingPKConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf(`Primary key in table "%s" mismatches the naming convention, expect %q but found "%s"`, indexData.tableName, regex, indexData.indexName),
- StartPosition: &storepb.Position{
- Line: int32(indexData.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingPKConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf(`Primary key in table "%s" mismatches the naming convention, expect %q but found "%s"`, indexData.tableName, regex, indexData.indexName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(indexData.line),
})
}
if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingPKConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf(`Primary key "%s" in table "%s" mismatches the naming convention, its length should be within %d characters`, indexData.indexName, indexData.tableName, checker.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(indexData.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingPKConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf(`Primary key "%s" in table "%s" mismatches the naming convention, its length should be within %d characters`, indexData.indexName, indexData.tableName, checker.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(indexData.line),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_naming_table.go b/backend/plugin/advisor/pg/advisor_naming_table.go
index 179e9792d1..b4bccf0181 100644
--- a/backend/plugin/advisor/pg/advisor_naming_table.go
+++ b/backend/plugin/advisor/pg/advisor_naming_table.go
@@ -79,24 +79,20 @@ func (checker *namingTableConventionChecker) Visit(node ast.Node) ast.Visitor {
for _, tableName := range tableNames {
if !checker.format.MatchString(tableName) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingTableConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf(`"%s" mismatches table naming convention, naming format should be %q`, tableName, checker.format),
- StartPosition: &storepb.Position{
- Line: int32(node.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.NamingTableConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf(`"%s" mismatches table naming convention, naming format should be %q`, tableName, checker.format),
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.LastLine()),
})
}
if checker.maxLength > 0 && len(tableName) > checker.maxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingTableConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" mismatches table naming convention, its length should be within %d characters", tableName, checker.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(node.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.NamingTableConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" mismatches table naming convention, its length should be within %d characters", tableName, checker.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.LastLine()),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_naming_unique_key_convention.go b/backend/plugin/advisor/pg/advisor_naming_unique_key_convention.go
index 4a1e757291..63d0c8fbc5 100644
--- a/backend/plugin/advisor/pg/advisor_naming_unique_key_convention.go
+++ b/backend/plugin/advisor/pg/advisor_naming_unique_key_convention.go
@@ -86,24 +86,20 @@ func (checker *namingUKConventionChecker) Visit(in ast.Node) ast.Visitor {
}
if !regex.MatchString(indexData.indexName) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingUKConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf(`Unique key in table "%s" mismatches the naming convention, expect %q but found "%s"`, indexData.tableName, regex, indexData.indexName),
- StartPosition: &storepb.Position{
- Line: int32(indexData.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingUKConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf(`Unique key in table "%s" mismatches the naming convention, expect %q but found "%s"`, indexData.tableName, regex, indexData.indexName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(indexData.line),
})
}
if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingUKConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf(`Unique key "%s" in table "%s" mismatches the naming convention, its length should be within %d characters`, indexData.indexName, indexData.tableName, checker.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(indexData.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingUKConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf(`Unique key "%s" in table "%s" mismatches the naming convention, its length should be within %d characters`, indexData.indexName, indexData.tableName, checker.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(indexData.line),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_statement_add_check_not_valid.go b/backend/plugin/advisor/pg/advisor_statement_add_check_not_valid.go
index e3a2165bdc..0d2074e1a7 100644
--- a/backend/plugin/advisor/pg/advisor_statement_add_check_not_valid.go
+++ b/backend/plugin/advisor/pg/advisor_statement_add_check_not_valid.go
@@ -61,13 +61,11 @@ func (checker *statementAddCheckNotValidChecker) Visit(in ast.Node) ast.Visitor
if node, ok := in.(*ast.AddConstraintStmt); ok {
if node.Constraint.Type == ast.ConstraintTypeCheck && !node.Constraint.SkipValidation {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementAddCheckWithValidation.Int32(),
- Title: checker.title,
- Content: "Adding check constraints with validation will block reads and writes. You can add check constraints not valid and then validate separately",
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.StatementAddCheckWithValidation.Int32(),
+ Title: checker.title,
+ Content: "Adding check constraints with validation will block reads and writes. You can add check constraints not valid and then validate separately",
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_statement_add_fk_not_valid.go b/backend/plugin/advisor/pg/advisor_statement_add_fk_not_valid.go
index 2b7e5ce8da..442e295b69 100644
--- a/backend/plugin/advisor/pg/advisor_statement_add_fk_not_valid.go
+++ b/backend/plugin/advisor/pg/advisor_statement_add_fk_not_valid.go
@@ -61,13 +61,11 @@ func (checker *statementAddFKNotValidChecker) Visit(in ast.Node) ast.Visitor {
if node, ok := in.(*ast.AddConstraintStmt); ok {
if node.Constraint.Type == ast.ConstraintTypeForeign && !node.Constraint.SkipValidation {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementAddFKWithValidation.Int32(),
- Title: checker.title,
- Content: "Adding foreign keys with validation will block reads and writes. You can add check foreign keys not valid and then validate separately",
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.StatementAddFKWithValidation.Int32(),
+ Title: checker.title,
+ Content: "Adding foreign keys with validation will block reads and writes. You can add check foreign keys not valid and then validate separately",
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_statement_affected_row_limit.go b/backend/plugin/advisor/pg/advisor_statement_affected_row_limit.go
index c464ef0c6e..9d9e348979 100644
--- a/backend/plugin/advisor/pg/advisor_statement_affected_row_limit.go
+++ b/backend/plugin/advisor/pg/advisor_statement_affected_row_limit.go
@@ -95,25 +95,21 @@ func (checker *statementAffectedRowLimitChecker) Visit(in ast.Node) ast.Visitor
}, checker.driver, storepb.Engine_POSTGRES, fmt.Sprintf("EXPLAIN %s", node.Text()))
if err != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.InsertTooManyRows.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" dry runs failed: %s", checker.text, err.Error()),
- StartPosition: &storepb.Position{
- Line: int32(node.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.InsertTooManyRows.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" dry runs failed: %s", checker.text, err.Error()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.LastLine()),
})
} else {
rowCount, err := getAffectedRows(res)
if err != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.Internal.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("failed to get row count for \"%s\": %s", checker.text, err.Error()),
- StartPosition: &storepb.Position{
- Line: int32(node.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.Internal.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("failed to get row count for \"%s\": %s", checker.text, err.Error()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.LastLine()),
})
} else if rowCount > int64(checker.maxRow) {
code = advisor.StatementAffectedRowExceedsLimit
@@ -124,13 +120,11 @@ func (checker *statementAffectedRowLimitChecker) Visit(in ast.Node) ast.Visitor
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The statement \"%s\" affected %d rows (estimated). The count exceeds %d.", checker.text, rows, checker.maxRow),
- StartPosition: &storepb.Position{
- Line: int32(in.LastLine()),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The statement \"%s\" affected %d rows (estimated). The count exceeds %d.", checker.text, rows, checker.maxRow),
+ StartPosition: advisor.ConvertANTLRLineToPosition(in.LastLine()),
})
}
return checker
diff --git a/backend/plugin/advisor/pg/advisor_statement_create_specify_schema.go b/backend/plugin/advisor/pg/advisor_statement_create_specify_schema.go
index 47ad06acfd..73a2fc863e 100644
--- a/backend/plugin/advisor/pg/advisor_statement_create_specify_schema.go
+++ b/backend/plugin/advisor/pg/advisor_statement_create_specify_schema.go
@@ -55,73 +55,61 @@ func (c *statementCreateSpecifySchemaChecker) Visit(node ast.Node) ast.Visitor {
case *ast.CreateTableStmt:
if n.Name.Schema == "" {
c.adviceList = append(c.adviceList, &storepb.Advice{
- Status: c.level,
- Code: advisor.StatementCreateWithoutSchemaName.Int32(),
- Title: c.title,
- Content: "Table schema should be specified.",
- StartPosition: &storepb.Position{
- Line: int32(node.LastLine()),
- },
+ Status: c.level,
+ Code: advisor.StatementCreateWithoutSchemaName.Int32(),
+ Title: c.title,
+ Content: "Table schema should be specified.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.LastLine()),
})
}
case *ast.CreateExtensionStmt:
if n.Schema == "" {
c.adviceList = append(c.adviceList, &storepb.Advice{
- Status: c.level,
- Code: advisor.StatementCreateWithoutSchemaName.Int32(),
- Title: c.title,
- Content: "Extension schema should be specified.",
- StartPosition: &storepb.Position{
- Line: int32(node.LastLine()),
- },
+ Status: c.level,
+ Code: advisor.StatementCreateWithoutSchemaName.Int32(),
+ Title: c.title,
+ Content: "Extension schema should be specified.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.LastLine()),
})
}
case *ast.CreateFunctionStmt:
if n.Function.Schema == "" {
c.adviceList = append(c.adviceList, &storepb.Advice{
- Status: c.level,
- Code: advisor.StatementCreateWithoutSchemaName.Int32(),
- Title: c.title,
- Content: "Function schema should be specified.",
- StartPosition: &storepb.Position{
- Line: int32(node.LastLine()),
- },
+ Status: c.level,
+ Code: advisor.StatementCreateWithoutSchemaName.Int32(),
+ Title: c.title,
+ Content: "Function schema should be specified.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.LastLine()),
})
}
case *ast.CreateIndexStmt:
if n.Index.Table.Schema == "" {
c.adviceList = append(c.adviceList, &storepb.Advice{
- Status: c.level,
- Code: advisor.StatementCreateWithoutSchemaName.Int32(),
- Title: c.title,
- Content: "Table schema for index should be specified.",
- StartPosition: &storepb.Position{
- Line: int32(node.LastLine()),
- },
+ Status: c.level,
+ Code: advisor.StatementCreateWithoutSchemaName.Int32(),
+ Title: c.title,
+ Content: "Table schema for index should be specified.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.LastLine()),
})
}
case *ast.CreateSequenceStmt:
if n.SequenceDef.SequenceName.Schema == "" {
c.adviceList = append(c.adviceList, &storepb.Advice{
- Status: c.level,
- Code: advisor.StatementCreateWithoutSchemaName.Int32(),
- Title: c.title,
- Content: "Sequence schema should be specified.",
- StartPosition: &storepb.Position{
- Line: int32(node.LastLine()),
- },
+ Status: c.level,
+ Code: advisor.StatementCreateWithoutSchemaName.Int32(),
+ Title: c.title,
+ Content: "Sequence schema should be specified.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.LastLine()),
})
}
case *ast.CreateTriggerStmt:
if n.Trigger.Table.Schema == "" {
c.adviceList = append(c.adviceList, &storepb.Advice{
- Status: c.level,
- Code: advisor.StatementCreateWithoutSchemaName.Int32(),
- Title: c.title,
- Content: "Table schema for trigger should be specified.",
- StartPosition: &storepb.Position{
- Line: int32(node.LastLine()),
- },
+ Status: c.level,
+ Code: advisor.StatementCreateWithoutSchemaName.Int32(),
+ Title: c.title,
+ Content: "Table schema for trigger should be specified.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.LastLine()),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_statement_disallow_add_column_with_default.go b/backend/plugin/advisor/pg/advisor_statement_disallow_add_column_with_default.go
index 9cff54ab56..75509ee0e6 100644
--- a/backend/plugin/advisor/pg/advisor_statement_disallow_add_column_with_default.go
+++ b/backend/plugin/advisor/pg/advisor_statement_disallow_add_column_with_default.go
@@ -62,13 +62,11 @@ func (checker *statementDisallowAddColumnWithDefaultChecker) Visit(in ast.Node)
for _, column := range node.ColumnList {
if setDefault(column) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementAddColumnWithDefault.Int32(),
- Title: checker.title,
- Content: "Adding column with DEFAULT will locked the whole table and rewriting each rows",
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.StatementAddColumnWithDefault.Int32(),
+ Title: checker.title,
+ Content: "Adding column with DEFAULT will locked the whole table and rewriting each rows",
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_statement_disallow_add_not_null.go b/backend/plugin/advisor/pg/advisor_statement_disallow_add_not_null.go
index 1aa4200de4..7a39c7ef82 100644
--- a/backend/plugin/advisor/pg/advisor_statement_disallow_add_not_null.go
+++ b/backend/plugin/advisor/pg/advisor_statement_disallow_add_not_null.go
@@ -61,13 +61,11 @@ type statementDisallowAddNotNullChecker struct {
func (checker *statementDisallowAddNotNullChecker) Visit(in ast.Node) ast.Visitor {
if node, ok := in.(*ast.SetNotNullStmt); ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementAddNotNull.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Setting NOT NULL will block reads and writes. You can use CHECK (%q IS NOT NULL) instead", node.ColumnName),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.StatementAddNotNull.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Setting NOT NULL will block reads and writes. You can use CHECK (%q IS NOT NULL) instead", node.ColumnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
diff --git a/backend/plugin/advisor/pg/advisor_statement_disallow_commit.go b/backend/plugin/advisor/pg/advisor_statement_disallow_commit.go
index 4824c6fbdd..ffe83b16bf 100644
--- a/backend/plugin/advisor/pg/advisor_statement_disallow_commit.go
+++ b/backend/plugin/advisor/pg/advisor_statement_disallow_commit.go
@@ -59,13 +59,11 @@ type statementDisallowCommitChecker struct {
func (checker *statementDisallowCommitChecker) Visit(in ast.Node) ast.Visitor {
if _, ok := in.(*ast.CommitStmt); ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementDisallowCommit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Commit is not allowed, related statement: \"%s\"", in.Text()),
- StartPosition: &storepb.Position{
- Line: int32(in.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementDisallowCommit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Commit is not allowed, related statement: \"%s\"", in.Text()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(in.LastLine()),
})
}
diff --git a/backend/plugin/advisor/pg/advisor_statement_disallow_mix_in_ddl.go b/backend/plugin/advisor/pg/advisor_statement_disallow_mix_in_ddl.go
index dbb153f936..654e57f49a 100644
--- a/backend/plugin/advisor/pg/advisor_statement_disallow_mix_in_ddl.go
+++ b/backend/plugin/advisor/pg/advisor_statement_disallow_mix_in_ddl.go
@@ -47,13 +47,11 @@ func (*StatementDisallowMixInDDLAdvisor) Check(_ context.Context, checkCtx advis
for _, stmt := range stmtList {
if _, ok := stmt.(ast.DMLNode); ok {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Alter schema can only run DDL, \"%s\" is not DDL", stmt.Text()),
- Code: advisor.StatementDisallowMixDDLDML.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Alter schema can only run DDL, \"%s\" is not DDL", stmt.Text()),
+ Code: advisor.StatementDisallowMixDDLDML.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_statement_disallow_mix_in_dml.go b/backend/plugin/advisor/pg/advisor_statement_disallow_mix_in_dml.go
index 8c3ee50a5b..014b4f3cab 100644
--- a/backend/plugin/advisor/pg/advisor_statement_disallow_mix_in_dml.go
+++ b/backend/plugin/advisor/pg/advisor_statement_disallow_mix_in_dml.go
@@ -47,13 +47,11 @@ func (*StatementDisallowMixInDMLAdvisor) Check(_ context.Context, checkCtx advis
for _, stmt := range stmtList {
if _, ok := stmt.(ast.DDLNode); ok {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Data change can only run DML, \"%s\" is not DML", stmt.Text()),
- Code: advisor.StatementDisallowMixDDLDML.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Data change can only run DML, \"%s\" is not DML", stmt.Text()),
+ Code: advisor.StatementDisallowMixDDLDML.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_statement_disallow_on_del_cascade.go b/backend/plugin/advisor/pg/advisor_statement_disallow_on_del_cascade.go
index 70ea154802..38f421abf5 100644
--- a/backend/plugin/advisor/pg/advisor_statement_disallow_on_del_cascade.go
+++ b/backend/plugin/advisor/pg/advisor_statement_disallow_on_del_cascade.go
@@ -9,6 +9,7 @@ import (
pgquery "github.com/pganalyze/pg_query_go/v5"
"github.com/pkg/errors"
+ "github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/plugin/advisor"
storepb "github.com/bytebase/bytebase/proto/generated-go/store"
)
@@ -57,10 +58,10 @@ func (*StatementDisallowOnDelCascadeAdvisor) Check(_ context.Context, checkCtx a
Title: string(checkCtx.Rule.Type),
Content: "The CASCADE option is not permitted for ON DELETE clauses",
Code: advisor.StatementDisallowCascade.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(p.line + 1),
- Column: int32(p.column + 1),
- },
+ StartPosition: common.ConvertANTLRPositionToPosition(&common.ANTLRPosition{
+ Line: int32(p.line),
+ Column: int32(p.column),
+ }, checkCtx.Statements),
})
}
diff --git a/backend/plugin/advisor/pg/advisor_statement_disallow_rm_tbl_cascade.go b/backend/plugin/advisor/pg/advisor_statement_disallow_rm_tbl_cascade.go
index 25178e32a0..9380d5531c 100644
--- a/backend/plugin/advisor/pg/advisor_statement_disallow_rm_tbl_cascade.go
+++ b/backend/plugin/advisor/pg/advisor_statement_disallow_rm_tbl_cascade.go
@@ -9,6 +9,7 @@ import (
pgquery "github.com/pganalyze/pg_query_go/v5"
"github.com/pkg/errors"
+ "github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/plugin/advisor"
storepb "github.com/bytebase/bytebase/proto/generated-go/store"
)
@@ -57,10 +58,10 @@ func (*StatementDisallowRemoveTblCascadeAdvisor) Check(_ context.Context, checkC
Title: string(checkCtx.Rule.Type),
Content: "The use of CASCADE is not permitted when removing a table",
Code: advisor.StatementDisallowCascade.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(p.line + 1),
- Column: int32(p.column + 1),
- },
+ StartPosition: common.ConvertANTLRPositionToPosition(&common.ANTLRPosition{
+ Line: int32(p.line),
+ Column: int32(p.column),
+ }, checkCtx.Statements),
})
}
diff --git a/backend/plugin/advisor/pg/advisor_statement_dml_dry_run.go b/backend/plugin/advisor/pg/advisor_statement_dml_dry_run.go
index ac4ef545e2..cafb4884da 100644
--- a/backend/plugin/advisor/pg/advisor_statement_dml_dry_run.go
+++ b/backend/plugin/advisor/pg/advisor_statement_dml_dry_run.go
@@ -84,13 +84,11 @@ func (checker *statementDmlDryRunChecker) Visit(in ast.Node) ast.Visitor {
PreExecutions: checker.setRoles,
}, checker.driver, storepb.Engine_POSTGRES, fmt.Sprintf("EXPLAIN %s", node.Text())); err != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementDMLDryRunFailed.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" dry runs failed: %s", node.Text(), err.Error()),
- StartPosition: &storepb.Position{
- Line: int32(node.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementDMLDryRunFailed.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" dry runs failed: %s", node.Text(), err.Error()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.LastLine()),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_statement_maximum_limit_value.go b/backend/plugin/advisor/pg/advisor_statement_maximum_limit_value.go
index aefe650a8d..19a2530a37 100644
--- a/backend/plugin/advisor/pg/advisor_statement_maximum_limit_value.go
+++ b/backend/plugin/advisor/pg/advisor_statement_maximum_limit_value.go
@@ -68,13 +68,11 @@ func (checker *statementMaximumLimitValueChecker) Visit(in ast.Node) ast.Visitor
if node, ok := in.(*ast.SelectStmt); ok {
if node.Limit != nil && int(*node.Limit) > checker.limitMaxValue {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementExceedMaximumLimitValue.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The limit value %d exceeds the maximum allowed value %d", *node.Limit, checker.limitMaxValue),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.StatementExceedMaximumLimitValue.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The limit value %d exceeds the maximum allowed value %d", *node.Limit, checker.limitMaxValue),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_statement_merge_alter_table.go b/backend/plugin/advisor/pg/advisor_statement_merge_alter_table.go
index 7b5410f37d..d7ec868feb 100644
--- a/backend/plugin/advisor/pg/advisor_statement_merge_alter_table.go
+++ b/backend/plugin/advisor/pg/advisor_statement_merge_alter_table.go
@@ -62,13 +62,11 @@ func (checker *statementMergeAlterTableChecker) generateAdvice() []*storepb.Advi
for _, table := range tableList {
if table.count > 1 {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementRedundantAlterTable.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("There are %d statements to modify table `%s`", table.count, table.name),
- StartPosition: &storepb.Position{
- Line: int32(table.line),
- },
+ Status: checker.level,
+ Code: advisor.StatementRedundantAlterTable.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("There are %d statements to modify table `%s`", table.count, table.name),
+ StartPosition: advisor.ConvertANTLRLineToPosition(table.line),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_statement_non_transactional.go b/backend/plugin/advisor/pg/advisor_statement_non_transactional.go
index de4fc2e01b..3a56a94039 100644
--- a/backend/plugin/advisor/pg/advisor_statement_non_transactional.go
+++ b/backend/plugin/advisor/pg/advisor_statement_non_transactional.go
@@ -42,13 +42,11 @@ func (*NonTransactionalAdvisor) Check(_ context.Context, checkCtx advisor.Contex
checker.line = stmt.LastLine()
if pg.IsNonTransactionStatement(checker.text) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementNonTransactional.Int32(),
- Title: checker.title,
- Content: "This statement is non-transactional",
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.StatementNonTransactional.Int32(),
+ Title: checker.title,
+ Content: "This statement is non-transactional",
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_statement_object_owner_check.go b/backend/plugin/advisor/pg/advisor_statement_object_owner_check.go
index 4af8ad469a..a01761bac2 100644
--- a/backend/plugin/advisor/pg/advisor_statement_object_owner_check.go
+++ b/backend/plugin/advisor/pg/advisor_statement_object_owner_check.go
@@ -79,13 +79,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Sequence \"%s\" is owned by \"%s\", but the current role is \"%s\".", n.Name.Name, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Sequence \"%s\" is owned by \"%s\", but the current role is \"%s\".", n.Name.Name, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
case *ast.AlterTableStmt:
@@ -110,13 +108,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Table \"%s\" is owned by \"%s\", but the current role is \"%s\".", n.Table.Name, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Table \"%s\" is owned by \"%s\", but the current role is \"%s\".", n.Table.Name, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
case *ast.AlterTypeStmt:
@@ -138,13 +134,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Type \"%s\" is owned by \"%s\", but the current role is \"%s\".", n.Type.Name, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Type \"%s\" is owned by \"%s\", but the current role is \"%s\".", n.Type.Name, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
case *ast.CreateExtensionStmt:
@@ -162,13 +156,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
case *ast.CreateFunctionStmt:
@@ -189,13 +181,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
case *ast.CreateIndexStmt:
@@ -216,26 +206,22 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
case *ast.CreateSchemaStmt:
owner := dbMetadata.GetOwner()
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Database \"%s\" is owned by \"%s\", but the current role is \"%s\".", dbMetadata.GetName(), owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Database \"%s\" is owned by \"%s\", but the current role is \"%s\".", dbMetadata.GetName(), owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
case *ast.CreateSequenceStmt:
@@ -256,13 +242,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
case *ast.CreateTableStmt:
@@ -283,13 +267,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
case *ast.CreateTriggerStmt:
@@ -310,13 +292,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
case *ast.CreateTypeStmt:
@@ -337,13 +317,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
case *ast.CreateViewStmt:
@@ -364,13 +342,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
case *ast.DropFunctionStmt:
@@ -392,13 +368,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
}
@@ -421,13 +395,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
}
@@ -443,13 +415,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
}
@@ -472,13 +442,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
}
@@ -507,13 +475,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Table \"%s\" is owned by \"%s\", but the current role is \"%s\".", table.Name, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Table \"%s\" is owned by \"%s\", but the current role is \"%s\".", table.Name, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
default:
@@ -524,13 +490,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
}
@@ -553,13 +517,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
case *ast.DropTypeStmt:
@@ -581,13 +543,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
}
@@ -606,13 +566,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", schemaName, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
case *ast.RenameSchemaStmt:
@@ -626,13 +584,11 @@ func (*StatementObjectOwnerCheckAdvisor) Check(ctx context.Context, checkCtx adv
}
if owner != currentRole {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", n.Schema, owner, currentRole),
- Code: advisor.StatementObjectOwnerCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Schema \"%s\" is owned by \"%s\", but the current role is \"%s\".", n.Schema, owner, currentRole),
+ Code: advisor.StatementObjectOwnerCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_stmt_no_leading_wildcard_like.go b/backend/plugin/advisor/pg/advisor_stmt_no_leading_wildcard_like.go
index 1f05e0a69b..8059255885 100644
--- a/backend/plugin/advisor/pg/advisor_stmt_no_leading_wildcard_like.go
+++ b/backend/plugin/advisor/pg/advisor_stmt_no_leading_wildcard_like.go
@@ -52,13 +52,11 @@ func (*NoLeadingWildcardLikeAdvisor) Check(_ context.Context, checkCtx advisor.C
if checker.leadingWildcardLike {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementLeadingWildcardLike.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" uses leading wildcard LIKE", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(stmt.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.StatementLeadingWildcardLike.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" uses leading wildcard LIKE", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmt.LastLine()),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_stmt_no_select_all.go b/backend/plugin/advisor/pg/advisor_stmt_no_select_all.go
index f7f8015576..c0d933e3f2 100644
--- a/backend/plugin/advisor/pg/advisor_stmt_no_select_all.go
+++ b/backend/plugin/advisor/pg/advisor_stmt_no_select_all.go
@@ -63,13 +63,11 @@ func (checker *noSelectAllChecker) Visit(node ast.Node) ast.Visitor {
for _, field := range n.FieldList {
if column, ok := field.(*ast.ColumnNameDef); ok && column.ColumnName == "*" {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementSelectAll.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" uses SELECT all", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.StatementSelectAll.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" uses SELECT all", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
break
}
diff --git a/backend/plugin/advisor/pg/advisor_stmt_where_required_select.go b/backend/plugin/advisor/pg/advisor_stmt_where_required_select.go
index 5b8d8ed2d6..9efdc56204 100644
--- a/backend/plugin/advisor/pg/advisor_stmt_where_required_select.go
+++ b/backend/plugin/advisor/pg/advisor_stmt_where_required_select.go
@@ -69,13 +69,11 @@ func (checker *whereRequirementForSelectChecker) Visit(node ast.Node) ast.Visito
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" requires WHERE clause", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" requires WHERE clause", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
return checker
diff --git a/backend/plugin/advisor/pg/advisor_stmt_where_required_update_delete.go b/backend/plugin/advisor/pg/advisor_stmt_where_required_update_delete.go
index 9e74378e44..565252e6aa 100644
--- a/backend/plugin/advisor/pg/advisor_stmt_where_required_update_delete.go
+++ b/backend/plugin/advisor/pg/advisor_stmt_where_required_update_delete.go
@@ -75,13 +75,11 @@ func (checker *whereRequirementForUpdateDeleteChecker) Visit(node ast.Node) ast.
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" requires WHERE clause", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" requires WHERE clause", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
return checker
diff --git a/backend/plugin/advisor/pg/advisor_table_comment_convention.go b/backend/plugin/advisor/pg/advisor_table_comment_convention.go
index ddd78289bf..73803e3250 100644
--- a/backend/plugin/advisor/pg/advisor_table_comment_convention.go
+++ b/backend/plugin/advisor/pg/advisor_table_comment_convention.go
@@ -65,38 +65,32 @@ func (*TableCommentConventionAdvisor) Check(_ context.Context, checkCtx advisor.
if commentStmt == nil || commentStmt.Comment == "" {
if checker.payload.Required {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CommentEmpty.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Comment is required for table `%s`", stringifyTableDef(createTableStmt.Name)),
- StartPosition: &storepb.Position{
- Line: int32(createTableStmt.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.CommentEmpty.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Comment is required for table `%s`", stringifyTableDef(createTableStmt.Name)),
+ StartPosition: advisor.ConvertANTLRLineToPosition(createTableStmt.LastLine()),
})
}
} else {
comment := commentStmt.Comment
if checker.payload.MaxLength > 0 && len(comment) > checker.payload.MaxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CommentTooLong.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table `%s` comment is too long. The length of comment should be within %d characters", stringifyTableDef(createTableStmt.Name), checker.payload.MaxLength),
- StartPosition: &storepb.Position{
- Line: int32(commentStmt.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.CommentTooLong.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table `%s` comment is too long. The length of comment should be within %d characters", stringifyTableDef(createTableStmt.Name), checker.payload.MaxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(commentStmt.LastLine()),
})
}
if checker.payload.RequiredClassification {
if classification, _ := common.GetClassificationAndUserComment(comment, checker.classificationConfig); classification == "" {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CommentMissingClassification.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table `%s` comment requires classification", stringifyTableDef(createTableStmt.Name)),
- StartPosition: &storepb.Position{
- Line: int32(commentStmt.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.CommentMissingClassification.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table `%s` comment requires classification", stringifyTableDef(createTableStmt.Name)),
+ StartPosition: advisor.ConvertANTLRLineToPosition(commentStmt.LastLine()),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_table_disallow_partition.go b/backend/plugin/advisor/pg/advisor_table_disallow_partition.go
index 598d164ac8..c6ecae7d4a 100644
--- a/backend/plugin/advisor/pg/advisor_table_disallow_partition.go
+++ b/backend/plugin/advisor/pg/advisor_table_disallow_partition.go
@@ -74,13 +74,11 @@ func (checker *tableDisallowPartitionChecker) Visit(in ast.Node) ast.Visitor {
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table partition is forbidden, but \"%s\" creates", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table partition is forbidden, but \"%s\" creates", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
diff --git a/backend/plugin/advisor/pg/advisor_table_drop_naming_convention.go b/backend/plugin/advisor/pg/advisor_table_drop_naming_convention.go
index 0fd9fbeea8..b616f6f5ef 100644
--- a/backend/plugin/advisor/pg/advisor_table_drop_naming_convention.go
+++ b/backend/plugin/advisor/pg/advisor_table_drop_naming_convention.go
@@ -69,13 +69,11 @@ func (checker *tableDropNamingConventionChecker) Visit(in ast.Node) ast.Visitor
for _, table := range node.TableList {
if !checker.format.MatchString(table.Name) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.TableDropNamingConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("`%s` mismatches drop table naming convention, naming format should be %q", table.Name, checker.format),
- StartPosition: &storepb.Position{
- Line: int32(node.LastLine()),
- },
+ Status: checker.level,
+ Code: advisor.TableDropNamingConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("`%s` mismatches drop table naming convention, naming format should be %q", table.Name, checker.format),
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.LastLine()),
})
}
}
diff --git a/backend/plugin/advisor/pg/advisor_table_no_fk.go b/backend/plugin/advisor/pg/advisor_table_no_fk.go
index 5252635b77..5bb806d733 100644
--- a/backend/plugin/advisor/pg/advisor_table_no_fk.go
+++ b/backend/plugin/advisor/pg/advisor_table_no_fk.go
@@ -88,9 +88,7 @@ func (checker *tableNoFKChecker) Visit(node ast.Node) ast.Visitor {
tableHasFK.Name,
checker.text,
),
- StartPosition: &storepb.Position{
- Line: int32(node.LastLine()),
- },
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.LastLine()),
})
}
diff --git a/backend/plugin/advisor/pg/advisor_table_require_pk.go b/backend/plugin/advisor/pg/advisor_table_require_pk.go
index 63b854c01d..a019a966c0 100644
--- a/backend/plugin/advisor/pg/advisor_table_require_pk.go
+++ b/backend/plugin/advisor/pg/advisor_table_require_pk.go
@@ -112,9 +112,7 @@ func (checker *tableRequirePKChecker) Visit(node ast.Node) ast.Visitor {
missingPK.Name,
checker.text,
),
- StartPosition: &storepb.Position{
- Line: int32(node.LastLine()),
- },
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.LastLine()),
})
}
diff --git a/backend/plugin/advisor/pg/test/builtin_prior_backup_check.yaml b/backend/plugin/advisor/pg/test/builtin_prior_backup_check.yaml
index 0ece15a37d..37e47c9796 100644
--- a/backend/plugin/advisor/pg/test/builtin_prior_backup_check.yaml
+++ b/backend/plugin/advisor/pg/test/builtin_prior_backup_check.yaml
@@ -36,7 +36,7 @@
title: builtin.prior-backup-check
content: Data change can only run DML, "CREATE TABLE t_test_backup(a int);" is not DML
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SET ROLE role1;DELETE FROM tech_book WHERE a > 1;
diff --git a/backend/plugin/advisor/pg/test/column_comment.yaml b/backend/plugin/advisor/pg/test/column_comment.yaml
index 69f7cc3286..a645b529ca 100644
--- a/backend/plugin/advisor/pg/test/column_comment.yaml
+++ b/backend/plugin/advisor/pg/test/column_comment.yaml
@@ -9,9 +9,8 @@
code: 1032
title: column.comment
content: Comment is required for column `t.a`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -23,9 +22,8 @@
code: 1301
title: column.comment
content: Column `t.a` comment is too long. The length of comment should be within 10 characters
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -37,9 +35,8 @@
code: 1032
title: column.comment
content: Comment is required for column `t.d`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -52,8 +49,7 @@
code: 1032
title: column.comment
content: Comment is required for column `t.a`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/column_default_disallow_volatile.yaml b/backend/plugin/advisor/pg/test/column_default_disallow_volatile.yaml
index d6d64e7940..28a7ad773f 100644
--- a/backend/plugin/advisor/pg/test/column_default_disallow_volatile.yaml
+++ b/backend/plugin/advisor/pg/test/column_default_disallow_volatile.yaml
@@ -7,8 +7,7 @@
code: 420
title: column.default-disallow-volatile
content: Column "tech_book"."b" in schema "public" has volatile DEFAULT
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/column_disallow_change_type.yaml b/backend/plugin/advisor/pg/test/column_disallow_change_type.yaml
index ae9beb9c7f..3e3514b055 100644
--- a/backend/plugin/advisor/pg/test/column_disallow_change_type.yaml
+++ b/backend/plugin/advisor/pg/test/column_disallow_change_type.yaml
@@ -5,9 +5,8 @@
code: 403
title: column.disallow-change-type
content: The statement "ALTER TABLE tech_book ALTER COLUMN id SET DATA TYPE INTEGER" changes column type
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD COLUMN c1 int
diff --git a/backend/plugin/advisor/pg/test/column_maximum_character_length.yaml b/backend/plugin/advisor/pg/test/column_maximum_character_length.yaml
index f59fdf9f31..ef452c0366 100644
--- a/backend/plugin/advisor/pg/test/column_maximum_character_length.yaml
+++ b/backend/plugin/advisor/pg/test/column_maximum_character_length.yaml
@@ -9,9 +9,8 @@
code: 415
title: column.maximum-character-length
content: The length of the CHAR column "name" in table "t" is bigger than 20, please use VARCHAR instead
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE public.tech_book ADD COLUMN name_2 char(225)
@@ -21,9 +20,8 @@
code: 415
title: column.maximum-character-length
content: The length of the CHAR column "name_2" in table "public"."tech_book" is bigger than 20, please use VARCHAR instead
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ALTER COLUMN name SET DATA TYPE char(225)
@@ -33,8 +31,7 @@
code: 415
title: column.maximum-character-length
content: The length of the CHAR column "name" in table "tech_book" is bigger than 20, please use VARCHAR instead
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/column_no_null.yaml b/backend/plugin/advisor/pg/test/column_no_null.yaml
index eaf2bc72d1..9ed943f06e 100644
--- a/backend/plugin/advisor/pg/test/column_no_null.yaml
+++ b/backend/plugin/advisor/pg/test/column_no_null.yaml
@@ -9,18 +9,16 @@
code: 402
title: column.no-null
content: Column "id" in "public"."book" cannot have NULL value
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 402
title: column.no-null
content: Column "name" in "public"."book" cannot have NULL value
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: CREATE TABLE book(id int, name varchar(255), PRIMARY KEY (id))
@@ -30,9 +28,8 @@
code: 402
title: column.no-null
content: Column "name" in "public"."book" cannot have NULL value
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255))
@@ -42,9 +39,8 @@
code: 402
title: column.no-null
content: Column "name" in "public"."book" cannot have NULL value
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id int NOT NULL, name varchar(255))
@@ -54,9 +50,8 @@
code: 402
title: column.no-null
content: Column "name" in "public"."book" cannot have NULL value
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255) NOT NULL)
@@ -68,9 +63,8 @@
code: 402
title: column.no-null
content: Column "reader" in "public"."tech_book" cannot have NULL value
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -87,9 +81,8 @@
code: 402
title: column.no-null
content: Column "name" in "public"."tech_book" cannot have NULL value
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: /* this is a comment */
diff --git a/backend/plugin/advisor/pg/test/column_require_default.yaml b/backend/plugin/advisor/pg/test/column_require_default.yaml
index c92485828c..6f79d64296 100644
--- a/backend/plugin/advisor/pg/test/column_require_default.yaml
+++ b/backend/plugin/advisor/pg/test/column_require_default.yaml
@@ -11,9 +11,8 @@
code: 420
title: column.require-default
content: Column "t"."a" in schema "public" doesn't have DEFAULT
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -25,17 +24,15 @@
code: 420
title: column.require-default
content: Column "tech_book"."a" in schema "public" doesn't have DEFAULT
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 420
title: column.require-default
content: Column "tech_book"."b" in schema "public" doesn't have DEFAULT
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/column_required.yaml b/backend/plugin/advisor/pg/test/column_required.yaml
index 5126e9c295..87f94492c1 100644
--- a/backend/plugin/advisor/pg/test/column_required.yaml
+++ b/backend/plugin/advisor/pg/test/column_required.yaml
@@ -5,9 +5,8 @@
code: 401
title: column.required
content: 'Table "book" requires columns: created_ts, creator_id, updated_ts, updater_id'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -27,9 +26,8 @@
code: 401
title: column.required
content: 'Table "tech_book" requires columns: creator_id'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -41,8 +39,7 @@
code: 401
title: column.required
content: 'Table "tech_book" requires columns: creator_id'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/column_type_disallow_list.yaml b/backend/plugin/advisor/pg/test/column_type_disallow_list.yaml
index 19e5436496..76de5f7519 100644
--- a/backend/plugin/advisor/pg/test/column_type_disallow_list.yaml
+++ b/backend/plugin/advisor/pg/test/column_type_disallow_list.yaml
@@ -7,9 +7,8 @@
code: 411
title: column.type-disallow-list
content: Disallow column type JSON but column "t"."b" is
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -21,8 +20,7 @@
code: 411
title: column.type-disallow-list
content: Disallow column type JSON but column "t"."a" is
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/index_create_concurrently.yaml b/backend/plugin/advisor/pg/test/index_create_concurrently.yaml
index 3425c61974..df3af9285d 100644
--- a/backend/plugin/advisor/pg/test/index_create_concurrently.yaml
+++ b/backend/plugin/advisor/pg/test/index_create_concurrently.yaml
@@ -5,9 +5,8 @@
code: 814
title: index.create-concurrently
content: Creating indexes will block writes on the table, unless use CONCURRENTLY
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: create index concurrently on tech_book(id);
diff --git a/backend/plugin/advisor/pg/test/index_key_number_limit.yaml b/backend/plugin/advisor/pg/test/index_key_number_limit.yaml
index 45aa68b933..b6e2141cda 100644
--- a/backend/plugin/advisor/pg/test/index_key_number_limit.yaml
+++ b/backend/plugin/advisor/pg/test/index_key_number_limit.yaml
@@ -11,9 +11,8 @@
code: 802
title: index.key-number-limit
content: The number of keys of index "t_id_name" in table "t" should be not greater than 5
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(id int, name char(225), c1 int, c2 int, c3 int, c4 int, CONSTRAINT t_id_name UNIQUE (id, name, c1, c2, c3, c4));
@@ -23,9 +22,8 @@
code: 802
title: index.key-number-limit
content: The number of keys of index "t_id_name" in table "t" should be not greater than 5
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -37,9 +35,8 @@
code: 802
title: index.key-number-limit
content: The number of keys of index "idx_address_phone" in table "address" should be not greater than 5
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -51,9 +48,8 @@
code: 802
title: index.key-number-limit
content: The number of keys of index "idx_address_phone" in table "address" should be not greater than 5
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -65,8 +61,7 @@
code: 802
title: index.key-number-limit
content: The number of keys of index "address_id_name" in table "address" should be not greater than 5
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/index_no_duplicate_column.yaml b/backend/plugin/advisor/pg/test/index_no_duplicate_column.yaml
index 9d62992f8e..e8bf233f5d 100644
--- a/backend/plugin/advisor/pg/test/index_no_duplicate_column.yaml
+++ b/backend/plugin/advisor/pg/test/index_no_duplicate_column.yaml
@@ -10,9 +10,8 @@
code: 812
title: index.no-duplicate-column
content: PRIMARY KEY "" has duplicate column "t"."a"
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -24,9 +23,8 @@
code: 812
title: index.no-duplicate-column
content: INDEX "idx_a" has duplicate column "t"."a"
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -38,9 +36,8 @@
code: 812
title: index.no-duplicate-column
content: UNIQUE KEY "uk_a" has duplicate column "t"."a"
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -52,9 +49,8 @@
code: 812
title: index.no-duplicate-column
content: PRIMARY KEY "pk_a" has duplicate column "t"."a"
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -66,8 +62,7 @@
code: 812
title: index.no-duplicate-column
content: FOREIGN KEY "fk_a" has duplicate column "t"."a"
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/index_primary_key_type_allowlist.yaml b/backend/plugin/advisor/pg/test/index_primary_key_type_allowlist.yaml
index 74f88a4198..cb34ab41f0 100644
--- a/backend/plugin/advisor/pg/test/index_primary_key_type_allowlist.yaml
+++ b/backend/plugin/advisor/pg/test/index_primary_key_type_allowlist.yaml
@@ -12,9 +12,8 @@
code: 803
title: index.primary-key-type-allowlist
content: The column "a" is one of the primary key, but its type "character varying(20)" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -28,8 +27,7 @@
code: 803
title: index.primary-key-type-allowlist
content: The column "a" is one of the primary key, but its type "character varying(20)" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/index_total_number_limit.yaml b/backend/plugin/advisor/pg/test/index_total_number_limit.yaml
index 82555c0758..cd3fa42ecf 100644
--- a/backend/plugin/advisor/pg/test/index_total_number_limit.yaml
+++ b/backend/plugin/advisor/pg/test/index_total_number_limit.yaml
@@ -14,9 +14,8 @@
code: 813
title: index.total-number-limit
content: The count of index in table "public"."tech_book" should be no more than 5, but found 8
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- statement: |-
@@ -32,9 +31,8 @@
code: 813
title: index.total-number-limit
content: The count of index in table "public"."t" should be no more than 5, but found 6
- detail: ""
startposition:
- line: 6
+ line: 5
column: 0
endposition: null
- statement: |-
@@ -53,8 +51,7 @@
code: 813
title: index.total-number-limit
content: The count of index in table "public"."t" should be no more than 5, but found 6
- detail: ""
startposition:
- line: 9
+ line: 8
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/naming_column.yaml b/backend/plugin/advisor/pg/test/naming_column.yaml
index 280d67aaf2..7a13a34847 100644
--- a/backend/plugin/advisor/pg/test/naming_column.yaml
+++ b/backend/plugin/advisor/pg/test/naming_column.yaml
@@ -5,9 +5,8 @@
code: 302
title: naming.column
content: '"book"."creatorId" mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id int, qavszgslczmsacubtvyymzhojfytkcmon int)
@@ -25,9 +24,8 @@
code: 302
title: naming.column
content: '"book"."creatorId" mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -43,9 +41,8 @@
code: 302
title: naming.column
content: '"book"."creatorId" mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/pg/test/naming_fully_qualified.yaml b/backend/plugin/advisor/pg/test/naming_fully_qualified.yaml
index 9a70713280..16114f50a0 100644
--- a/backend/plugin/advisor/pg/test/naming_fully_qualified.yaml
+++ b/backend/plugin/advisor/pg/test/naming_fully_qualified.yaml
@@ -9,9 +9,8 @@
code: 310
title: naming.fully-qualified
content: 'unqualified object name: ''pokesv2'''
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- statement: |-
@@ -24,9 +23,8 @@
code: 310
title: naming.fully-qualified
content: 'unqualified object name: ''seq'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -41,9 +39,8 @@
code: 310
title: naming.fully-qualified
content: 'unqualified object name: ''pokesv1'''
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- statement: DROP TRIGGER test_trigger ON public.pokes;
@@ -57,9 +54,8 @@
code: 310
title: naming.fully-qualified
content: 'unqualified object name: ''pokesv1'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -72,9 +68,8 @@
code: 310
title: naming.fully-qualified
content: 'unqualified object name: ''pokesv1'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -89,9 +84,8 @@
code: 310
title: naming.fully-qualified
content: 'unqualified object name: ''pokesv1'''
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- statement: "CREATE TABLE public.pokes (foo int); \nSELECT * FROM (SELECT (id) FROM tech_book) AS foo;"
@@ -101,9 +95,8 @@
code: 310
title: naming.fully-qualified
content: 'unqualified object name: ''tech_book'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: "CREATE TABLE public.pokes (foo int);\nWITH foo1 AS (SELECT * FROM public.tech_book) \nSELECT * FROM foo1;"
diff --git a/backend/plugin/advisor/pg/test/naming_index_fk.yaml b/backend/plugin/advisor/pg/test/naming_index_fk.yaml
index c88d175ccf..544d307271 100644
--- a/backend/plugin/advisor/pg/test/naming_index_fk.yaml
+++ b/backend/plugin/advisor/pg/test/naming_index_fk.yaml
@@ -7,9 +7,8 @@
code: 305
title: naming.index.fk
content: Foreign key in table "tech_book" mismatches the naming convention, expect "^$|^fk_tech_book_author_id_author_id$" but found "fk_author_id"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD CONSTRAINT wlwflloczhmazamdotbibvqrrzyhmvkslvyzpmlmxt FOREIGN KEY (author_id) REFERENCES author (id)
@@ -19,9 +18,8 @@
code: 305
title: naming.index.fk
content: Foreign key in table "tech_book" mismatches the naming convention, expect "^$|^fk_tech_book_author_id_author_id$" but found "wlwflloczhmazamdotbibvqrrzyhmvkslvyzpmlmxt"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD COLUMN author_id INT CONSTRAINT fk_tech_book_author_id_author_id REFERENCES author (id)
@@ -33,9 +31,8 @@
code: 305
title: naming.index.fk
content: Foreign key in table "tech_book" mismatches the naming convention, expect "^$|^fk_tech_book_author_id_author_id$" but found "fk_author_id"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id INT, author_id INT, CONSTRAINT fk_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id))
@@ -47,9 +44,8 @@
code: 305
title: naming.index.fk
content: Foreign key in table "book" mismatches the naming convention, expect "^$|^fk_book_author_id_author_id$" but found "fk_book_author_id"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id INT, author_id INT CONSTRAINT fk_book_author_id_author_id REFERENCES author (id))
@@ -66,8 +62,7 @@
code: 305
title: naming.index.fk
content: Foreign key in table "book" mismatches the naming convention, expect "^$|^fk_book_author_id_author_id$" but found "fk_book_author_id"
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/naming_index_idx.yaml b/backend/plugin/advisor/pg/test/naming_index_idx.yaml
index 3fb40381d6..0ba7f6cd2b 100644
--- a/backend/plugin/advisor/pg/test/naming_index_idx.yaml
+++ b/backend/plugin/advisor/pg/test/naming_index_idx.yaml
@@ -7,9 +7,8 @@
code: 303
title: naming.index.idx
content: Index in table "tech_book" mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found "tech_book_id_name"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE INDEX wfdtqyetsyoovcvikjlyfukxyjxxxhifl ON tech_book(id, name)
@@ -19,9 +18,8 @@
code: 303
title: naming.index.idx
content: Index in table "tech_book" mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found "wfdtqyetsyoovcvikjlyfukxyjxxxhifl"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER INDEX old_index RENAME TO idx_tech_book_id_name
@@ -33,8 +31,7 @@
code: 303
title: naming.index.idx
content: Index in table "tech_book" mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found "idx_tech_book"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/naming_index_pk.yaml b/backend/plugin/advisor/pg/test/naming_index_pk.yaml
index 03f733adb8..84611bdf32 100644
--- a/backend/plugin/advisor/pg/test/naming_index_pk.yaml
+++ b/backend/plugin/advisor/pg/test/naming_index_pk.yaml
@@ -7,9 +7,8 @@
code: 306
title: naming.index.pk
content: Primary key in table "tech_book" mismatches the naming convention, expect "^$|^pk_tech_book_id_name$" but found "tech_book_id_name"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD CONSTRAINT udmhjtnsaablcmjhqcznfiwtnevcehcvw PRIMARY KEY (id, name)
@@ -19,9 +18,8 @@
code: 306
title: naming.index.pk
content: Primary key in table "tech_book" mismatches the naming convention, expect "^$|^pk_tech_book_id_name$" but found "udmhjtnsaablcmjhqcznfiwtnevcehcvw"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id INT, name VARCHAR(20), CONSTRAINT pk_book_name PRIMARY KEY (name))
@@ -39,9 +37,8 @@
code: 306
title: naming.index.pk
content: Primary key in table "book" mismatches the naming convention, expect "^$|^pk_book_name$" but found "tech_book_name"
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- statement: CREATE TABLE book(id INT, name VARCHAR(20), PRIMARY KEY (name))
@@ -57,9 +54,8 @@
code: 306
title: naming.index.pk
content: Primary key in table "tech_book" mismatches the naming convention, expect "^$|^pk_tech_book_id_name$" but found "pk_tech_book"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book RENAME CONSTRAINT old_pk TO pk_tech_book_id_name
@@ -71,9 +67,8 @@
code: 306
title: naming.index.pk
content: Primary key in table "tech_book" mismatches the naming convention, expect "^$|^pk_tech_book_id_name$" but found "pk_tech_book"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER INDEX old_pk RENAME TO pk_tech_book_id_name
@@ -85,8 +80,7 @@
code: 306
title: naming.index.pk
content: Primary key in table "tech_book" mismatches the naming convention, expect "^$|^pk_tech_book_id_name$" but found "pk_tech_book"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/naming_index_uk.yaml b/backend/plugin/advisor/pg/test/naming_index_uk.yaml
index 3acb2e5a4f..afa3ba9bfa 100644
--- a/backend/plugin/advisor/pg/test/naming_index_uk.yaml
+++ b/backend/plugin/advisor/pg/test/naming_index_uk.yaml
@@ -7,9 +7,8 @@
code: 304
title: naming.index.uk
content: Unique key in table "tech_book" mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found "tech_book_id_name"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE UNIQUE INDEX dzfzqbhnkiiegdhvqjeqoevesfuwcmokrehxlapoqj ON tech_book(id, name)
@@ -19,9 +18,8 @@
code: 304
title: naming.index.uk
content: Unique key in table "tech_book" mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found "dzfzqbhnkiiegdhvqjeqoevesfuwcmokrehxlapoqj"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD CONSTRAINT uk_tech_book_id_name UNIQUE (id, name)
@@ -33,9 +31,8 @@
code: 304
title: naming.index.uk
content: Unique key in table "tech_book" mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found "tech_book_id_name"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id INT PRIMARY KEY, name VARCHAR(20), CONSTRAINT uk_book_name UNIQUE (name))
@@ -53,9 +50,8 @@
code: 304
title: naming.index.uk
content: Unique key in table "book" mismatches the naming convention, expect "^$|^uk_book_name$" but found "book_name"
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- statement: CREATE TABLE book(id INT PRIMARY KEY, name VARCHAR(20), UNIQUE (name))
@@ -71,9 +67,8 @@
code: 304
title: naming.index.uk
content: Unique key in table "tech_book" mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found "uk_tech_book"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book RENAME CONSTRAINT old_uk TO uk_tech_book_id_name
@@ -85,9 +80,8 @@
code: 304
title: naming.index.uk
content: Unique key in table "tech_book" mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found "uk_tech_book"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER INDEX old_uk RENAME TO uk_tech_book_id_name
@@ -99,8 +93,7 @@
code: 304
title: naming.index.uk
content: Unique key in table "tech_book" mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found "uk_tech_book"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/naming_table.yaml b/backend/plugin/advisor/pg/test/naming_table.yaml
index 34a0442f87..281b351b7a 100644
--- a/backend/plugin/advisor/pg/test/naming_table.yaml
+++ b/backend/plugin/advisor/pg/test/naming_table.yaml
@@ -5,9 +5,8 @@
code: 301
title: naming.table
content: '"techBook" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE "rlcmidzlevbivwvcntihenpoibtiutqeb"(id int, name varchar(255))
@@ -19,9 +18,8 @@
code: 301
title: naming.table
content: '"_techbook" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE techBook(id int, name varchar(255))
@@ -35,9 +33,8 @@
code: 301
title: naming.table
content: '"TechBook" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -53,17 +50,15 @@
code: 301
title: naming.table
content: '"_techbook" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 301
title: naming.table
content: '"TechBook" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/schema_backward_compatibility.yaml b/backend/plugin/advisor/pg/test/schema_backward_compatibility.yaml
index 9ed982161b..e6199ba5bf 100644
--- a/backend/plugin/advisor/pg/test/schema_backward_compatibility.yaml
+++ b/backend/plugin/advisor/pg/test/schema_backward_compatibility.yaml
@@ -5,8 +5,7 @@
code: 111
title: schema.backward-compatibility
content: '"ALTER TABLE tech_book ALTER COLUMN name TYPE TEXT" may cause incompatibility with the existing data and code'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/statement_add_check_not_valid.yaml b/backend/plugin/advisor/pg/test/statement_add_check_not_valid.yaml
index 7d48197cd9..9a310484a0 100644
--- a/backend/plugin/advisor/pg/test/statement_add_check_not_valid.yaml
+++ b/backend/plugin/advisor/pg/test/statement_add_check_not_valid.yaml
@@ -5,9 +5,8 @@
code: 211
title: statement.add-check-not-valid
content: Adding check constraints with validation will block reads and writes. You can add check constraints not valid and then validate separately
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: alter table tech_book add constraint check_id check(id > 0) NOT VALID;
diff --git a/backend/plugin/advisor/pg/test/statement_add_foreign_key_not_valid.yaml b/backend/plugin/advisor/pg/test/statement_add_foreign_key_not_valid.yaml
index 679df42af4..6664f181e3 100644
--- a/backend/plugin/advisor/pg/test/statement_add_foreign_key_not_valid.yaml
+++ b/backend/plugin/advisor/pg/test/statement_add_foreign_key_not_valid.yaml
@@ -17,9 +17,8 @@
code: 229
title: statement.add-foreign-key-not-valid
content: Adding foreign keys with validation will block reads and writes. You can add check foreign keys not valid and then validate separately
- detail: ""
startposition:
- line: 12
+ line: 11
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/pg/test/statement_check_set_role_variable.yaml b/backend/plugin/advisor/pg/test/statement_check_set_role_variable.yaml
index 8e891ffdca..cde90234f0 100644
--- a/backend/plugin/advisor/pg/test/statement_check_set_role_variable.yaml
+++ b/backend/plugin/advisor/pg/test/statement_check_set_role_variable.yaml
@@ -7,7 +7,6 @@
code: 217
title: statement.check-set-role-variable
content: No SET ROLE statement found.
- detail: ""
startposition:
line: 1
column: 0
diff --git a/backend/plugin/advisor/pg/test/statement_create_specify_schema.yaml b/backend/plugin/advisor/pg/test/statement_create_specify_schema.yaml
index 519d2be11e..e959df2c5e 100644
--- a/backend/plugin/advisor/pg/test/statement_create_specify_schema.yaml
+++ b/backend/plugin/advisor/pg/test/statement_create_specify_schema.yaml
@@ -5,9 +5,8 @@
code: 216
title: statement.create-specify-schema
content: Table schema should be specified.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE public.t(id int);
diff --git a/backend/plugin/advisor/pg/test/statement_disallow_add_column_with_default.yaml b/backend/plugin/advisor/pg/test/statement_disallow_add_column_with_default.yaml
index 2ca213dfef..0451dcf330 100644
--- a/backend/plugin/advisor/pg/test/statement_disallow_add_column_with_default.yaml
+++ b/backend/plugin/advisor/pg/test/statement_disallow_add_column_with_default.yaml
@@ -7,8 +7,7 @@
code: 210
title: statement.disallow-add-column-with-default
content: Adding column with DEFAULT will locked the whole table and rewriting each rows
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/statement_disallow_add_not_null.yaml b/backend/plugin/advisor/pg/test/statement_disallow_add_not_null.yaml
index 148894615b..3c8e081b23 100644
--- a/backend/plugin/advisor/pg/test/statement_disallow_add_not_null.yaml
+++ b/backend/plugin/advisor/pg/test/statement_disallow_add_not_null.yaml
@@ -5,9 +5,8 @@
code: 212
title: statement.disallow-add-not-null
content: Setting NOT NULL will block reads and writes. You can use CHECK ("name" IS NOT NULL) instead
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/pg/test/statement_disallow_commit.yaml b/backend/plugin/advisor/pg/test/statement_disallow_commit.yaml
index 806ff53e06..10735b4545 100644
--- a/backend/plugin/advisor/pg/test/statement_disallow_commit.yaml
+++ b/backend/plugin/advisor/pg/test/statement_disallow_commit.yaml
@@ -8,9 +8,8 @@
code: 206
title: statement.disallow-commit
content: 'Commit is not allowed, related statement: "COMMIT;"'
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -27,17 +26,15 @@
code: 206
title: statement.disallow-commit
content: 'Commit is not allowed, related statement: "COMMIT;"'
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 206
title: statement.disallow-commit
content: 'Commit is not allowed, related statement: "COMMIT;"'
- detail: ""
startposition:
- line: 7
+ line: 6
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/statement_disallow_mix_in_ddl.yaml b/backend/plugin/advisor/pg/test/statement_disallow_mix_in_ddl.yaml
index c3fd0f30ad..2455aa3b98 100644
--- a/backend/plugin/advisor/pg/test/statement_disallow_mix_in_ddl.yaml
+++ b/backend/plugin/advisor/pg/test/statement_disallow_mix_in_ddl.yaml
@@ -5,9 +5,8 @@
code: 227
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL, "DELETE FROM tech_book WHERE a > 1;" is not DDL
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: UPDATE tech_book SET id = 1;
@@ -17,9 +16,8 @@
code: 227
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL, "UPDATE tech_book SET id = 1;" is not DDL
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD COLUMN author TEXT; UPDATE tech_book SET id = 1;DELETE FROM tech_book WHERE a > 1;
@@ -29,17 +27,15 @@
code: 227
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL, "DELETE FROM tech_book WHERE a > 1;" is not DDL
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 227
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL, "UPDATE tech_book SET id = 1;" is not DDL
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/statement_disallow_mix_in_dml.yaml b/backend/plugin/advisor/pg/test/statement_disallow_mix_in_dml.yaml
index 51ccbeb2e8..58503bd9b5 100644
--- a/backend/plugin/advisor/pg/test/statement_disallow_mix_in_dml.yaml
+++ b/backend/plugin/advisor/pg/test/statement_disallow_mix_in_dml.yaml
@@ -9,8 +9,7 @@
code: 227
title: statement.disallow-mix-in-dml
content: Data change can only run DML, "ALTER TABLE tech_book ADD COLUMN author TEXT;" is not DML
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/statement_disallow_on_del_cascade.yaml b/backend/plugin/advisor/pg/test/statement_disallow_on_del_cascade.yaml
index cd6fc488a7..9fad83822e 100644
--- a/backend/plugin/advisor/pg/test/statement_disallow_on_del_cascade.yaml
+++ b/backend/plugin/advisor/pg/test/statement_disallow_on_del_cascade.yaml
@@ -12,10 +12,9 @@
code: 213
title: statement.disallow-on-del-cascade
content: The CASCADE option is not permitted for ON DELETE clauses
- detail: ""
startposition:
- line: 1
- column: 1
+ line: 0
+ column: 0
endposition: null
- statement: |-
CREATE TABLE users (
@@ -39,8 +38,7 @@
code: 213
title: statement.disallow-on-del-cascade
content: The CASCADE option is not permitted for ON DELETE clauses
- detail: ""
startposition:
- line: 3
- column: 1
+ line: 1
+ column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/statement_disallow_rm_tbl_cascade.yaml b/backend/plugin/advisor/pg/test/statement_disallow_rm_tbl_cascade.yaml
index cd02431e62..98bd84ab4f 100644
--- a/backend/plugin/advisor/pg/test/statement_disallow_rm_tbl_cascade.yaml
+++ b/backend/plugin/advisor/pg/test/statement_disallow_rm_tbl_cascade.yaml
@@ -5,10 +5,9 @@
code: 213
title: statement.disallow-rm-tbl-cascade
content: The use of CASCADE is not permitted when removing a table
- detail: ""
startposition:
- line: 1
- column: 1
+ line: 0
+ column: 0
endposition: null
- statement: |-
CREATE TABLE users (
@@ -39,17 +38,15 @@
code: 213
title: statement.disallow-rm-tbl-cascade
content: The use of CASCADE is not permitted when removing a table
- detail: ""
startposition:
- line: 1
- column: 1
+ line: 0
+ column: 0
endposition: null
- status: 2
code: 213
title: statement.disallow-rm-tbl-cascade
content: The use of CASCADE is not permitted when removing a table
- detail: ""
startposition:
- line: 2
- column: 1
+ line: 0
+ column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/statement_insert_disallow_order_by_rand.yaml b/backend/plugin/advisor/pg/test/statement_insert_disallow_order_by_rand.yaml
index 94697b3e9f..c7e7f7c1b8 100644
--- a/backend/plugin/advisor/pg/test/statement_insert_disallow_order_by_rand.yaml
+++ b/backend/plugin/advisor/pg/test/statement_insert_disallow_order_by_rand.yaml
@@ -7,8 +7,7 @@
code: 1108
title: statement.insert.disallow-order-by-rand
content: The INSERT statement uses ORDER BY random() or random_between(), related statement "INSERT INTO tech_book SELECT * FROM tech_book ORDER BY random()"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/statement_insert_must_specify_column.yaml b/backend/plugin/advisor/pg/test/statement_insert_must_specify_column.yaml
index 72316511c2..749b0c4482 100644
--- a/backend/plugin/advisor/pg/test/statement_insert_must_specify_column.yaml
+++ b/backend/plugin/advisor/pg/test/statement_insert_must_specify_column.yaml
@@ -7,8 +7,7 @@
code: 1107
title: statement.insert.must-specify-column
content: The INSERT statement must specify columns but "INSERT INTO tech_book VALUES (1, '1')" does not
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/statement_insert_row_limit.yaml b/backend/plugin/advisor/pg/test/statement_insert_row_limit.yaml
index fcc8a932f4..076fd6dba4 100644
--- a/backend/plugin/advisor/pg/test/statement_insert_row_limit.yaml
+++ b/backend/plugin/advisor/pg/test/statement_insert_row_limit.yaml
@@ -7,9 +7,8 @@
code: 1101
title: statement.insert.row-limit
content: The statement "INSERT INTO tech_book values(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')" inserts 6 rows. The count exceeds 5.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: INSERT INTO tech_book SELECT * FROM tech_book;
diff --git a/backend/plugin/advisor/pg/test/statement_maximum_limit_value.yaml b/backend/plugin/advisor/pg/test/statement_maximum_limit_value.yaml
index 341261a746..2a5837919e 100644
--- a/backend/plugin/advisor/pg/test/statement_maximum_limit_value.yaml
+++ b/backend/plugin/advisor/pg/test/statement_maximum_limit_value.yaml
@@ -6,8 +6,7 @@
code: 222
title: statement.maximum-limit-value
content: The limit value 1000000 exceeds the maximum allowed value 1000
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/statement_merge_alter_table.yaml b/backend/plugin/advisor/pg/test/statement_merge_alter_table.yaml
index a4ad01647b..7b559090b7 100644
--- a/backend/plugin/advisor/pg/test/statement_merge_alter_table.yaml
+++ b/backend/plugin/advisor/pg/test/statement_merge_alter_table.yaml
@@ -10,8 +10,7 @@
code: 207
title: statement.merge-alter-table
content: There are 2 statements to modify table `t`
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/statement_non_transactional.yaml b/backend/plugin/advisor/pg/test/statement_non_transactional.yaml
index 50169065ec..5fe035c84f 100644
--- a/backend/plugin/advisor/pg/test/statement_non_transactional.yaml
+++ b/backend/plugin/advisor/pg/test/statement_non_transactional.yaml
@@ -7,9 +7,8 @@
code: 230
title: statement.non-transactional
content: This statement is non-transactional
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: VACUUM FULL tech_book
@@ -19,8 +18,7 @@
code: 230
title: statement.non-transactional
content: This statement is non-transactional
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/statement_select_no_select_all.yaml b/backend/plugin/advisor/pg/test/statement_select_no_select_all.yaml
index 34d8f8e812..8a32534ec0 100644
--- a/backend/plugin/advisor/pg/test/statement_select_no_select_all.yaml
+++ b/backend/plugin/advisor/pg/test/statement_select_no_select_all.yaml
@@ -5,9 +5,8 @@
code: 203
title: statement.select.no-select-all
content: '"SELECT * FROM t" uses SELECT all'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT a, b FROM t
@@ -19,9 +18,8 @@
code: 203
title: statement.select.no-select-all
content: '"SELECT a, b FROM (SELECT * from t1, t2) t" uses SELECT all'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: INSERT INTO t SELECT * FROM t1
@@ -31,8 +29,7 @@
code: 203
title: statement.select.no-select-all
content: '"INSERT INTO t SELECT * FROM t1" uses SELECT all'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/statement_where_no_leading_wildcard_like.yaml b/backend/plugin/advisor/pg/test/statement_where_no_leading_wildcard_like.yaml
index 223de58bff..241f8c6b50 100644
--- a/backend/plugin/advisor/pg/test/statement_where_no_leading_wildcard_like.yaml
+++ b/backend/plugin/advisor/pg/test/statement_where_no_leading_wildcard_like.yaml
@@ -7,9 +7,8 @@
code: 204
title: statement.where.no-leading-wildcard-like
content: '"SELECT * FROM t WHERE a LIKE ''%abc''" uses leading wildcard LIKE'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT * FROM t WHERE a LIKE 'abc' OR a LIKE '%abc'
@@ -19,9 +18,8 @@
code: 204
title: statement.where.no-leading-wildcard-like
content: '"SELECT * FROM t WHERE a LIKE ''abc'' OR a LIKE ''%abc''" uses leading wildcard LIKE'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc'
@@ -31,9 +29,8 @@
code: 204
title: statement.where.no-leading-wildcard-like
content: '"SELECT * FROM t WHERE a LIKE ''%acc'' OR a LIKE ''%abc''" uses leading wildcard LIKE'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT * FROM (SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc') t1
@@ -43,8 +40,7 @@
code: 204
title: statement.where.no-leading-wildcard-like
content: '"SELECT * FROM (SELECT * FROM t WHERE a LIKE ''%acc'' OR a LIKE ''%abc'') t1" uses leading wildcard LIKE'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/statement_where_require_select.yaml b/backend/plugin/advisor/pg/test/statement_where_require_select.yaml
index 82a490b1a8..cdee2fc94b 100644
--- a/backend/plugin/advisor/pg/test/statement_where_require_select.yaml
+++ b/backend/plugin/advisor/pg/test/statement_where_require_select.yaml
@@ -5,9 +5,8 @@
code: 202
title: statement.where.require.select
content: '"SELECT a FROM t" requires WHERE clause'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT a FROM t WHERE a > 0
@@ -19,9 +18,8 @@
code: 202
title: statement.where.require.select
content: '"SELECT a FROM t WHERE a > (SELECT max(id) FROM user)" requires WHERE clause'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT 1
diff --git a/backend/plugin/advisor/pg/test/statement_where_require_update_delete.yaml b/backend/plugin/advisor/pg/test/statement_where_require_update_delete.yaml
index 481eb4302a..92ca695582 100644
--- a/backend/plugin/advisor/pg/test/statement_where_require_update_delete.yaml
+++ b/backend/plugin/advisor/pg/test/statement_where_require_update_delete.yaml
@@ -5,9 +5,8 @@
code: 202
title: statement.where.require.update-delete
content: '"DELETE FROM t1" requires WHERE clause'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: UPDATE t1 SET a = 1
@@ -17,9 +16,8 @@
code: 202
title: statement.where.require.update-delete
content: '"UPDATE t1 SET a = 1" requires WHERE clause'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: DELETE FROM t1 WHERE a > 0
diff --git a/backend/plugin/advisor/pg/test/system_charset_allowlist.yaml b/backend/plugin/advisor/pg/test/system_charset_allowlist.yaml
index 38989ce842..3300c666eb 100644
--- a/backend/plugin/advisor/pg/test/system_charset_allowlist.yaml
+++ b/backend/plugin/advisor/pg/test/system_charset_allowlist.yaml
@@ -9,7 +9,6 @@
code: 1001
title: system.charset.allowlist
content: '"" used disabled encoding ''latin1'''
- detail: ""
startposition:
line: 0
column: 0
diff --git a/backend/plugin/advisor/pg/test/system_collation_allowlist.yaml b/backend/plugin/advisor/pg/test/system_collation_allowlist.yaml
index f3aefb3e94..90a156c133 100644
--- a/backend/plugin/advisor/pg/test/system_collation_allowlist.yaml
+++ b/backend/plugin/advisor/pg/test/system_collation_allowlist.yaml
@@ -7,9 +7,8 @@
code: 1201
title: system.collation.allowlist
content: Use disabled collation "unknown", related statement "CREATE TABLE t(a text COLLATE "unknown")"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD COLUMN c1 text COLLATE "unknown"
@@ -19,9 +18,8 @@
code: 1201
title: system.collation.allowlist
content: Use disabled collation "unknown", related statement "ALTER TABLE tech_book ADD COLUMN c1 text COLLATE "unknown""
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ALTER COLUMN id TYPE text COLLATE "unknown"
@@ -31,8 +29,7 @@
code: 1201
title: system.collation.allowlist
content: Use disabled collation "unknown", related statement "ALTER TABLE tech_book ALTER COLUMN id TYPE text COLLATE "unknown""
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/system_comment_length.yaml b/backend/plugin/advisor/pg/test/system_comment_length.yaml
index 5e74b88d18..5cf3be82ad 100644
--- a/backend/plugin/advisor/pg/test/system_comment_length.yaml
+++ b/backend/plugin/advisor/pg/test/system_comment_length.yaml
@@ -7,9 +7,8 @@
code: 1301
title: system.comment.length
content: The length of comment should be within 20 characters
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: comment on table public is 'is a table name'
@@ -21,8 +20,7 @@
code: 1301
title: system.comment.length
content: The length of comment should be within 20 characters
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/table_comment.yaml b/backend/plugin/advisor/pg/test/table_comment.yaml
index bd241ec469..981bd1327c 100644
--- a/backend/plugin/advisor/pg/test/table_comment.yaml
+++ b/backend/plugin/advisor/pg/test/table_comment.yaml
@@ -9,9 +9,8 @@
code: 1032
title: table.comment
content: Comment is required for table `t`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -24,9 +23,8 @@
code: 1032
title: table.comment
content: Comment is required for table `d`
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -39,9 +37,8 @@
code: 1032
title: table.comment
content: Comment is required for table `t`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -54,9 +51,8 @@
code: 1032
title: table.comment
content: Comment is required for table `t`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -68,8 +64,7 @@
code: 1301
title: table.comment
content: Table `t` comment is too long. The length of comment should be within 10 characters
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/table_disallow_partition.yaml b/backend/plugin/advisor/pg/test/table_disallow_partition.yaml
index 0465be2695..55da4e8451 100644
--- a/backend/plugin/advisor/pg/test/table_disallow_partition.yaml
+++ b/backend/plugin/advisor/pg/test/table_disallow_partition.yaml
@@ -7,9 +7,8 @@
code: 608
title: table.disallow-partition
content: Table partition is forbidden, but "CREATE TABLE t(a int) PARTITION BY RANGE (a);" creates
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ATTACH PARTITION p1 DEFAULT;
@@ -19,8 +18,7 @@
code: 608
title: table.disallow-partition
content: Table partition is forbidden, but "ALTER TABLE tech_book ATTACH PARTITION p1 DEFAULT;" creates
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/table_drop_naming_convention.yaml b/backend/plugin/advisor/pg/test/table_drop_naming_convention.yaml
index 80e1fdc6e5..b1271e3866 100644
--- a/backend/plugin/advisor/pg/test/table_drop_naming_convention.yaml
+++ b/backend/plugin/advisor/pg/test/table_drop_naming_convention.yaml
@@ -7,9 +7,8 @@
code: 603
title: table.drop-naming-convention
content: '`foo` mismatches drop table naming convention, naming format should be "_delete$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: DROP TABLE IF EXISTS foo_delete, bar
@@ -19,8 +18,7 @@
code: 603
title: table.drop-naming-convention
content: '`bar` mismatches drop table naming convention, naming format should be "_delete$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/table_no_foreign_key.yaml b/backend/plugin/advisor/pg/test/table_no_foreign_key.yaml
index a3c70f19ee..acd4481b0c 100644
--- a/backend/plugin/advisor/pg/test/table_no_foreign_key.yaml
+++ b/backend/plugin/advisor/pg/test/table_no_foreign_key.yaml
@@ -5,9 +5,8 @@
code: 602
title: table.no-foreign-key
content: 'Foreign key is not allowed in the table "public"."tech_book", related statement: "ALTER TABLE tech_book ADD CONSTRAINT fk_tech_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id)"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id INT, author_id INT, CONSTRAINT fk_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id))
@@ -17,8 +16,7 @@
code: 602
title: table.no-foreign-key
content: 'Foreign key is not allowed in the table "public"."book", related statement: "CREATE TABLE book(id INT, author_id INT, CONSTRAINT fk_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id))"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/pg/test/table_require_pk.yaml b/backend/plugin/advisor/pg/test/table_require_pk.yaml
index d8cdbee491..8440f60aca 100644
--- a/backend/plugin/advisor/pg/test/table_require_pk.yaml
+++ b/backend/plugin/advisor/pg/test/table_require_pk.yaml
@@ -9,9 +9,8 @@
code: 601
title: table.require-pk
content: 'Table "public"."t" requires PRIMARY KEY, related statement: "CREATE TABLE t(id INT)"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE "tech_book" DROP CONSTRAINT "old_pk"
@@ -21,9 +20,8 @@
code: 601
title: table.require-pk
content: 'Table "public"."tech_book" requires PRIMARY KEY, related statement: "ALTER TABLE \"tech_book\" DROP CONSTRAINT \"old_pk\""'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE "tech_book" DROP CONSTRAINT "old_index"
@@ -37,9 +35,8 @@
code: 601
title: table.require-pk
content: 'Table "public"."tech_book" requires PRIMARY KEY, related statement: "ALTER TABLE \"tech_book\" DROP COLUMN id"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/snowflake/advisor_column_maximum_varchar_length.go b/backend/plugin/advisor/snowflake/advisor_column_maximum_varchar_length.go
index 9adc6b0b17..d75414ed31 100644
--- a/backend/plugin/advisor/snowflake/advisor_column_maximum_varchar_length.go
+++ b/backend/plugin/advisor/snowflake/advisor_column_maximum_varchar_length.go
@@ -94,13 +94,11 @@ func (l *columnMaximumVarcharLengthChecker) EnterData_type(ctx *parser.Data_type
if length > l.maximum {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.VarcharLengthExceedsLimit.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("The maximum varchar length is %d.", l.maximum),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.VarcharLengthExceedsLimit.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("The maximum varchar length is %d.", l.maximum),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/snowflake/advisor_column_no_null.go b/backend/plugin/advisor/snowflake/advisor_column_no_null.go
index e61a0a936b..89cb0ade2c 100644
--- a/backend/plugin/advisor/snowflake/advisor_column_no_null.go
+++ b/backend/plugin/advisor/snowflake/advisor_column_no_null.go
@@ -80,13 +80,11 @@ func (l *columnNoNullChecker) EnterCreate_table(ctx *parser.Create_tableContext)
func (l *columnNoNullChecker) ExitCreate_table(*parser.Create_tableContext) {
for normalizedColumnName, columnNullableLine := range l.columnNullable {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.ColumnCannotNull.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Column %s is nullable, which is not allowed.", normalizedColumnName),
- StartPosition: &storepb.Position{
- Line: int32(columnNullableLine),
- },
+ Status: l.level,
+ Code: advisor.ColumnCannotNull.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Column %s is nullable, which is not allowed.", normalizedColumnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(columnNullableLine),
})
}
l.currentOriginalTableName = ""
@@ -138,13 +136,11 @@ func (l *columnNoNullChecker) EnterAlter_table(ctx *parser.Alter_tableContext) {
func (l *columnNoNullChecker) ExitAlter_table(*parser.Alter_tableContext) {
for normalizedColumnName, columnNullableLine := range l.columnNullable {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.ColumnCannotNull.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Column %s is nullable, which is not allowed.", normalizedColumnName),
- StartPosition: &storepb.Position{
- Line: int32(columnNullableLine),
- },
+ Status: l.level,
+ Code: advisor.ColumnCannotNull.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Column %s is nullable, which is not allowed.", normalizedColumnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(columnNullableLine),
})
}
l.currentOriginalTableName = ""
@@ -185,13 +181,11 @@ func (l *columnNoNullChecker) EnterAlter_table_alter_column(ctx *parser.Alter_ta
func (l *columnNoNullChecker) ExitAlter_table_alter_column(*parser.Alter_table_alter_columnContext) {
for normalizedColumnName, columnNullableLine := range l.columnNullable {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.ColumnCannotNull.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("After dropping NOT NULL of column %s, it will be nullable, which is not allowed.", normalizedColumnName),
- StartPosition: &storepb.Position{
- Line: int32(columnNullableLine),
- },
+ Status: l.level,
+ Code: advisor.ColumnCannotNull.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("After dropping NOT NULL of column %s, it will be nullable, which is not allowed.", normalizedColumnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(columnNullableLine),
})
}
l.currentOriginalTableName = ""
diff --git a/backend/plugin/advisor/snowflake/advisor_column_require.go b/backend/plugin/advisor/snowflake/advisor_column_require.go
index 301dfad352..557b81c35d 100644
--- a/backend/plugin/advisor/snowflake/advisor_column_require.go
+++ b/backend/plugin/advisor/snowflake/advisor_column_require.go
@@ -121,13 +121,11 @@ func (l *columnRequireChecker) ExitCreate_table(ctx *parser.Create_tableContext)
})
for _, column := range columnNames {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NoRequiredColumn.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Table %s missing required column %q", l.currentOriginalTableName, column),
- StartPosition: &storepb.Position{
- Line: int32(ctx.Column_decl_item_list().GetStop().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NoRequiredColumn.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Table %s missing required column %q", l.currentOriginalTableName, column),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.Column_decl_item_list().GetStop().GetLine()),
})
}
l.currentOriginalTableName = ""
@@ -169,13 +167,11 @@ func (l *columnRequireChecker) ExitAlter_table(ctx *parser.Alter_tableContext) {
})
for _, column := range columnNames {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NoRequiredColumn.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Table %s missing required column %q", l.currentOriginalTableName, column),
- StartPosition: &storepb.Position{
- Line: int32(ctx.Table_column_action().GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NoRequiredColumn.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Table %s missing required column %q", l.currentOriginalTableName, column),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.Table_column_action().GetStart().GetLine()),
})
}
l.currentOriginalTableName = ""
diff --git a/backend/plugin/advisor/snowflake/advisor_migration_compatibility.go b/backend/plugin/advisor/snowflake/advisor_migration_compatibility.go
index 5a664b8e3a..e645d82c99 100644
--- a/backend/plugin/advisor/snowflake/advisor_migration_compatibility.go
+++ b/backend/plugin/advisor/snowflake/advisor_migration_compatibility.go
@@ -114,13 +114,11 @@ func (l *migrationCompatibilityChecker) EnterDrop_table(ctx *parser.Drop_tableCo
level = storepb.Advice_WARNING
}
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: level,
- Code: advisor.CompatibilityDropTable.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Drop table %q may cause incompatibility with the existing data and code", normalizedFullDropTableName),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: level,
+ Code: advisor.CompatibilityDropTable.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Drop table %q may cause incompatibility with the existing data and code", normalizedFullDropTableName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
@@ -136,13 +134,11 @@ func (l *migrationCompatibilityChecker) EnterDrop_schema(ctx *parser.Drop_schema
level = storepb.Advice_WARNING
}
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: level,
- Code: advisor.CompatibilityDropSchema.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Drop schema %q may cause incompatibility with the existing data and code", normalizedFullDropSchemaName),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: level,
+ Code: advisor.CompatibilityDropSchema.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Drop schema %q may cause incompatibility with the existing data and code", normalizedFullDropSchemaName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
@@ -158,13 +154,11 @@ func (l *migrationCompatibilityChecker) EnterDrop_database(ctx *parser.Drop_data
level = storepb.Advice_WARNING
}
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: level,
- Code: advisor.CompatibilityDropDatabase.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Drop database %q may cause incompatibility with the existing data and code", normalizedFullDropDatabaseName),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: level,
+ Code: advisor.CompatibilityDropDatabase.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Drop database %q may cause incompatibility with the existing data and code", normalizedFullDropDatabaseName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
@@ -184,12 +178,10 @@ func (l *migrationCompatibilityChecker) EnterAlter_table(ctx *parser.Alter_table
normalizedAllColumnNames = append(normalizedAllColumnNames, fmt.Sprintf("%q", snowsqlparser.NormalizeSnowSQLObjectNamePart(columnName.Id_())))
}
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.CompatibilityDropColumn.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Drop column %s may cause incompatibility with the existing data and code", strings.Join(normalizedAllColumnNames, ",")),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.CompatibilityDropColumn.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Drop column %s may cause incompatibility with the existing data and code", strings.Join(normalizedAllColumnNames, ",")),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
diff --git a/backend/plugin/advisor/snowflake/advisor_naming_identifier_case.go b/backend/plugin/advisor/snowflake/advisor_naming_identifier_case.go
index 07c28dcd28..fdcceca1b2 100644
--- a/backend/plugin/advisor/snowflake/advisor_naming_identifier_case.go
+++ b/backend/plugin/advisor/snowflake/advisor_naming_identifier_case.go
@@ -105,13 +105,11 @@ func (l *namingIdentifierCaseChecker) EnterColumn_decl_item_list(ctx *parser.Col
originalColName := snowsqlparser.NormalizeSnowSQLObjectNamePart(originalID)
if strings.ToUpper(originalColName) != originalColName {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NamingCaseMismatch.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Identifier %q should be upper case", originalColName),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NamingCaseMismatch.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Identifier %q should be upper case", originalColName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
@@ -128,13 +126,11 @@ func (l *namingIdentifierCaseChecker) EnterAlter_table(ctx *parser.Alter_tableCo
renameToColName := snowsqlparser.NormalizeSnowSQLObjectNamePart(renameToID)
if strings.ToUpper(renameToColName) != renameToColName {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NamingCaseMismatch.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Identifier %q should be upper case", renameToColName),
- StartPosition: &storepb.Position{
- Line: int32(renameToID.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NamingCaseMismatch.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Identifier %q should be upper case", renameToColName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(renameToID.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/snowflake/advisor_naming_identifier_no_keyword.go b/backend/plugin/advisor/snowflake/advisor_naming_identifier_no_keyword.go
index d18991faf9..2ea37a006b 100644
--- a/backend/plugin/advisor/snowflake/advisor_naming_identifier_no_keyword.go
+++ b/backend/plugin/advisor/snowflake/advisor_naming_identifier_no_keyword.go
@@ -103,13 +103,11 @@ func (l *namingIdentifierNoKeywordChecker) EnterColumn_decl_item_list(ctx *parse
originalColName := snowsqlparser.NormalizeSnowSQLObjectNamePart(originalID)
if snowsqlparser.IsSnowflakeKeyword(originalColName, false) {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NameIsKeywordIdentifier.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Identifier %s is a keyword and should be avoided", originalID.GetText()),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NameIsKeywordIdentifier.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Identifier %s is a keyword and should be avoided", originalID.GetText()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
@@ -126,13 +124,11 @@ func (l *namingIdentifierNoKeywordChecker) EnterAlter_table(ctx *parser.Alter_ta
renameToColName := snowsqlparser.NormalizeSnowSQLObjectNamePart(renameToID)
if snowsqlparser.IsSnowflakeKeyword(renameToColName, false) {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NameIsKeywordIdentifier.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Identifier %s is a keyword and should be avoided", renameToID.GetText()),
- StartPosition: &storepb.Position{
- Line: int32(renameToID.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NameIsKeywordIdentifier.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Identifier %s is a keyword and should be avoided", renameToID.GetText()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(renameToID.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/snowflake/advisor_naming_table.go b/backend/plugin/advisor/snowflake/advisor_naming_table.go
index cd9fddbf88..168465e531 100644
--- a/backend/plugin/advisor/snowflake/advisor_naming_table.go
+++ b/backend/plugin/advisor/snowflake/advisor_naming_table.go
@@ -79,24 +79,20 @@ func (l *namingTableListener) EnterCreate_table(ctx *parser.Create_tableContext)
if !l.format.MatchString(tableName) {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NamingTableConventionMismatch.Int32(),
- Title: l.title,
- Content: fmt.Sprintf(`"%s" mismatches table naming convention, naming format should be %q`, tableName, l.format),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NamingTableConventionMismatch.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf(`"%s" mismatches table naming convention, naming format should be %q`, tableName, l.format),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
if l.maxLength > 0 && len(tableName) > l.maxLength {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NamingTableConventionMismatch.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("\"%s\" mismatches table naming convention, its length should be within %d characters", tableName, l.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NamingTableConventionMismatch.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("\"%s\" mismatches table naming convention, its length should be within %d characters", tableName, l.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
@@ -118,24 +114,20 @@ func (l *namingTableListener) EnterAlter_table(ctx *parser.Alter_tableContext) {
if !l.format.MatchString(tableName) {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NamingTableConventionMismatch.Int32(),
- Title: l.title,
- Content: fmt.Sprintf(`"%s" mismatches table naming convention, naming format should be %q`, tableName, l.format),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NamingTableConventionMismatch.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf(`"%s" mismatches table naming convention, naming format should be %q`, tableName, l.format),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
if l.maxLength > 0 && len(tableName) > l.maxLength {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.NamingTableConventionMismatch.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("\"%s\" mismatches table naming convention, its length should be within %d characters", tableName, l.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.NamingTableConventionMismatch.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("\"%s\" mismatches table naming convention, its length should be within %d characters", tableName, l.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/snowflake/advisor_select_no_select_all.go b/backend/plugin/advisor/snowflake/advisor_select_no_select_all.go
index fb5c981e19..46feb9e40b 100644
--- a/backend/plugin/advisor/snowflake/advisor_select_no_select_all.go
+++ b/backend/plugin/advisor/snowflake/advisor_select_no_select_all.go
@@ -66,13 +66,11 @@ func (l *selectNoSelectAllChecker) EnterSelect_list_elem(ctx *parser.Select_list
if v := ctx.Column_elem(); v != nil {
if v.STAR() != nil {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.StatementSelectAll.Int32(),
- Title: l.title,
- Content: "Avoid using SELECT *.",
- StartPosition: &storepb.Position{
- Line: int32(v.STAR().GetSymbol().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.StatementSelectAll.Int32(),
+ Title: l.title,
+ Content: "Avoid using SELECT *.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(v.STAR().GetSymbol().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/snowflake/advisor_table_drop_naming_convention.go b/backend/plugin/advisor/snowflake/advisor_table_drop_naming_convention.go
index d3dc829623..c7161e20fa 100644
--- a/backend/plugin/advisor/snowflake/advisor_table_drop_naming_convention.go
+++ b/backend/plugin/advisor/snowflake/advisor_table_drop_naming_convention.go
@@ -75,13 +75,11 @@ func (l *tableDropNamingConventionChecker) EnterDrop_table(ctx *parser.Drop_tabl
normalizedObjectName := snowsqlparser.NormalizeSnowSQLObjectNamePart(ctx.Object_name().GetO())
if !l.format.MatchString(normalizedObjectName) {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.TableDropNamingConventionMismatch.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("%q mismatches drop table naming convention, naming format should be %q", normalizedObjectName, l.format),
- StartPosition: &storepb.Position{
- Line: int32(ctx.Object_name().GetO().GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.TableDropNamingConventionMismatch.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("%q mismatches drop table naming convention, naming format should be %q", normalizedObjectName, l.format),
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.Object_name().GetO().GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/snowflake/advisor_table_no_foreign_key.go b/backend/plugin/advisor/snowflake/advisor_table_no_foreign_key.go
index 3a03e9faef..082bcae077 100644
--- a/backend/plugin/advisor/snowflake/advisor_table_no_foreign_key.go
+++ b/backend/plugin/advisor/snowflake/advisor_table_no_foreign_key.go
@@ -83,13 +83,11 @@ func (l *tableNoForeignKeyChecker) generateAdvice() ([]*storepb.Advice, error) {
for tableName, times := range l.tableForeignKeyTimes {
if times > 0 {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.TableHasFK.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("FOREIGN KEY is not allowed in the table %s.", l.tableOriginalName[tableName]),
- StartPosition: &storepb.Position{
- Line: int32(l.tableLine[tableName]),
- },
+ Status: l.level,
+ Code: advisor.TableHasFK.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("FOREIGN KEY is not allowed in the table %s.", l.tableOriginalName[tableName]),
+ StartPosition: advisor.ConvertANTLRLineToPosition(l.tableLine[tableName]),
})
}
}
diff --git a/backend/plugin/advisor/snowflake/advisor_table_require_pk.go b/backend/plugin/advisor/snowflake/advisor_table_require_pk.go
index 01c662252f..0705a1d1f7 100644
--- a/backend/plugin/advisor/snowflake/advisor_table_require_pk.go
+++ b/backend/plugin/advisor/snowflake/advisor_table_require_pk.go
@@ -83,13 +83,11 @@ func (l *tableRequirePkChecker) generateAdvice() ([]*storepb.Advice, error) {
for tableName, has := range l.tableHasPrimaryKey {
if !has {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.TableNoPK.Int32(),
- Title: l.title,
- Content: fmt.Sprintf("Table %s requires PRIMARY KEY.", l.tableOriginalName[tableName]),
- StartPosition: &storepb.Position{
- Line: int32(l.tableLine[tableName]),
- },
+ Status: l.level,
+ Code: advisor.TableNoPK.Int32(),
+ Title: l.title,
+ Content: fmt.Sprintf("Table %s requires PRIMARY KEY.", l.tableOriginalName[tableName]),
+ StartPosition: advisor.ConvertANTLRLineToPosition(l.tableLine[tableName]),
})
}
}
diff --git a/backend/plugin/advisor/snowflake/advisor_where_require_select.go b/backend/plugin/advisor/snowflake/advisor_where_require_select.go
index d07bace060..67aa3bf2ff 100644
--- a/backend/plugin/advisor/snowflake/advisor_where_require_select.go
+++ b/backend/plugin/advisor/snowflake/advisor_where_require_select.go
@@ -73,13 +73,11 @@ func (l *whereRequireForSelectChecker) EnterQuery_statement(ctx *parser.Query_st
// Allow SELECT queries without a FROM clause to proceed, e.g. SELECT 1.
if optional.Where_clause() == nil && optional.From_clause() != nil {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.StatementNoWhere.Int32(),
- Title: l.title,
- Content: "WHERE clause is required for SELECT statement.",
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.StatementNoWhere.Int32(),
+ Title: l.title,
+ Content: "WHERE clause is required for SELECT statement.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/snowflake/advisor_where_require_update_delete.go b/backend/plugin/advisor/snowflake/advisor_where_require_update_delete.go
index 435e60231e..c0fffbc272 100644
--- a/backend/plugin/advisor/snowflake/advisor_where_require_update_delete.go
+++ b/backend/plugin/advisor/snowflake/advisor_where_require_update_delete.go
@@ -65,13 +65,11 @@ func (l *whereRequireForUpdateDeleteChecker) generateAdvice() ([]*storepb.Advice
func (l *whereRequireForUpdateDeleteChecker) EnterUpdate_statement(ctx *parser.Update_statementContext) {
if ctx.WHERE() == nil {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.StatementNoWhere.Int32(),
- Title: l.title,
- Content: "WHERE clause is required for UPDATE statement.",
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.StatementNoWhere.Int32(),
+ Title: l.title,
+ Content: "WHERE clause is required for UPDATE statement.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
@@ -80,13 +78,11 @@ func (l *whereRequireForUpdateDeleteChecker) EnterUpdate_statement(ctx *parser.U
func (l *whereRequireForUpdateDeleteChecker) EnterDelete_statement(ctx *parser.Delete_statementContext) {
if ctx.WHERE() == nil {
l.adviceList = append(l.adviceList, &storepb.Advice{
- Status: l.level,
- Code: advisor.StatementNoWhere.Int32(),
- Title: l.title,
- Content: "WHERE clause is required for DELETE statement.",
- StartPosition: &storepb.Position{
- Line: int32(ctx.GetStart().GetLine()),
- },
+ Status: l.level,
+ Code: advisor.StatementNoWhere.Int32(),
+ Title: l.title,
+ Content: "WHERE clause is required for DELETE statement.",
+ StartPosition: advisor.ConvertANTLRLineToPosition(ctx.GetStart().GetLine()),
})
}
}
diff --git a/backend/plugin/advisor/snowflake/test/column_maximum_varchar_length.yaml b/backend/plugin/advisor/snowflake/test/column_maximum_varchar_length.yaml
index ecd1f8a45d..d1d91778c0 100644
--- a/backend/plugin/advisor/snowflake/test/column_maximum_varchar_length.yaml
+++ b/backend/plugin/advisor/snowflake/test/column_maximum_varchar_length.yaml
@@ -7,9 +7,8 @@
code: 422
title: column.maximum-varchar-length
content: The maximum varchar length is 2560.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE CUSTOMER(NAME VARCHAR);
@@ -19,9 +18,8 @@
code: 422
title: column.maximum-varchar-length
content: The maximum varchar length is 2560.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE PUBLIC.CUSTOMER ADD NAME_2 VARCHAR(22225);
@@ -31,9 +29,8 @@
code: 422
title: column.maximum-varchar-length
content: The maximum varchar length is 2560.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE PUBLIC.CUSTOMER MODIFY COLUMN NAME VARCHAR(22225);
@@ -43,9 +40,8 @@
code: 422
title: column.maximum-varchar-length
content: The maximum varchar length is 2560.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE PUBLIC.CUSTOMER MODIFY COLUMN NAME VARCHAR(20);
@@ -57,8 +53,7 @@
code: 422
title: column.maximum-varchar-length
content: The maximum varchar length is 2560.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/snowflake/test/column_no_null.yaml b/backend/plugin/advisor/snowflake/test/column_no_null.yaml
index 42b27a73f0..2a0eaa904a 100644
--- a/backend/plugin/advisor/snowflake/test/column_no_null.yaml
+++ b/backend/plugin/advisor/snowflake/test/column_no_null.yaml
@@ -11,18 +11,16 @@
code: 402
title: column.no-null
content: Column AGE is nullable, which is not allowed.
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- status: 2
code: 402
title: column.no-null
content: Column ADDRESS is nullable, which is not allowed.
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- statement: |-
@@ -39,9 +37,8 @@
code: 402
title: column.no-null
content: Column ADDRESS is nullable, which is not allowed.
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- statement: |-
@@ -59,9 +56,8 @@
code: 402
title: column.no-null
content: Column AGE is nullable, which is not allowed.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE a ADD COLUMN age INT NOT NULL;
@@ -73,8 +69,7 @@
code: 402
title: column.no-null
content: After dropping NOT NULL of column AGE, it will be nullable, which is not allowed.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/snowflake/test/column_required.yaml b/backend/plugin/advisor/snowflake/test/column_required.yaml
index 573d4f7e8b..fc5b124aa4 100644
--- a/backend/plugin/advisor/snowflake/test/column_required.yaml
+++ b/backend/plugin/advisor/snowflake/test/column_required.yaml
@@ -18,45 +18,40 @@
code: 401
title: column.required
content: Table t missing required column "created_ts"
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 401
title: column.required
content: Table t missing required column "creator_id"
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 401
title: column.required
content: Table t missing required column "id"
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 401
title: column.required
content: Table t missing required column "updated_ts"
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 401
title: column.required
content: Table t missing required column "updater_id"
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -72,9 +67,8 @@
code: 401
title: column.required
content: Table t missing required column "updated_ts"
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- statement: ALTER TABLE t DROP COLUMN "created_ts";
@@ -84,9 +78,8 @@
code: 401
title: column.required
content: Table t missing required column "created_ts"
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE t DROP COLUMN creator_id;
diff --git a/backend/plugin/advisor/snowflake/test/naming_identifier_case.yaml b/backend/plugin/advisor/snowflake/test/naming_identifier_case.yaml
index 5c088e544e..6af74559d0 100644
--- a/backend/plugin/advisor/snowflake/test/naming_identifier_case.yaml
+++ b/backend/plugin/advisor/snowflake/test/naming_identifier_case.yaml
@@ -16,9 +16,8 @@
code: 309
title: naming.identifier.case
content: Identifier "address" should be upper case
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -33,9 +32,8 @@
code: 309
title: naming.identifier.case
content: Identifier "address" should be upper case
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -52,9 +50,8 @@
code: 309
title: naming.identifier.case
content: Identifier "address" should be upper case
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE mytable RENAME COLUMN name TO address;
diff --git a/backend/plugin/advisor/snowflake/test/naming_identifier_no_keyword.yaml b/backend/plugin/advisor/snowflake/test/naming_identifier_no_keyword.yaml
index d9d0cd14cd..c597207f96 100644
--- a/backend/plugin/advisor/snowflake/test/naming_identifier_no_keyword.yaml
+++ b/backend/plugin/advisor/snowflake/test/naming_identifier_no_keyword.yaml
@@ -9,9 +9,8 @@
code: 308
title: naming.identifier.no-keyword
content: Identifier "CONNECT" is a keyword and should be avoided
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -25,9 +24,8 @@
code: 308
title: naming.identifier.no-keyword
content: Identifier "connect" is a keyword and should be avoided
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -47,9 +45,8 @@
code: 308
title: naming.identifier.no-keyword
content: Identifier "connect" is a keyword and should be avoided
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -65,9 +62,8 @@
code: 308
title: naming.identifier.no-keyword
content: Identifier "connect" is a keyword and should be avoided
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE mytable RENAME COLUMN name TO age;
diff --git a/backend/plugin/advisor/snowflake/test/naming_table.yaml b/backend/plugin/advisor/snowflake/test/naming_table.yaml
index 319e7409fd..39730528bc 100644
--- a/backend/plugin/advisor/snowflake/test/naming_table.yaml
+++ b/backend/plugin/advisor/snowflake/test/naming_table.yaml
@@ -9,9 +9,8 @@
code: 301
title: naming.table
content: '"lower_case_table_name_without_double_quotes" mismatches table naming convention, naming format should be "^[A-Z]+(_[A-Z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE "lower_case_table_name_with_double_quotes"(ID INT);
@@ -21,9 +20,8 @@
code: 301
title: naming.table
content: '"lower_case_table_name_with_double_quotes" mismatches table naming convention, naming format should be "^[A-Z]+(_[A-Z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: "CREATE TABLE \"\U0001F608EMOJI\U0001F604\"(ID INT);"
@@ -33,9 +31,8 @@
code: 301
title: naming.table
content: "\"\U0001F608EMOJI\U0001F604\" mismatches table naming convention, naming format should be \"^[A-Z]+(_[A-Z]+)*$\""
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE "lower_case_table_with_double_quotes" RENAME TO UPPER_CASE_TABLE_NAME_WITHOUT_DOUBLE_QUOTES;
@@ -47,9 +44,8 @@
code: 301
title: naming.table
content: '"lower_case_table_with_double_quotes" mismatches table naming convention, naming format should be "^[A-Z]+(_[A-Z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -61,9 +57,8 @@
code: 301
title: naming.table
content: '"lower_case_table_with_double_quotes" mismatches table naming convention, naming format should be "^[A-Z]+(_[A-Z]+)*$"'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -75,9 +70,8 @@
code: 301
title: naming.table
content: '"lower_case_table_name_with_double_quotes" mismatches table naming convention, naming format should be "^[A-Z]+(_[A-Z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -89,8 +83,7 @@
code: 301
title: naming.table
content: '"lowercase" mismatches table naming convention, naming format should be "^[A-Z]+(_[A-Z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/snowflake/test/naming_table_no_keyword.yaml b/backend/plugin/advisor/snowflake/test/naming_table_no_keyword.yaml
index f8f82de90e..8f08e30bbe 100644
--- a/backend/plugin/advisor/snowflake/test/naming_table_no_keyword.yaml
+++ b/backend/plugin/advisor/snowflake/test/naming_table_no_keyword.yaml
@@ -5,7 +5,6 @@
code: 308
title: naming.table.no-keyword
content: Table name "CONNECT" is a keyword identifier and should be avoided.
- detail: ""
startposition: null
endposition: null
- statement: CREATE TABLE "DB_NAME"."SCHEMA_NAME"."CONNECT"(ID INT);
@@ -15,7 +14,6 @@
code: 308
title: naming.table.no-keyword
content: Table name "CONNECT" is a keyword identifier and should be avoided.
- detail: ""
startposition: null
endposition: null
- statement: CREATE TABLE "DB_NAME"."SCHEMA_NAME"."TABLE_NAME"(ID INT);
@@ -27,6 +25,5 @@
code: 308
title: naming.table.no-keyword
content: Table name "CONNECT" is a keyword identifier and should be avoided.
- detail: ""
startposition: null
endposition: null
diff --git a/backend/plugin/advisor/snowflake/test/schema_backward_compatibility.yaml b/backend/plugin/advisor/snowflake/test/schema_backward_compatibility.yaml
index f7d28910e6..df59726a5f 100644
--- a/backend/plugin/advisor/snowflake/test/schema_backward_compatibility.yaml
+++ b/backend/plugin/advisor/snowflake/test/schema_backward_compatibility.yaml
@@ -5,9 +5,8 @@
code: 101
title: schema.backward-compatibility
content: Drop database "DB" may cause incompatibility with the existing data and code
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: DROP SCHEMA SCHEMA1;
@@ -17,9 +16,8 @@
code: 112
title: schema.backward-compatibility
content: Drop schema "TEST_DB.SCHEMA1" may cause incompatibility with the existing data and code
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: DROP TABLE T;
@@ -29,9 +27,8 @@
code: 103
title: schema.backward-compatibility
content: Drop table "TEST_DB.PUBLIC.T" may cause incompatibility with the existing data and code
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE T DROP COLUMN COL1;
@@ -41,9 +38,8 @@
code: 105
title: schema.backward-compatibility
content: Drop column "COL1" may cause incompatibility with the existing data and code
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -55,9 +51,8 @@
code: 103
title: schema.backward-compatibility
content: Drop table "TEST_DB.PUBLIC.T" may cause incompatibility with the existing data and code
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/snowflake/test/statement_select_no_select_all.yaml b/backend/plugin/advisor/snowflake/test/statement_select_no_select_all.yaml
index 0548a580f9..2ff05e6e09 100644
--- a/backend/plugin/advisor/snowflake/test/statement_select_no_select_all.yaml
+++ b/backend/plugin/advisor/snowflake/test/statement_select_no_select_all.yaml
@@ -5,9 +5,8 @@
code: 203
title: statement.select.no-select-all
content: Avoid using SELECT *.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT a, b FROM t
@@ -19,9 +18,8 @@
code: 203
title: statement.select.no-select-all
content: Avoid using SELECT *.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: INSERT INTO t SELECT * FROM t1
@@ -31,8 +29,7 @@
code: 203
title: statement.select.no-select-all
content: Avoid using SELECT *.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/snowflake/test/statement_where_require_select.yaml b/backend/plugin/advisor/snowflake/test/statement_where_require_select.yaml
index 0d319aae1a..2a36a8df8c 100644
--- a/backend/plugin/advisor/snowflake/test/statement_where_require_select.yaml
+++ b/backend/plugin/advisor/snowflake/test/statement_where_require_select.yaml
@@ -5,9 +5,8 @@
code: 202
title: statement.where.require.select
content: WHERE clause is required for SELECT statement.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT * FROM t;
@@ -17,9 +16,8 @@
code: 202
title: statement.where.require.select
content: WHERE clause is required for SELECT statement.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT * FROM t WHERE b = 2;
@@ -40,18 +38,16 @@
code: 202
title: statement.where.require.select
content: WHERE clause is required for SELECT statement.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 202
title: statement.where.require.select
content: WHERE clause is required for SELECT statement.
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- statement: |-
@@ -66,9 +62,8 @@
code: 202
title: statement.where.require.select
content: WHERE clause is required for SELECT statement.
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: SELECT 1;
diff --git a/backend/plugin/advisor/snowflake/test/statement_where_require_update_delete.yaml b/backend/plugin/advisor/snowflake/test/statement_where_require_update_delete.yaml
index 4a95fc62fe..67d6d04b71 100644
--- a/backend/plugin/advisor/snowflake/test/statement_where_require_update_delete.yaml
+++ b/backend/plugin/advisor/snowflake/test/statement_where_require_update_delete.yaml
@@ -5,9 +5,8 @@
code: 202
title: statement.where.require.update-delete
content: WHERE clause is required for UPDATE statement.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: UPDATE t SET a = 1 WHERE b = 2;
@@ -19,9 +18,8 @@
code: 202
title: statement.where.require.update-delete
content: WHERE clause is required for DELETE statement.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: DELETE FROM t WHERE a = 1;
diff --git a/backend/plugin/advisor/snowflake/test/table_drop_naming_convention.yaml b/backend/plugin/advisor/snowflake/test/table_drop_naming_convention.yaml
index 91cc151abf..74fa88e23e 100644
--- a/backend/plugin/advisor/snowflake/test/table_drop_naming_convention.yaml
+++ b/backend/plugin/advisor/snowflake/test/table_drop_naming_convention.yaml
@@ -7,8 +7,7 @@
code: 603
title: table.drop-naming-convention
content: '"FOO" mismatches drop table naming convention, naming format should be "_delete$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/snowflake/test/table_no_foreign_key.yaml b/backend/plugin/advisor/snowflake/test/table_no_foreign_key.yaml
index 1ae8261484..e5f804a4a2 100644
--- a/backend/plugin/advisor/snowflake/test/table_no_foreign_key.yaml
+++ b/backend/plugin/advisor/snowflake/test/table_no_foreign_key.yaml
@@ -11,9 +11,8 @@
code: 602
title: table.no-foreign-key
content: FOREIGN KEY is not allowed in the table CUSTOMER.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -30,9 +29,8 @@
code: 602
title: table.no-foreign-key
content: FOREIGN KEY is not allowed in the table CUSTOMER.
- detail: ""
startposition:
- line: 6
+ line: 5
column: 0
endposition: null
- statement: |-
@@ -49,9 +47,8 @@
code: 602
title: table.no-foreign-key
content: FOREIGN KEY is not allowed in the table CUSTOMER.
- detail: ""
startposition:
- line: 7
+ line: 6
column: 0
endposition: null
- statement: |-
@@ -68,9 +65,8 @@
code: 602
title: table.no-foreign-key
content: FOREIGN KEY is not allowed in the table "ANOTHER_SCHEMA"."CUSTOMER".
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -102,8 +98,7 @@
code: 602
title: table.no-foreign-key
content: FOREIGN KEY is not allowed in the table CUSTOMER.
- detail: ""
startposition:
- line: 13
+ line: 12
column: 0
endposition: null
diff --git a/backend/plugin/advisor/snowflake/test/table_require_pk.yaml b/backend/plugin/advisor/snowflake/test/table_require_pk.yaml
index 9c871164d3..625cd38b72 100644
--- a/backend/plugin/advisor/snowflake/test/table_require_pk.yaml
+++ b/backend/plugin/advisor/snowflake/test/table_require_pk.yaml
@@ -28,9 +28,8 @@
code: 601
title: table.require-pk
content: Table CUSTOMER requires PRIMARY KEY.
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -47,9 +46,8 @@
code: 601
title: table.require-pk
content: Table CUSTOMER requires PRIMARY KEY.
- detail: ""
startposition:
- line: 7
+ line: 6
column: 0
endposition: null
- statement: |-
@@ -91,9 +89,8 @@
code: 601
title: table.require-pk
content: Table CUSTOMER requires PRIMARY KEY.
- detail: ""
startposition:
- line: 9
+ line: 8
column: 0
endposition: null
- statement: |-
@@ -128,17 +125,15 @@
code: 601
title: table.require-pk
content: Table CUSTOMER requires PRIMARY KEY.
- detail: ""
startposition:
- line: 24
+ line: 23
column: 0
endposition: null
- status: 2
code: 601
title: table.require-pk
content: Table ORDERING requires PRIMARY KEY.
- detail: ""
startposition:
- line: 25
+ line: 24
column: 0
endposition: null
diff --git a/backend/plugin/advisor/sql_review.go b/backend/plugin/advisor/sql_review.go
index 7095653e03..5589de1526 100644
--- a/backend/plugin/advisor/sql_review.go
+++ b/backend/plugin/advisor/sql_review.go
@@ -630,13 +630,11 @@ func convertWalkThroughErrorToAdvice(err error) ([]*storepb.Advice, error) {
switch walkThroughError.Type {
case catalog.ErrorTypeUnsupported:
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: Unsupported.Int32(),
- Title: walkThroughError.Content,
- Content: "",
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: Unsupported.Int32(),
+ Title: walkThroughError.Content,
+ Content: "",
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
case catalog.ErrorTypeParseError:
res = append(res, &storepb.Advice{
@@ -647,195 +645,157 @@ func convertWalkThroughErrorToAdvice(err error) ([]*storepb.Advice, error) {
})
case catalog.ErrorTypeDeparseError:
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: Internal.Int32(),
- Title: "Internal error for walk-through",
- Content: walkThroughError.Content,
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: Internal.Int32(),
+ Title: "Internal error for walk-through",
+ Content: walkThroughError.Content,
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
case catalog.ErrorTypeAccessOtherDatabase:
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: NotCurrentDatabase.Int32(),
- Title: "Access other database",
- Content: walkThroughError.Content,
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: NotCurrentDatabase.Int32(),
+ Title: "Access other database",
+ Content: walkThroughError.Content,
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
case catalog.ErrorTypeDatabaseIsDeleted:
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: DatabaseIsDeleted.Int32(),
- Title: "Access deleted database",
- Content: walkThroughError.Content,
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: DatabaseIsDeleted.Int32(),
+ Title: "Access deleted database",
+ Content: walkThroughError.Content,
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
case catalog.ErrorTypeTableExists:
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: TableExists.Int32(),
- Title: "Table already exists",
- Content: walkThroughError.Content,
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: TableExists.Int32(),
+ Title: "Table already exists",
+ Content: walkThroughError.Content,
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
case catalog.ErrorTypeTableNotExists:
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: TableNotExists.Int32(),
- Title: "Table does not exist",
- Content: walkThroughError.Content,
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: TableNotExists.Int32(),
+ Title: "Table does not exist",
+ Content: walkThroughError.Content,
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
case catalog.ErrorTypeColumnExists:
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: ColumnExists.Int32(),
- Title: "Column already exists",
- Content: walkThroughError.Content,
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: ColumnExists.Int32(),
+ Title: "Column already exists",
+ Content: walkThroughError.Content,
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
case catalog.ErrorTypeColumnNotExists:
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: ColumnNotExists.Int32(),
- Title: "Column does not exist",
- Content: walkThroughError.Content,
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: ColumnNotExists.Int32(),
+ Title: "Column does not exist",
+ Content: walkThroughError.Content,
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
case catalog.ErrorTypeDropAllColumns:
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: DropAllColumns.Int32(),
- Title: "Drop all columns",
- Content: walkThroughError.Content,
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: DropAllColumns.Int32(),
+ Title: "Drop all columns",
+ Content: walkThroughError.Content,
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
case catalog.ErrorTypePrimaryKeyExists:
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: PrimaryKeyExists.Int32(),
- Title: "Primary key exists",
- Content: walkThroughError.Content,
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: PrimaryKeyExists.Int32(),
+ Title: "Primary key exists",
+ Content: walkThroughError.Content,
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
case catalog.ErrorTypeIndexExists:
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: IndexExists.Int32(),
- Title: "Index exists",
- Content: walkThroughError.Content,
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: IndexExists.Int32(),
+ Title: "Index exists",
+ Content: walkThroughError.Content,
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
case catalog.ErrorTypeIndexEmptyKeys:
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: IndexEmptyKeys.Int32(),
- Title: "Index empty keys",
- Content: walkThroughError.Content,
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: IndexEmptyKeys.Int32(),
+ Title: "Index empty keys",
+ Content: walkThroughError.Content,
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
case catalog.ErrorTypePrimaryKeyNotExists:
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: PrimaryKeyNotExists.Int32(),
- Title: "Primary key does not exist",
- Content: walkThroughError.Content,
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: PrimaryKeyNotExists.Int32(),
+ Title: "Primary key does not exist",
+ Content: walkThroughError.Content,
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
case catalog.ErrorTypeIndexNotExists:
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: IndexNotExists.Int32(),
- Title: "Index does not exist",
- Content: walkThroughError.Content,
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: IndexNotExists.Int32(),
+ Title: "Index does not exist",
+ Content: walkThroughError.Content,
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
case catalog.ErrorTypeIncorrectIndexName:
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: IncorrectIndexName.Int32(),
- Title: "Incorrect index name",
- Content: walkThroughError.Content,
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: IncorrectIndexName.Int32(),
+ Title: "Incorrect index name",
+ Content: walkThroughError.Content,
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
case catalog.ErrorTypeSpatialIndexKeyNullable:
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: SpatialIndexKeyNullable.Int32(),
- Title: "Spatial index key must be NOT NULL",
- Content: walkThroughError.Content,
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: SpatialIndexKeyNullable.Int32(),
+ Title: "Spatial index key must be NOT NULL",
+ Content: walkThroughError.Content,
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
case catalog.ErrorTypeColumnIsReferencedByView:
details := walkThroughError.Content
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: ColumnIsReferencedByView.Int32(),
- Title: "Column is referenced by view",
- Content: details,
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: ColumnIsReferencedByView.Int32(),
+ Title: "Column is referenced by view",
+ Content: details,
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
case catalog.ErrorTypeTableIsReferencedByView:
details := walkThroughError.Content
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: TableIsReferencedByView.Int32(),
- Title: "Table is referenced by view",
- Content: details,
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: TableIsReferencedByView.Int32(),
+ Title: "Table is referenced by view",
+ Content: details,
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
case catalog.ErrorTypeInvalidColumnTypeForDefaultValue:
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: InvalidColumnDefault.Int32(),
- Title: "Invalid column default value",
- Content: walkThroughError.Content,
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: InvalidColumnDefault.Int32(),
+ Title: "Invalid column default value",
+ Content: walkThroughError.Content,
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
default:
res = append(res, &storepb.Advice{
- Status: storepb.Advice_ERROR,
- Code: Internal.Int32(),
- Title: fmt.Sprintf("Failed to walk-through with code %d", walkThroughError.Type),
- Content: walkThroughError.Content,
- StartPosition: &storepb.Position{
- Line: int32(walkThroughError.Line),
- },
+ Status: storepb.Advice_ERROR,
+ Code: Internal.Int32(),
+ Title: fmt.Sprintf("Failed to walk-through with code %d", walkThroughError.Type),
+ Content: walkThroughError.Content,
+ StartPosition: ConvertANTLRLineToPosition(walkThroughError.Line),
})
}
diff --git a/backend/plugin/advisor/tidb/advisor_builtin_prior_backup_check.go b/backend/plugin/advisor/tidb/advisor_builtin_prior_backup_check.go
index dd9de121be..65a9116e05 100644
--- a/backend/plugin/advisor/tidb/advisor_builtin_prior_backup_check.go
+++ b/backend/plugin/advisor/tidb/advisor_builtin_prior_backup_check.go
@@ -68,13 +68,11 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx context.Context, checkCtx adv
if isDDL {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: "Prior backup cannot deal with mixed DDL and DML statements",
- Code: advisor.BuiltinPriorBackupCheck.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmtNode.OriginTextPosition()),
- },
+ Status: level,
+ Title: title,
+ Content: "Prior backup cannot deal with mixed DDL and DML statements",
+ Code: advisor.BuiltinPriorBackupCheck.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmtNode.OriginTextPosition()),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_charset_allowlist.go b/backend/plugin/advisor/tidb/advisor_charset_allowlist.go
index 7eff9ec13f..2e66db9f24 100644
--- a/backend/plugin/advisor/tidb/advisor_charset_allowlist.go
+++ b/backend/plugin/advisor/tidb/advisor_charset_allowlist.go
@@ -132,13 +132,11 @@ func (checker *charsetAllowlistChecker) Enter(in ast.Node) (ast.Node, bool) {
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" used disabled charset '%s'", checker.text, disabledCharset),
- StartPosition: &storepb.Position{
- Line: int32(line),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" used disabled charset '%s'", checker.text, disabledCharset),
+ StartPosition: advisor.ConvertANTLRLineToPosition(line),
})
}
diff --git a/backend/plugin/advisor/tidb/advisor_collation_allowlist.go b/backend/plugin/advisor/tidb/advisor_collation_allowlist.go
index 88ec143ed1..98b7be8cd5 100644
--- a/backend/plugin/advisor/tidb/advisor_collation_allowlist.go
+++ b/backend/plugin/advisor/tidb/advisor_collation_allowlist.go
@@ -133,13 +133,11 @@ func (checker *collationAllowlistChecker) Enter(in ast.Node) (ast.Node, bool) {
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" used disabled collation '%s'", checker.text, disabledCollation),
- StartPosition: &storepb.Position{
- Line: int32(line),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" used disabled collation '%s'", checker.text, disabledCollation),
+ StartPosition: advisor.ConvertANTLRLineToPosition(line),
})
}
diff --git a/backend/plugin/advisor/tidb/advisor_colum_require_default.go b/backend/plugin/advisor/tidb/advisor_colum_require_default.go
index 58dfee6559..2369a08afd 100644
--- a/backend/plugin/advisor/tidb/advisor_colum_require_default.go
+++ b/backend/plugin/advisor/tidb/advisor_colum_require_default.go
@@ -105,13 +105,11 @@ func (checker *columRequireDefaultChecker) Enter(in ast.Node) (ast.Node, bool) {
for _, column := range columnList {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NoDefault.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Column `%s`.`%s` doesn't have DEFAULT.", column.table, column.column),
- StartPosition: &storepb.Position{
- Line: int32(column.line),
- },
+ Status: checker.level,
+ Code: advisor.NoDefault.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Column `%s`.`%s` doesn't have DEFAULT.", column.table, column.column),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.line),
})
}
diff --git a/backend/plugin/advisor/tidb/advisor_column_auto_increment_initial_value.go b/backend/plugin/advisor/tidb/advisor_column_auto_increment_initial_value.go
index cffc7bae0f..cf2fbb3fba 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
@@ -72,13 +72,11 @@ func (checker *columnAutoIncrementInitialValueChecker) Enter(in ast.Node) (ast.N
if option.Tp == ast.TableOptionAutoIncrement {
if option.UintValue != uint64(checker.value) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.AutoIncrementColumnInitialValueNotMatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The initial auto-increment value in table `%s` is %v, which doesn't equal %v", createTable.Table.Name.O, option.UintValue, checker.value),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.AutoIncrementColumnInitialValueNotMatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The initial auto-increment value in table `%s` is %v, which doesn't equal %v", createTable.Table.Name.O, option.UintValue, checker.value),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_integer.go b/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_integer.go
index 0eb0e1dfc4..c9f5c53158 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
@@ -108,13 +108,11 @@ func (checker *columnAutoIncrementMustIntegerChecker) Enter(in ast.Node) (ast.No
for _, column := range columnList {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.AutoIncrementColumnNotInteger.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Auto-increment column `%s`.`%s` requires integer type", column.table, column.column),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.AutoIncrementColumnNotInteger.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Auto-increment column `%s`.`%s` requires integer type", column.table, column.column),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
diff --git a/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_unsigned.go b/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_unsigned.go
index 37a178e225..ca70682f29 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
@@ -101,13 +101,11 @@ func (checker *columnAutoIncrementMustUnsignedChecker) Enter(in ast.Node) (ast.N
for _, column := range columnList {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.AutoIncrementColumnSigned.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Auto-increment column `%s`.`%s` is not UNSIGNED type", column.table, column.column),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.AutoIncrementColumnSigned.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Auto-increment column `%s`.`%s` is not UNSIGNED type", column.table, column.column),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
diff --git a/backend/plugin/advisor/tidb/advisor_column_comment_convention.go b/backend/plugin/advisor/tidb/advisor_column_comment_convention.go
index 7dbaac2951..3f7e6f0808 100644
--- a/backend/plugin/advisor/tidb/advisor_column_comment_convention.go
+++ b/backend/plugin/advisor/tidb/advisor_column_comment_convention.go
@@ -123,36 +123,30 @@ func (checker *columnCommentConventionChecker) Enter(in ast.Node) (ast.Node, boo
for _, column := range columnList {
if checker.payload.Required && !column.exist {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CommentEmpty.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Column `%s`.`%s` requires comments", column.table, column.column),
- StartPosition: &storepb.Position{
- Line: int32(column.line),
- },
+ Status: checker.level,
+ Code: advisor.CommentEmpty.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Column `%s`.`%s` requires comments", column.table, column.column),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.line),
})
}
if checker.payload.MaxLength >= 0 && len(column.comment) > checker.payload.MaxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CommentTooLong.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The length of column `%s`.`%s` comment should be within %d characters", column.table, column.column, checker.payload.MaxLength),
- StartPosition: &storepb.Position{
- Line: int32(column.line),
- },
+ Status: checker.level,
+ Code: advisor.CommentTooLong.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The length of column `%s`.`%s` comment should be within %d characters", column.table, column.column, checker.payload.MaxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.line),
})
}
if checker.payload.RequiredClassification {
if classification, _ := common.GetClassificationAndUserComment(column.comment, checker.classificationConfig); classification == "" {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CommentMissingClassification.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Column `%s`.`%s` comment requires classification", column.table, column.column),
- StartPosition: &storepb.Position{
- Line: int32(column.line),
- },
+ Status: checker.level,
+ Code: advisor.CommentMissingClassification.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Column `%s`.`%s` comment requires classification", column.table, column.column),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.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.go
index 04c66a3d52..95c3f0c413 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
@@ -87,24 +87,20 @@ func (checker *columnCurrentTimeCountLimitChecker) generateAdvice() []*storepb.A
for _, table := range tableList {
if table.defaultCurrentTimeCount > maxDefaultCurrentTimeColumCount {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DefaultCurrentTimeColumnCountExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table `%s` has %d DEFAULT CURRENT_TIMESTAMP() columns. The count greater than %d.", table.tableName, table.defaultCurrentTimeCount, maxDefaultCurrentTimeColumCount),
- StartPosition: &storepb.Position{
- Line: int32(table.line),
- },
+ Status: checker.level,
+ Code: advisor.DefaultCurrentTimeColumnCountExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table `%s` has %d DEFAULT CURRENT_TIMESTAMP() columns. The count greater than %d.", table.tableName, table.defaultCurrentTimeCount, maxDefaultCurrentTimeColumCount),
+ StartPosition: advisor.ConvertANTLRLineToPosition(table.line),
})
}
if table.onUpdateCurrentTimeCount > maxOnUpdateCurrentTimeColumnCount {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.OnUpdateCurrentTimeColumnCountExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table `%s` has %d ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than %d.", table.tableName, table.onUpdateCurrentTimeCount, maxOnUpdateCurrentTimeColumnCount),
- StartPosition: &storepb.Position{
- Line: int32(table.line),
- },
+ Status: checker.level,
+ Code: advisor.OnUpdateCurrentTimeColumnCountExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table `%s` has %d ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than %d.", table.tableName, table.onUpdateCurrentTimeCount, maxOnUpdateCurrentTimeColumnCount),
+ StartPosition: advisor.ConvertANTLRLineToPosition(table.line),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_column_disallow_changing.go b/backend/plugin/advisor/tidb/advisor_column_disallow_changing.go
index b272bcacfc..9627ecc9ea 100644
--- a/backend/plugin/advisor/tidb/advisor_column_disallow_changing.go
+++ b/backend/plugin/advisor/tidb/advisor_column_disallow_changing.go
@@ -65,13 +65,11 @@ func (checker *columnDisallowChangingChecker) Enter(in ast.Node) (ast.Node, bool
for _, spec := range node.Specs {
if spec.Tp == ast.AlterTableChangeColumn {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.UseChangeColumnStatement.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" contains CHANGE COLUMN statement", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.UseChangeColumnStatement.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" contains CHANGE COLUMN statement", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
break
}
diff --git a/backend/plugin/advisor/tidb/advisor_column_disallow_changing_order.go b/backend/plugin/advisor/tidb/advisor_column_disallow_changing_order.go
index 10535597ce..d9f84756bd 100644
--- a/backend/plugin/advisor/tidb/advisor_column_disallow_changing_order.go
+++ b/backend/plugin/advisor/tidb/advisor_column_disallow_changing_order.go
@@ -66,13 +66,11 @@ func (checker *columnDisallowChangingOrderChecker) Enter(in ast.Node) (ast.Node,
if (spec.Tp == ast.AlterTableChangeColumn || spec.Tp == ast.AlterTableModifyColumn) &&
spec.Position.Tp != ast.ColumnPositionNone {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.ChangeColumnOrder.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" changes column order", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.ChangeColumnOrder.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" changes column order", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
break
}
diff --git a/backend/plugin/advisor/tidb/advisor_column_disallow_changing_type.go b/backend/plugin/advisor/tidb/advisor_column_disallow_changing_type.go
index 74bd02ad22..3f70d0f209 100644
--- a/backend/plugin/advisor/tidb/advisor_column_disallow_changing_type.go
+++ b/backend/plugin/advisor/tidb/advisor_column_disallow_changing_type.go
@@ -82,13 +82,11 @@ func (checker *columnDisallowChangingTypeChecker) Enter(in ast.Node) (ast.Node,
if changeType {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.ChangeColumnType.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" changes column type", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.ChangeColumnType.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" changes column type", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
diff --git a/backend/plugin/advisor/tidb/advisor_column_disallow_drop_in_index.go b/backend/plugin/advisor/tidb/advisor_column_disallow_drop_in_index.go
index 03757a1c2b..34525d845d 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
@@ -105,13 +105,11 @@ func (checker *columnDisallowDropInIndexChecker) dropColumn(in ast.Node) (ast.No
colName := spec.OldColumnName.Name.String()
if !checker.canDrop(table, colName) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DropIndexColumn.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("`%s`.`%s` cannot drop index column", table, colName),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.DropIndexColumn.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("`%s`.`%s` cannot drop index column", table, colName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_column_disallow_set_charset.go b/backend/plugin/advisor/tidb/advisor_column_disallow_set_charset.go
index 2d4802d62c..9624d8149c 100644
--- a/backend/plugin/advisor/tidb/advisor_column_disallow_set_charset.go
+++ b/backend/plugin/advisor/tidb/advisor_column_disallow_set_charset.go
@@ -95,13 +95,11 @@ func (checker *columnDisallowSetCharsetChecker) Enter(in ast.Node) (ast.Node, bo
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.SetColumnCharset.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Disallow set column charset but \"%s\" does", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.SetColumnCharset.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Disallow set column charset but \"%s\" does", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
diff --git a/backend/plugin/advisor/tidb/advisor_column_maximum_character_length.go b/backend/plugin/advisor/tidb/advisor_column_maximum_character_length.go
index 8ab521aec4..6c28396347 100644
--- a/backend/plugin/advisor/tidb/advisor_column_maximum_character_length.go
+++ b/backend/plugin/advisor/tidb/advisor_column_maximum_character_length.go
@@ -109,13 +109,11 @@ func (checker *columnMaximumCharacterLengthChecker) Enter(in ast.Node) (ast.Node
if tableName != "" {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CharLengthExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The length of the CHAR column `%s` is bigger than %d, please use VARCHAR instead", columnName, checker.maximum),
- StartPosition: &storepb.Position{
- Line: int32(line),
- },
+ Status: checker.level,
+ Code: advisor.CharLengthExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The length of the CHAR column `%s` is bigger than %d, please use VARCHAR instead", columnName, checker.maximum),
+ StartPosition: advisor.ConvertANTLRLineToPosition(line),
})
}
diff --git a/backend/plugin/advisor/tidb/advisor_column_no_null.go b/backend/plugin/advisor/tidb/advisor_column_no_null.go
index 736deb72e9..8b85e203b7 100644
--- a/backend/plugin/advisor/tidb/advisor_column_no_null.go
+++ b/backend/plugin/advisor/tidb/advisor_column_no_null.go
@@ -78,13 +78,11 @@ func (checker *columnNoNullChecker) generateAdvice() []*storepb.Advice {
})
if col != nil && col.Nullable() {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.ColumnCannotNull.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("`%s`.`%s` cannot have NULL value", column.tableName, column.columnName),
- StartPosition: &storepb.Position{
- Line: int32(column.line),
- },
+ Status: checker.level,
+ Code: advisor.ColumnCannotNull.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("`%s`.`%s` cannot have NULL value", column.tableName, column.columnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.line),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_column_required.go b/backend/plugin/advisor/tidb/advisor_column_required.go
index 38e7a58dae..4617eb6dad 100644
--- a/backend/plugin/advisor/tidb/advisor_column_required.go
+++ b/backend/plugin/advisor/tidb/advisor_column_required.go
@@ -130,13 +130,11 @@ func (v *columnRequirementChecker) generateAdviceList() []*storepb.Advice {
// Order it cause the random iteration order in Go, see https://go.dev/blog/maps
sort.Strings(missingColumns)
v.adviceList = append(v.adviceList, &storepb.Advice{
- Status: v.level,
- Code: advisor.NoRequiredColumn.Int32(),
- Title: v.title,
- Content: fmt.Sprintf("Table `%s` requires columns: %s", tableName, strings.Join(missingColumns, ", ")),
- StartPosition: &storepb.Position{
- Line: int32(v.line[tableName]),
- },
+ Status: v.level,
+ Code: advisor.NoRequiredColumn.Int32(),
+ Title: v.title,
+ Content: fmt.Sprintf("Table `%s` requires columns: %s", tableName, strings.Join(missingColumns, ", ")),
+ StartPosition: advisor.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.go
index 7bffc17a02..f68d180d36 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
@@ -115,13 +115,11 @@ func (checker *columnSetDefaultForNotNullChecker) Enter(in ast.Node) (ast.Node,
for _, column := range notNullColumnWithNoDefault {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NotNullColumnWithNoDefault.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Column `%s`.`%s` is NOT NULL but doesn't have DEFAULT", column.tableName, column.columnName),
- StartPosition: &storepb.Position{
- Line: int32(column.line),
- },
+ Status: checker.level,
+ Code: advisor.NotNullColumnWithNoDefault.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Column `%s`.`%s` is NOT NULL but doesn't have DEFAULT", column.tableName, column.columnName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.line),
})
}
diff --git a/backend/plugin/advisor/tidb/advisor_column_type_disallow_list.go b/backend/plugin/advisor/tidb/advisor_column_type_disallow_list.go
index cfe9dd08ed..405ff6e308 100644
--- a/backend/plugin/advisor/tidb/advisor_column_type_disallow_list.go
+++ b/backend/plugin/advisor/tidb/advisor_column_type_disallow_list.go
@@ -121,13 +121,11 @@ func (checker *columnTypeDisallowListChecker) Enter(in ast.Node) (ast.Node, bool
for _, column := range columnList {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DisabledColumnType.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Disallow column type %s but column `%s`.`%s` is", column.tp, column.table, column.column),
- StartPosition: &storepb.Position{
- Line: int32(column.line),
- },
+ Status: checker.level,
+ Code: advisor.DisabledColumnType.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Disallow column type %s but column `%s`.`%s` is", column.tp, column.table, column.column),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.line),
})
}
diff --git a/backend/plugin/advisor/tidb/advisor_database_drop_empty_db.go b/backend/plugin/advisor/tidb/advisor_database_drop_empty_db.go
index 6ccdd0eabe..9c3a8c1c74 100644
--- a/backend/plugin/advisor/tidb/advisor_database_drop_empty_db.go
+++ b/backend/plugin/advisor/tidb/advisor_database_drop_empty_db.go
@@ -61,23 +61,19 @@ func (v *allowDropEmptyDBChecker) Enter(in ast.Node) (ast.Node, bool) {
if node, ok := in.(*ast.DropDatabaseStmt); ok {
if v.catalog.Origin.DatabaseName() != node.Name.O {
v.adviceList = append(v.adviceList, &storepb.Advice{
- Status: v.level,
- Code: advisor.NotCurrentDatabase.Int32(),
- Title: v.title,
- Content: fmt.Sprintf("Database `%s` that is trying to be deleted is not the current database `%s`", node.Name, v.catalog.Origin.DatabaseName()),
- StartPosition: &storepb.Position{
- Line: int32(node.OriginTextPosition()),
- },
+ Status: v.level,
+ Code: advisor.NotCurrentDatabase.Int32(),
+ Title: v.title,
+ Content: fmt.Sprintf("Database `%s` that is trying to be deleted is not the current database `%s`", node.Name, v.catalog.Origin.DatabaseName()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.OriginTextPosition()),
})
} else if !v.catalog.Origin.HasNoTable() {
v.adviceList = append(v.adviceList, &storepb.Advice{
- Status: v.level,
- Code: advisor.DatabaseNotEmpty.Int32(),
- Title: v.title,
- Content: fmt.Sprintf("Database `%s` is not allowed to drop if not empty", node.Name),
- StartPosition: &storepb.Position{
- Line: int32(node.OriginTextPosition()),
- },
+ Status: v.level,
+ Code: advisor.DatabaseNotEmpty.Int32(),
+ Title: v.title,
+ Content: fmt.Sprintf("Database `%s` is not allowed to drop if not empty", node.Name),
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.OriginTextPosition()),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_index_key_number_limit.go b/backend/plugin/advisor/tidb/advisor_index_key_number_limit.go
index fc235c57b6..a31f7b10de 100644
--- a/backend/plugin/advisor/tidb/advisor_index_key_number_limit.go
+++ b/backend/plugin/advisor/tidb/advisor_index_key_number_limit.go
@@ -106,13 +106,11 @@ func (checker *indexKeyNumberLimitChecker) Enter(in ast.Node) (ast.Node, bool) {
for _, index := range indexList {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.IndexKeyNumberExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The number of index `%s` in table `%s` should be not greater than %d", index.index, index.table, checker.max),
- StartPosition: &storepb.Position{
- Line: int32(index.line),
- },
+ Status: checker.level,
+ Code: advisor.IndexKeyNumberExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The number of index `%s` in table `%s` should be not greater than %d", index.index, index.table, checker.max),
+ StartPosition: advisor.ConvertANTLRLineToPosition(index.line),
})
}
diff --git a/backend/plugin/advisor/tidb/advisor_index_no_duplicate_column.go b/backend/plugin/advisor/tidb/advisor_index_no_duplicate_column.go
index 2404c9f671..847115ae0c 100644
--- a/backend/plugin/advisor/tidb/advisor_index_no_duplicate_column.go
+++ b/backend/plugin/advisor/tidb/advisor_index_no_duplicate_column.go
@@ -124,13 +124,11 @@ func (checker *indexNoDuplicateColumnChecker) Enter(in ast.Node) (ast.Node, bool
for _, column := range columnList {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.DuplicateColumnInIndex.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("%s `%s` has duplicate column `%s`.`%s`", column.tp, column.index, column.table, column.column),
- StartPosition: &storepb.Position{
- Line: int32(column.line),
- },
+ Status: checker.level,
+ Code: advisor.DuplicateColumnInIndex.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("%s `%s` has duplicate column `%s`.`%s`", column.tp, column.index, column.table, column.column),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.line),
})
}
diff --git a/backend/plugin/advisor/tidb/advisor_index_pk_type.go b/backend/plugin/advisor/tidb/advisor_index_pk_type.go
index cdb61eeaaa..230c1c8d87 100644
--- a/backend/plugin/advisor/tidb/advisor_index_pk_type.go
+++ b/backend/plugin/advisor/tidb/advisor_index_pk_type.go
@@ -135,13 +135,11 @@ func (v *indexPkTypeChecker) Enter(in ast.Node) (ast.Node, bool) {
}
for _, pd := range pkDataList {
v.adviceList = append(v.adviceList, &storepb.Advice{
- Status: v.level,
- Code: advisor.IndexPKType.Int32(),
- Title: v.title,
- Content: fmt.Sprintf("Columns in primary key must be INT/BIGINT but `%s`.`%s` is %s", pd.table, pd.column, pd.columnType),
- StartPosition: &storepb.Position{
- Line: int32(pd.line),
- },
+ Status: v.level,
+ Code: advisor.IndexPKType.Int32(),
+ Title: v.title,
+ Content: fmt.Sprintf("Columns in primary key must be INT/BIGINT but `%s`.`%s` is %s", pd.table, pd.column, pd.columnType),
+ StartPosition: advisor.ConvertANTLRLineToPosition(pd.line),
})
}
return in, false
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.go
index 1696842de4..9767978bd9 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
@@ -115,13 +115,11 @@ func (v *indexPrimaryKeyTypeAllowlistChecker) Enter(in ast.Node) (ast.Node, bool
}
for _, pd := range pkDataList {
v.adviceList = append(v.adviceList, &storepb.Advice{
- Status: v.level,
- Code: advisor.IndexPKType.Int32(),
- Title: v.title,
- Content: fmt.Sprintf("The column `%s` in table `%s` is one of the primary key, but its type \"%s\" is not in allowlist", pd.column, pd.table, pd.columnType),
- StartPosition: &storepb.Position{
- Line: int32(pd.line),
- },
+ Status: v.level,
+ Code: advisor.IndexPKType.Int32(),
+ Title: v.title,
+ Content: fmt.Sprintf("The column `%s` in table `%s` is one of the primary key, but its type \"%s\" is not in allowlist", pd.column, pd.table, pd.columnType),
+ StartPosition: advisor.ConvertANTLRLineToPosition(pd.line),
})
}
return in, false
diff --git a/backend/plugin/advisor/tidb/advisor_index_total_number_limit.go b/backend/plugin/advisor/tidb/advisor_index_total_number_limit.go
index 1e533857b3..e8d5a6cd52 100644
--- a/backend/plugin/advisor/tidb/advisor_index_total_number_limit.go
+++ b/backend/plugin/advisor/tidb/advisor_index_total_number_limit.go
@@ -92,13 +92,11 @@ func (checker *indexTotalNumberLimitChecker) generateAdvice() []*storepb.Advice
tableInfo := checker.catalog.Final.FindTable(&catalog.TableFind{TableName: table.name})
if tableInfo != nil && tableInfo.CountIndex() > checker.max {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.IndexCountExceedsLimit.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The count of index in table `%s` should be no more than %d, but found %d", table.name, checker.max, tableInfo.CountIndex()),
- StartPosition: &storepb.Position{
- Line: int32(table.line),
- },
+ Status: checker.level,
+ Code: advisor.IndexCountExceedsLimit.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The count of index in table `%s` should be no more than %d, but found %d", table.name, checker.max, tableInfo.CountIndex()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(table.line),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_index_type_no_blob.go b/backend/plugin/advisor/tidb/advisor_index_type_no_blob.go
index 3db9bc1570..64111a6a55 100644
--- a/backend/plugin/advisor/tidb/advisor_index_type_no_blob.go
+++ b/backend/plugin/advisor/tidb/advisor_index_type_no_blob.go
@@ -112,13 +112,11 @@ func (v *indexTypeNoBlobChecker) Enter(in ast.Node) (ast.Node, bool) {
}
for _, pd := range pkDataList {
v.adviceList = append(v.adviceList, &storepb.Advice{
- Status: v.level,
- Code: advisor.IndexTypeNoBlob.Int32(),
- Title: v.title,
- Content: fmt.Sprintf("Columns in index must not be BLOB but `%s`.`%s` is %s", pd.table, pd.column, pd.columnType),
- StartPosition: &storepb.Position{
- Line: int32(pd.line),
- },
+ Status: v.level,
+ Code: advisor.IndexTypeNoBlob.Int32(),
+ Title: v.title,
+ Content: fmt.Sprintf("Columns in index must not be BLOB but `%s`.`%s` is %s", pd.table, pd.column, pd.columnType),
+ StartPosition: advisor.ConvertANTLRLineToPosition(pd.line),
})
}
return in, false
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.go
index b0d05c0b43..44aeab21eb 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
@@ -81,13 +81,11 @@ func (checker *insertDisallowOrderByRandChecker) Enter(in ast.Node) (ast.Node, b
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" uses ORDER BY RAND in the INSERT statement", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" uses ORDER BY RAND in the INSERT statement", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
diff --git a/backend/plugin/advisor/tidb/advisor_insert_must_specify_column.go b/backend/plugin/advisor/tidb/advisor_insert_must_specify_column.go
index e5921dc0a7..dba2cb6aac 100644
--- a/backend/plugin/advisor/tidb/advisor_insert_must_specify_column.go
+++ b/backend/plugin/advisor/tidb/advisor_insert_must_specify_column.go
@@ -64,13 +64,11 @@ func (checker *insertMustSpecifyColumnChecker) Enter(in ast.Node) (ast.Node, boo
if node, ok := in.(*ast.InsertStmt); ok {
if node.Columns == nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.InsertNotSpecifyColumn.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The INSERT statement must specify columns but \"%s\" does not", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.InsertNotSpecifyColumn.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The INSERT statement must specify columns but \"%s\" does not", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_migration_compatibility.go b/backend/plugin/advisor/tidb/advisor_migration_compatibility.go
index 653a5e3d9c..710720bff3 100644
--- a/backend/plugin/advisor/tidb/advisor_migration_compatibility.go
+++ b/backend/plugin/advisor/tidb/advisor_migration_compatibility.go
@@ -151,13 +151,11 @@ func (v *compatibilityChecker) Enter(in ast.Node) (ast.Node, bool) {
if code != advisor.Ok {
v.adviceList = append(v.adviceList, &storepb.Advice{
- Status: v.level,
- Code: code.Int32(),
- Title: v.title,
- Content: fmt.Sprintf("\"%s\" may cause incompatibility with the existing data and code", in.Text()),
- StartPosition: &storepb.Position{
- Line: int32(in.OriginTextPosition()),
- },
+ Status: v.level,
+ Code: code.Int32(),
+ Title: v.title,
+ Content: fmt.Sprintf("\"%s\" may cause incompatibility with the existing data and code", in.Text()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(in.OriginTextPosition()),
})
}
return in, false
diff --git a/backend/plugin/advisor/tidb/advisor_naming_auto_increment_column.go b/backend/plugin/advisor/tidb/advisor_naming_auto_increment_column.go
index 37a279c279..86fa1a57b1 100644
--- a/backend/plugin/advisor/tidb/advisor_naming_auto_increment_column.go
+++ b/backend/plugin/advisor/tidb/advisor_naming_auto_increment_column.go
@@ -118,24 +118,20 @@ func (checker *namingAutoIncrementColumnChecker) Enter(in ast.Node) (ast.Node, b
for _, column := range columnList {
if !checker.format.MatchString(column.name) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingAutoIncrementColumnConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("`%s`.`%s` mismatches auto_increment column naming convention, naming format should be %q", tableName, column.name, checker.format),
- StartPosition: &storepb.Position{
- Line: int32(column.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingAutoIncrementColumnConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("`%s`.`%s` mismatches auto_increment column naming convention, naming format should be %q", tableName, column.name, checker.format),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.line),
})
}
if checker.maxLength > 0 && len(column.name) > checker.maxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingAutoIncrementColumnConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("`%s`.`%s` mismatches auto_increment column naming convention, its length should be within %d characters", tableName, column.name, checker.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(column.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingAutoIncrementColumnConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("`%s`.`%s` mismatches auto_increment column naming convention, its length should be within %d characters", tableName, column.name, checker.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.line),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_naming_column.go b/backend/plugin/advisor/tidb/advisor_naming_column.go
index 42cec9e11a..6190c4dd36 100644
--- a/backend/plugin/advisor/tidb/advisor_naming_column.go
+++ b/backend/plugin/advisor/tidb/advisor_naming_column.go
@@ -114,24 +114,20 @@ func (v *namingColumnConventionChecker) Enter(in ast.Node) (ast.Node, bool) {
for _, column := range columnList {
if !v.format.MatchString(column.name) {
v.adviceList = append(v.adviceList, &storepb.Advice{
- Status: v.level,
- Code: advisor.NamingColumnConventionMismatch.Int32(),
- Title: v.title,
- Content: fmt.Sprintf("`%s`.`%s` mismatches column naming convention, naming format should be %q", tableName, column.name, v.format),
- StartPosition: &storepb.Position{
- Line: int32(column.line),
- },
+ Status: v.level,
+ Code: advisor.NamingColumnConventionMismatch.Int32(),
+ Title: v.title,
+ Content: fmt.Sprintf("`%s`.`%s` mismatches column naming convention, naming format should be %q", tableName, column.name, v.format),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.line),
})
}
if v.maxLength > 0 && len(column.name) > v.maxLength {
v.adviceList = append(v.adviceList, &storepb.Advice{
- Status: v.level,
- Code: advisor.NamingColumnConventionMismatch.Int32(),
- Title: v.title,
- Content: fmt.Sprintf("`%s`.`%s` mismatches column naming convention, its length should be within %d characters", tableName, column.name, v.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(column.line),
- },
+ Status: v.level,
+ Code: advisor.NamingColumnConventionMismatch.Int32(),
+ Title: v.title,
+ Content: fmt.Sprintf("`%s`.`%s` mismatches column naming convention, its length should be within %d characters", tableName, column.name, v.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(column.line),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_naming_foreign_key_convention.go b/backend/plugin/advisor/tidb/advisor_naming_foreign_key_convention.go
index df7b1def68..9b67fcbb10 100644
--- a/backend/plugin/advisor/tidb/advisor_naming_foreign_key_convention.go
+++ b/backend/plugin/advisor/tidb/advisor_naming_foreign_key_convention.go
@@ -81,24 +81,20 @@ func (checker *namingFKConventionChecker) Enter(in ast.Node) (ast.Node, bool) {
}
if !regex.MatchString(indexData.indexName) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingFKConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Foreign key in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),
- StartPosition: &storepb.Position{
- Line: int32(indexData.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingFKConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Foreign key in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(indexData.line),
})
}
if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingFKConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Foreign key `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(indexData.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingFKConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Foreign key `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(indexData.line),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_naming_index_convention.go b/backend/plugin/advisor/tidb/advisor_naming_index_convention.go
index 5eb63684fa..be5c766e14 100644
--- a/backend/plugin/advisor/tidb/advisor_naming_index_convention.go
+++ b/backend/plugin/advisor/tidb/advisor_naming_index_convention.go
@@ -85,24 +85,20 @@ func (checker *namingIndexConventionChecker) Enter(in ast.Node) (ast.Node, bool)
}
if !regex.MatchString(indexData.indexName) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingIndexConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Index in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),
- StartPosition: &storepb.Position{
- Line: int32(indexData.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingIndexConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Index in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(indexData.line),
})
}
if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingIndexConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Index `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(indexData.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingIndexConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Index `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(indexData.line),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_naming_table.go b/backend/plugin/advisor/tidb/advisor_naming_table.go
index c4f1f25f90..bc51b96cae 100644
--- a/backend/plugin/advisor/tidb/advisor_naming_table.go
+++ b/backend/plugin/advisor/tidb/advisor_naming_table.go
@@ -87,24 +87,20 @@ func (v *namingTableConventionChecker) Enter(in ast.Node) (ast.Node, bool) {
for _, tableName := range tableNames {
if !v.format.MatchString(tableName) {
v.adviceList = append(v.adviceList, &storepb.Advice{
- Status: v.level,
- Code: advisor.NamingTableConventionMismatch.Int32(),
- Title: v.title,
- Content: fmt.Sprintf("`%s` mismatches table naming convention, naming format should be %q", tableName, v.format),
- StartPosition: &storepb.Position{
- Line: int32(in.OriginTextPosition()),
- },
+ Status: v.level,
+ Code: advisor.NamingTableConventionMismatch.Int32(),
+ Title: v.title,
+ Content: fmt.Sprintf("`%s` mismatches table naming convention, naming format should be %q", tableName, v.format),
+ StartPosition: advisor.ConvertANTLRLineToPosition(in.OriginTextPosition()),
})
}
if v.maxLength > 0 && len(tableName) > v.maxLength {
v.adviceList = append(v.adviceList, &storepb.Advice{
- Status: v.level,
- Code: advisor.NamingTableConventionMismatch.Int32(),
- Title: v.title,
- Content: fmt.Sprintf("`%s` mismatches table naming convention, its length should be within %d characters", tableName, v.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(in.OriginTextPosition()),
- },
+ Status: v.level,
+ Code: advisor.NamingTableConventionMismatch.Int32(),
+ Title: v.title,
+ Content: fmt.Sprintf("`%s` mismatches table naming convention, its length should be within %d characters", tableName, v.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(in.OriginTextPosition()),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_naming_unique_key_convention.go b/backend/plugin/advisor/tidb/advisor_naming_unique_key_convention.go
index ddac405646..17c8832653 100644
--- a/backend/plugin/advisor/tidb/advisor_naming_unique_key_convention.go
+++ b/backend/plugin/advisor/tidb/advisor_naming_unique_key_convention.go
@@ -84,24 +84,20 @@ func (checker *namingUKConventionChecker) Enter(in ast.Node) (ast.Node, bool) {
}
if !regex.MatchString(indexData.indexName) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingUKConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Unique key in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),
- StartPosition: &storepb.Position{
- Line: int32(indexData.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingUKConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Unique key in table `%s` mismatches the naming convention, expect %q but found `%s`", indexData.tableName, regex, indexData.indexName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(indexData.line),
})
}
if checker.maxLength > 0 && len(indexData.indexName) > checker.maxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.NamingUKConventionMismatch.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Unique key `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),
- StartPosition: &storepb.Position{
- Line: int32(indexData.line),
- },
+ Status: checker.level,
+ Code: advisor.NamingUKConventionMismatch.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Unique key `%s` in table `%s` mismatches the naming convention, its length should be within %d characters", indexData.indexName, indexData.tableName, checker.maxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(indexData.line),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_statement_disallow_mix_in_ddl.go b/backend/plugin/advisor/tidb/advisor_statement_disallow_mix_in_ddl.go
index af2375c54e..56eb88717f 100644
--- a/backend/plugin/advisor/tidb/advisor_statement_disallow_mix_in_ddl.go
+++ b/backend/plugin/advisor/tidb/advisor_statement_disallow_mix_in_ddl.go
@@ -45,13 +45,11 @@ func (*StatementDisallowMixInDDLAdvisor) Check(_ context.Context, checkCtx advis
for _, stmtNode := range root {
if _, ok := stmtNode.(ast.DMLNode); ok {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Alter schema can only run DDL, \"%s\" is not DDL", stmtNode.Text()),
- Code: advisor.StatementDisallowMixDDLDML.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmtNode.OriginTextPosition()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Alter schema can only run DDL, \"%s\" is not DDL", stmtNode.Text()),
+ Code: advisor.StatementDisallowMixDDLDML.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmtNode.OriginTextPosition()),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_statement_disallow_mix_in_dml.go b/backend/plugin/advisor/tidb/advisor_statement_disallow_mix_in_dml.go
index 3795651c37..4163713c8b 100644
--- a/backend/plugin/advisor/tidb/advisor_statement_disallow_mix_in_dml.go
+++ b/backend/plugin/advisor/tidb/advisor_statement_disallow_mix_in_dml.go
@@ -45,13 +45,11 @@ func (*StatementDisallowMixInDMLAdvisor) Check(_ context.Context, checkCtx advis
for _, stmtNode := range root {
if _, ok := stmtNode.(ast.DDLNode); ok {
adviceList = append(adviceList, &storepb.Advice{
- Status: level,
- Title: title,
- Content: fmt.Sprintf("Data change can only run DML, \"%s\" is not DML", stmtNode.Text()),
- Code: advisor.StatementDisallowMixDDLDML.Int32(),
- StartPosition: &storepb.Position{
- Line: int32(stmtNode.OriginTextPosition()),
- },
+ Status: level,
+ Title: title,
+ Content: fmt.Sprintf("Data change can only run DML, \"%s\" is not DML", stmtNode.Text()),
+ Code: advisor.StatementDisallowMixDDLDML.Int32(),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmtNode.OriginTextPosition()),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_statement_dml_dry_run.go b/backend/plugin/advisor/tidb/advisor_statement_dml_dry_run.go
index aa91dc2cf9..85eac674af 100644
--- a/backend/plugin/advisor/tidb/advisor_statement_dml_dry_run.go
+++ b/backend/plugin/advisor/tidb/advisor_statement_dml_dry_run.go
@@ -78,13 +78,11 @@ func (checker *statementDmlDryRunChecker) Enter(in ast.Node) (ast.Node, bool) {
checker.explainCount++
if _, err := advisor.Query(checker.ctx, advisor.QueryContext{}, checker.driver, storepb.Engine_TIDB, fmt.Sprintf("EXPLAIN %s", node.Text())); err != nil {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementDMLDryRunFailed.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("\"%s\" dry runs failed: %s", node.Text(), err.Error()),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.StatementDMLDryRunFailed.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("\"%s\" dry runs failed: %s", node.Text(), err.Error()),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_statement_maximum_limit_value.go b/backend/plugin/advisor/tidb/advisor_statement_maximum_limit_value.go
index 6100f7e3ba..8ebb5a5a5b 100644
--- a/backend/plugin/advisor/tidb/advisor_statement_maximum_limit_value.go
+++ b/backend/plugin/advisor/tidb/advisor_statement_maximum_limit_value.go
@@ -75,13 +75,11 @@ func (checker *statementMaximumLimitValueChecker) Enter(in ast.Node) (ast.Node,
limitVal := ve.GetInt64()
if limitVal > int64(checker.limitMaxValue) {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementExceedMaximumLimitValue.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The limit value %d exceeds the maximum allowed value %d", limitVal, checker.limitMaxValue),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.StatementExceedMaximumLimitValue.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The limit value %d exceeds the maximum allowed value %d", limitVal, checker.limitMaxValue),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_statement_merge_alter_table.go b/backend/plugin/advisor/tidb/advisor_statement_merge_alter_table.go
index 271e296331..6ec3d607f7 100644
--- a/backend/plugin/advisor/tidb/advisor_statement_merge_alter_table.go
+++ b/backend/plugin/advisor/tidb/advisor_statement_merge_alter_table.go
@@ -111,13 +111,11 @@ func (checker *statementMergeAlterTableChecker) generateAdvice() []*storepb.Advi
for _, table := range tableList {
if table.count > 1 {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementRedundantAlterTable.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("There are %d statements to modify table `%s`", table.count, table.name),
- StartPosition: &storepb.Position{
- Line: int32(table.lastLine),
- },
+ Status: checker.level,
+ Code: advisor.StatementRedundantAlterTable.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("There are %d statements to modify table `%s`", table.count, table.name),
+ StartPosition: advisor.ConvertANTLRLineToPosition(table.lastLine),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_stmt_disallow_commit.go b/backend/plugin/advisor/tidb/advisor_stmt_disallow_commit.go
index cadca12ee4..baa6e886de 100644
--- a/backend/plugin/advisor/tidb/advisor_stmt_disallow_commit.go
+++ b/backend/plugin/advisor/tidb/advisor_stmt_disallow_commit.go
@@ -63,13 +63,11 @@ type statementDisallowCommitChecker struct {
func (c *statementDisallowCommitChecker) Enter(in ast.Node) (ast.Node, bool) {
if _, ok := in.(*ast.CommitStmt); ok {
c.adviceList = append(c.adviceList, &storepb.Advice{
- Status: c.level,
- Code: advisor.StatementDisallowCommit.Int32(),
- Title: c.title,
- Content: fmt.Sprintf("Commit is not allowed, related statement: \"%s\"", c.text),
- StartPosition: &storepb.Position{
- Line: int32(c.line),
- },
+ Status: c.level,
+ Code: advisor.StatementDisallowCommit.Int32(),
+ Title: c.title,
+ Content: fmt.Sprintf("Commit is not allowed, related statement: \"%s\"", c.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(c.line),
})
}
diff --git a/backend/plugin/advisor/tidb/advisor_stmt_disallow_limit.go b/backend/plugin/advisor/tidb/advisor_stmt_disallow_limit.go
index 47b95c991b..fa1a6fc288 100644
--- a/backend/plugin/advisor/tidb/advisor_stmt_disallow_limit.go
+++ b/backend/plugin/advisor/tidb/advisor_stmt_disallow_limit.go
@@ -79,13 +79,11 @@ func (checker *statementDisallowLimitChecker) Enter(in ast.Node) (ast.Node, bool
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but \"%s\" uses", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but \"%s\" uses", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
diff --git a/backend/plugin/advisor/tidb/advisor_stmt_disallow_order_by.go b/backend/plugin/advisor/tidb/advisor_stmt_disallow_order_by.go
index 6c4c730c1b..4b8fea6eec 100644
--- a/backend/plugin/advisor/tidb/advisor_stmt_disallow_order_by.go
+++ b/backend/plugin/advisor/tidb/advisor_stmt_disallow_order_by.go
@@ -75,13 +75,11 @@ func (checker *disallowOrderByChecker) Enter(in ast.Node) (ast.Node, bool) {
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("ORDER BY clause is forbidden in DELETE and UPDATE statements, but \"%s\" uses", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("ORDER BY clause is forbidden in DELETE and UPDATE statements, but \"%s\" uses", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
return in, false
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.go
index 9b0f28e105..02649e255a 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
@@ -49,13 +49,11 @@ func (*NoLeadingWildcardLikeAdvisor) Check(_ context.Context, checkCtx advisor.C
if checker.leadingWildcardLike {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.StatementLeadingWildcardLike.Int32(),
- Title: string(checkCtx.Rule.Type),
- Content: fmt.Sprintf("\"%s\" uses leading wildcard LIKE", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(stmtNode.OriginTextPosition()),
- },
+ Status: checker.level,
+ Code: advisor.StatementLeadingWildcardLike.Int32(),
+ Title: string(checkCtx.Rule.Type),
+ Content: fmt.Sprintf("\"%s\" uses leading wildcard LIKE", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(stmtNode.OriginTextPosition()),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_stmt_no_select_all.go b/backend/plugin/advisor/tidb/advisor_stmt_no_select_all.go
index 76dd95565d..9f12d91ab0 100644
--- a/backend/plugin/advisor/tidb/advisor_stmt_no_select_all.go
+++ b/backend/plugin/advisor/tidb/advisor_stmt_no_select_all.go
@@ -62,13 +62,11 @@ func (v *noSelectAllChecker) Enter(in ast.Node) (ast.Node, bool) {
for _, field := range node.Fields.Fields {
if field.WildCard != nil {
v.adviceList = append(v.adviceList, &storepb.Advice{
- Status: v.level,
- Code: advisor.StatementSelectAll.Int32(),
- Title: v.title,
- Content: fmt.Sprintf("\"%s\" uses SELECT all", v.text),
- StartPosition: &storepb.Position{
- Line: int32(v.line),
- },
+ Status: v.level,
+ Code: advisor.StatementSelectAll.Int32(),
+ Title: v.title,
+ Content: fmt.Sprintf("\"%s\" uses SELECT all", v.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(v.line),
})
break
}
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.go
index b63d444fed..320a2e30bd 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
@@ -69,13 +69,11 @@ func (v *whereRequirementForSelectChecker) Enter(in ast.Node) (ast.Node, bool) {
if code != advisor.Ok {
v.adviceList = append(v.adviceList, &storepb.Advice{
- Status: v.level,
- Code: code.Int32(),
- Title: v.title,
- Content: fmt.Sprintf("\"%s\" requires WHERE clause", v.text),
- StartPosition: &storepb.Position{
- Line: int32(v.line),
- },
+ Status: v.level,
+ Code: code.Int32(),
+ Title: v.title,
+ Content: fmt.Sprintf("\"%s\" requires WHERE clause", v.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(v.line),
})
}
return in, false
diff --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.go
index 850e98cd8d..0ccffbab67 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
@@ -75,13 +75,11 @@ func (v *whereRequirementForUpdateDeleteChecker) Enter(in ast.Node) (ast.Node, b
if code != advisor.Ok {
v.adviceList = append(v.adviceList, &storepb.Advice{
- Status: v.level,
- Code: code.Int32(),
- Title: v.title,
- Content: fmt.Sprintf("\"%s\" requires WHERE clause", v.text),
- StartPosition: &storepb.Position{
- Line: int32(v.line),
- },
+ Status: v.level,
+ Code: code.Int32(),
+ Title: v.title,
+ Content: fmt.Sprintf("\"%s\" requires WHERE clause", v.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(v.line),
})
}
return in, false
diff --git a/backend/plugin/advisor/tidb/advisor_table_comment_convention.go b/backend/plugin/advisor/tidb/advisor_table_comment_convention.go
index 4e4867aeab..140904ab13 100644
--- a/backend/plugin/advisor/tidb/advisor_table_comment_convention.go
+++ b/backend/plugin/advisor/tidb/advisor_table_comment_convention.go
@@ -74,36 +74,30 @@ func (checker *tableCommentConventionChecker) Enter(in ast.Node) (ast.Node, bool
exist, comment := tableComment(node.Options)
if checker.payload.Required && !exist {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CommentEmpty.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table `%s` requires comments", node.Table.Name.O),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.CommentEmpty.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table `%s` requires comments", node.Table.Name.O),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
if checker.payload.MaxLength >= 0 && len(comment) > checker.payload.MaxLength {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CommentTooLong.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("The length of table `%s` comment should be within %d characters", node.Table.Name.O, checker.payload.MaxLength),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.CommentTooLong.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("The length of table `%s` comment should be within %d characters", node.Table.Name.O, checker.payload.MaxLength),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
if checker.payload.RequiredClassification {
if classification, _ := common.GetClassificationAndUserComment(comment, checker.classificationConfig); classification == "" {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.CommentMissingClassification.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table `%s` comment requires classification", node.Table.Name.O),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: advisor.CommentMissingClassification.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table `%s` comment requires classification", node.Table.Name.O),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_table_disallow_partition.go b/backend/plugin/advisor/tidb/advisor_table_disallow_partition.go
index d43fd777d0..aab56b38aa 100644
--- a/backend/plugin/advisor/tidb/advisor_table_disallow_partition.go
+++ b/backend/plugin/advisor/tidb/advisor_table_disallow_partition.go
@@ -78,13 +78,11 @@ func (checker *tableDisallowPartitionChecker) Enter(in ast.Node) (ast.Node, bool
if code != advisor.Ok {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Table partition is forbidden, but \"%s\" creates", checker.text),
- StartPosition: &storepb.Position{
- Line: int32(checker.line),
- },
+ Status: checker.level,
+ Code: code.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Table partition is forbidden, but \"%s\" creates", checker.text),
+ StartPosition: advisor.ConvertANTLRLineToPosition(checker.line),
})
}
diff --git a/backend/plugin/advisor/tidb/advisor_table_drop_naming_convention.go b/backend/plugin/advisor/tidb/advisor_table_drop_naming_convention.go
index bf1b626266..f9f0a5929b 100644
--- a/backend/plugin/advisor/tidb/advisor_table_drop_naming_convention.go
+++ b/backend/plugin/advisor/tidb/advisor_table_drop_naming_convention.go
@@ -66,13 +66,11 @@ func (v *namingDropTableConventionChecker) Enter(in ast.Node) (ast.Node, bool) {
for _, table := range node.Tables {
if !v.format.MatchString(table.Name.O) {
v.adviceList = append(v.adviceList, &storepb.Advice{
- Status: v.level,
- Code: advisor.TableDropNamingConventionMismatch.Int32(),
- Title: v.title,
- Content: fmt.Sprintf("`%s` mismatches drop table naming convention, naming format should be %q", table.Name.O, v.format),
- StartPosition: &storepb.Position{
- Line: int32(node.OriginTextPosition()),
- },
+ Status: v.level,
+ Code: advisor.TableDropNamingConventionMismatch.Int32(),
+ Title: v.title,
+ Content: fmt.Sprintf("`%s` mismatches drop table naming convention, naming format should be %q", table.Name.O, v.format),
+ StartPosition: advisor.ConvertANTLRLineToPosition(node.OriginTextPosition()),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_table_no_fk.go b/backend/plugin/advisor/tidb/advisor_table_no_fk.go
index 1997ee893b..d87bf71674 100644
--- a/backend/plugin/advisor/tidb/advisor_table_no_fk.go
+++ b/backend/plugin/advisor/tidb/advisor_table_no_fk.go
@@ -59,13 +59,11 @@ func (checker *tableNoFKChecker) Enter(in ast.Node) (ast.Node, bool) {
for _, constraint := range node.Constraints {
if constraint.Tp == ast.ConstraintForeignKey {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.TableHasFK.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Foreign key is not allowed in the table `%s`", node.Table.Name),
- StartPosition: &storepb.Position{
- Line: int32(constraint.OriginTextPosition()),
- },
+ Status: checker.level,
+ Code: advisor.TableHasFK.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Foreign key is not allowed in the table `%s`", node.Table.Name),
+ StartPosition: advisor.ConvertANTLRLineToPosition(constraint.OriginTextPosition()),
})
}
}
@@ -73,13 +71,11 @@ func (checker *tableNoFKChecker) Enter(in ast.Node) (ast.Node, bool) {
for _, spec := range node.Specs {
if spec.Tp == ast.AlterTableAddConstraint && spec.Constraint.Tp == ast.ConstraintForeignKey {
checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: advisor.TableHasFK.Int32(),
- Title: checker.title,
- Content: fmt.Sprintf("Foreign key is not allowed in the table `%s`", node.Table.Name),
- StartPosition: &storepb.Position{
- Line: int32(in.OriginTextPosition()),
- },
+ Status: checker.level,
+ Code: advisor.TableHasFK.Int32(),
+ Title: checker.title,
+ Content: fmt.Sprintf("Foreign key is not allowed in the table `%s`", node.Table.Name),
+ StartPosition: advisor.ConvertANTLRLineToPosition(in.OriginTextPosition()),
})
}
}
diff --git a/backend/plugin/advisor/tidb/advisor_table_require_pk.go b/backend/plugin/advisor/tidb/advisor_table_require_pk.go
index 43a25f3fa3..ca6d8975d6 100644
--- a/backend/plugin/advisor/tidb/advisor_table_require_pk.go
+++ b/backend/plugin/advisor/tidb/advisor_table_require_pk.go
@@ -131,13 +131,11 @@ func (v *tableRequirePKChecker) generateAdviceList() []*storepb.Advice {
for _, tableName := range tableList {
if len(v.tables[tableName]) == 0 {
v.adviceList = append(v.adviceList, &storepb.Advice{
- Status: v.level,
- Code: advisor.TableNoPK.Int32(),
- Title: v.title,
- Content: fmt.Sprintf("Table `%s` requires PRIMARY KEY", tableName),
- StartPosition: &storepb.Position{
- Line: int32(v.line[tableName]),
- },
+ Status: v.level,
+ Code: advisor.TableNoPK.Int32(),
+ Title: v.title,
+ Content: fmt.Sprintf("Table `%s` requires PRIMARY KEY", tableName),
+ StartPosition: advisor.ConvertANTLRLineToPosition(v.line[tableName]),
})
}
}
diff --git a/backend/plugin/advisor/tidb/test/column_auto_increment_initial_value.yaml b/backend/plugin/advisor/tidb/test/column_auto_increment_initial_value.yaml
index 6a6bec1c2e..a9169543af 100644
--- a/backend/plugin/advisor/tidb/test/column_auto_increment_initial_value.yaml
+++ b/backend/plugin/advisor/tidb/test/column_auto_increment_initial_value.yaml
@@ -9,8 +9,7 @@
code: 416
title: column.auto-increment-initial-value
content: The initial auto-increment value in table `t` is 2, which doesn't equal 20
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/column_auto_increment_must_integer.yaml b/backend/plugin/advisor/tidb/test/column_auto_increment_must_integer.yaml
index fa02e6ae77..f3bedbb6e5 100644
--- a/backend/plugin/advisor/tidb/test/column_auto_increment_must_integer.yaml
+++ b/backend/plugin/advisor/tidb/test/column_auto_increment_must_integer.yaml
@@ -7,9 +7,8 @@
code: 410
title: column.auto-increment-must-integer
content: Auto-increment column `t`.`a` requires integer type
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -21,9 +20,8 @@
code: 410
title: column.auto-increment-must-integer
content: Auto-increment column `t`.`a` requires integer type
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -35,9 +33,8 @@
code: 410
title: column.auto-increment-must-integer
content: Auto-increment column `t`.`a` requires integer type
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -49,8 +46,7 @@
code: 410
title: column.auto-increment-must-integer
content: Auto-increment column `t`.`a` requires integer type
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/column_auto_increment_must_unsigned.yaml b/backend/plugin/advisor/tidb/test/column_auto_increment_must_unsigned.yaml
index 870c44f104..f56195a171 100644
--- a/backend/plugin/advisor/tidb/test/column_auto_increment_must_unsigned.yaml
+++ b/backend/plugin/advisor/tidb/test/column_auto_increment_must_unsigned.yaml
@@ -7,9 +7,8 @@
code: 417
title: column.auto-increment-must-unsigned
content: Auto-increment column `t`.`a` is not UNSIGNED type
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -21,9 +20,8 @@
code: 417
title: column.auto-increment-must-unsigned
content: Auto-increment column `t`.`a` is not UNSIGNED type
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -35,9 +33,8 @@
code: 417
title: column.auto-increment-must-unsigned
content: Auto-increment column `t`.`a` is not UNSIGNED type
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -49,8 +46,7 @@
code: 417
title: column.auto-increment-must-unsigned
content: Auto-increment column `t`.`a` is not UNSIGNED type
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/column_comment.yaml b/backend/plugin/advisor/tidb/test/column_comment.yaml
index 2eb618deff..de70d01258 100644
--- a/backend/plugin/advisor/tidb/test/column_comment.yaml
+++ b/backend/plugin/advisor/tidb/test/column_comment.yaml
@@ -11,27 +11,24 @@
code: 1301
title: column.comment
content: The length of column `t`.`a` comment should be within 10 characters
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 1032
title: column.comment
content: Column `t`.`b` requires comments
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 1032
title: column.comment
content: Column `t`.`c` requires comments
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- statement: |-
@@ -43,9 +40,8 @@
code: 1032
title: column.comment
content: Column `t`.`b` requires comments
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -57,18 +53,16 @@
code: 1301
title: column.comment
content: The length of column `t`.`a` comment should be within 10 characters
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 1032
title: column.comment
content: Column `t`.`b` requires comments
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -80,18 +74,16 @@
code: 1301
title: column.comment
content: The length of column `t`.`b` comment should be within 10 characters
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 1032
title: column.comment
content: Column `t`.`b` requires comments
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -103,17 +95,15 @@
code: 1301
title: column.comment
content: The length of column `t`.`b` comment should be within 10 characters
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 1301
title: column.comment
content: The length of column `t`.`b` comment should be within 10 characters
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/column_current_time_count_limit.yaml b/backend/plugin/advisor/tidb/test/column_current_time_count_limit.yaml
index ae790e848a..e726aee5ab 100644
--- a/backend/plugin/advisor/tidb/test/column_current_time_count_limit.yaml
+++ b/backend/plugin/advisor/tidb/test/column_current_time_count_limit.yaml
@@ -12,9 +12,8 @@
code: 418
title: column.current-time-count-limit
content: Table `t` has 3 DEFAULT CURRENT_TIMESTAMP() columns. The count greater than 2.
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- statement: |-
@@ -28,9 +27,8 @@
code: 419
title: column.current-time-count-limit
content: Table `t` has 2 ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than 1.
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- statement: |-
@@ -42,8 +40,7 @@
code: 419
title: column.current-time-count-limit
content: Table `tech_book` has 2 ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than 1.
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/column_disallow_change.yaml b/backend/plugin/advisor/tidb/test/column_disallow_change.yaml
index ceccf6466e..b2178545b9 100644
--- a/backend/plugin/advisor/tidb/test/column_disallow_change.yaml
+++ b/backend/plugin/advisor/tidb/test/column_disallow_change.yaml
@@ -11,8 +11,7 @@
code: 406
title: column.disallow-change
content: '"ALTER TABLE t CHANGE COLUMN b a int" contains CHANGE COLUMN statement'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/column_disallow_change_type.yaml b/backend/plugin/advisor/tidb/test/column_disallow_change_type.yaml
index a04465ce3b..c57b4c908e 100644
--- a/backend/plugin/advisor/tidb/test/column_disallow_change_type.yaml
+++ b/backend/plugin/advisor/tidb/test/column_disallow_change_type.yaml
@@ -5,9 +5,8 @@
code: 403
title: column.disallow-change-type
content: '"ALTER TABLE tech_book MODIFY id INTEGER UNSIGNED" changes column type'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book MODIFY id int
@@ -19,9 +18,8 @@
code: 403
title: column.disallow-change-type
content: '"ALTER TABLE tech_book MODIFY id bigint" changes column type'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book CHANGE name uname varchar(20)
@@ -31,8 +29,7 @@
code: 403
title: column.disallow-change-type
content: '"ALTER TABLE tech_book CHANGE name uname varchar(20)" changes column type'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/column_disallow_changing_order.yaml b/backend/plugin/advisor/tidb/test/column_disallow_changing_order.yaml
index dda4c1aead..e8bb7cd88c 100644
--- a/backend/plugin/advisor/tidb/test/column_disallow_changing_order.yaml
+++ b/backend/plugin/advisor/tidb/test/column_disallow_changing_order.yaml
@@ -7,9 +7,8 @@
code: 407
title: column.disallow-changing-order
content: '"ALTER TABLE t MODIFY COLUMN a int" changes column order'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -21,9 +20,8 @@
code: 407
title: column.disallow-changing-order
content: '"ALTER TABLE t MODIFY COLUMN a int FIRST" changes column order'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -35,9 +33,8 @@
code: 407
title: column.disallow-changing-order
content: '"ALTER TABLE t CHANGE COLUMN a1 a int FIRST" changes column order'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -49,9 +46,8 @@
code: 407
title: column.disallow-changing-order
content: '"ALTER TABLE t MODIFY COLUMN a int AFTER b" changes column order'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -63,8 +59,7 @@
code: 407
title: column.disallow-changing-order
content: '"ALTER TABLE t CHANGE COLUMN a1 a int AFTER b" changes column order'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/column_disallow_drop_in_index.yaml b/backend/plugin/advisor/tidb/test/column_disallow_drop_in_index.yaml
index fbd65168bf..47d047eff7 100644
--- a/backend/plugin/advisor/tidb/test/column_disallow_drop_in_index.yaml
+++ b/backend/plugin/advisor/tidb/test/column_disallow_drop_in_index.yaml
@@ -11,9 +11,8 @@
code: 424
title: column.disallow-drop-in-index
content: '`t`.`b` cannot drop index column'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -25,9 +24,8 @@
code: 424
title: column.disallow-drop-in-index
content: '`t`.`c` cannot drop index column'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -45,17 +43,15 @@
code: 424
title: column.disallow-drop-in-index
content: '`t`.`a` cannot drop index column'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 424
title: column.disallow-drop-in-index
content: '`t`.`c` cannot drop index column'
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/column_disallow_set_charset.yaml b/backend/plugin/advisor/tidb/test/column_disallow_set_charset.yaml
index 9bde904f21..dce69e6d5b 100644
--- a/backend/plugin/advisor/tidb/test/column_disallow_set_charset.yaml
+++ b/backend/plugin/advisor/tidb/test/column_disallow_set_charset.yaml
@@ -11,9 +11,8 @@
code: 414
title: column.disallow-set-charset
content: Disallow set column charset but "CREATE TABLE t(a varchar(20) CHARSET ascii)" does
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD COLUMN a varchar(20) CHARSET ascii
@@ -23,9 +22,8 @@
code: 414
title: column.disallow-set-charset
content: Disallow set column charset but "ALTER TABLE tech_book ADD COLUMN a varchar(20) CHARSET ascii" does
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book MODIFY COLUMN id varchar(20) CHARSET ascii
@@ -35,9 +33,8 @@
code: 414
title: column.disallow-set-charset
content: Disallow set column charset but "ALTER TABLE tech_book MODIFY COLUMN id varchar(20) CHARSET ascii" does
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book CHANGE COLUMN name name varchar(20) CHARSET ascii
@@ -47,8 +44,7 @@
code: 414
title: column.disallow-set-charset
content: Disallow set column charset but "ALTER TABLE tech_book CHANGE COLUMN name name varchar(20) CHARSET ascii" does
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/column_maximum_character_length.yaml b/backend/plugin/advisor/tidb/test/column_maximum_character_length.yaml
index 61f38c3fa4..00fcd38b93 100644
--- a/backend/plugin/advisor/tidb/test/column_maximum_character_length.yaml
+++ b/backend/plugin/advisor/tidb/test/column_maximum_character_length.yaml
@@ -9,9 +9,8 @@
code: 415
title: column.maximum-character-length
content: The length of the CHAR column `name` is bigger than 20, please use VARCHAR instead
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD COLUMN name_2 char(225)
@@ -21,9 +20,8 @@
code: 415
title: column.maximum-character-length
content: The length of the CHAR column `name_2` is bigger than 20, please use VARCHAR instead
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book CHANGE COLUMN name name char(225)
@@ -33,9 +31,8 @@
code: 415
title: column.maximum-character-length
content: The length of the CHAR column `name` is bigger than 20, please use VARCHAR instead
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book MODIFY COLUMN name char(225)
@@ -45,8 +42,7 @@
code: 415
title: column.maximum-character-length
content: The length of the CHAR column `name` is bigger than 20, please use VARCHAR instead
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/column_no_null.yaml b/backend/plugin/advisor/tidb/test/column_no_null.yaml
index 014bc275db..bc4828b55c 100644
--- a/backend/plugin/advisor/tidb/test/column_no_null.yaml
+++ b/backend/plugin/advisor/tidb/test/column_no_null.yaml
@@ -8,18 +8,16 @@
code: 402
title: column.no-null
content: '`book`.`id` cannot have NULL value'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 402
title: column.no-null
content: '`book`.`name` cannot have NULL value'
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255))
@@ -29,9 +27,8 @@
code: 402
title: column.no-null
content: '`book`.`name` cannot have NULL value'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id int NOT NULL, name varchar(255))
@@ -41,9 +38,8 @@
code: 402
title: column.no-null
content: '`book`.`name` cannot have NULL value'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255) NOT NULL)
@@ -57,9 +53,8 @@
code: 402
title: column.no-null
content: '`book`.`id` cannot have NULL value'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -75,9 +70,8 @@
code: 402
title: column.no-null
content: '`book`.`name` cannot have NULL value'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/tidb/test/column_require_default.yaml b/backend/plugin/advisor/tidb/test/column_require_default.yaml
index 067bad6a8f..9baec53fc7 100644
--- a/backend/plugin/advisor/tidb/test/column_require_default.yaml
+++ b/backend/plugin/advisor/tidb/test/column_require_default.yaml
@@ -11,9 +11,8 @@
code: 420
title: column.require-default
content: Column `t`.`a` doesn't have DEFAULT.
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -26,17 +25,15 @@
code: 420
title: column.require-default
content: Column `tech_book`.`b` doesn't have DEFAULT.
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 420
title: column.require-default
content: Column `tech_book`.`a` doesn't have DEFAULT.
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/column_required.yaml b/backend/plugin/advisor/tidb/test/column_required.yaml
index 5c69bfdf18..1c17f21e1e 100644
--- a/backend/plugin/advisor/tidb/test/column_required.yaml
+++ b/backend/plugin/advisor/tidb/test/column_required.yaml
@@ -5,9 +5,8 @@
code: 401
title: column.required
content: 'Table `book` requires columns: created_ts, creator_id, updated_ts, updater_id'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -32,9 +31,8 @@
code: 401
title: column.required
content: 'Table `book` requires columns: creator_id'
- detail: ""
startposition:
- line: 7
+ line: 6
column: 0
endposition: null
- statement: |-
@@ -60,9 +58,8 @@
code: 401
title: column.required
content: 'Table `book` requires columns: creator_id'
- detail: ""
startposition:
- line: 7
+ line: 6
column: 0
endposition: null
- statement: |-
@@ -88,9 +85,8 @@
code: 401
title: column.required
content: 'Table `book` requires columns: creator_id'
- detail: ""
startposition:
- line: 7
+ line: 6
column: 0
endposition: null
- statement: |-
@@ -116,9 +112,8 @@
code: 401
title: column.required
content: 'Table `book` requires columns: updater_id'
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- statement: |-
@@ -146,18 +141,16 @@
code: 401
title: column.required
content: 'Table `book` requires columns: creator_id'
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- status: 2
code: 401
title: column.required
content: 'Table `student` requires columns: creator_id, updater_id'
- detail: ""
startposition:
- line: 9
+ line: 8
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/tidb/test/column_set_default_for_not_null.yaml b/backend/plugin/advisor/tidb/test/column_set_default_for_not_null.yaml
index 176a487ab6..66d90fe36f 100644
--- a/backend/plugin/advisor/tidb/test/column_set_default_for_not_null.yaml
+++ b/backend/plugin/advisor/tidb/test/column_set_default_for_not_null.yaml
@@ -18,9 +18,8 @@
code: 404
title: column.set-default-for-not-null
content: Column `book`.`id` is NOT NULL but doesn't have DEFAULT
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -42,9 +41,8 @@
code: 404
title: column.set-default-for-not-null
content: Column `book`.`id` is NOT NULL but doesn't have DEFAULT
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -56,9 +54,8 @@
code: 404
title: column.set-default-for-not-null
content: Column `book`.`id` is NOT NULL but doesn't have DEFAULT
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -78,9 +75,8 @@
code: 404
title: column.set-default-for-not-null
content: Column `book`.`id` is NOT NULL but doesn't have DEFAULT
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: "\n\t\t\t\tCREATE TABLE book(uid int, id int);\n\t\t\t\tALTER TABLE book \n\t\t\t\t\tCHANGE COLUMN uid uid int NOT NULL DEFAULT 0,\n\t\t\t\t\tMODIFY COLUMN id int PRIMARY KEY DEFAULT 0,\n\t\t\t\t\tADD COLUMN name varchar(20) NOT NULL DEFAULT ''\n\t\t\t\t"
diff --git a/backend/plugin/advisor/tidb/test/column_type_disallow_list.yaml b/backend/plugin/advisor/tidb/test/column_type_disallow_list.yaml
index 7a34c71324..328db3b7b2 100644
--- a/backend/plugin/advisor/tidb/test/column_type_disallow_list.yaml
+++ b/backend/plugin/advisor/tidb/test/column_type_disallow_list.yaml
@@ -7,9 +7,8 @@
code: 411
title: column.type-disallow-list
content: Disallow column type JSON but column `t`.`a` is
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -21,9 +20,8 @@
code: 411
title: column.type-disallow-list
content: Disallow column type JSON but column `t`.`a` is
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -35,8 +33,7 @@
code: 411
title: column.type-disallow-list
content: Disallow column type JSON but column `t`.`a` is
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/database_drop_empty_database.yaml b/backend/plugin/advisor/tidb/test/database_drop_empty_database.yaml
index f15fb8b751..277a9b503e 100644
--- a/backend/plugin/advisor/tidb/test/database_drop_empty_database.yaml
+++ b/backend/plugin/advisor/tidb/test/database_drop_empty_database.yaml
@@ -5,8 +5,7 @@
code: 701
title: database.drop-empty-database
content: Database `test` is not allowed to drop if not empty
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/index_key_number_limit.yaml b/backend/plugin/advisor/tidb/test/index_key_number_limit.yaml
index decfa262d6..a66f1982b1 100644
--- a/backend/plugin/advisor/tidb/test/index_key_number_limit.yaml
+++ b/backend/plugin/advisor/tidb/test/index_key_number_limit.yaml
@@ -11,9 +11,8 @@
code: 802
title: index.key-number-limit
content: The number of index `pk` in table `t` should be not greater than 5
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- statement: |-
@@ -25,9 +24,8 @@
code: 802
title: index.key-number-limit
content: The number of index `idx` in table `t` should be not greater than 5
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -39,9 +37,8 @@
code: 802
title: index.key-number-limit
content: The number of index `uk` in table `t` should be not greater than 5
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -53,8 +50,7 @@
code: 802
title: index.key-number-limit
content: The number of index `uk` in table `t` should be not greater than 5
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/index_no_duplicate_column.yaml b/backend/plugin/advisor/tidb/test/index_no_duplicate_column.yaml
index 86dca9e855..1360e2a543 100644
--- a/backend/plugin/advisor/tidb/test/index_no_duplicate_column.yaml
+++ b/backend/plugin/advisor/tidb/test/index_no_duplicate_column.yaml
@@ -10,9 +10,8 @@
code: 812
title: index.no-duplicate-column
content: INDEX `idx_a` has duplicate column `t`.`a`
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -24,9 +23,8 @@
code: 812
title: index.no-duplicate-column
content: INDEX `idx_a` has duplicate column `t`.`a`
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -38,9 +36,8 @@
code: 812
title: index.no-duplicate-column
content: INDEX `idx_a` has duplicate column `t`.`a`
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -52,9 +49,8 @@
code: 812
title: index.no-duplicate-column
content: PRIMARY KEY `pk_a` has duplicate column `t`.`a`
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -66,9 +62,8 @@
code: 812
title: index.no-duplicate-column
content: UNIQUE KEY `uk_a` has duplicate column `t`.`a`
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -80,8 +75,7 @@
code: 812
title: index.no-duplicate-column
content: FOREIGN KEY `fk_a` has duplicate column `t`.`a`
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/index_pk_type_limit.yaml b/backend/plugin/advisor/tidb/test/index_pk_type_limit.yaml
index 6abeed821e..2326318fed 100644
--- a/backend/plugin/advisor/tidb/test/index_pk_type_limit.yaml
+++ b/backend/plugin/advisor/tidb/test/index_pk_type_limit.yaml
@@ -5,9 +5,8 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(id INT PRIMARY KEY)
@@ -19,9 +18,8 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(id INT, id2 VARCHAR(5), id3 VARCHAR(5), PRIMARY KEY(id, id2, id3))
@@ -31,18 +29,16 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id3` is varchar(5)
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(id INT, id2 BIGINT, PRIMARY KEY(id, id2))
@@ -58,9 +54,8 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -76,9 +71,8 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -90,18 +84,16 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id3` is varchar(5)
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -121,9 +113,8 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -135,18 +126,16 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id3` is varchar(5)
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -166,9 +155,8 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -184,9 +172,8 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/tidb/test/index_primary_key_type_allowlist.yaml b/backend/plugin/advisor/tidb/test/index_primary_key_type_allowlist.yaml
index 771d55f7a5..ce83e660a6 100644
--- a/backend/plugin/advisor/tidb/test/index_primary_key_type_allowlist.yaml
+++ b/backend/plugin/advisor/tidb/test/index_primary_key_type_allowlist.yaml
@@ -5,9 +5,8 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(id INT PRIMARY KEY)
@@ -19,9 +18,8 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(id INT, id2 VARCHAR(5), id3 VARCHAR(5), PRIMARY KEY(id, id2, id3))
@@ -31,18 +29,16 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id2` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 803
title: index.primary-key-type-allowlist
content: The column `id3` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(id INT, id2 BIGINT, PRIMARY KEY(id, id2))
@@ -58,9 +54,8 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -76,9 +71,8 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -90,18 +84,16 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id2` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 803
title: index.primary-key-type-allowlist
content: The column `id3` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -121,9 +113,8 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -135,18 +126,16 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id2` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 803
title: index.primary-key-type-allowlist
content: The column `id3` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -166,9 +155,8 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -184,9 +172,8 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id2` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/tidb/test/index_total_number_limit.yaml b/backend/plugin/advisor/tidb/test/index_total_number_limit.yaml
index e3cce7a971..9ffd2163e9 100644
--- a/backend/plugin/advisor/tidb/test/index_total_number_limit.yaml
+++ b/backend/plugin/advisor/tidb/test/index_total_number_limit.yaml
@@ -14,9 +14,8 @@
code: 813
title: index.total-number-limit
content: The count of index in table `tech_book` should be no more than 5, but found 8
- detail: ""
startposition:
- line: 5
+ line: 4
column: 0
endposition: null
- statement: |-
@@ -32,9 +31,8 @@
code: 813
title: index.total-number-limit
content: The count of index in table `t` should be no more than 5, but found 6
- detail: ""
startposition:
- line: 6
+ line: 5
column: 0
endposition: null
- statement: |-
@@ -53,8 +51,7 @@
code: 813
title: index.total-number-limit
content: The count of index in table `t` should be no more than 5, but found 6
- detail: ""
startposition:
- line: 9
+ line: 8
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/index_type_no_blob.yaml b/backend/plugin/advisor/tidb/test/index_type_no_blob.yaml
index 1f55f4b7c6..f31a963a31 100644
--- a/backend/plugin/advisor/tidb/test/index_type_no_blob.yaml
+++ b/backend/plugin/advisor/tidb/test/index_type_no_blob.yaml
@@ -5,9 +5,8 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(b BLOB, mb MEDIUMBLOB, lb LONGBLOB, id INT, PRIMARY KEY(b(1), mb(2), lb(3), id))
@@ -17,27 +16,24 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(b BLOB, mb MEDIUMBLOB, lb LONGBLOB, id INT, UNIQUE INDEX(b(1), mb(2), lb(3), id))
@@ -47,27 +43,24 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(b BLOB, mb MEDIUMBLOB, lb LONGBLOB, id iNT, INDEX(b(1), mb(2), lb(3), id))
@@ -77,27 +70,24 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(id INT, PRIMARY KEY(id))
@@ -111,9 +101,8 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -125,27 +114,24 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -157,27 +143,24 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -196,27 +179,24 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- statement: |-
diff --git a/backend/plugin/advisor/tidb/test/naming_column.yaml b/backend/plugin/advisor/tidb/test/naming_column.yaml
index f2f72810f2..8fb3d5d32f 100644
--- a/backend/plugin/advisor/tidb/test/naming_column.yaml
+++ b/backend/plugin/advisor/tidb/test/naming_column.yaml
@@ -5,9 +5,8 @@
code: 302
title: naming.column
content: '`book`.`creatorId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id int, gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx int)
@@ -17,9 +16,8 @@
code: 302
title: naming.column
content: '`book`.`gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx` mismatches column naming convention, its length should be within 64 characters'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id int, creator_id int)
@@ -33,9 +31,8 @@
code: 302
title: naming.column
content: '`book`.`creatorId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: ALTER TABLE tech_book RENAME COLUMN id TO creator_id;
@@ -54,9 +51,8 @@
code: 302
title: naming.column
content: '`book`.`creatorId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 7
+ line: 6
column: 0
endposition: null
- statement: ALTER TABLE tech_book CHANGE COLUMN id creator_id int;
@@ -76,9 +72,8 @@
code: 302
title: naming.column
content: '`book`.`contentString` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 6
+ line: 5
column: 0
endposition: null
- statement: |-
@@ -97,35 +92,31 @@
code: 302
title: naming.column
content: '`book`.`createdTs` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 302
title: naming.column
content: '`book`.`updaterId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- status: 2
code: 302
title: naming.column
content: '`student`.`createdTs` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 8
+ line: 7
column: 0
endposition: null
- status: 2
code: 302
title: naming.column
content: '`student`.`updatedTs` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 9
+ line: 8
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/naming_column_auto_increment.yaml b/backend/plugin/advisor/tidb/test/naming_column_auto_increment.yaml
index fc227ca465..7f8ecccc9e 100644
--- a/backend/plugin/advisor/tidb/test/naming_column_auto_increment.yaml
+++ b/backend/plugin/advisor/tidb/test/naming_column_auto_increment.yaml
@@ -7,9 +7,8 @@
code: 307
title: naming.column.auto-increment
content: '`book`.`a` mismatches auto_increment column naming convention, naming format should be "^id$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD COLUMN a int AUTO_INCREMENT
@@ -19,9 +18,8 @@
code: 307
title: naming.column.auto-increment
content: '`tech_book`.`a` mismatches auto_increment column naming convention, naming format should be "^id$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book CHANGE COLUMN id a int AUTO_INCREMENT
@@ -31,9 +29,8 @@
code: 307
title: naming.column.auto-increment
content: '`tech_book`.`a` mismatches auto_increment column naming convention, naming format should be "^id$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book MODIFY COLUMN name int AUTO_INCREMENT
@@ -43,8 +40,7 @@
code: 307
title: naming.column.auto-increment
content: '`tech_book`.`name` mismatches auto_increment column naming convention, naming format should be "^id$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/naming_index_fk.yaml b/backend/plugin/advisor/tidb/test/naming_index_fk.yaml
index d26f183353..75ceacbf22 100644
--- a/backend/plugin/advisor/tidb/test/naming_index_fk.yaml
+++ b/backend/plugin/advisor/tidb/test/naming_index_fk.yaml
@@ -7,9 +7,8 @@
code: 305
title: naming.index.fk
content: Foreign key in table `tech_book` mismatches the naming convention, expect "^$|^fk_tech_book_author_id_author_id$" but found `fk_author_id`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD CONSTRAINT rvemempmcmmhutaskvcidmwaldtfjdgmcpkhmibtadfydtkexpuzczrrneucthfwk FOREIGN KEY (author_id) REFERENCES author (id)
@@ -19,18 +18,16 @@
code: 305
title: naming.index.fk
content: Foreign key `rvemempmcmmhutaskvcidmwaldtfjdgmcpkhmibtadfydtkexpuzczrrneucthfwk` in table `tech_book` mismatches the naming convention, its length should be within 64 characters
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 305
title: naming.index.fk
content: Foreign key in table `tech_book` mismatches the naming convention, expect "^$|^fk_tech_book_author_id_author_id$" but found `rvemempmcmmhutaskvcidmwaldtfjdgmcpkhmibtadfydtkexpuzczrrneucthfwk`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id INT, author_id INT, FOREIGN KEY fk_book_author_id_author_id (author_id) REFERENCES author (id))
@@ -44,8 +41,7 @@
code: 305
title: naming.index.fk
content: Foreign key in table `book` mismatches the naming convention, expect "^$|^fk_book_author_id_author_id$" but found `fk_book_author_id`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/naming_index_idx.yaml b/backend/plugin/advisor/tidb/test/naming_index_idx.yaml
index b8ded7db57..d06903cf49 100644
--- a/backend/plugin/advisor/tidb/test/naming_index_idx.yaml
+++ b/backend/plugin/advisor/tidb/test/naming_index_idx.yaml
@@ -7,9 +7,8 @@
code: 303
title: naming.index.idx
content: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `tech_book_id_name`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE INDEX afvjwsgrbgqzjfrkmbcoxzstznuypasijbbcdykoboredqovetzfcmmqliaelyavw ON tech_book(id, name)
@@ -19,18 +18,16 @@
code: 303
title: naming.index.idx
content: Index `afvjwsgrbgqzjfrkmbcoxzstznuypasijbbcdykoboredqovetzfcmmqliaelyavw` in table `tech_book` mismatches the naming convention, its length should be within 64 characters
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 303
title: naming.index.idx
content: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `afvjwsgrbgqzjfrkmbcoxzstznuypasijbbcdykoboredqovetzfcmmqliaelyavw`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book RENAME INDEX old_index TO idx_tech_book_id_name
@@ -42,9 +39,8 @@
code: 303
title: naming.index.idx
content: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `idx_tech_book`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD INDEX idx_tech_book_id_name (id, name)
@@ -56,9 +52,8 @@
code: 303
title: naming.index.idx
content: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `tech_book_id_name`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE tech_book_copy(id INT PRIMARY KEY, name VARCHAR(20), INDEX idx_tech_book_copy_name (name))
diff --git a/backend/plugin/advisor/tidb/test/naming_index_uk.yaml b/backend/plugin/advisor/tidb/test/naming_index_uk.yaml
index 3e562c0d8d..11e6bb394c 100644
--- a/backend/plugin/advisor/tidb/test/naming_index_uk.yaml
+++ b/backend/plugin/advisor/tidb/test/naming_index_uk.yaml
@@ -7,9 +7,8 @@
code: 304
title: naming.index.uk
content: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `tech_book_id_name`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE UNIQUE INDEX qtzmquwvlnttctfluoouxelxeliltcfzzstrtyocogwwyiyrflmrkbhbfasynlacy ON tech_book(id, name)
@@ -19,18 +18,16 @@
code: 304
title: naming.index.uk
content: Unique key `qtzmquwvlnttctfluoouxelxeliltcfzzstrtyocogwwyiyrflmrkbhbfasynlacy` in table `tech_book` mismatches the naming convention, its length should be within 64 characters
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 304
title: naming.index.uk
content: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `qtzmquwvlnttctfluoouxelxeliltcfzzstrtyocogwwyiyrflmrkbhbfasynlacy`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD UNIQUE uk_tech_book_id_name (id, name)
@@ -42,9 +39,8 @@
code: 304
title: naming.index.uk
content: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `tech_book_id_name`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book RENAME INDEX old_uk TO uk_tech_book_id_name
@@ -56,9 +52,8 @@
code: 304
title: naming.index.uk
content: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `uk_tech_book`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id INT PRIMARY KEY, name VARCHAR(20), UNIQUE INDEX uk_book_name (name))
diff --git a/backend/plugin/advisor/tidb/test/naming_table.yaml b/backend/plugin/advisor/tidb/test/naming_table.yaml
index 726be80023..b46fa977dd 100644
--- a/backend/plugin/advisor/tidb/test/naming_table.yaml
+++ b/backend/plugin/advisor/tidb/test/naming_table.yaml
@@ -5,9 +5,8 @@
code: 301
title: naming.table
content: '`techBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE tech_book_copy(id int, name varchar(255))
@@ -19,9 +18,8 @@
code: 301
title: naming.table
content: '`cjnubexocfhqoogdmihudyahmmghviqkzvpixnwvxtxumvuannpwdcbtsgwrvzpde` mismatches table naming convention, its length should be within 64 characters'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book RENAME TO TechBook
@@ -31,9 +29,8 @@
code: 301
title: naming.table
content: '`TechBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book RENAME TO tech_book_copy
@@ -45,9 +42,8 @@
code: 301
title: naming.table
content: '`LiteraryBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE literary_book(a int);RENAME TABLE tech_book TO TechBook, literary_book TO LiteraryBook
@@ -57,18 +53,16 @@
code: 301
title: naming.table
content: '`LiteraryBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 301
title: naming.table
content: '`TechBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE literary_book(a int);RENAME TABLE tech_book TO tech_book_copy, literary_book TO literary_book_copy
diff --git a/backend/plugin/advisor/tidb/test/schema_backward_compatibility.yaml b/backend/plugin/advisor/tidb/test/schema_backward_compatibility.yaml
index 2c1692c55e..ecf47a54da 100644
--- a/backend/plugin/advisor/tidb/test/schema_backward_compatibility.yaml
+++ b/backend/plugin/advisor/tidb/test/schema_backward_compatibility.yaml
@@ -5,9 +5,8 @@
code: 111
title: schema.backward-compatibility
content: '"ALTER TABLE tech_book CHANGE name f2 TEXT" may cause incompatibility with the existing data and code'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book MODIFY name TEXT
@@ -17,9 +16,8 @@
code: 111
title: schema.backward-compatibility
content: '"ALTER TABLE tech_book MODIFY name TEXT" may cause incompatibility with the existing data and code'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book MODIFY name TEXT NULL
@@ -29,9 +27,8 @@
code: 111
title: schema.backward-compatibility
content: '"ALTER TABLE tech_book MODIFY name TEXT NULL" may cause incompatibility with the existing data and code'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book MODIFY name TEXT NOT NULL
@@ -41,9 +38,8 @@
code: 111
title: schema.backward-compatibility
content: '"ALTER TABLE tech_book MODIFY name TEXT NOT NULL" may cause incompatibility with the existing data and code'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book MODIFY name TEXT COMMENT 'bla'
@@ -53,8 +49,7 @@
code: 111
title: schema.backward-compatibility
content: '"ALTER TABLE tech_book MODIFY name TEXT COMMENT ''bla''" may cause incompatibility with the existing data and code'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/statement_disallow_commit.yaml b/backend/plugin/advisor/tidb/test/statement_disallow_commit.yaml
index 806ff53e06..10735b4545 100644
--- a/backend/plugin/advisor/tidb/test/statement_disallow_commit.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_disallow_commit.yaml
@@ -8,9 +8,8 @@
code: 206
title: statement.disallow-commit
content: 'Commit is not allowed, related statement: "COMMIT;"'
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- statement: |-
@@ -27,17 +26,15 @@
code: 206
title: statement.disallow-commit
content: 'Commit is not allowed, related statement: "COMMIT;"'
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 206
title: statement.disallow-commit
content: 'Commit is not allowed, related statement: "COMMIT;"'
- detail: ""
startposition:
- line: 7
+ line: 6
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/statement_disallow_limit.yaml b/backend/plugin/advisor/tidb/test/statement_disallow_limit.yaml
index abb681575b..f7b2048fd8 100644
--- a/backend/plugin/advisor/tidb/test/statement_disallow_limit.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_disallow_limit.yaml
@@ -7,9 +7,8 @@
code: 1103
title: statement.disallow-limit
content: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO tech_book SELECT * FROM tech_book LIMIT 1" uses
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: INSERT INTO tech_book SELECT * FROM tech_book UNION SELECT * FROM tech_book LIMIT 1
@@ -19,9 +18,8 @@
code: 1103
title: statement.disallow-limit
content: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO tech_book SELECT * FROM tech_book UNION SELECT * FROM tech_book LIMIT 1" uses
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: UPDATE tech_book SET name = 'my name' LIMIT 10
@@ -31,9 +29,8 @@
code: 1102
title: statement.disallow-limit
content: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "UPDATE tech_book SET name = 'my name' LIMIT 10" uses
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: DELETE FROM tech_book LIMIT 10
@@ -43,8 +40,7 @@
code: 1106
title: statement.disallow-limit
content: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "DELETE FROM tech_book LIMIT 10" uses
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/statement_disallow_mix_in_ddl.yaml b/backend/plugin/advisor/tidb/test/statement_disallow_mix_in_ddl.yaml
index c3fd0f30ad..2455aa3b98 100644
--- a/backend/plugin/advisor/tidb/test/statement_disallow_mix_in_ddl.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_disallow_mix_in_ddl.yaml
@@ -5,9 +5,8 @@
code: 227
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL, "DELETE FROM tech_book WHERE a > 1;" is not DDL
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: UPDATE tech_book SET id = 1;
@@ -17,9 +16,8 @@
code: 227
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL, "UPDATE tech_book SET id = 1;" is not DDL
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD COLUMN author TEXT; UPDATE tech_book SET id = 1;DELETE FROM tech_book WHERE a > 1;
@@ -29,17 +27,15 @@
code: 227
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL, "DELETE FROM tech_book WHERE a > 1;" is not DDL
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- status: 2
code: 227
title: statement.disallow-mix-in-ddl
content: Alter schema can only run DDL, "UPDATE tech_book SET id = 1;" is not DDL
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/statement_disallow_mix_in_dml.yaml b/backend/plugin/advisor/tidb/test/statement_disallow_mix_in_dml.yaml
index 51ccbeb2e8..58503bd9b5 100644
--- a/backend/plugin/advisor/tidb/test/statement_disallow_mix_in_dml.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_disallow_mix_in_dml.yaml
@@ -9,8 +9,7 @@
code: 227
title: statement.disallow-mix-in-dml
content: Data change can only run DML, "ALTER TABLE tech_book ADD COLUMN author TEXT;" is not DML
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/statement_disallow_order_by.yaml b/backend/plugin/advisor/tidb/test/statement_disallow_order_by.yaml
index 88223c5049..cbeffdb91e 100644
--- a/backend/plugin/advisor/tidb/test/statement_disallow_order_by.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_disallow_order_by.yaml
@@ -7,9 +7,8 @@
code: 1104
title: statement.disallow-order-by
content: ORDER BY clause is forbidden in DELETE and UPDATE statements, but "UPDATE tech_book SET name = 'my name' ORDER BY id" uses
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: DELETE FROM tech_book ORDER BY id
@@ -19,8 +18,7 @@
code: 1105
title: statement.disallow-order-by
content: ORDER BY clause is forbidden in DELETE and UPDATE statements, but "DELETE FROM tech_book ORDER BY id" uses
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/statement_insert_disallow_order_by_rand.yaml b/backend/plugin/advisor/tidb/test/statement_insert_disallow_order_by_rand.yaml
index 957420705b..2a9dfca09a 100644
--- a/backend/plugin/advisor/tidb/test/statement_insert_disallow_order_by_rand.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_insert_disallow_order_by_rand.yaml
@@ -7,8 +7,7 @@
code: 1108
title: statement.insert.disallow-order-by-rand
content: '"INSERT INTO tech_book SELECT * FROM tech_book ORDER BY rand()" uses ORDER BY RAND in the INSERT statement'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/statement_insert_must_specify_column.yaml b/backend/plugin/advisor/tidb/test/statement_insert_must_specify_column.yaml
index 72316511c2..749b0c4482 100644
--- a/backend/plugin/advisor/tidb/test/statement_insert_must_specify_column.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_insert_must_specify_column.yaml
@@ -7,8 +7,7 @@
code: 1107
title: statement.insert.must-specify-column
content: The INSERT statement must specify columns but "INSERT INTO tech_book VALUES (1, '1')" does not
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/statement_maximum_limit_value.yaml b/backend/plugin/advisor/tidb/test/statement_maximum_limit_value.yaml
index 341261a746..2a5837919e 100644
--- a/backend/plugin/advisor/tidb/test/statement_maximum_limit_value.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_maximum_limit_value.yaml
@@ -6,8 +6,7 @@
code: 222
title: statement.maximum-limit-value
content: The limit value 1000000 exceeds the maximum allowed value 1000
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/statement_merge_alter_table.yaml b/backend/plugin/advisor/tidb/test/statement_merge_alter_table.yaml
index af428f8b91..08a0750804 100644
--- a/backend/plugin/advisor/tidb/test/statement_merge_alter_table.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_merge_alter_table.yaml
@@ -9,9 +9,8 @@
code: 207
title: statement.merge-alter-table
content: There are 2 statements to modify table `tech_book`
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -25,18 +24,16 @@
code: 207
title: statement.merge-alter-table
content: There are 2 statements to modify table `t`
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 207
title: statement.merge-alter-table
content: There are 2 statements to modify table `tech_book`
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- statement: |-
@@ -50,17 +47,15 @@
code: 207
title: statement.merge-alter-table
content: There are 2 statements to modify table `tech_book`
- detail: ""
startposition:
- line: 3
+ line: 2
column: 0
endposition: null
- status: 2
code: 207
title: statement.merge-alter-table
content: There are 2 statements to modify table `t`
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/statement_select_no_select_all.yaml b/backend/plugin/advisor/tidb/test/statement_select_no_select_all.yaml
index 3411a7df03..97c0fb904a 100644
--- a/backend/plugin/advisor/tidb/test/statement_select_no_select_all.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_select_no_select_all.yaml
@@ -5,9 +5,8 @@
code: 203
title: statement.select.no-select-all
content: '"SELECT * FROM t" uses SELECT all'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT a, b FROM t
@@ -19,8 +18,7 @@
code: 203
title: statement.select.no-select-all
content: '"SELECT a, b FROM (SELECT * from t1 JOIN t2) t" uses SELECT all'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/statement_where_no_leading_wildcard_like.yaml b/backend/plugin/advisor/tidb/test/statement_where_no_leading_wildcard_like.yaml
index 223de58bff..241f8c6b50 100644
--- a/backend/plugin/advisor/tidb/test/statement_where_no_leading_wildcard_like.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_where_no_leading_wildcard_like.yaml
@@ -7,9 +7,8 @@
code: 204
title: statement.where.no-leading-wildcard-like
content: '"SELECT * FROM t WHERE a LIKE ''%abc''" uses leading wildcard LIKE'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT * FROM t WHERE a LIKE 'abc' OR a LIKE '%abc'
@@ -19,9 +18,8 @@
code: 204
title: statement.where.no-leading-wildcard-like
content: '"SELECT * FROM t WHERE a LIKE ''abc'' OR a LIKE ''%abc''" uses leading wildcard LIKE'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc'
@@ -31,9 +29,8 @@
code: 204
title: statement.where.no-leading-wildcard-like
content: '"SELECT * FROM t WHERE a LIKE ''%acc'' OR a LIKE ''%abc''" uses leading wildcard LIKE'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT * FROM (SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc') t1
@@ -43,8 +40,7 @@
code: 204
title: statement.where.no-leading-wildcard-like
content: '"SELECT * FROM (SELECT * FROM t WHERE a LIKE ''%acc'' OR a LIKE ''%abc'') t1" uses leading wildcard LIKE'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/statement_where_require_select.yaml b/backend/plugin/advisor/tidb/test/statement_where_require_select.yaml
index 463756f422..18ae66df33 100644
--- a/backend/plugin/advisor/tidb/test/statement_where_require_select.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_where_require_select.yaml
@@ -5,9 +5,8 @@
code: 202
title: statement.where.require.select
content: '"SELECT id FROM tech_book" requires WHERE clause'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT id FROM tech_book WHERE id > 0
@@ -19,9 +18,8 @@
code: 202
title: statement.where.require.select
content: '"SELECT id FROM tech_book WHERE id > (SELECT max(id) FROM tech_book)" requires WHERE clause'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: SELECT CURDATE()
diff --git a/backend/plugin/advisor/tidb/test/statement_where_require_update_delete.yaml b/backend/plugin/advisor/tidb/test/statement_where_require_update_delete.yaml
index ca32975190..261ff85760 100644
--- a/backend/plugin/advisor/tidb/test/statement_where_require_update_delete.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_where_require_update_delete.yaml
@@ -5,9 +5,8 @@
code: 202
title: statement.where.require.update-delete
content: '"DELETE FROM tech_book" requires WHERE clause'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: UPDATE tech_book SET id = 1
@@ -17,9 +16,8 @@
code: 202
title: statement.where.require.update-delete
content: '"UPDATE tech_book SET id = 1" requires WHERE clause'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: DELETE FROM tech_book WHERE id > 0
diff --git a/backend/plugin/advisor/tidb/test/system_charset_allowlist.yaml b/backend/plugin/advisor/tidb/test/system_charset_allowlist.yaml
index 991941b80f..c0d2a463ca 100644
--- a/backend/plugin/advisor/tidb/test/system_charset_allowlist.yaml
+++ b/backend/plugin/advisor/tidb/test/system_charset_allowlist.yaml
@@ -9,9 +9,8 @@
code: 1001
title: system.charset.allowlist
content: '"CREATE TABLE t(a int) CHARSET ascii" used disabled charset ''ascii'''
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -23,9 +22,8 @@
code: 1001
title: system.charset.allowlist
content: '"ALTER TABLE t CHARSET ascii" used disabled charset ''ascii'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: ALTER DATABASE test CHARSET ascii
@@ -35,9 +33,8 @@
code: 1001
title: system.charset.allowlist
content: '"ALTER DATABASE test CHARSET ascii" used disabled charset ''ascii'''
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(a varchar(255) CHARSET ascii)
@@ -47,9 +44,8 @@
code: 1001
title: system.charset.allowlist
content: '"CREATE TABLE t(a varchar(255) CHARSET ascii)" used disabled charset ''ascii'''
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -61,9 +57,8 @@
code: 1001
title: system.charset.allowlist
content: '"ALTER TABLE t ADD COLUMN a varchar(255) CHARSET ascii" used disabled charset ''ascii'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -75,9 +70,8 @@
code: 1001
title: system.charset.allowlist
content: '"ALTER TABLE t MODIFY COLUMN a varchar(255) CHARSET ascii" used disabled charset ''ascii'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -89,9 +83,8 @@
code: 1001
title: system.charset.allowlist
content: '"ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARSET ascii" used disabled charset ''ascii'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: /* this is a comment */
diff --git a/backend/plugin/advisor/tidb/test/system_collation_allowlist.yaml b/backend/plugin/advisor/tidb/test/system_collation_allowlist.yaml
index f971335897..4bdac88d0c 100644
--- a/backend/plugin/advisor/tidb/test/system_collation_allowlist.yaml
+++ b/backend/plugin/advisor/tidb/test/system_collation_allowlist.yaml
@@ -5,9 +5,8 @@
code: 1201
title: system.collation.allowlist
content: '"CREATE TABLE t(a int) COLLATE utf8mb4_polish_ci" used disabled collation ''utf8mb4_polish_ci'''
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(a varchar(255))
@@ -19,9 +18,8 @@
code: 1201
title: system.collation.allowlist
content: '"CREATE TABLE t(a int) COLLATE latin1_bin" used disabled collation ''latin1_bin'''
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -33,9 +31,8 @@
code: 1201
title: system.collation.allowlist
content: '"ALTER TABLE t COLLATE latin1_bin" used disabled collation ''latin1_bin'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: ALTER DATABASE test COLLATE latin1_bin
@@ -45,9 +42,8 @@
code: 1201
title: system.collation.allowlist
content: '"ALTER DATABASE test COLLATE latin1_bin" used disabled collation ''latin1_bin'''
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin)
@@ -57,9 +53,8 @@
code: 1201
title: system.collation.allowlist
content: '"CREATE TABLE t(a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin)" used disabled collation ''latin1_bin'''
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -71,9 +66,8 @@
code: 1201
title: system.collation.allowlist
content: '"ALTER TABLE t ADD COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin" used disabled collation ''latin1_bin'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -85,9 +79,8 @@
code: 1201
title: system.collation.allowlist
content: '"ALTER TABLE t MODIFY COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin" used disabled collation ''latin1_bin'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -99,8 +92,7 @@
code: 1201
title: system.collation.allowlist
content: '"ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin" used disabled collation ''latin1_bin'''
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/table_comment.yaml b/backend/plugin/advisor/tidb/test/table_comment.yaml
index 431ae460a9..371fb12ec6 100644
--- a/backend/plugin/advisor/tidb/test/table_comment.yaml
+++ b/backend/plugin/advisor/tidb/test/table_comment.yaml
@@ -5,9 +5,8 @@
code: 1301
title: table.comment
content: The length of table `t` comment should be within 10 characters
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(a int)
@@ -17,9 +16,8 @@
code: 1032
title: table.comment
content: Table `t` requires comments
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE t(a int) COMMENT 'sdlfkjalkseblkjduafelbnlsdfkljayue'
@@ -29,8 +27,7 @@
code: 1301
title: table.comment
content: The length of table `t` comment should be within 10 characters
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/table_disallow_partition.yaml b/backend/plugin/advisor/tidb/test/table_disallow_partition.yaml
index cdd6b22cd4..e6589209d2 100644
--- a/backend/plugin/advisor/tidb/test/table_disallow_partition.yaml
+++ b/backend/plugin/advisor/tidb/test/table_disallow_partition.yaml
@@ -15,9 +15,8 @@
PARTITION p0 VALUES LESS THAN (6),
PARTITION p1 VALUES LESS THAN (11)
)" creates
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
- statement: |-
@@ -35,8 +34,7 @@
PARTITION p0 VALUES LESS THAN (6),
PARTITION p1 VALUES LESS THAN (11)
)" creates
- detail: ""
startposition:
- line: 4
+ line: 3
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/table_drop_naming_convention.yaml b/backend/plugin/advisor/tidb/test/table_drop_naming_convention.yaml
index 80e1fdc6e5..b1271e3866 100644
--- a/backend/plugin/advisor/tidb/test/table_drop_naming_convention.yaml
+++ b/backend/plugin/advisor/tidb/test/table_drop_naming_convention.yaml
@@ -7,9 +7,8 @@
code: 603
title: table.drop-naming-convention
content: '`foo` mismatches drop table naming convention, naming format should be "_delete$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: DROP TABLE IF EXISTS foo_delete, bar
@@ -19,8 +18,7 @@
code: 603
title: table.drop-naming-convention
content: '`bar` mismatches drop table naming convention, naming format should be "_delete$"'
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/table_no_foreign_key.yaml b/backend/plugin/advisor/tidb/test/table_no_foreign_key.yaml
index 45c0796aa3..391b25e470 100644
--- a/backend/plugin/advisor/tidb/test/table_no_foreign_key.yaml
+++ b/backend/plugin/advisor/tidb/test/table_no_foreign_key.yaml
@@ -5,9 +5,8 @@
code: 602
title: table.no-foreign-key
content: Foreign key is not allowed in the table `tech_book`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: CREATE TABLE book(id INT, author_id INT, FOREIGN KEY fk_book_author_id_author_id (author_id) REFERENCES author (id))
@@ -17,8 +16,7 @@
code: 602
title: table.no-foreign-key
content: Foreign key is not allowed in the table `book`
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
diff --git a/backend/plugin/advisor/tidb/test/table_require_pk.yaml b/backend/plugin/advisor/tidb/test/table_require_pk.yaml
index 7844795eb2..bcc003db93 100644
--- a/backend/plugin/advisor/tidb/test/table_require_pk.yaml
+++ b/backend/plugin/advisor/tidb/test/table_require_pk.yaml
@@ -9,9 +9,8 @@
code: 601
title: table.require-pk
content: Table `t` requires PRIMARY KEY
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: |-
@@ -31,9 +30,8 @@
code: 601
title: table.require-pk
content: Table `t` requires PRIMARY KEY
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -45,9 +43,8 @@
code: 601
title: table.require-pk
content: Table `t` requires PRIMARY KEY
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: |-
@@ -79,9 +76,8 @@
code: 601
title: table.require-pk
content: Table `t` requires PRIMARY KEY
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
- statement: ALTER TABLE tech_book ADD COLUMN a int, DROP COLUMN id, DROP COLUMN name
@@ -91,9 +87,8 @@
code: 601
title: table.require-pk
content: Table `tech_book` requires PRIMARY KEY
- detail: ""
startposition:
- line: 1
+ line: 0
column: 0
endposition: null
- statement: ALTER TABLE tech_book DROP COLUMN name
@@ -107,8 +102,7 @@
code: 601
title: table.require-pk
content: Table `tech_book` requires PRIMARY KEY
- detail: ""
startposition:
- line: 2
+ line: 1
column: 0
endposition: null
diff --git a/backend/plugin/advisor/utils.go b/backend/plugin/advisor/utils.go
index c526ce523e..e195826cac 100644
--- a/backend/plugin/advisor/utils.go
+++ b/backend/plugin/advisor/utils.go
@@ -163,3 +163,13 @@ func DatabaseExists(ctx context.Context, checkCtx Context, database string) bool
return false
}
+
+func ConvertANTLRLineToPosition(line int) *storepb.Position {
+ positionLine := line - 1
+ if line == 0 {
+ positionLine = 0
+ }
+ return &storepb.Position{
+ Line: int32(positionLine),
+ }
+}
diff --git a/backend/tests/test-data/sql_review_mysql.yaml b/backend/tests/test-data/sql_review_mysql.yaml
index 1389278291..04c1b5dd33 100644
--- a/backend/tests/test-data/sql_review_mysql.yaml
+++ b/backend/tests/test-data/sql_review_mysql.yaml
@@ -12,8 +12,8 @@
{
"status": "ERROR",
"title": "Syntax error",
- "code": 201,
"content": "Syntax error at line 1:20 \nrelated text: CREATE TABLE user(id)",
+ "code": 201,
"sqlReviewReport": {
"line": 1,
"column": 20,
@@ -33,10 +33,7 @@
"content": "\"CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin;\" doesn't use InnoDB engine",
"code": 501,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -46,10 +43,7 @@
"content": "Table `userTable` requires PRIMARY KEY",
"code": 601,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -59,10 +53,7 @@
"content": "Foreign key is not allowed in the table `userTable`",
"code": 602,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -72,10 +63,7 @@
"content": "Disallow column type JSON but column `userTable`.`json_content` is",
"code": 411,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -85,10 +73,7 @@
"content": "`userTable` mismatches table naming convention, naming format should be \"^[a-z]+(_[a-z]+)*$\"",
"code": 301,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -98,10 +83,7 @@
"content": "`userTable`.`roomId` mismatches column naming convention, naming format should be \"^[a-z]+(_[a-z]+)*$\"",
"code": 302,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -111,10 +93,7 @@
"content": "Index in table `userTable` mismatches the naming convention, expect \"^$|^idx_userTable_name$\" but found `idx1`",
"code": 303,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -124,10 +103,7 @@
"content": "Unique key in table `userTable` mismatches the naming convention, expect \"^$|^uk_userTable_id_name$\" but found `uk1`",
"code": 304,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -137,10 +113,7 @@
"content": "Foreign key in table `userTable` mismatches the naming convention, expect \"^$|^fk_userTable_roomId_room_id$\" but found `fk1`",
"code": 305,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -150,10 +123,7 @@
"content": "Table `userTable` requires comments",
"code": 1032,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -163,10 +133,7 @@
"content": "Table `userTable` requires columns: created_ts, creator_id, updated_ts, updater_id",
"code": 401,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -176,10 +143,7 @@
"content": "`userTable`.`name` cannot have NULL value",
"code": 402,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -189,10 +153,7 @@
"content": "`userTable`.`roomId` cannot have NULL value",
"code": 402,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -202,10 +163,7 @@
"content": "Column `userTable`.`id` is NOT NULL but doesn't have DEFAULT",
"code": 404,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -215,10 +173,7 @@
"content": "Column `userTable`.`id` requires comments",
"code": 1032,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -228,10 +183,7 @@
"content": "Column `userTable`.`name` requires comments",
"code": 1032,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -241,10 +193,7 @@
"content": "Column `userTable`.`roomId` requires comments",
"code": 1032,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -254,10 +203,7 @@
"content": "Disallow set column charset but \"CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin;\" does",
"code": 414,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -267,10 +213,7 @@
"content": "Table `userTable` has 2 ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than 1.",
"code": 419,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -280,10 +223,7 @@
"content": "Column `userTable`.`id` doesn't have DEFAULT.",
"code": 420,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -293,10 +233,7 @@
"content": "Column `userTable`.`name` doesn't have DEFAULT.",
"code": 420,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -306,10 +243,7 @@
"content": "Column `userTable`.`roomId` doesn't have DEFAULT.",
"code": 420,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -319,10 +253,7 @@
"content": "Columns in index must not be BLOB but `userTable`.`content` is blob",
"code": 804,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -332,10 +263,7 @@
"content": "\"CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin;\" used disabled charset 'ascii'",
"code": 1001,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -345,10 +273,7 @@
"content": "\"CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin;\" used disabled collation 'latin1_bin'",
"code": 1201,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
run: false
@@ -361,10 +286,7 @@
"content": "Auto-increment column `t_auto`.`auto_id` requires integer type",
"code": 410,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -374,10 +296,7 @@
"content": "`t_auto`.`auto_id` mismatches auto_increment column naming convention, naming format should be \"^id$\"",
"code": 307,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -387,10 +306,7 @@
"content": "Table `t_auto` requires columns: created_ts, creator_id, id, updated_ts, updater_id",
"code": 401,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -400,10 +316,7 @@
"content": "The initial auto-increment value in table `t_auto` is 2, which doesn't equal 20",
"code": 416,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -413,10 +326,7 @@
"content": "Auto-increment column `t_auto`.`auto_id` is not UNSIGNED type",
"code": 417,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -426,14 +336,11 @@
"content": "Columns in primary key must be INT/BIGINT but `t_auto`.`auto_id` is varchar(20)",
"code": 803,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
run: false
-- statement: " DELETE FROM tech_book"
+- statement: ' DELETE FROM tech_book'
result:
- |-
{
@@ -442,10 +349,7 @@
"content": "\"DELETE FROM tech_book;\" requires WHERE clause",
"code": 202,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -455,10 +359,7 @@
"content": "\"DELETE FROM tech_book\" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist",
"code": 208,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -468,10 +369,7 @@
"content": "\"DELETE FROM tech_book;\" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist",
"code": 209,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
run: false
@@ -484,10 +382,7 @@
"content": "\"DELETE FROM tech_book WHERE name like \"%abc\";\" uses leading wildcard LIKE",
"code": 204,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -497,10 +392,7 @@
"content": "\"DELETE FROM tech_book WHERE name like \"%abc\"\" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist",
"code": 208,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -510,14 +402,11 @@
"content": "\"DELETE FROM tech_book WHERE name like \"%abc\";\" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist",
"code": 209,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
run: false
-- statement: " INSERT INTO t_copy SELECT * FROM t"
+- statement: ' INSERT INTO t_copy SELECT * FROM t'
result:
- |-
{
@@ -526,10 +415,7 @@
"content": "\"INSERT INTO t_copy SELECT * FROM t;\" uses SELECT all",
"code": 203,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -539,10 +425,7 @@
"content": "\"INSERT INTO t_copy SELECT * FROM t;\" requires WHERE clause",
"code": 202,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -552,10 +435,7 @@
"content": "\"INSERT INTO t_copy SELECT * FROM t\" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.t_copy' doesn't exist",
"code": 208,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -565,10 +445,7 @@
"content": "\"INSERT INTO t_copy SELECT * FROM t;\" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.t_copy' doesn't exist",
"code": 1101,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -578,14 +455,11 @@
"content": "The INSERT statement must specify columns but \"INSERT INTO t_copy SELECT * FROM t;\" does not",
"code": 1107,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
run: false
-- statement: " INSERT INTO t VALUES (1, 1, now(), 1, now())"
+- statement: ' INSERT INTO t VALUES (1, 1, now(), 1, now())'
result:
- |-
{
@@ -594,10 +468,7 @@
"content": "\"INSERT INTO t VALUES (1, 1, now(), 1, now())\" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.t' doesn't exist",
"code": 208,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -607,10 +478,7 @@
"content": "The INSERT statement must specify columns but \"INSERT INTO t VALUES (1, 1, now(), 1, now());\" does not",
"code": 1107,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
run: false
@@ -623,10 +491,7 @@
"content": "\"DELETE FROM tech_book WHERE id = (SELECT max(id) FROM tech_book WHERE name = 'bytebase')\" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist",
"code": 208,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -636,10 +501,7 @@
"content": "\"DELETE FROM tech_book WHERE id = (SELECT max(id) FROM tech_book WHERE name = 'bytebase');\" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist",
"code": 209,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
run: false
@@ -652,10 +514,7 @@
"content": "Commit is not allowed, related statement: \"COMMIT;\"",
"code": 206,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
run: false
@@ -700,10 +559,7 @@
"content": "\"DELETE FROM user WHERE id <= 10;\" affected 10 rows (estimated). The count exceeds 5.",
"code": 209,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
run: false
@@ -726,10 +582,7 @@
"content": "\"INSERT INTO user(id, name) SELECT id, name FROM (SELECT 1 AS id, 'a' AS name WHERE 1=1 UNION ALL\n SELECT 2 AS id, 'b' AS name WHERE 1=1 UNION ALL\n SELECT 3 AS id, 'c' AS name WHERE 1=1 UNION ALL\n SELECT 4 AS id, 'd' AS name WHERE 1=1 UNION ALL\n SELECT 5 AS id, 'e' AS name WHERE 1=1 UNION ALL\n SELECT 6 AS id, 'f' AS name WHERE 1=1 UNION ALL\n SELECT 7 AS id, 'g' AS name WHERE 1=1 UNION ALL\n SELECT 8 AS id, 'h' AS name WHERE 1=1 UNION ALL\n SELECT 9 AS id, 'i' AS name WHERE 1=1 UNION ALL\n SELECT 10 AS id, 'j' AS name WHERE 1=1) value_table WHERE 1=1;\" inserts 10 rows. The count exceeds 5.",
"code": 1101,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
run: false
@@ -742,14 +595,11 @@
"content": "LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but \"INSERT INTO user(id, name) SELECT id, name FROM user WHERE id=1 LIMIT 1;\" uses",
"code": 1103,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
run: false
-- statement: " ALTER TABLE user PARTITION BY HASH(id) PARTITIONS 8;"
+- statement: ' ALTER TABLE user PARTITION BY HASH(id) PARTITIONS 8;'
result:
- |-
{
@@ -758,10 +608,7 @@
"content": "Table partition is forbidden, but \"ALTER TABLE user PARTITION BY HASH(id) PARTITIONS 8;\" creates",
"code": 608,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
run: false
@@ -776,9 +623,9 @@
"content": "There are 2 statements to modify table `user`",
"code": 207,
"sqlReviewReport": {
- "line": 2,
+ "line": 1,
"startPosition": {
- "line": 2
+ "line": 1
}
}
}
@@ -789,10 +636,7 @@
"content": "\"ALTER TABLE user CHANGE name name varchar(320) NOT NULL DEFAULT '' COMMENT 'COMMENT' FIRST;\" changes column type",
"code": 403,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -802,10 +646,7 @@
"content": "\"ALTER TABLE user CHANGE name name varchar(320) NOT NULL DEFAULT '' COMMENT 'COMMENT' FIRST;\" contains CHANGE COLUMN statement",
"code": 406,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -815,10 +656,7 @@
"content": "\"ALTER TABLE user CHANGE name name varchar(320) NOT NULL DEFAULT '' COMMENT 'COMMENT' FIRST;\" changes column order",
"code": 407,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -828,14 +666,11 @@
"content": "\"ALTER TABLE user CHANGE name name varchar(320) NOT NULL DEFAULT '' COMMENT 'COMMENT' FIRST;\" may cause incompatibility with the existing data and code",
"code": 111,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
run: false
-- statement: " DROP TABLE user;"
+- statement: ' DROP TABLE user;'
result:
- |-
{
@@ -844,10 +679,7 @@
"content": "`user` mismatches drop table naming convention, naming format should be \"_delete$\"",
"code": 603,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
- |-
@@ -857,10 +689,7 @@
"content": "\"DROP TABLE user;\" may cause incompatibility with the existing data and code",
"code": 103,
"sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "startPosition": {}
}
}
run: false
diff --git a/backend/tests/test-data/sql_review_pg.yaml b/backend/tests/test-data/sql_review_pg.yaml
index 5b7516954a..30e8af99f5 100644
--- a/backend/tests/test-data/sql_review_pg.yaml
+++ b/backend/tests/test-data/sql_review_pg.yaml
@@ -14,22 +14,22 @@
result:
- |-
{
- "status": "SUCCESS",
- "title": "OK"
+ "status": "SUCCESS",
+ "title": "OK"
}
run: false
- statement: CREATE TABLE user(id);
result:
- |-
{
- "status": "ERROR",
- "title": "Syntax error",
- "content": "syntax error at or near \"user\"",
- "code": 201,
- "sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
+ "status": "ERROR",
+ "title": "Syntax error",
+ "content": "syntax error at or near \"user\"",
+ "code": 201,
+ "sqlReviewReport": {
+ "line": 1,
+ "startPosition": {
+ "line": 1
}
}
}
@@ -46,131 +46,131 @@
result:
- |-
{
- "status": "ERROR",
- "title": "table.require-pk",
- "content": "Table \"public\".\"userTable\" requires PRIMARY KEY, related statement: \"CREATE TABLE \\\"userTable\\\"(\\n id INT,\\n name VARCHAR(255),\\n \\\"roomId\\\" INT,\\n CONSTRAINT uk1 UNIQUE (id, name),\\n CONSTRAINT fk1 FOREIGN KEY (\\\"roomId\\\") REFERENCES room(id)\\n );\"",
- "code": 601,
- "sqlReviewReport": {
- "line": 7,
- "startPosition": {
- "line": 7
+ "status": "ERROR",
+ "title": "table.require-pk",
+ "content": "Table \"public\".\"userTable\" requires PRIMARY KEY, related statement: \"CREATE TABLE \\\"userTable\\\"(\\n id INT,\\n name VARCHAR(255),\\n \\\"roomId\\\" INT,\\n CONSTRAINT uk1 UNIQUE (id, name),\\n CONSTRAINT fk1 FOREIGN KEY (\\\"roomId\\\") REFERENCES room(id)\\n );\"",
+ "code": 601,
+ "sqlReviewReport": {
+ "line": 6,
+ "startPosition": {
+ "line": 6
}
}
}
- |-
{
- "status": "ERROR",
- "title": "table.no-foreign-key",
- "content": "Foreign key is not allowed in the table \"public\".\"userTable\", related statement: \"CREATE TABLE \"userTable\"(\n id INT,\n name VARCHAR(255),\n \"roomId\" INT,\n CONSTRAINT uk1 UNIQUE (id, name),\n CONSTRAINT fk1 FOREIGN KEY (\"roomId\") REFERENCES room(id)\n );\"",
- "code": 602,
- "sqlReviewReport": {
- "line": 7,
- "startPosition": {
- "line": 7
+ "status": "ERROR",
+ "title": "table.no-foreign-key",
+ "content": "Foreign key is not allowed in the table \"public\".\"userTable\", related statement: \"CREATE TABLE \"userTable\"(\n id INT,\n name VARCHAR(255),\n \"roomId\" INT,\n CONSTRAINT uk1 UNIQUE (id, name),\n CONSTRAINT fk1 FOREIGN KEY (\"roomId\") REFERENCES room(id)\n );\"",
+ "code": 602,
+ "sqlReviewReport": {
+ "line": 6,
+ "startPosition": {
+ "line": 6
}
}
}
- |-
{
- "status": "WARNING",
- "title": "naming.table",
- "content": "\"userTable\" mismatches table naming convention, naming format should be \"^[a-z]+(_[a-z]+)*$\"",
- "code": 301,
- "sqlReviewReport": {
- "line": 7,
- "startPosition": {
- "line": 7
+ "status": "WARNING",
+ "title": "naming.table",
+ "content": "\"userTable\" mismatches table naming convention, naming format should be \"^[a-z]+(_[a-z]+)*$\"",
+ "code": 301,
+ "sqlReviewReport": {
+ "line": 6,
+ "startPosition": {
+ "line": 6
}
}
}
- |-
{
- "status": "WARNING",
- "title": "naming.column",
- "content": "\"userTable\".\"roomId\" mismatches column naming convention, naming format should be \"^[a-z]+(_[a-z]+)*$\"",
- "code": 302,
- "sqlReviewReport": {
- "line": 4,
- "startPosition": {
- "line": 4
+ "status": "WARNING",
+ "title": "naming.column",
+ "content": "\"userTable\".\"roomId\" mismatches column naming convention, naming format should be \"^[a-z]+(_[a-z]+)*$\"",
+ "code": 302,
+ "sqlReviewReport": {
+ "line": 3,
+ "startPosition": {
+ "line": 3
}
}
}
- |-
{
- "status": "WARNING",
- "title": "naming.index.uk",
- "content": "Unique key in table \"userTable\" mismatches the naming convention, expect \"^$|^uk_userTable_id_name$\" but found \"uk1\"",
- "code": 304,
- "sqlReviewReport": {
- "line": 5,
- "startPosition": {
- "line": 5
+ "status": "WARNING",
+ "title": "naming.index.uk",
+ "content": "Unique key in table \"userTable\" mismatches the naming convention, expect \"^$|^uk_userTable_id_name$\" but found \"uk1\"",
+ "code": 304,
+ "sqlReviewReport": {
+ "line": 4,
+ "startPosition": {
+ "line": 4
}
}
}
- |-
{
- "status": "WARNING",
- "title": "naming.index.fk",
- "content": "Foreign key in table \"userTable\" mismatches the naming convention, expect \"^$|^fk_userTable_roomId_room_id$\" but found \"fk1\"",
- "code": 305,
- "sqlReviewReport": {
- "line": 6,
- "startPosition": {
- "line": 6
+ "status": "WARNING",
+ "title": "naming.index.fk",
+ "content": "Foreign key in table \"userTable\" mismatches the naming convention, expect \"^$|^fk_userTable_roomId_room_id$\" but found \"fk1\"",
+ "code": 305,
+ "sqlReviewReport": {
+ "line": 5,
+ "startPosition": {
+ "line": 5
}
}
}
- |-
{
- "status": "WARNING",
- "title": "column.required",
- "content": "Table \"userTable\" requires columns: created_ts, creator_id, updated_ts, updater_id",
- "code": 401,
- "sqlReviewReport": {
- "line": 7,
- "startPosition": {
- "line": 7
+ "status": "WARNING",
+ "title": "column.required",
+ "content": "Table \"userTable\" requires columns: created_ts, creator_id, updated_ts, updater_id",
+ "code": 401,
+ "sqlReviewReport": {
+ "line": 6,
+ "startPosition": {
+ "line": 6
}
}
}
- |-
{
- "status": "WARNING",
- "title": "column.no-null",
- "content": "Column \"id\" in \"public\".\"userTable\" cannot have NULL value",
- "code": 402,
- "sqlReviewReport": {
- "line": 2,
- "startPosition": {
- "line": 2
+ "status": "WARNING",
+ "title": "column.no-null",
+ "content": "Column \"id\" in \"public\".\"userTable\" cannot have NULL value",
+ "code": 402,
+ "sqlReviewReport": {
+ "line": 1,
+ "startPosition": {
+ "line": 1
}
}
}
- |-
{
- "status": "WARNING",
- "title": "column.no-null",
- "content": "Column \"name\" in \"public\".\"userTable\" cannot have NULL value",
- "code": 402,
- "sqlReviewReport": {
- "line": 3,
- "startPosition": {
- "line": 3
+ "status": "WARNING",
+ "title": "column.no-null",
+ "content": "Column \"name\" in \"public\".\"userTable\" cannot have NULL value",
+ "code": 402,
+ "sqlReviewReport": {
+ "line": 2,
+ "startPosition": {
+ "line": 2
}
}
}
- |-
{
- "status": "WARNING",
- "title": "column.no-null",
- "content": "Column \"roomId\" in \"public\".\"userTable\" cannot have NULL value",
- "code": 402,
- "sqlReviewReport": {
- "line": 4,
- "startPosition": {
- "line": 4
+ "status": "WARNING",
+ "title": "column.no-null",
+ "content": "Column \"roomId\" in \"public\".\"userTable\" cannot have NULL value",
+ "code": 402,
+ "sqlReviewReport": {
+ "line": 3,
+ "startPosition": {
+ "line": 3
}
}
}
@@ -179,15 +179,12 @@
result:
- |-
{
- "status": "ERROR",
- "title": "statement.where.require.update-delete",
- "content": "\"DELETE FROM t\" requires WHERE clause",
- "code": 202,
- "sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "status": "ERROR",
+ "title": "statement.where.require.update-delete",
+ "content": "\"DELETE FROM t\" requires WHERE clause",
+ "code": 202,
+ "sqlReviewReport": {
+ "startPosition": {}
}
}
run: false
@@ -195,15 +192,12 @@
result:
- |-
{
- "status": "ERROR",
- "title": "statement.where.no-leading-wildcard-like",
- "content": "\"DELETE FROM t WHERE a like '%abc'\" uses leading wildcard LIKE",
- "code": 204,
- "sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "status": "ERROR",
+ "title": "statement.where.no-leading-wildcard-like",
+ "content": "\"DELETE FROM t WHERE a like '%abc'\" uses leading wildcard LIKE",
+ "code": 204,
+ "sqlReviewReport": {
+ "startPosition": {}
}
}
run: false
@@ -211,16 +205,16 @@
result:
- |-
{
- "status": "SUCCESS",
- "title": "OK"
+ "status": "SUCCESS",
+ "title": "OK"
}
run: false
- statement: INSERT INTO t VALUES (1), (2)
result:
- |-
{
- "status": "SUCCESS",
- "title": "OK"
+ "status": "SUCCESS",
+ "title": "OK"
}
run: false
- statement: |-
@@ -236,23 +230,20 @@
result:
- |-
{
- "status": "SUCCESS",
- "title": "OK"
+ "status": "SUCCESS",
+ "title": "OK"
}
run: true
- statement: ALTER INDEX pk_tech_book_id RENAME TO pk1
result:
- |-
{
- "status": "WARNING",
- "title": "naming.index.pk",
- "content": "Primary key in table \"tech_book\" mismatches the naming convention, expect \"^$|^pk_tech_book_id$\" but found \"pk1\"",
- "code": 306,
- "sqlReviewReport": {
- "line": 1,
- "startPosition": {
- "line": 1
- }
+ "status": "WARNING",
+ "title": "naming.index.pk",
+ "content": "Primary key in table \"tech_book\" mismatches the naming convention, expect \"^$|^pk_tech_book_id$\" but found \"pk1\"",
+ "code": 306,
+ "sqlReviewReport": {
+ "startPosition": {}
}
}
run: false
diff --git a/frontend/src/types/proto/google/protobuf/descriptor.ts b/frontend/src/types/proto/google/protobuf/descriptor.ts
index 2fdf22f5e2..ae3f877dc7 100644
--- a/frontend/src/types/proto/google/protobuf/descriptor.ts
+++ b/frontend/src/types/proto/google/protobuf/descriptor.ts
@@ -36,7 +36,7 @@ export enum Edition {
EDITION_2024 = "EDITION_2024",
/**
* EDITION_1_TEST_ONLY - Placeholder editions for testing feature resolution. These should not be
- * used or relied on outside of tests.
+ * used or relyed on outside of tests.
*/
EDITION_1_TEST_ONLY = "EDITION_1_TEST_ONLY",
EDITION_2_TEST_ONLY = "EDITION_2_TEST_ONLY",
@@ -1093,13 +1093,12 @@ export interface MessageOptions {
export interface FieldOptions {
/**
- * NOTE: ctype is deprecated. Use `features.(pb.cpp).string_type` instead.
* The ctype option instructs the C++ code generator to use a different
* representation of the field than it normally would. See the specific
* options below. This option is only implemented to support use of
* [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of
- * type "bytes" in the open source release.
- * TODO: make ctype actually deprecated.
+ * type "bytes" in the open source release -- sorry, we'll try to include
+ * other types in a future version!
*/
ctype?:
| FieldOptions_CType
@@ -1315,7 +1314,11 @@ export function fieldOptions_JSTypeToNumber(object: FieldOptions_JSType): number
}
}
-/** If set to RETENTION_SOURCE, the option will be omitted from the binary. */
+/**
+ * If set to RETENTION_SOURCE, the option will be omitted from the binary.
+ * Note: as of January 2023, support for this is in progress and does not yet
+ * have an effect (b/264593489).
+ */
export enum FieldOptions_OptionRetention {
RETENTION_UNKNOWN = "RETENTION_UNKNOWN",
RETENTION_RUNTIME = "RETENTION_RUNTIME",
@@ -1372,7 +1375,8 @@ export function fieldOptions_OptionRetentionToNumber(object: FieldOptions_Option
/**
* This indicates the types of entities that the field may apply to when used
* as an option. If it is unset, then the field may be freely used as an
- * option on any kind of entity.
+ * option on any kind of entity. Note: as of January 2023, support for this is
+ * in progress and does not yet have an effect (b/264593489).
*/
export enum FieldOptions_OptionTargetType {
TARGET_TYPE_UNKNOWN = "TARGET_TYPE_UNKNOWN",
diff --git a/frontend/src/types/proto/store/advice.ts b/frontend/src/types/proto/store/advice.ts
index de9fc4abf2..1c959464fa 100644
--- a/frontend/src/types/proto/store/advice.ts
+++ b/frontend/src/types/proto/store/advice.ts
@@ -20,7 +20,10 @@ export interface Advice {
title: string;
/** The advice content. */
content: string;
- /** 1-based positions of the sql statment. */
+ /**
+ * The start_position is inclusive and the end_position is exclusive.
+ * TODO: use range instead.
+ */
startPosition: Position | undefined;
endPosition: Position | undefined;
}
diff --git a/frontend/src/types/proto/store/common.ts b/frontend/src/types/proto/store/common.ts
index 72dfd56804..8afc65f774 100644
--- a/frontend/src/types/proto/store/common.ts
+++ b/frontend/src/types/proto/store/common.ts
@@ -468,8 +468,14 @@ export interface PageToken {
offset: number;
}
+/**
+ * Position in a text expressed as zero-based line and zero-based column byte
+ * offset.
+ */
export interface Position {
+ /** Line position in a text (zero-based). */
line: number;
+ /** Column position in a text (zero-based), equivalent to byte offset. */
column: number;
}
diff --git a/frontend/src/types/proto/store/task_run.ts b/frontend/src/types/proto/store/task_run.ts
index bf4bb6d63a..3eb60aa25c 100644
--- a/frontend/src/types/proto/store/task_run.ts
+++ b/frontend/src/types/proto/store/task_run.ts
@@ -27,7 +27,10 @@ export interface TaskRunResult {
priorBackupDetail: PriorBackupDetail | undefined;
}
-/** The following fields are used for error reporting. */
+/**
+ * The following fields are used for error reporting.
+ * TODO(zp): Use common Position instead.
+ */
export interface TaskRunResult_Position {
line: number;
column: number;
diff --git a/frontend/src/types/proto/v1/common.ts b/frontend/src/types/proto/v1/common.ts
index 0211d738c7..2f48cf454e 100644
--- a/frontend/src/types/proto/v1/common.ts
+++ b/frontend/src/types/proto/v1/common.ts
@@ -454,8 +454,14 @@ export function exportFormatToNumber(object: ExportFormat): number {
}
}
+/**
+ * Position in a text expressed as zero-based line and zero-based column byte
+ * offset.
+ */
export interface Position {
+ /** Line position in a text (zero-based). */
line: number;
+ /** Column position in a text (zero-based), equivalent to byte offset. */
column: number;
}
diff --git a/frontend/src/types/proto/v1/sql_service.ts b/frontend/src/types/proto/v1/sql_service.ts
index 5dc3803d20..9aeb9fe7e1 100644
--- a/frontend/src/types/proto/v1/sql_service.ts
+++ b/frontend/src/types/proto/v1/sql_service.ts
@@ -282,8 +282,9 @@ export interface Advice {
/** The advice column number in the SQL statement. */
column: number;
/**
- * 1-based Position of the SQL statement.
* To supersede `line` and `column` above.
+ * The start_position is inclusive and the end_position is exclusive.
+ * TODO: use range instead
*/
startPosition: Position | undefined;
endPosition: Position | undefined;
@@ -513,7 +514,10 @@ export interface DiffMetadataRequest {
| undefined;
/** The database engine of the schema. */
engine: Engine;
- /** If false, we will build the raw common by classification in database config. */
+ /**
+ * If false, we will build the raw common by classification in database
+ * config.
+ */
classificationFromConfig: boolean;
}
@@ -643,7 +647,10 @@ export interface AICompletionRequest_Message {
}
export interface AICompletionResponse {
- /** candidates is used for results with multiple choices and candidates. Used for OpenAI and Gemini. */
+ /**
+ * candidates is used for results with multiple choices and candidates. Used
+ * for OpenAI and Gemini.
+ */
candidates: AICompletionResponse_Candidate[];
}
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index 1d87247f7f..01a8e03858 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -7756,7 +7756,9 @@ components:
type: array
items:
$ref: '#/components/schemas/AICompletionResponse_Candidate'
- description: candidates is used for results with multiple choices and candidates. Used for OpenAI and Gemini.
+ description: |-
+ candidates is used for results with multiple choices and candidates. Used
+ for OpenAI and Gemini.
AICompletionResponse_Candidate:
type: object
properties:
@@ -7926,7 +7928,9 @@ components:
startPosition:
allOf:
- $ref: '#/components/schemas/Position'
- description: 1-based positions of the sql statment.
+ description: |-
+ The start_position is inclusive and the end_position is exclusive.
+ TODO: use range instead.
endPosition:
$ref: '#/components/schemas/Position'
AgentPluginSetting:
@@ -9356,7 +9360,9 @@ components:
format: enum
classificationFromConfig:
type: boolean
- description: If false, we will build the raw common by classification in database config.
+ description: |-
+ If false, we will build the raw common by classification in database
+ config.
DiffMetadataResponse:
type: object
properties:
@@ -11300,10 +11306,15 @@ components:
properties:
line:
type: integer
+ description: Line position in a text (zero-based).
format: int32
column:
type: integer
+ description: Column position in a text (zero-based), equivalent to byte offset.
format: int32
+ description: |-
+ Position in a text expressed as zero-based line and zero-based column byte
+ offset.
Postgres_Session:
type: object
properties:
diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.md
index 19fa7b496a..7dd52530a1 100644
--- a/proto/gen/grpc-doc/store/README.md
+++ b/proto/gen/grpc-doc/store/README.md
@@ -357,13 +357,14 @@ Used internally for obfuscating the page token.
<a name="bytebase-store-Position"></a>
### Position
-
+Position in a text expressed as zero-based line and zero-based column byte
+offset.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
-| line | [int32](#int32) | | |
-| column | [int32](#int32) | | |
+| line | [int32](#int32) | | Line position in a text (zero-based). |
+| column | [int32](#int32) | | Column position in a text (zero-based), equivalent to byte offset. |
@@ -496,7 +497,7 @@ Used internally for obfuscating the page token.
| code | [int32](#int32) | | The advice code. |
| title | [string](#string) | | The advice title. |
| content | [string](#string) | | The advice content. |
-| start_position | [Position](#bytebase-store-Position) | | 1-based positions of the sql statment. |
+| start_position | [Position](#bytebase-store-Position) | | The start_position is inclusive and the end_position is exclusive. TODO: use range instead. |
| end_position | [Position](#bytebase-store-Position) | | |
@@ -4800,6 +4801,7 @@ We support three types of SMTP encryption: NONE, STARTTLS, and SSL/TLS.
### TaskRunResult.Position
The following fields are used for error reporting.
+TODO(zp): Use common Position instead.
| Field | Type | Label | Description |
diff --git a/proto/gen/grpc-doc/store/index.html b/proto/gen/grpc-doc/store/index.html
index 4217f9e6d7..6f2e2482e9 100644
--- a/proto/gen/grpc-doc/store/index.html
+++ b/proto/gen/grpc-doc/store/index.html
@@ -1552,7 +1552,7 @@
<h3 id="bytebase.store.Position">Position</h3>
- <p></p>
+ <p>Position in a text expressed as zero-based line and zero-based column byte</p><p>offset.</p>
<table class="field-table">
@@ -1565,14 +1565,14 @@
<td>line</td>
<td><a href="#int32">int32</a></td>
<td></td>
- <td><p> </p></td>
+ <td><p>Line position in a text (zero-based). </p></td>
</tr>
<tr>
<td>column</td>
<td><a href="#int32">int32</a></td>
<td></td>
- <td><p> </p></td>
+ <td><p>Column position in a text (zero-based), equivalent to byte offset. </p></td>
</tr>
</tbody>
@@ -1965,7 +1965,8 @@
<td>start_position</td>
<td><a href="#bytebase.store.Position">Position</a></td>
<td></td>
- <td><p>1-based positions of the sql statment. </p></td>
+ <td><p>The start_position is inclusive and the end_position is exclusive.
+TODO: use range instead. </p></td>
</tr>
<tr>
@@ -12236,7 +12237,7 @@ Format: instances/{instance}/databases/{database} </p></td>
<h3 id="bytebase.store.TaskRunResult.Position">TaskRunResult.Position</h3>
- <p>The following fields are used for error reporting.</p>
+ <p>The following fields are used for error reporting.</p><p>TODO(zp): Use common Position instead.</p>
<table class="field-table">
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 6e729733f2..b082c436ae 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -768,13 +768,14 @@
<a name="bytebase-v1-Position"></a>
### Position
-
+Position in a text expressed as zero-based line and zero-based column byte
+offset.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
-| line | [int32](#int32) | | |
-| column | [int32](#int32) | | |
+| line | [int32](#int32) | | Line position in a text (zero-based). |
+| column | [int32](#int32) | | Column position in a text (zero-based), equivalent to byte offset. |
@@ -8703,7 +8704,7 @@ TYPE_PROJECT_REPOSITORY_PUSH represents Bytebase receiving a push event from the
| content | [string](#string) | | The advice content. |
| line | [int32](#int32) | | The advice line number in the SQL statement. |
| column | [int32](#int32) | | The advice column number in the SQL statement. |
-| start_position | [Position](#bytebase-v1-Position) | | 1-based Position of the SQL statement. To supersede `line` and `column` above. |
+| start_position | [Position](#bytebase-v1-Position) | | To supersede `line` and `column` above. The start_position is inclusive and the end_position is exclusive. TODO: use range instead |
| end_position | [Position](#bytebase-v1-Position) | | |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 97a6d1dde5..2df2b98fb1 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -2994,7 +2994,7 @@
<h3 id="bytebase.v1.Position">Position</h3>
- <p></p>
+ <p>Position in a text expressed as zero-based line and zero-based column byte</p><p>offset.</p>
<table class="field-table">
@@ -3007,14 +3007,14 @@
<td>line</td>
<td><a href="#int32">int32</a></td>
<td></td>
- <td><p> </p></td>
+ <td><p>Line position in a text (zero-based). </p></td>
</tr>
<tr>
<td>column</td>
<td><a href="#int32">int32</a></td>
<td></td>
- <td><p> </p></td>
+ <td><p>Column position in a text (zero-based), equivalent to byte offset. </p></td>
</tr>
</tbody>
@@ -23861,7 +23861,8 @@ TYPE_SQL_EDITOR_QUERY represents executing query in SQL Editor.</p></td>
<td>candidates</td>
<td><a href="#bytebase.v1.AICompletionResponse.Candidate">AICompletionResponse.Candidate</a></td>
<td>repeated</td>
- <td><p>candidates is used for results with multiple choices and candidates. Used for OpenAI and Gemini. </p></td>
+ <td><p>candidates is used for results with multiple choices and candidates. Used
+for OpenAI and Gemini. </p></td>
</tr>
</tbody>
@@ -24078,8 +24079,9 @@ CosmosDB only. </p></td>
<td>start_position</td>
<td><a href="#bytebase.v1.Position">Position</a></td>
<td></td>
- <td><p>1-based Position of the SQL statement.
-To supersede `line` and `column` above. </p></td>
+ <td><p>To supersede `line` and `column` above.
+The start_position is inclusive and the end_position is exclusive.
+TODO: use range instead </p></td>
</tr>
<tr>
@@ -24215,7 +24217,8 @@ Format: instances/{instance}/databases/{database} </p></td>
<td>classification_from_config</td>
<td><a href="#bool">bool</a></td>
<td></td>
- <td><p>If false, we will build the raw common by classification in database config. </p></td>
+ <td><p>If false, we will build the raw common by classification in database
+config. </p></td>
</tr>
</tbody>
diff --git a/proto/generated-go/store/advice.pb.go b/proto/generated-go/store/advice.pb.go
index ddf1eedcd7..9834c7de96 100644
--- a/proto/generated-go/store/advice.pb.go
+++ b/proto/generated-go/store/advice.pb.go
@@ -84,7 +84,8 @@ type Advice struct {
Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"`
// The advice content.
Content string `protobuf:"bytes,4,opt,name=content,proto3" json:"content,omitempty"`
- // 1-based positions of the sql statment.
+ // The start_position is inclusive and the end_position is exclusive.
+ // TODO: use range instead.
StartPosition *Position `protobuf:"bytes,6,opt,name=start_position,json=startPosition,proto3" json:"start_position,omitempty"`
EndPosition *Position `protobuf:"bytes,7,opt,name=end_position,json=endPosition,proto3" json:"end_position,omitempty"`
unknownFields protoimpl.UnknownFields
diff --git a/proto/generated-go/store/common.pb.go b/proto/generated-go/store/common.pb.go
index d0ac74d28d..7cb09b5d59 100644
--- a/proto/generated-go/store/common.pb.go
+++ b/proto/generated-go/store/common.pb.go
@@ -360,10 +360,14 @@ func (x *PageToken) GetOffset() int32 {
return 0
}
+// Position in a text expressed as zero-based line and zero-based column byte
+// offset.
type Position struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Line int32 `protobuf:"varint,1,opt,name=line,proto3" json:"line,omitempty"`
- Column int32 `protobuf:"varint,2,opt,name=column,proto3" json:"column,omitempty"`
+ state protoimpl.MessageState `protogen:"open.v1"`
+ // Line position in a text (zero-based).
+ Line int32 `protobuf:"varint,1,opt,name=line,proto3" json:"line,omitempty"`
+ // Column position in a text (zero-based), equivalent to byte offset.
+ Column int32 `protobuf:"varint,2,opt,name=column,proto3" json:"column,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
diff --git a/proto/generated-go/store/task_run.pb.go b/proto/generated-go/store/task_run.pb.go
index aadbd4d055..56cf98a52e 100644
--- a/proto/generated-go/store/task_run.pb.go
+++ b/proto/generated-go/store/task_run.pb.go
@@ -214,6 +214,7 @@ func (x *SchedulerInfo) GetWaitingCause() *SchedulerInfo_WaitingCause {
}
// The following fields are used for error reporting.
+// TODO(zp): Use common Position instead.
type TaskRunResult_Position struct {
state protoimpl.MessageState `protogen:"open.v1"`
Line int32 `protobuf:"varint,1,opt,name=line,proto3" json:"line,omitempty"`
diff --git a/proto/generated-go/v1/common.pb.go b/proto/generated-go/v1/common.pb.go
index 2dfd5ade0f..069fdfc0a4 100644
--- a/proto/generated-go/v1/common.pb.go
+++ b/proto/generated-go/v1/common.pb.go
@@ -304,10 +304,14 @@ func (ExportFormat) EnumDescriptor() ([]byte, []int) {
return file_v1_common_proto_rawDescGZIP(), []int{3}
}
+// Position in a text expressed as zero-based line and zero-based column byte
+// offset.
type Position struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Line int32 `protobuf:"varint,1,opt,name=line,proto3" json:"line,omitempty"`
- Column int32 `protobuf:"varint,2,opt,name=column,proto3" json:"column,omitempty"`
+ state protoimpl.MessageState `protogen:"open.v1"`
+ // Line position in a text (zero-based).
+ Line int32 `protobuf:"varint,1,opt,name=line,proto3" json:"line,omitempty"`
+ // Column position in a text (zero-based), equivalent to byte offset.
+ Column int32 `protobuf:"varint,2,opt,name=column,proto3" json:"column,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
diff --git a/proto/generated-go/v1/sql_service.pb.go b/proto/generated-go/v1/sql_service.pb.go
index d71e5786ab..e72ce7b707 100644
--- a/proto/generated-go/v1/sql_service.pb.go
+++ b/proto/generated-go/v1/sql_service.pb.go
@@ -1043,8 +1043,9 @@ type Advice struct {
Line int32 `protobuf:"varint,5,opt,name=line,proto3" json:"line,omitempty"`
// The advice column number in the SQL statement.
Column int32 `protobuf:"varint,6,opt,name=column,proto3" json:"column,omitempty"`
- // 1-based Position of the SQL statement.
// To supersede `line` and `column` above.
+ // The start_position is inclusive and the end_position is exclusive.
+ // TODO: use range instead
StartPosition *Position `protobuf:"bytes,8,opt,name=start_position,json=startPosition,proto3" json:"start_position,omitempty"`
EndPosition *Position `protobuf:"bytes,9,opt,name=end_position,json=endPosition,proto3" json:"end_position,omitempty"`
unknownFields protoimpl.UnknownFields
@@ -1619,7 +1620,8 @@ type DiffMetadataRequest struct {
TargetCatalog *DatabaseCatalog `protobuf:"bytes,6,opt,name=target_catalog,json=targetCatalog,proto3" json:"target_catalog,omitempty"`
// The database engine of the schema.
Engine Engine `protobuf:"varint,3,opt,name=engine,proto3,enum=bytebase.v1.Engine" json:"engine,omitempty"`
- // If false, we will build the raw common by classification in database config.
+ // If false, we will build the raw common by classification in database
+ // config.
ClassificationFromConfig bool `protobuf:"varint,4,opt,name=classification_from_config,json=classificationFromConfig,proto3" json:"classification_from_config,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
@@ -2024,7 +2026,8 @@ func (x *AICompletionRequest) GetMessages() []*AICompletionRequest_Message {
type AICompletionResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
- // candidates is used for results with multiple choices and candidates. Used for OpenAI and Gemini.
+ // candidates is used for results with multiple choices and candidates. Used
+ // for OpenAI and Gemini.
Candidates []*AICompletionResponse_Candidate `protobuf:"bytes,1,rep,name=candidates,proto3" json:"candidates,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
diff --git a/proto/store/advice.proto b/proto/store/advice.proto
index 6e7422701c..c8290bec4c 100644
--- a/proto/store/advice.proto
+++ b/proto/store/advice.proto
@@ -28,7 +28,8 @@ message Advice {
// The advice content.
string content = 4;
- // 1-based positions of the sql statment.
+ // The start_position is inclusive and the end_position is exclusive.
+ // TODO: use range instead.
Position start_position = 6;
Position end_position = 7;
}
diff --git a/proto/store/common.proto b/proto/store/common.proto
index e1e2e345c0..89d964838e 100644
--- a/proto/store/common.proto
+++ b/proto/store/common.proto
@@ -64,8 +64,12 @@ enum ExportFormat {
XLSX = 4;
}
+// Position in a text expressed as zero-based line and zero-based column byte
+// offset.
message Position {
+ // Line position in a text (zero-based).
int32 line = 1;
+ // Column position in a text (zero-based), equivalent to byte offset.
int32 column = 2;
}
diff --git a/proto/store/task_run.proto b/proto/store/task_run.proto
index 2537076ee1..2e693c2be1 100644
--- a/proto/store/task_run.proto
+++ b/proto/store/task_run.proto
@@ -14,6 +14,7 @@ message TaskRunResult {
string version = 3;
// The following fields are used for error reporting.
+ // TODO(zp): Use common Position instead.
message Position {
int32 line = 1;
int32 column = 2;
diff --git a/proto/v1/common.proto b/proto/v1/common.proto
index 82f4b0b983..fecb6cfe37 100644
--- a/proto/v1/common.proto
+++ b/proto/v1/common.proto
@@ -57,8 +57,12 @@ enum ExportFormat {
XLSX = 4;
}
+// Position in a text expressed as zero-based line and zero-based column byte
+// offset.
message Position {
+ // Line position in a text (zero-based).
int32 line = 1;
+ // Column position in a text (zero-based), equivalent to byte offset.
int32 column = 2;
}
diff --git a/proto/v1/sql_service.proto b/proto/v1/sql_service.proto
index bbe6583f39..9aa355d987 100644
--- a/proto/v1/sql_service.proto
+++ b/proto/v1/sql_service.proto
@@ -18,48 +18,46 @@ option go_package = "generated-go/v1";
service SQLService {
rpc Query(QueryRequest) returns (QueryResponse) {
option (google.api.http) = {
- post: "/v1/{name=instances/*/databases/*}:query"
- body: "*"
+ post : "/v1/{name=instances/*/databases/*}:query"
+ body : "*"
- additional_bindings: {
- post: "/v1/{name=instances/*}:query"
- body: "*"
- }
+ additional_bindings : {post : "/v1/{name=instances/*}:query" body : "*"}
};
option (bytebase.v1.permission) = "bb.databases.get";
option (bytebase.v1.auth_method) = IAM;
option (bytebase.v1.audit) = true;
}
- rpc AdminExecute(stream AdminExecuteRequest) returns (stream AdminExecuteResponse) {
+ rpc AdminExecute(stream AdminExecuteRequest)
+ returns (stream AdminExecuteResponse) {
// GRPC streaming / websocket requires GET method instead of POST.
- option (google.api.http) = {get: "/v1:adminExecute"};
+ option (google.api.http) = {
+ get : "/v1:adminExecute"
+ };
option (bytebase.v1.permission) = "bb.sql.admin";
option (bytebase.v1.auth_method) = IAM;
option (bytebase.v1.audit) = true;
}
// SearchQueryHistories searches query histories for the caller.
- rpc SearchQueryHistories(SearchQueryHistoriesRequest) returns (SearchQueryHistoriesResponse) {
+ rpc SearchQueryHistories(SearchQueryHistoriesRequest)
+ returns (SearchQueryHistoriesResponse) {
option (google.api.http) = {
- post: "/v1/queryHistories:search"
- body: "*"
+ post : "/v1/queryHistories:search"
+ body : "*"
};
option (bytebase.v1.auth_method) = CUSTOM;
}
rpc Export(ExportRequest) returns (ExportResponse) {
option (google.api.http) = {
- post: "/v1/{name=instances/*/databases/*}:export"
- body: "*"
+ post : "/v1/{name=instances/*/databases/*}:export"
+ body : "*"
- additional_bindings: {
- post: "/v1/{name=instances/*}:export"
- body: "*"
- }
- additional_bindings: {
- post: "/v1/{name=projects/*/issues/*}:export"
- body: "*"
+ additional_bindings : {post : "/v1/{name=instances/*}:export" body : "*"}
+ additional_bindings : {
+ post : "/v1/{name=projects/*/issues/*}:export"
+ body : "*"
}
};
option (bytebase.v1.permission) = "bb.databases.get";
@@ -69,33 +67,34 @@ service SQLService {
rpc Check(CheckRequest) returns (CheckResponse) {
option (google.api.http) = {
- post: "/v1/sql/check"
- body: "*"
+ post : "/v1/sql/check"
+ body : "*"
};
option (bytebase.v1.permission) = "bb.databases.check";
option (bytebase.v1.auth_method) = IAM;
}
- rpc ParseMyBatisMapper(ParseMyBatisMapperRequest) returns (ParseMyBatisMapperResponse) {
+ rpc ParseMyBatisMapper(ParseMyBatisMapperRequest)
+ returns (ParseMyBatisMapperResponse) {
option (google.api.http) = {
- post: "/v1/sql/parseMyBatisMapper"
- body: "*"
+ post : "/v1/sql/parseMyBatisMapper"
+ body : "*"
};
option (bytebase.v1.allow_without_credential) = true;
}
rpc Pretty(PrettyRequest) returns (PrettyResponse) {
option (google.api.http) = {
- post: "/v1/sql/pretty"
- body: "*"
+ post : "/v1/sql/pretty"
+ body : "*"
};
option (bytebase.v1.allow_without_credential) = true;
}
rpc DiffMetadata(DiffMetadataRequest) returns (DiffMetadataResponse) {
option (google.api.http) = {
- post: "/v1/schemaDesign:diffMetadata"
- body: "*"
+ post : "/v1/schemaDesign:diffMetadata"
+ body : "*"
};
option (bytebase.v1.allow_without_credential) = true;
// This is a util method requiring no authentication thus no authorization.
@@ -103,8 +102,8 @@ service SQLService {
rpc AICompletion(AICompletionRequest) returns (AICompletionResponse) {
option (google.api.http) = {
- post: "/v1/sql/aiCompletion"
- body: "*"
+ post : "/v1/sql/aiCompletion"
+ body : "*"
};
option (bytebase.v1.auth_method) = CUSTOM;
}
@@ -117,7 +116,7 @@ message AdminExecuteRequest {
// Format: instances/{instance}/databases/{databaseName}
string name = 1 [
(google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {type: "bytebase.com/Database"}
+ (google.api.resource_reference) = {type : "bytebase.com/Database"}
];
// The SQL statement to execute.
@@ -147,7 +146,7 @@ message QueryRequest {
// Format: instances/{instance}/databases/{databaseName}
string name = 1 [
(google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {type: "bytebase.com/Database"}
+ (google.api.resource_reference) = {type : "bytebase.com/Database"}
];
// The SQL statement to execute.
@@ -224,9 +223,7 @@ message QueryResult {
// The query statement for the result.
string statement = 8;
- oneof detailed_error {
- PostgresError postgres_error = 9;
- }
+ oneof detailed_error { PostgresError postgres_error = 9; }
// refer https://www.postgresql.org/docs/11/protocol-error-fields.html
// for field description.
@@ -329,8 +326,9 @@ message Advice {
// The advice column number in the SQL statement.
int32 column = 6;
- // 1-based Position of the SQL statement.
// To supersede `line` and `column` above.
+ // The start_position is inclusive and the end_position is exclusive.
+ // TODO: use range instead
Position start_position = 8;
Position end_position = 9;
}
@@ -343,7 +341,7 @@ message ExportRequest {
// Format: projects/{project}/issues/{issue} for data export issue.
string name = 1 [
(google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {type: "bytebase.com/Database"}
+ (google.api.resource_reference) = {type : "bytebase.com/Database"}
];
// The SQL statement to execute.
@@ -400,7 +398,7 @@ message CheckRequest {
// Format: instances/{instance}/databases/{database}
string name = 2 [
(google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {type: "bytebase.com/Database"}
+ (google.api.resource_reference) = {type : "bytebase.com/Database"}
];
string statement = 1;
@@ -422,20 +420,18 @@ message CheckResponse {
int32 affected_rows = 2;
}
-message ParseMyBatisMapperRequest {
- bytes content = 1;
-}
+message ParseMyBatisMapperRequest { bytes content = 1; }
-message ParseMyBatisMapperResponse {
- repeated string statements = 1;
-}
+message ParseMyBatisMapperResponse { repeated string statements = 1; }
message DiffMetadataRequest {
// The metadata of the source schema.
- DatabaseMetadata source_metadata = 1 [(google.api.field_behavior) = REQUIRED];
+ DatabaseMetadata source_metadata = 1
+ [ (google.api.field_behavior) = REQUIRED ];
// The metadata of the target schema.
- DatabaseMetadata target_metadata = 2 [(google.api.field_behavior) = REQUIRED];
+ DatabaseMetadata target_metadata = 2
+ [ (google.api.field_behavior) = REQUIRED ];
DatabaseCatalog source_catalog = 5;
@@ -444,7 +440,8 @@ message DiffMetadataRequest {
// The database engine of the schema.
Engine engine = 3;
- // If false, we will build the raw common by classification in database config.
+ // If false, we will build the raw common by classification in database
+ // config.
bool classification_from_config = 4;
}
@@ -479,7 +476,8 @@ message SearchQueryHistoriesRequest {
message SearchQueryHistoriesResponse {
// The list of history.
- repeated QueryHistory query_histories = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
+ repeated QueryHistory query_histories = 1
+ [ (google.api.field_behavior) = OUTPUT_ONLY ];
// A token to retrieve next page of history.
// Pass this value in the page_token field in the subsequent call to
@@ -490,21 +488,23 @@ message SearchQueryHistoriesResponse {
message QueryHistory {
// The name for the query history.
// Format: queryHistories/{uid}
- string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
+ string name = 1 [ (google.api.field_behavior) = OUTPUT_ONLY ];
// The database name to execute the query.
// Format: instances/{instance}/databases/{databaseName}
- string database = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
+ string database = 2 [ (google.api.field_behavior) = OUTPUT_ONLY ];
- string creator = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
+ string creator = 3 [ (google.api.field_behavior) = OUTPUT_ONLY ];
- google.protobuf.Timestamp create_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
+ google.protobuf.Timestamp create_time = 4
+ [ (google.api.field_behavior) = OUTPUT_ONLY ];
- string statement = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
+ string statement = 5 [ (google.api.field_behavior) = OUTPUT_ONLY ];
- optional string error = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
+ optional string error = 6 [ (google.api.field_behavior) = OUTPUT_ONLY ];
- google.protobuf.Duration duration = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
+ google.protobuf.Duration duration = 7
+ [ (google.api.field_behavior) = OUTPUT_ONLY ];
enum Type {
TYPE_UNSPECIFIED = 0;
@@ -526,14 +526,13 @@ message AICompletionRequest {
message AICompletionResponse {
message Candidate {
message Content {
- message Part {
- string text = 1;
- }
+ message Part { string text = 1; }
// parts is used for a result content with multiple parts.
repeated Part parts = 1;
}
Content content = 1;
}
- // candidates is used for results with multiple choices and candidates. Used for OpenAI and Gemini.
+ // candidates is used for results with multiple choices and candidates. Used
+ // for OpenAI and Gemini.
repeated Candidate candidates = 1;
}