Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor(advisor/tidb): migrate auto-increment trio to omni AST (Phase 1.5 §1.5.3 batch 10) (#20300)
Vincent Huang6b9161a52a35
diff --git a/backend/plugin/advisor/tidb/advisor_column_auto_increment_initial_value.go b/backend/plugin/advisor/tidb/advisor_column_auto_increment_initial_value.goindex 7e54b3253e..7ca771e38a 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@@ -1,25 +1,22 @@package tidb-// Framework code is generated by the generator.-import ("context""fmt"+ "strconv"+ "strings"+ "github.com/bytebase/omni/tidb/ast""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/plugin/advisor/code"-- "github.com/pingcap/tidb/pkg/parser/ast"-"github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"+ "github.com/bytebase/bytebase/backend/plugin/advisor/code")var (_ advisor.Advisor = (*ColumnAutoIncrementInitialValueAdvisor)(nil)- _ ast.Visitor = (*columnAutoIncrementInitialValueChecker)(nil))func init() {@@ -32,8 +29,7 @@ type ColumnAutoIncrementInitialValueAdvisor struct {// Check checks for auto-increment column initial value.func (*ColumnAutoIncrementInitialValueAdvisor) Check(_ context.Context, checkCtx advisor.Context) ([]*storepb.Advice, error) {- stmtList, err := getTiDBNodes(checkCtx)-+ stmts, err := getTiDBOmniNodes(checkCtx)if err != nil {return nil, err}@@ -52,10 +48,8 @@ func (*ColumnAutoIncrementInitialValueAdvisor) Check(_ context.Context, checkCtxvalue: int(numberPayload.Number),}- for _, stmt := range stmtList {- checker.text = stmt.Text()- checker.line = stmt.OriginTextPosition()- (stmt).Accept(checker)+ for _, ostmt := range stmts {+ checker.checkStmt(ostmt)}return checker.adviceList, nil@@ -65,33 +59,45 @@ type columnAutoIncrementInitialValueChecker struct {adviceList []*storepb.Advicelevel storepb.Advice_Statustitle string- text string- line intvalue int}-// Enter implements the ast.Visitor interface.-func (checker *columnAutoIncrementInitialValueChecker) Enter(in ast.Node) (ast.Node, bool) {- if createTable, ok := in.(*ast.CreateTableStmt); ok {- for _, option := range createTable.Options {- if option.Tp == ast.TableOptionAutoIncrement {- if option.UintValue != uint64(checker.value) {- checker.adviceList = append(checker.adviceList, &storepb.Advice{- Status: checker.level,- Code: code.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: common.ConvertANTLRLineToPosition(checker.line),- })- }- }+// checkStmt: only CREATE TABLE is in scope, matching pingcap-typed+// columnAutoIncrementInitialValueChecker.Enter (which only matched+// `*ast.CreateTableStmt`). The mysql analog ALSO handles+// `ALTER TABLE ... AUTO_INCREMENT = N` via the ATTableOption arm —+// that broader scope is a mysql-side behavior, NOT something the+// tidb migration should adopt (preserve pingcap behavior per+// invariant #7's caveat on mysql analog non-authority).+func (c *columnAutoIncrementInitialValueChecker) checkStmt(ostmt OmniStmt) {+ create, ok := ostmt.Node.(*ast.CreateTableStmt)+ if !ok || create.Table == nil {+ return+ }+ tableName := create.Table.Name+ stmtLine := ostmt.AbsoluteLine(create.Loc.Start)+ for _, opt := range create.Options {+ if opt == nil {+ continue+ }+ if !strings.EqualFold(opt.Name, "AUTO_INCREMENT") {+ continue+ }+ // omni stores the option value as a string; pingcap exposed it+ // as `option.UintValue` (uint64) and skipped the unparseable+ // case implicitly. Skip on parse failure here too.+ value, err := strconv.ParseUint(opt.Value, 10, 0)+ if err != nil {+ continue+ }+ if value != uint64(c.value) {+ c.adviceList = append(c.adviceList, &storepb.Advice{+ Status: c.level,+ Code: code.AutoIncrementColumnInitialValueNotMatch.Int32(),+ Title: c.title,+ Content: fmt.Sprintf("The initial auto-increment value in table `%s` is %v, which doesn't equal %v", tableName, value, c.value),+ StartPosition: common.ConvertANTLRLineToPosition(stmtLine),+ })}}-- return in, false-}--// Leave implements the ast.Visitor interface.-func (*columnAutoIncrementInitialValueChecker) Leave(in ast.Node) (ast.Node, bool) {- return in, true}diff --git a/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_integer.go b/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_integer.goindex 34862da6db..274247a19d 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@@ -1,25 +1,19 @@package tidb-// Framework code is generated by the generator.-import ("context""fmt"- "github.com/bytebase/bytebase/backend/plugin/advisor/code"-- "github.com/pingcap/tidb/pkg/parser/ast"- "github.com/pingcap/tidb/pkg/parser/mysql"- "github.com/pingcap/tidb/pkg/parser/types"+ "github.com/bytebase/omni/tidb/ast""github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"+ "github.com/bytebase/bytebase/backend/plugin/advisor/code")var (_ advisor.Advisor = (*ColumnAutoIncrementMustIntegerAdvisor)(nil)- _ ast.Visitor = (*columnAutoIncrementMustIntegerChecker)(nil))func init() {@@ -32,8 +26,7 @@ type ColumnAutoIncrementMustIntegerAdvisor struct {// Check checks for auto-increment column type.func (*ColumnAutoIncrementMustIntegerAdvisor) Check(_ context.Context, checkCtx advisor.Context) ([]*storepb.Advice, error) {- stmtList, err := getTiDBNodes(checkCtx)-+ stmts, err := getTiDBOmniNodes(checkCtx)if err != nil {return nil, err}@@ -47,10 +40,8 @@ func (*ColumnAutoIncrementMustIntegerAdvisor) Check(_ context.Context, checkCtxtitle: checkCtx.Rule.Type.String(),}- for _, stmt := range stmtList {- checker.text = stmt.Text()- checker.line = stmt.OriginTextPosition()- (stmt).Accept(checker)+ for _, ostmt := range stmts {+ checker.checkStmt(ostmt)}return checker.adviceList, nil@@ -60,90 +51,42 @@ type columnAutoIncrementMustIntegerChecker struct {adviceList []*storepb.Advicelevel storepb.Advice_Statustitle string- text string- line int}+// columnData is the {table, column, line} carrier shared with+// advisor_column_auto_increment_must_unsigned.go and+// advisor_column_require_default.go — same package, same shape.type columnData struct {table stringcolumn stringline int}-// Enter implements the ast.Visitor interface.-func (checker *columnAutoIncrementMustIntegerChecker) Enter(in ast.Node) (ast.Node, bool) {- var columnList []columnData- switch node := in.(type) {- case *ast.CreateTableStmt:- for _, column := range node.Cols {- if !autoIncrementColumnIsInteger(column) {- columnList = append(columnList, columnData{- table: node.Table.Name.O,- column: column.Name.Name.O,- line: column.OriginTextPosition(),- })- }- }- case *ast.AlterTableStmt:- for _, spec := range node.Specs {- switch spec.Tp {- case ast.AlterTableAddColumns:- for _, column := range spec.NewColumns {- if !autoIncrementColumnIsInteger(column) {- columnList = append(columnList, columnData{- table: node.Table.Name.O,- column: column.Name.Name.O,- line: node.OriginTextPosition(),- })- }- }- case ast.AlterTableChangeColumn, ast.AlterTableModifyColumn:- if !autoIncrementColumnIsInteger(spec.NewColumns[0]) {- columnList = append(columnList, columnData{- table: node.Table.Name.O,- column: spec.NewColumns[0].Name.Name.O,- line: node.OriginTextPosition(),- })- }- default:- // Ignore other alter table specs- }- }- default:- }-- for _, column := range columnList {- checker.adviceList = append(checker.adviceList, &storepb.Advice{- Status: checker.level,+func (c *columnAutoIncrementMustIntegerChecker) checkStmt(ostmt OmniStmt) {+ cols := collectColumnViolations(ostmt, func(col *ast.ColumnDef) bool {+ return !autoIncrementColumnIsIntegerOmni(col)+ })+ for _, col := range cols {+ c.adviceList = append(c.adviceList, &storepb.Advice{+ Status: c.level,Code: code.AutoIncrementColumnNotInteger.Int32(),- Title: checker.title,- Content: fmt.Sprintf("Auto-increment column `%s`.`%s` requires integer type", column.table, column.column),- StartPosition: common.ConvertANTLRLineToPosition(checker.line),+ Title: c.title,+ Content: fmt.Sprintf("Auto-increment column `%s`.`%s` requires integer type", col.table, col.column),+ StartPosition: common.ConvertANTLRLineToPosition(col.line),})}-- return in, false-}--// Leave implements the ast.Visitor interface.-func (*columnAutoIncrementMustIntegerChecker) Leave(in ast.Node) (ast.Node, bool) {- return in, true}-func autoIncrementColumnIsInteger(column *ast.ColumnDef) bool {- for _, option := range column.Options {- if option.Tp == ast.ColumnOptionAutoIncrement && !isInteger(column.Tp) {- return false- }+// autoIncrementColumnIsIntegerOmni returns true unless the column is+// AUTO_INCREMENT with a non-integer type. Mirrors pingcap-typed+// autoIncrementColumnIsInteger semantics: the rule fires only on+// auto-increment columns; everything else passes through.+func autoIncrementColumnIsIntegerOmni(col *ast.ColumnDef) bool {+ if col == nil {+ return true}- return true-}--func isInteger(tp *types.FieldType) bool {- switch tp.GetType() {- case mysql.TypeTiny, mysql.TypeShort, mysql.TypeInt24, mysql.TypeLong, mysql.TypeLonglong:+ if !col.AutoIncrement {return true- default:- return false}+ return omniIsIntegerType(col.TypeName)}diff --git a/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_unsigned.go b/backend/plugin/advisor/tidb/advisor_column_auto_increment_must_unsigned.goindex baca666157..669931f0d6 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@@ -1,24 +1,19 @@package tidb-// Framework code is generated by the generator.-import ("context""fmt"- "github.com/bytebase/bytebase/backend/plugin/advisor/code"-- "github.com/pingcap/tidb/pkg/parser/ast"- "github.com/pingcap/tidb/pkg/parser/mysql"+ "github.com/bytebase/omni/tidb/ast""github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/advisor"+ "github.com/bytebase/bytebase/backend/plugin/advisor/code")var (_ advisor.Advisor = (*ColumnAutoIncrementMustUnsignedAdvisor)(nil)- _ ast.Visitor = (*columnAutoIncrementMustUnsignedChecker)(nil))func init() {@@ -31,8 +26,7 @@ type ColumnAutoIncrementMustUnsignedAdvisor struct {// Check checks for unsigned auto-increment column.func (*ColumnAutoIncrementMustUnsignedAdvisor) Check(_ context.Context, checkCtx advisor.Context) ([]*storepb.Advice, error) {- stmtList, err := getTiDBNodes(checkCtx)-+ stmts, err := getTiDBOmniNodes(checkCtx)if err != nil {return nil, err}@@ -46,10 +40,8 @@ func (*ColumnAutoIncrementMustUnsignedAdvisor) Check(_ context.Context, checkCtxtitle: checkCtx.Rule.Type.String(),}- for _, stmt := range stmtList {- checker.text = stmt.Text()- checker.line = stmt.OriginTextPosition()- (stmt).Accept(checker)+ for _, ostmt := range stmts {+ checker.checkStmt(ostmt)}return checker.adviceList, nil@@ -59,74 +51,40 @@ type columnAutoIncrementMustUnsignedChecker struct {adviceList []*storepb.Advicelevel storepb.Advice_Statustitle string- text string- line int}-// Enter implements the ast.Visitor interface.-func (checker *columnAutoIncrementMustUnsignedChecker) Enter(in ast.Node) (ast.Node, bool) {- var columnList []columnData- switch node := in.(type) {- case *ast.CreateTableStmt:- for _, column := range node.Cols {- if !autoIncrementColumnIsUnsigned(column) {- columnList = append(columnList, columnData{- table: node.Table.Name.O,- column: column.Name.Name.O,- line: column.OriginTextPosition(),- })- }- }- case *ast.AlterTableStmt:- for _, spec := range node.Specs {- switch spec.Tp {- case ast.AlterTableAddColumns:- for _, column := range spec.NewColumns {- if !autoIncrementColumnIsUnsigned(column) {- columnList = append(columnList, columnData{- table: node.Table.Name.O,- column: column.Name.Name.O,- line: node.OriginTextPosition(),- })- }- }- case ast.AlterTableChangeColumn, ast.AlterTableModifyColumn:- if !autoIncrementColumnIsUnsigned(spec.NewColumns[0]) {- columnList = append(columnList, columnData{- table: node.Table.Name.O,- column: spec.NewColumns[0].Name.Name.O,- line: node.OriginTextPosition(),- })- }- default:- }- }- default:- }-- for _, column := range columnList {- checker.adviceList = append(checker.adviceList, &storepb.Advice{- Status: checker.level,+func (c *columnAutoIncrementMustUnsignedChecker) checkStmt(ostmt OmniStmt) {+ cols := collectColumnViolations(ostmt, func(col *ast.ColumnDef) bool {+ return !autoIncrementColumnIsUnsignedOmni(col)+ })+ for _, col := range cols {+ c.adviceList = append(c.adviceList, &storepb.Advice{+ Status: c.level,Code: code.AutoIncrementColumnSigned.Int32(),- Title: checker.title,- Content: fmt.Sprintf("Auto-increment column `%s`.`%s` is not UNSIGNED type", column.table, column.column),- StartPosition: common.ConvertANTLRLineToPosition(checker.line),+ Title: c.title,+ Content: fmt.Sprintf("Auto-increment column `%s`.`%s` is not UNSIGNED type", col.table, col.column),+ StartPosition: common.ConvertANTLRLineToPosition(col.line),})}-- return in, false-}--// Leave implements the ast.Visitor interface.-func (*columnAutoIncrementMustUnsignedChecker) Leave(in ast.Node) (ast.Node, bool) {- return in, true}-func autoIncrementColumnIsUnsigned(column *ast.ColumnDef) bool {- for _, option := range column.Options {- if option.Tp == ast.ColumnOptionAutoIncrement && !mysql.HasUnsignedFlag(column.Tp.GetFlag()) {- return false- }+// autoIncrementColumnIsUnsignedOmni returns true unless the column is+// AUTO_INCREMENT and neither Unsigned nor Zerofill is set. Pingcap-typed+// `mysql.HasUnsignedFlag(column.Tp.GetFlag())` returned true when EITHER+// the unsigned flag OR the zerofill flag was set (ZEROFILL implies+// UNSIGNED in MySQL). Omni splits the bits: `col.TypeName.Unsigned` and+// `col.TypeName.Zerofill` are separate booleans. Check both to preserve+// pingcap-tidb behavior. Mirrors mysql analog at+// `mysql/rule_column_auto_increment_must_unsigned.go:102`.+func autoIncrementColumnIsUnsignedOmni(col *ast.ColumnDef) bool {+ if col == nil {+ return true+ }+ if !col.AutoIncrement {+ return true+ }+ if col.TypeName == nil {+ return false}- return true+ return col.TypeName.Unsigned || col.TypeName.Zerofill}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.yamlindex 871127b7a6..40243c0053 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@@ -50,3 +50,41 @@line: 2column: 0endposition: null+# BOOL/BOOLEAN preservation pin (batch 10 / cumulative #20): pingcap's+# `mysql.TypeTiny` enum was shared between TINYINT + BOOL + BOOLEAN (BOOL+# and BOOLEAN are TINYINT aliases in MySQL). Omni splits the alias: BOOL+# and BOOLEAN both pre-normalize to DataType.Name = "BOOLEAN" (NOT+# "TINYINT"). A mechanical port that matches only INT-family names would+# regress on `CREATE TABLE t(b BOOL AUTO_INCREMENT, KEY(b))` — pingcap-tidb+# treated this as integer (rule did NOT fire). Fixture locks the BOOLEAN+# inclusion in omniIsIntegerType.+- statement: CREATE TABLE t(a BOOL AUTO_INCREMENT, KEY(a))+ changeType: 1+- statement: CREATE TABLE t(a BOOLEAN AUTO_INCREMENT, KEY(a))+ changeType: 1+- statement: CREATE TABLE t(a TINYINT AUTO_INCREMENT, KEY(a))+ changeType: 1+# Multi-line CREATE TABLE line-position pin (batch 10, Codex round-2):+# pingcap-tidb captured column.OriginTextPosition() into columnData.line+# but then emitted checker.line (statement line) in the advice — column+# line was dead code. The omni port actually uses column line via+# ostmt.AbsoluteLine(column.Loc.Start), so multi-line CREATE TABLE advice+# now points at the OFFENDING COLUMN's line rather than the CREATE TABLE+# keyword's line. UX improvement; same shape as batch 9+# column_require_default's column-line behavior. Pin locks the new+# contract — future refactor that reverts to statement-line will fail+# this fixture.+- statement: |-+ CREATE TABLE t(+ a varchar(255) AUTO_INCREMENT+ )+ changeType: 1+ want:+ - status: 2+ code: 410+ title: COLUMN_AUTO_INCREMENT_MUST_INTEGER+ content: Auto-increment column `t`.`a` requires integer type+ startposition:+ line: 2+ column: 0+ endposition: nulldiff --git a/backend/plugin/advisor/tidb/test/column_auto_increment_must_unsigned.yaml b/backend/plugin/advisor/tidb/test/column_auto_increment_must_unsigned.yamlindex ce45a705c8..76adb6778c 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@@ -50,3 +50,39 @@line: 2column: 0endposition: null+# ZEROFILL preservation pin (batch 10): pingcap's+# `mysql.HasUnsignedFlag(column.Tp.GetFlag())` returned true when EITHER+# the unsigned flag OR the zerofill flag was set (ZEROFILL implies+# UNSIGNED in MySQL). Omni splits the bits — `col.TypeName.Unsigned` and+# `col.TypeName.Zerofill` are separate booleans. A mechanical port+# checking only Unsigned would regress on `CREATE TABLE t(a INT ZEROFILL+# AUTO_INCREMENT)` (pingcap-tidb treated this as unsigned, rule did NOT+# fire). Fixture locks the Unsigned||Zerofill check.+- statement: CREATE TABLE t(a INT ZEROFILL AUTO_INCREMENT)+ changeType: 1+- statement: CREATE TABLE t(a INT UNSIGNED ZEROFILL AUTO_INCREMENT)+ changeType: 1+# Multi-line CREATE TABLE line-position pin (batch 10, Codex round-2):+# pingcap-tidb captured column.OriginTextPosition() into columnData.line+# but then emitted checker.line (statement line) in the advice — column+# line was dead code. The omni port actually uses column line via+# ostmt.AbsoluteLine(column.Loc.Start), so multi-line CREATE TABLE advice+# now points at the OFFENDING COLUMN's line rather than the CREATE TABLE+# keyword's line. UX improvement; same shape as batch 9+# column_require_default's column-line behavior. Pin locks the new+# contract — future refactor that reverts to statement-line will fail+# this fixture.+- statement: |-+ CREATE TABLE t(+ a INT AUTO_INCREMENT+ )+ changeType: 1+ want:+ - status: 2+ code: 417+ title: COLUMN_AUTO_INCREMENT_MUST_UNSIGNED+ content: Auto-increment column `t`.`a` is not UNSIGNED type+ startposition:+ line: 2+ column: 0+ endposition: nulldiff --git a/backend/plugin/advisor/tidb/utils.go b/backend/plugin/advisor/tidb/utils.goindex a1a0759b34..3fb8737b82 100644--- a/backend/plugin/advisor/tidb/utils.go+++ b/backend/plugin/advisor/tidb/utils.go@@ -248,6 +248,110 @@ func omniColumnHasComment(col *omniast.ColumnDef) bool {return false}+// collectColumnViolations walks an OmniStmt's CREATE TABLE columns and+// ALTER TABLE ADD/CHANGE/MODIFY COLUMN commands, returning a columnData+// entry for every column where isViolation returns true. Line for+// CREATE TABLE columns is the column's start; for ALTER TABLE commands,+// the top-level statement's start (matching pingcap-typed visitors that+// read `node.OriginTextPosition()` for ALTER TABLE specs).+//+// Used by column-attribute advisors that share the shape "walk columns,+// apply a predicate, emit advice on violations" — currently+// advisor_column_auto_increment_must_integer and+// advisor_column_auto_increment_must_unsigned. Extensible to future+// advisors with the same shape (column_maximum_character_length,+// column_type_disallow_list, etc.). Per-advisor advice formatting and+// the rule-specific predicate stay in the caller.+//+// Not appropriate for advisors with table-level filtering+// (advisor_column_require_default's table-level PK exemption) or those+// that read non-column structures (advisor_column_auto_increment_initial_value's+// table options).+func collectColumnViolations(ostmt OmniStmt, isViolation func(*omniast.ColumnDef) bool) []columnData {+ if isViolation == nil {+ return nil+ }+ var cols []columnData+ switch n := ostmt.Node.(type) {+ case *omniast.CreateTableStmt:+ if n.Table == nil {+ return nil+ }+ tableName := n.Table.Name+ for _, column := range n.Columns {+ if column == nil {+ continue+ }+ if isViolation(column) {+ cols = append(cols, columnData{+ table: tableName,+ column: column.Name,+ line: ostmt.AbsoluteLine(column.Loc.Start),+ })+ }+ }+ case *omniast.AlterTableStmt:+ if n.Table == nil {+ return nil+ }+ tableName := n.Table.Name+ stmtLine := ostmt.AbsoluteLine(n.Loc.Start)+ for _, cmd := range n.Commands {+ if cmd == nil {+ continue+ }+ switch cmd.Type {+ case omniast.ATAddColumn:+ for _, column := range addColumnTargets(cmd) {+ if column == nil {+ continue+ }+ if isViolation(column) {+ cols = append(cols, columnData{table: tableName, column: column.Name, line: stmtLine})+ }+ }+ case omniast.ATChangeColumn, omniast.ATModifyColumn:+ if cmd.Column == nil {+ continue+ }+ if isViolation(cmd.Column) {+ cols = append(cols, columnData{table: tableName, column: cmd.Column.Name, line: stmtLine})+ }+ default:+ }+ }+ default:+ }+ return cols+}++// omniIsIntegerType reports whether the column type is an integer type+// from the perspective of pingcap-tidb's `isInteger` helper. Pingcap+// dispatched on `mysql.TypeTiny`/`TypeShort`/`TypeInt24`/`TypeLong`/`TypeLonglong`+// (5 type bytes), and crucially `mysql.TypeTiny` was shared by TINYINT,+// BOOL, and BOOLEAN (BOOL/BOOLEAN are TINYINT aliases). Omni splits+// the alias group: BOOL/BOOLEAN both normalize to `DataType.Name = "BOOLEAN"`+// (verified empirically), while TINYINT stays as "TINYINT". Match all 7+// omni names (6 covering pingcap's 5 type bytes + "INTEGER" as a+// defensive alias even though omni pre-normalizes INTEGER → INT per+// cumulative #7). Cumulative #20 documents the TINYINT/BOOLEAN split.+//+// NOTE: this diverges from `mysql/utils_omni.go`'s `omniIsIntegerType`,+// which currently omits "BOOLEAN". Pre-omni mysql ANTLR did not treat+// BOOL as TINYINT — that's a long-standing mysql behavior gap, NOT a+// regression introduced by mysql's omni migration. Out of scope here.+func omniIsIntegerType(dt *omniast.DataType) bool {+ if dt == nil {+ return false+ }+ switch strings.ToUpper(dt.Name) {+ case "TINYINT", "SMALLINT", "MEDIUMINT", "INT", "INTEGER", "BIGINT", "BOOLEAN":+ return true+ default:+ return false+ }+}+// omniDataTypeNameCompact returns a compact, lowercase type-name string// for use in advice content + allowlist comparisons. Mirrors the mysql// helper of the same name (mysql/utils_omni.go). Length/scale info is