{"record":{"id":"d404fbaf383bdb82","repo":"vitessio/vitess","slug":"rename-clause-found","errorCode":null,"errorMessage":"RENAME clause found","messagePattern":"RENAME clause found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/schema/online_ddl.go","lineNumber":57,"sourceCode":")\n\nvar onlineDDLInternalTableHintsMap = map[string]bool{\n\t\"vrp\": true, // vreplication\n\t\"gho\": true, // gh-ost\n\t\"ghc\": true, // gh-ost\n\t\"del\": true, // gh-ost\n\t\"new\": true, // pt-osc\n}\n\nvar (\n\t// ErrDirectDDLDisabled is returned when direct DDL is disabled, and a user attempts to run a DDL statement\n\tErrDirectDDLDisabled = errors.New(\"direct DDL is disabled\")\n\t// ErrOnlineDDLDisabled is returned when online DDL is disabled, and a user attempts to run an online DDL operation (submit, review, control)\n\tErrOnlineDDLDisabled = errors.New(\"online DDL is disabled\")\n\t// ErrForeignKeyFound indicates any finding of FOREIGN KEY clause in a DDL statement\n\tErrForeignKeyFound = errors.New(\"Foreign key found\")\n\t// ErrRenameTableFound indicates finding of ALTER TABLE...RENAME in ddl statement\n\tErrRenameTableFound = errors.New(\"RENAME clause found\")\n)\n\nconst (\n\tSchemaMigrationsTableName = \"schema_migrations\"\n\tRevertActionStr           = \"revert\"\n)\n\n// ValidateMigrationContext validates that the given migration context only uses valid characters\nfunc ValidateMigrationContext(migrationContext string) error {\n\tif migrationContextValidatorRegexp.MatchString(migrationContext) {\n\t\treturn nil\n\t}\n\treturn vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, \"invalid characters in migration_context %v. Use alphanumeric, dash, underscore and colon only\", migrationContext)\n}\n\n// when validateWalk returns true, then the child nodes are also visited\nfunc validateWalk(node sqlparser.SQLNode, allowForeignKeys bool) (kontinue bool, err error) {\n\tswitch node.(type) {","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/schema/online_ddl.go#L39-L75","documentation":"ErrRenameTableFound is a sentinel error indicating an ALTER TABLE ... RENAME (or RENAME TABLE) clause was found during online-DDL statement validation (validateWalk / onlineDDLStatementSanity). Renames cannot be expressed as an online migration on the same table, so the statement is rejected in the online path.","triggerScenarios":"Submitting ALTER TABLE t RENAME TO t2 (or equivalent rename syntax) with an online ddl_strategy; the sanity walk detects the rename clause and returns ErrRenameTableFound.","commonSituations":"Refactoring table names in production via vtctld; automated migration tools generating rename statements; users expecting gh-ost/pt-osc to support renames like plain MySQL does.","solutions":["Execute the rename with a direct DDL strategy: ALTER /*vt+ ddl_strategy=direct */ TABLE ...","Avoid renaming; create the new table online, copy data (vreplication), then drop the old table","Run RENAME TABLE as a separate permitted statement outside the online-DDL path","Check errors.Is(err, schema.ErrRenameTableFound) in tooling to redirect renames to direct execution"],"exampleFix":"-- before\nALTER /*vt+ ddl_strategy=gh-ost */ TABLE t RENAME TO t2;\n-- after\nALTER /*vt+ ddl_strategy=direct */ TABLE t RENAME TO t2;","handlingStrategy":"validation","validationCode":"if strings.Contains(strings.ToUpper(stmt), \" RENAME \") {\n    return fmt.Errorf(\"renames require ddl_strategy=direct or a copy-based migration\")\n}","typeGuard":null,"tryCatchPattern":"_, err := tm.TryExecute(ctx, stmt)\nif errors.Is(err, schema.ErrRenameTableFound) {\n    // reroute to direct strategy or a create+copy+drop plan\n}","preventionTips":["Never use online ddl_strategy for RENAME statements","For large table renames, plan create-new + vreplication copy + atomic swap","Lint generated migrations for RENAME clauses","Keep rename operations in a separate, direct-DDL-approved change window"],"tags":["ddl","online-ddl","rename","mysql"],"backgroundTag":"ddl-rename-unsupported","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}