Skip to content

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

chore: update column type disallow list rule name for MySQL (#10885)

boojack015cda30892e
diff --git a/backend/plugin/advisor/advisor.go b/backend/plugin/advisor/advisor.go
index 96ef5451f0..71eecbc0ee 100644
--- a/backend/plugin/advisor/advisor.go
+++ b/backend/plugin/advisor/advisor.go
@@ -128,12 +128,12 @@ const (
// MySQLAutoIncrementColumnMustInteger is an advisor type for auto-increment column.
MySQLAutoIncrementColumnMustInteger Type = "bb.plugin.advisor.mysql.column.auto-increment-must-integer"
- // MySQLColumnTypeRestriction is an advisor type for MySQL column type restriction.
- MySQLColumnTypeRestriction Type = "bb.plugin.advisor.mysql.column.type-restriction"
-
// MySQLDisallowSetColumnCharset is an advisor type for MySQL disallow set column charset.
MySQLDisallowSetColumnCharset Type = "bb.plugin.advisor.mysql.column.disallow-set-charset"
+ // MySQLColumnTypeDisallowList is an advisor type for MySQL column type disallow list.
+ MySQLColumnTypeDisallowList Type = "bb.plugin.advisor.mysql.column.type-disallow-list"
+
// MySQLColumnMaximumCharacterLength is an advisor type for MySQL maximum character length.
MySQLColumnMaximumCharacterLength Type = "bb.plugin.advisor.mysql.column.maximum-character-length"
diff --git a/backend/plugin/advisor/mysql/advisor_column_type_restriction.go b/backend/plugin/advisor/mysql/advisor_column_type_disallow_list.go
similarity index 84%
rename from backend/plugin/advisor/mysql/advisor_column_type_restriction.go
rename to backend/plugin/advisor/mysql/advisor_column_type_disallow_list.go
index 9242ceab69..1b34d72316 100644
--- a/backend/plugin/advisor/mysql/advisor_column_type_restriction.go
+++ b/backend/plugin/advisor/mysql/advisor_column_type_disallow_list.go
@@ -17,21 +17,21 @@ import (
)
var (
- _ advisor.Advisor = (*ColumnTypeRestrictionAdvisor)(nil)
+ _ advisor.Advisor = (*ColumnTypeDisallowListAdvisor)(nil)
)
func init() {
- advisor.Register(storepb.Engine_MYSQL, advisor.MySQLColumnTypeRestriction, &ColumnTypeRestrictionAdvisor{})
- advisor.Register(storepb.Engine_MARIADB, advisor.MySQLColumnTypeRestriction, &ColumnTypeRestrictionAdvisor{})
- advisor.Register(storepb.Engine_OCEANBASE, advisor.MySQLColumnTypeRestriction, &ColumnTypeRestrictionAdvisor{})
+ advisor.Register(storepb.Engine_MYSQL, advisor.MySQLColumnTypeDisallowList, &ColumnTypeDisallowListAdvisor{})
+ advisor.Register(storepb.Engine_MARIADB, advisor.MySQLColumnTypeDisallowList, &ColumnTypeDisallowListAdvisor{})
+ advisor.Register(storepb.Engine_OCEANBASE, advisor.MySQLColumnTypeDisallowList, &ColumnTypeDisallowListAdvisor{})
}
-// ColumnTypeRestrictionAdvisor is the advisor checking for column type restriction.
-type ColumnTypeRestrictionAdvisor struct {
+// ColumnTypeDisallowListAdvisor is the advisor checking for column type restriction.
+type ColumnTypeDisallowListAdvisor struct {
}
// Check checks for column type restriction.
-func (*ColumnTypeRestrictionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {
+func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {
stmtList, ok := ctx.AST.([]*mysqlparser.ParseResult)
if !ok {
return nil, errors.Errorf("failed to convert to mysql parser result")
@@ -45,7 +45,7 @@ func (*ColumnTypeRestrictionAdvisor) Check(ctx advisor.Context, _ string) ([]adv
if err != nil {
return nil, err
}
- checker := &columnTypeRestrictionChecker{
+ checker := &columnTypeDisallowListChecker{
level: level,
title: string(ctx.Rule.Type),
typeRestriction: make(map[string]bool),
@@ -70,7 +70,7 @@ func (*ColumnTypeRestrictionAdvisor) Check(ctx advisor.Context, _ string) ([]adv
return checker.adviceList, nil
}
-type columnTypeRestrictionChecker struct {
+type columnTypeDisallowListChecker struct {
*mysql.BaseMySQLParserListener
baseLine int
@@ -80,7 +80,7 @@ type columnTypeRestrictionChecker struct {
typeRestriction map[string]bool
}
-func (checker *columnTypeRestrictionChecker) EnterCreateTable(ctx *mysql.CreateTableContext) {
+func (checker *columnTypeDisallowListChecker) EnterCreateTable(ctx *mysql.CreateTableContext) {
if ctx.TableName() == nil {
return
}
@@ -105,7 +105,7 @@ func (checker *columnTypeRestrictionChecker) EnterCreateTable(ctx *mysql.CreateT
}
}
-func (checker *columnTypeRestrictionChecker) checkFieldDefinition(tableName, columnName string, ctx mysql.IFieldDefinitionContext) {
+func (checker *columnTypeDisallowListChecker) checkFieldDefinition(tableName, columnName string, ctx mysql.IFieldDefinitionContext) {
if ctx.DataType() == nil {
return
}
@@ -123,7 +123,7 @@ func (checker *columnTypeRestrictionChecker) checkFieldDefinition(tableName, col
}
// EnterAlterTable is called when production alterTable is entered.
-func (checker *columnTypeRestrictionChecker) EnterAlterTable(ctx *mysql.AlterTableContext) {
+func (checker *columnTypeDisallowListChecker) EnterAlterTable(ctx *mysql.AlterTableContext) {
if ctx.AlterTableActions() == nil {
return
}
diff --git a/backend/plugin/advisor/sql_review.go b/backend/plugin/advisor/sql_review.go
index 8307b7f973..5f578b2b7d 100644
--- a/backend/plugin/advisor/sql_review.go
+++ b/backend/plugin/advisor/sql_review.go
@@ -1196,7 +1196,7 @@ func getAdvisorTypeByRule(ruleType SQLReviewRuleType, engine storepb.Engine) (Ty
case SchemaRuleColumnTypeDisallowList:
switch engine {
case storepb.Engine_MYSQL, storepb.Engine_TIDB, storepb.Engine_MARIADB, storepb.Engine_OCEANBASE:
- return MySQLColumnTypeRestriction, nil
+ return MySQLColumnTypeDisallowList, nil
case storepb.Engine_POSTGRES:
return PostgreSQLColumnTypeDisallowList, nil
case storepb.Engine_ORACLE, storepb.Engine_OCEANBASE_ORACLE:
diff --git a/backend/plugin/advisor/tidb/advisor_column_type_restriction.go b/backend/plugin/advisor/tidb/advisor_column_type_disallow_list.go
similarity index 82%
rename from backend/plugin/advisor/tidb/advisor_column_type_restriction.go
rename to backend/plugin/advisor/tidb/advisor_column_type_disallow_list.go
index 96aa339456..7761b020d1 100644
--- a/backend/plugin/advisor/tidb/advisor_column_type_restriction.go
+++ b/backend/plugin/advisor/tidb/advisor_column_type_disallow_list.go
@@ -14,20 +14,20 @@ import (
)
var (
- _ advisor.Advisor = (*ColumnTypeRestrictionAdvisor)(nil)
- _ ast.Visitor = (*columnTypeRestrictionChecker)(nil)
+ _ advisor.Advisor = (*ColumnTypeDisallowListAdvisor)(nil)
+ _ ast.Visitor = (*columnTypeDisallowListChecker)(nil)
)
func init() {
- advisor.Register(storepb.Engine_TIDB, advisor.MySQLColumnTypeRestriction, &ColumnTypeRestrictionAdvisor{})
+ advisor.Register(storepb.Engine_TIDB, advisor.MySQLColumnTypeDisallowList, &ColumnTypeDisallowListAdvisor{})
}
-// ColumnTypeRestrictionAdvisor is the advisor checking for column type restriction.
-type ColumnTypeRestrictionAdvisor struct {
+// ColumnTypeDisallowListAdvisor is the advisor checking for column type restriction.
+type ColumnTypeDisallowListAdvisor struct {
}
// Check checks for column type restriction.
-func (*ColumnTypeRestrictionAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {
+func (*ColumnTypeDisallowListAdvisor) Check(ctx advisor.Context, _ string) ([]advisor.Advice, error) {
stmtList, ok := ctx.AST.([]ast.StmtNode)
if !ok {
return nil, errors.Errorf("failed to convert to StmtNode")
@@ -41,7 +41,7 @@ func (*ColumnTypeRestrictionAdvisor) Check(ctx advisor.Context, _ string) ([]adv
if err != nil {
return nil, err
}
- checker := &columnTypeRestrictionChecker{
+ checker := &columnTypeDisallowListChecker{
level: level,
title: string(ctx.Rule.Type),
typeRestriction: make(map[string]bool),
@@ -67,7 +67,7 @@ func (*ColumnTypeRestrictionAdvisor) Check(ctx advisor.Context, _ string) ([]adv
return checker.adviceList, nil
}
-type columnTypeRestrictionChecker struct {
+type columnTypeDisallowListChecker struct {
adviceList []advisor.Advice
level advisor.Status
title string
@@ -84,7 +84,7 @@ type columnTypeData struct {
}
// Enter implements the ast.Visitor interface.
-func (checker *columnTypeRestrictionChecker) Enter(in ast.Node) (ast.Node, bool) {
+func (checker *columnTypeDisallowListChecker) Enter(in ast.Node) (ast.Node, bool) {
var columnList []columnTypeData
switch node := in.(type) {
case *ast.CreateTableStmt:
@@ -140,6 +140,6 @@ func (checker *columnTypeRestrictionChecker) Enter(in ast.Node) (ast.Node, bool)
}
// Leave implements the ast.Visitor interface.
-func (*columnTypeRestrictionChecker) Leave(in ast.Node) (ast.Node, bool) {
+func (*columnTypeDisallowListChecker) Leave(in ast.Node) (ast.Node, bool) {
return in, true
}