fix(schema/mysql): align omni catalogToProto with driver metadata conventions#20571
Merged
Conversation
…ventions Sync Schema reports false-positive diffs between identical MySQL databases since 3.17.0 (#20486, BYT-9688). DiffSchema compares driver-synced metadata against metadata re-parsed from the schema dump, and the omni parse path (GetDatabaseMetadataOmni -> catalogToProto) lacks the normalizations the driver applies in SyncDBSchema, so the byte-for-byte differ flags every nullable column, auto-increment PK, and index as changed. Align catalogToProto with the driver conventions: - AUTO_INCREMENT columns report Default "AUTO_INCREMENT" - nullable columns without an explicit default report Default "NULL" - static defaults are single-quoted, expression defaults parenthesized - index key length is -1 when no prefix length is specified, 32 for SPATIAL index columns - system-hidden columns (functional index backing columns) are skipped - RANGE/LIST COLUMNS partitions report the joined column list as the partition expression Repoint TestGetDatabaseMetadataWithTestcontainer at GetDatabaseMetadataOmni so the driver-vs-parser parity check guards the function production registers, instead of the unused ANTLR parser. Walk-through goldens updated for the new conventions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aba7bdae8e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
h3n4l
approved these changes
Jun 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
Fixes Sync Schema false-positive diffs between identical MySQL databases, a regression shipped in 3.17.0. Fixes #20486 (Linear: BYT-9688).
DiffSchemacompares driver-synced metadata (backend/plugin/db/mysql/sync.go) against metadata re-parsed from the schema dump. Since #19905 the parse path isGetDatabaseMetadataOmni→catalogToProto, which lacked the normalizations the driver applies — and the differ compares these fields byte-for-byte, so every nullable column, auto-increment PK, and index on identical databases was flagged as changed, generating spurious ALTER/index DDL.Changes to
catalogToProto(production parity with driver sync)Default: "AUTO_INCREMENT"Default: "NULL"'0'), expression defaults parenthesized ((uuid())), keyed off the omniDefaultKind; explicitDEFAULT NULLstaysNULL-1when no prefix length is specified,32for SPATIAL index columnsinformation_schemaRANGE COLUMNS/LIST COLUMNSpartitions report the joined column list as the partition expressionTest path fix (why CI never caught this)
TestGetDatabaseMetadataWithTestcontainerdoes exactly this driver-vs-parser parity comparison — but it called the package-local ANTLRGetDatabaseMetadata, while production registersGetDatabaseMetadataOmni. CI stayed green for three minor releases while testing a parser the production diff path no longer uses. The test now calls the registered omni function. The five additional mismatches it immediately exposed (default quoting, hidden columns, column partitions, spatial key length) are fixed above.Walk-through goldens (
testdata/walk_through.yaml) updated for the new conventions.Why
Affects every MySQL and OceanBase user of Sync Schema / DiffSchema on 3.17.0 → 3.19.0: identical databases diff as different, and real diffs include unrelated index/PK/FK churn. Should be cherry-picked to a 3.19.x patch release.
Testing
TestGetDatabaseMetadataWithTestcontaineragainst a real MySQL 8.0 testcontainer: 23/23 subtests pass (was 18/23 once repointed at the omni function)backend/plugin/schema/mysqlandbackend/plugin/advisor/mysqlpackage tests passgolangci-lintclean, full server build passes🤖 Generated with Claude Code