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 cross-stmt column-state pair to omni AST (Phase 1.5 §1.5.3 batch 16) (#20322)
Vincent Huange77558acb9fb
diff --git a/backend/plugin/advisor/tidb/advisor_column_disallow_drop_in_index.go b/backend/plugin/advisor/tidb/advisor_column_disallow_drop_in_index.goindex 0aa65f8fc5..4d245bad3c 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@@ -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/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/store/model"+ "github.com/bytebase/bytebase/backend/plugin/advisor/code")var (_ advisor.Advisor = (*ColumnDisallowDropInIndexAdvisor)(nil)- _ ast.Visitor = (*columnDisallowDropInIndexChecker)(nil))func init() {@@ -26,13 +21,31 @@ func init() {}// ColumnDisallowDropInIndexAdvisor is the advisor checking for disallow DROP COLUMN in index.-type ColumnDisallowDropInIndexAdvisor struct {-}--// Check checks for disallow Drop COLUMN in index statement.+type ColumnDisallowDropInIndexAdvisor struct{}++// Check tracks index-column membership across the reviewed statements+// (Recipe A cross-stmt state) and emits an advice when an ALTER TABLE+// DROP COLUMN targets a column that's part of an index.+//+// Per-arm state-mutation semantics (cumulative #25 audit axis):+// - CreateTableStmt: INCREMENT — populate tables[name][col]=true for+// each plain column in the table's KEY/INDEX constraints (omni+// ConstrIndex; pingcap analog was ConstraintIndex, plain non-unique+// only — UNIQUE / PRIMARY KEY / FULLTEXT / SPATIAL are NOT tracked).+// - AlterTableStmt ATDropColumn: SIDE-LOAD CATALOG + READ — populate+// tables[name] from OriginalMetadata.ListIndexes() (which reflects+// the FINAL schema state including any pre-statement indexes the+// reviewed CREATE TABLEs didn't add), then check if the dropped+// column is in the index set. Side-load is idempotent across+// multiple DROP COLUMN cmds in the same ALTER.+//+// Identifier case-sensitivity (cumulative #19): pre-omni used `.O`+// (original case) throughout; omni's direct strings preserve user case.+// `CREATE TABLE t(A INT, INDEX(A)); ALTER TABLE t DROP COLUMN a` does+// NOT fire (case-mismatched lookup misses the index set) — matches+// pingcap-tidb's pre-omni case-sensitive behavior. Pinned with fixture.func (*ColumnDisallowDropInIndexAdvisor) Check(_ context.Context, checkCtx advisor.Context) ([]*storepb.Advice, error) {- stmtList, err := getTiDBNodes(checkCtx)-+ stmts, err := getTiDBOmniNodes(checkCtx)if err != nil {return nil, err}@@ -41,101 +54,61 @@ func (*ColumnDisallowDropInIndexAdvisor) Check(_ context.Context, checkCtx advisif err != nil {return nil, err}-- checker := &columnDisallowDropInIndexChecker{- level: level,- title: checkCtx.Rule.Type.String(),- tables: make(tableState),- originalMetadata: checkCtx.OriginalMetadata,- }-- for _, stmt := range stmtList {- checker.text = stmt.Text()- checker.line = stmt.OriginTextPosition()- (stmt).Accept(checker)- }-- return checker.adviceList, nil-}--type columnDisallowDropInIndexChecker struct {- adviceList []*storepb.Advice- level storepb.Advice_Status- title string- text string- tables tableState // the variable mean whether the column in index.- originalMetadata *model.DatabaseMetadata- line int-}--func (checker *columnDisallowDropInIndexChecker) Enter(in ast.Node) (ast.Node, bool) {- switch node := in.(type) {- case *ast.CreateTableStmt:- checker.addIndexColumn(node)- case *ast.AlterTableStmt:- return checker.dropColumn(node)- default:- }- return in, false-}--func (*columnDisallowDropInIndexChecker) Leave(in ast.Node) (ast.Node, bool) {- return in, true-}--func (checker *columnDisallowDropInIndexChecker) dropColumn(in ast.Node) (ast.Node, bool) {- if node, ok := in.(*ast.AlterTableStmt); ok {- for _, spec := range node.Specs {- if spec.Tp == ast.AlterTableDropColumn {- table := node.Table.Name.O-- tableMetadata := checker.originalMetadata.GetSchemaMetadata("").GetTable(table)- if tableMetadata != nil {- if checker.tables[table] == nil {- checker.tables[table] = make(columnSet)+ title := checkCtx.Rule.Type.String()+ tables := make(tableState)++ var adviceList []*storepb.Advice+ for _, ostmt := range stmts {+ switch n := ostmt.Node.(type) {+ case *ast.CreateTableStmt:+ if n.Table == nil {+ continue+ }+ tableName := n.Table.Name+ if tables[tableName] == nil {+ tables[tableName] = make(columnSet)+ }+ for _, c := range n.Constraints {+ if c == nil || c.Type != ast.ConstrIndex {+ continue+ }+ for _, col := range omniIndexColumns(c.IndexColumns) {+ tables[tableName][col] = true+ }+ }+ case *ast.AlterTableStmt:+ if n.Table == nil {+ continue+ }+ tableName := n.Table.Name+ stmtLine := ostmt.FirstTokenLine()+ for _, cmd := range n.Commands {+ if cmd == nil || cmd.Type != ast.ATDropColumn {+ continue+ }+ if tableMetadata := checkCtx.OriginalMetadata.GetSchemaMetadata("").GetTable(tableName); tableMetadata != nil {+ if tables[tableName] == nil {+ tables[tableName] = make(columnSet)}- for _, indexColumn := range tableMetadata.ListIndexes() {- for _, column := range indexColumn.GetProto().GetExpressions() {- checker.tables[table][column] = true+ for _, idx := range tableMetadata.ListIndexes() {+ for _, indexedCol := range idx.GetProto().GetExpressions() {+ tables[tableName][indexedCol] = true}}}-- colName := spec.OldColumnName.Name.String()- if !checker.canDrop(table, colName) {- checker.adviceList = append(checker.adviceList, &storepb.Advice{- Status: checker.level,+ colName := cmd.Name+ if _, isIndexCol := tables[tableName][colName]; isIndexCol {+ adviceList = append(adviceList, &storepb.Advice{+ Status: level,Code: code.DropIndexColumn.Int32(),- Title: checker.title,- Content: fmt.Sprintf("`%s`.`%s` cannot drop index column", table, colName),- StartPosition: common.ConvertANTLRLineToPosition(checker.line),+ Title: title,+ Content: fmt.Sprintf("`%s`.`%s` cannot drop index column", tableName, colName),+ StartPosition: common.ConvertANTLRLineToPosition(stmtLine),})}}+ default:}}- return in, false-}--func (checker *columnDisallowDropInIndexChecker) addIndexColumn(in ast.Node) {- if node, ok := in.(*ast.CreateTableStmt); ok {- for _, spec := range node.Constraints {- if spec.Tp == ast.ConstraintIndex {- for _, key := range spec.Keys {- table := node.Table.Name.O- if checker.tables[table] == nil {- checker.tables[table] = make(columnSet)- }- checker.tables[table][key.Column.Name.O] = true- }- }- }- }-}--func (checker *columnDisallowDropInIndexChecker) canDrop(table string, column string) bool {- if _, ok := checker.tables[table][column]; ok {- return false- }- return true+ return adviceList, nil}diff --git a/backend/plugin/advisor/tidb/advisor_column_required.go b/backend/plugin/advisor/tidb/advisor_column_required.goindex 6cc35c69de..d96a940235 100644--- a/backend/plugin/advisor/tidb/advisor_column_required.go+++ b/backend/plugin/advisor/tidb/advisor_column_required.go@@ -6,20 +6,17 @@ import ("slices""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 = (*ColumnRequirementAdvisor)(nil)- _ ast.Visitor = (*columnRequirementChecker)(nil))func init() {@@ -27,13 +24,58 @@ func init() {}// ColumnRequirementAdvisor is the advisor checking for column requirement.-type ColumnRequirementAdvisor struct {-}+type ColumnRequirementAdvisor struct{}-// Check checks for the column requirement.+// Check tracks per-table required-column presence across the reviewed+// statements and emits a per-table advice listing any required columns+// that ended up missing.+//+// Per-arm state-mutation semantics (cumulative #25 audit axis — five+// distinct semantics across arms; preserve each independently):+// - CreateTableStmt: REPLACE — `initEmptyTable(name)` then `addColumn`+// per column in the new table. Resets prior state on re-creation.+// - DropTableStmt: DELETE — `delete(tables, name)` per dropped table.+// The table no longer appears in `generateAdviceList`. Pre-omni did+// NOT delete from the `line` map; preserved (orphaned line entries+// are harmless — generateAdviceList iterates tables, not line).+// - AlterTableStmt ATRenameColumn: READ-MODIFY-WRITE — `renameColumn`+// toggles old→false / new→true in the required-column map; lazy-+// initializes the table state as "all required present" if absent.+// - AlterTableStmt ATAddColumn: READ-MODIFY-WRITE — `addColumn` per+// added column (handles both singular `cmd.Column` and grouped+// `cmd.Columns` via `addColumnTargets`); lazy-initializes the+// table state as "all required present" if absent. NO line update+// (ADD COLUMN can only make missing required columns present;+// never triggers a new advice).+// - AlterTableStmt ATDropColumn: READ-MODIFY-WRITE — `dropColumn`+// marks the column false if it's required.+// - AlterTableStmt ATChangeColumn: equivalent to RENAME — `cmd.Name`+// is old, `cmd.Column.Name` is new (verified in+// advisor_column_disallow_changing_type.go pattern).+//+// Line tracking has per-arm semantics distinct from primary state+// (cumulative #27 — auxiliary state maps have their own conditionality+// contracts; mechanical port must audit each state map independently):+// - CreateTable: seeds line[table] unconditionally.+// - DropTable: does NOT delete from line (orphaned entries harmless;+// generateAdviceList iterates tables, not line).+// - ATRenameColumn: updates line UNCONDITIONALLY (RENAME is a more+// explicit "user modified this table at this line" signal).+// - ATAddColumn: does NOT update line (ADD can only make missing+// required columns present; never triggers new advice).+// - ATDropColumn: updates line ONLY when the dropped column was+// required (return value of dropColumn).+// - ATChangeColumn: updates line ONLY when the old name was required+// (return value of renameColumn). Asymmetric vs ATRenameColumn —+// pre-omni intentional asymmetry preserved.+//+// Identifier case-sensitivity (cumulative #19): pre-omni used `.O`+// throughout (no `.L` lowercase); omni's direct strings preserve user+// case. `CREATE TABLE t(A INT); ALTER TABLE t RENAME COLUMN a TO X`+// matches case-sensitively — pre-omni would NOT match `a` to required+// column `A`. Preserved.func (*ColumnRequirementAdvisor) Check(_ context.Context, checkCtx advisor.Context) ([]*storepb.Advice, error) {- root, err := getTiDBNodes(checkCtx)-+ stmts, err := getTiDBOmniNodes(checkCtx)if err != nil {return nil, err}@@ -46,86 +88,94 @@ func (*ColumnRequirementAdvisor) Check(_ context.Context, checkCtx advisor.Conteif stringArrayPayload == nil {return nil, errors.New("string_array_payload is required for column required rule")}- requiredColumns := make(columnSet)- for _, column := range stringArrayPayload.List {- requiredColumns[column] = true- }- checker := &columnRequirementChecker{- level: level,- title: checkCtx.Rule.Type.String(),+ requiredColumns := newColumnSet(stringArrayPayload.List)+ title := checkCtx.Rule.Type.String()++ v := &columnRequirementState{requiredColumns: requiredColumns,tables: make(tableState),line: make(map[string]int),}- for _, stmtNode := range root {- (stmtNode).Accept(checker)- }-- return checker.generateAdviceList(), nil-}--type columnRequirementChecker struct {- adviceList []*storepb.Advice- level storepb.Advice_Status- title string- requiredColumns columnSet- tables tableState- line map[string]int-}--// Enter implements the ast.Visitor interface.-func (v *columnRequirementChecker) Enter(in ast.Node) (ast.Node, bool) {- switch node := in.(type) {- // CREATE TABLE- case *ast.CreateTableStmt:- v.createTable(node)- // DROP TABLE- case *ast.DropTableStmt:- for _, table := range node.Tables {- delete(v.tables, table.Name.String())- }- // ALTER TABLE- case *ast.AlterTableStmt:- table := node.Table.Name.O- for _, spec := range node.Specs {- switch spec.Tp {- // RENAME COLUMN- case ast.AlterTableRenameColumn:- v.renameColumn(table, spec.OldColumnName.Name.O, spec.NewColumnName.Name.O)- v.line[table] = node.OriginTextPosition()- // ADD COLUMNS- case ast.AlterTableAddColumns:- for _, column := range spec.NewColumns {- v.addColumn(table, column.Name.Name.O)+ for _, ostmt := range stmts {+ stmtLine := ostmt.FirstTokenLine()+ switch n := ostmt.Node.(type) {+ case *ast.CreateTableStmt:+ if n.Table == nil {+ continue+ }+ v.line[n.Table.Name] = stmtLine+ v.initEmptyTable(n.Table.Name)+ for _, column := range n.Columns {+ if column == nil {+ continue+ }+ v.addColumn(n.Table.Name, column.Name)+ }+ case *ast.DropTableStmt:+ for _, table := range n.Tables {+ if table != nil {+ delete(v.tables, table.Name)}- // DROP COLUMN- case ast.AlterTableDropColumn:- if v.dropColumn(table, spec.OldColumnName.Name.O) {- v.line[table] = node.OriginTextPosition()+ }+ case *ast.AlterTableStmt:+ if n.Table == nil {+ continue+ }+ table := n.Table.Name+ for _, cmd := range n.Commands {+ if cmd == nil {+ continue}- // CHANGE COLUMN- case ast.AlterTableChangeColumn:- if v.renameColumn(table, spec.OldColumnName.Name.O, spec.NewColumns[0].Name.Name.O) {- v.line[table] = node.OriginTextPosition()+ switch cmd.Type {+ case ast.ATRenameColumn:+ // Cumulative #27: pre-omni updated line[table]+ // UNCONDITIONALLY for RENAME COLUMN, even when+ // neither old nor new is in the required set.+ // CHANGE COLUMN (below) is conditional on return+ // value — asymmetric pre-omni behavior preserved.+ // RENAME is a more explicit "user modified this+ // table at this line" signal that should mark the+ // position regardless of required-column impact.+ v.renameColumn(table, cmd.Name, cmd.NewName)+ v.line[table] = stmtLine+ case ast.ATAddColumn:+ for _, column := range addColumnTargets(cmd) {+ if column == nil {+ continue+ }+ v.addColumn(table, column.Name)+ }+ case ast.ATDropColumn:+ if v.dropColumn(table, cmd.Name) {+ v.line[table] = stmtLine+ }+ case ast.ATChangeColumn:+ if cmd.Column == nil {+ continue+ }+ if v.renameColumn(table, cmd.Name, cmd.Column.Name) {+ v.line[table] = stmtLine+ }+ default:}- default:}+ default:}- default:}- return in, false++ return v.generateAdviceList(level, title), nil}-// Leave implements the ast.Visitor interface.-func (*columnRequirementChecker) Leave(in ast.Node) (ast.Node, bool) {- return in, true+type columnRequirementState struct {+ requiredColumns columnSet+ tables tableState+ line map[string]int}-func (v *columnRequirementChecker) generateAdviceList() []*storepb.Advice {- // Order it cause the random iteration order in Go, see https://go.dev/blog/maps- tableList := v.tables.tableList()- for _, tableName := range tableList {+func (v *columnRequirementState) generateAdviceList(level storepb.Advice_Status, title string) []*storepb.Advice {+ var adviceList []*storepb.Advice+ for _, tableName := range v.tables.tableList() {table := v.tables[tableName]var missingColumns []stringfor column := range v.requiredColumns {@@ -134,29 +184,30 @@ func (v *columnRequirementChecker) generateAdviceList() []*storepb.Advice {}}if len(missingColumns) > 0 {- // Order it cause the random iteration order in Go, see https://go.dev/blog/mapsslices.Sort(missingColumns)- v.adviceList = append(v.adviceList, &storepb.Advice{- Status: v.level,+ adviceList = append(adviceList, &storepb.Advice{+ Status: level,Code: code.NoRequiredColumn.Int32(),- Title: v.title,+ Title: title,Content: fmt.Sprintf("Table `%s` requires columns: %s", tableName, strings.Join(missingColumns, ", ")),StartPosition: common.ConvertANTLRLineToPosition(v.line[tableName]),})}}-- return v.adviceList+ return adviceList}-// initEmptyTable will initialize a table without any required columns.-func (v *columnRequirementChecker) initEmptyTable(name string) columnSet {+// initEmptyTable initializes a table with no required columns present.+func (v *columnRequirementState) initEmptyTable(name string) columnSet {v.tables[name] = make(columnSet)return v.tables[name]}-// initFullTable will initialize a table with all required columns.-func (v *columnRequirementChecker) initFullTable(name string) columnSet {+// initFullTable initializes a table with all required columns present.+// Used for "we don't retrospectively check": when ALTER targets a table+// we haven't seen CREATE for, we assume it had all required columns,+// so only modifications surfaced in this review affect the verdict.+func (v *columnRequirementState) initFullTable(name string) columnSet {table := v.initEmptyTable(name)for column := range v.requiredColumns {table[column] = true@@ -164,7 +215,11 @@ func (v *columnRequirementChecker) initFullTable(name string) columnSet {return table}-func (v *columnRequirementChecker) renameColumn(table string, oldColumn string, newColumn string) bool {+// renameColumn marks the old name absent and the new name present, if+// either is in the required set. Returns true if the OLD name was+// required (meaning the rename could surface a new missing-required;+// caller updates the line).+func (v *columnRequirementState) renameColumn(table, oldColumn, newColumn string) bool {_, oldNeed := v.requiredColumns[oldColumn]_, newNeed := v.requiredColumns[newColumn]if !oldNeed && !newNeed {@@ -172,8 +227,6 @@ func (v *columnRequirementChecker) renameColumn(table string, oldColumn string,}t, ok := v.tables[table]if !ok {- // We do not retrospectively check.- // So we assume it contains all required columns.t = v.initFullTable(table)}if oldNeed {@@ -185,37 +238,28 @@ func (v *columnRequirementChecker) renameColumn(table string, oldColumn string,return oldNeed}-func (v *columnRequirementChecker) dropColumn(table string, column string) bool {+// dropColumn marks the column absent if it's required. Returns true+// when the dropped column was required.+func (v *columnRequirementState) dropColumn(table, column string) bool {if _, ok := v.requiredColumns[column]; !ok {return false}t, ok := v.tables[table]if !ok {- // We do not retrospectively check.- // So we assume it contains all required columns.t = v.initFullTable(table)}t[column] = falsereturn true}-func (v *columnRequirementChecker) addColumn(table string, column string) {+// addColumn marks the column present if it's required.+func (v *columnRequirementState) addColumn(table, column string) {if _, ok := v.requiredColumns[column]; !ok {return}if t, ok := v.tables[table]; !ok {- // We do not retrospectively check.- // So we assume it contains all required columns.v.initFullTable(table)} else {t[column] = true}}--func (v *columnRequirementChecker) createTable(node *ast.CreateTableStmt) {- v.line[node.Table.Name.O] = node.OriginTextPosition()- v.initEmptyTable(node.Table.Name.O)- for _, column := range node.Cols {- v.addColumn(node.Table.Name.O, column.Name.Name.O)- }-}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.yamlindex 83de8a462c..56ca440518 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@@ -54,4 +54,36 @@startposition:line: 3column: 0- endposition: null\ No newline at end of file+ endposition: null+# Batch 16: catalog side-load pin — ALTER DROP COLUMN on a table NOT+# created in the reviewed statements should consult OriginalMetadata+# for index membership. tech_book is pre-populated in the mock catalog+# with an index on (id, name) (utils_for_tests.go:80-82); dropping+# either column should fire via the SIDE-LOAD CATALOG path. This pin+# exercises the load-bearing path that existing CREATE-then-ALTER+# fixtures didn't reach (those built index info via the CREATE arm).+- statement: ALTER TABLE tech_book DROP COLUMN name+ changeType: 1+ want:+ - status: 2+ code: 424+ title: COLUMN_DISALLOW_DROP_IN_INDEX+ content: '`tech_book`.`name` cannot drop index column'+ startposition:+ line: 1+ column: 0+ endposition: null+# Batch 16: case-sensitivity pin (cumulative #19 territory) — pre-omni+# pingcap-tidb used .O (original case) throughout, with no .L+# lowercase normalization. CREATE TABLE t(A INT, INDEX(A)) stores+# "A" in the index set; ALTER TABLE t DROP COLUMN a looks up "a"+# which DOES NOT match. Rule does NOT fire — preserves pingcap-tidb+# case-sensitive behavior. Omni's direct strings also preserve user+# case, so the omni port matches mechanically. NOT a regression. Pin+# documents that this advisor doesn't need the strings.ToLower+# normalization that batch 9's column_require_default needed (which+# used .L explicitly in pre-omni source).+- statement: |-+ CREATE TABLE t(A int, INDEX idx_A(A));+ ALTER TABLE t DROP COLUMN a+ changeType: 1\ No newline at end of filediff --git a/backend/plugin/advisor/tidb/test/column_required.yaml b/backend/plugin/advisor/tidb/test/column_required.yamlindex 69c2d99333..9975f98f6d 100644--- a/backend/plugin/advisor/tidb/test/column_required.yaml+++ b/backend/plugin/advisor/tidb/test/column_required.yaml@@ -162,3 +162,80 @@updated_ts timestamp);DROP TABLE book;changeType: 1+# Batch 16: DROP-then-reCREATE pin (cumulative #25 axis) — DROP TABLE+# removes the table from state; the subsequent CREATE TABLE on the+# same name REPLACES with a fresh empty state (initEmptyTable ++# per-column addColumn). The re-CREATE is missing required columns,+# so the rule fires on the SECOND incarnation. Distinct from+# statement_merge_alter_table's CREATE-resets pattern but same audit+# axis: per-arm state-mutation semantics (DELETE then REPLACE).+- statement: |-+ CREATE TABLE book(+ id int,+ creator_id int,+ created_ts timestamp,+ updater_id int,+ updated_ts timestamp);+ DROP TABLE book;+ CREATE TABLE book(id int);+ changeType: 1+ want:+ - status: 2+ code: 401+ title: COLUMN_REQUIRED+ content: 'Table `book` requires columns: created_ts, creator_id, updated_ts, updater_id'+ startposition:+ line: 8+ column: 0+ endposition: null+# Batch 16: case-sensitivity pin (cumulative #19 territory) — pre-omni+# pingcap used .O throughout (no .L). `requiredColumns` is keyed by+# the rule's configured strings (e.g. "creator_id" exactly). A column+# named "Creator_id" in the user's CREATE TABLE would NOT match+# "creator_id" in the required set — rule fires (case-mismatch =+# missing). Omni preserves user case in column.Name; matches+# pingcap-tidb behavior. NOT a regression.+- statement: |-+ CREATE TABLE book(+ id int,+ Creator_id int,+ created_ts timestamp,+ updater_id int,+ updated_ts timestamp);+ changeType: 1+ want:+ - status: 2+ code: 401+ title: COLUMN_REQUIRED+ content: 'Table `book` requires columns: creator_id'+ startposition:+ line: 1+ column: 0+ endposition: null+# Cumulative #27 pin (batch 16, Codex P2 catch pre-merge): pre-omni+# ATRenameColumn arm UNCONDITIONALLY updated line[table] — even when+# the rename touched no required column. CHANGE COLUMN is conditional+# (only on advice-relevant rename). Initial batch 16 migration unified+# both arms behind the conditional pattern, regressing RENAME's+# unconditional line update. Externally observable: for `CREATE TABLE+# book(id); ALTER TABLE book RENAME COLUMN x TO y;` the advice+# StartPosition was line 1 (CREATE) on the regressed branch instead+# of line 2 (RENAME) on pre-omni. Fix: split the line-update from the+# renameColumn() return-value check on ATRenameColumn only; CHANGE+# COLUMN remains conditional. Cumulative #27 documents the auxiliary-+# state-map audit refinement of #25: each state map (primary `tables`+# AND auxiliary `line`) has its own per-arm conditionality contract;+# the audit must enumerate cross-arm × cross-map (Cartesian).+- statement: |-+ CREATE TABLE book(id int);+ ALTER TABLE book RENAME COLUMN x TO y;+ changeType: 1+ want:+ - status: 2+ code: 401+ title: COLUMN_REQUIRED+ content: 'Table `book` requires columns: created_ts, creator_id, updated_ts, updater_id'+ startposition:+ line: 2+ column: 0+ endposition: null