Skip to content

fix(schema/mysql): align omni catalogToProto with driver metadata conventions#20571

Merged
rebelice merged 1 commit into
mainfrom
claude/angry-euler-94c79f
Jun 10, 2026
Merged

fix(schema/mysql): align omni catalogToProto with driver metadata conventions#20571
rebelice merged 1 commit into
mainfrom
claude/angry-euler-94c79f

Conversation

@rebelice

Copy link
Copy Markdown
Contributor

What

Fixes Sync Schema false-positive diffs between identical MySQL databases, a regression shipped in 3.17.0. Fixes #20486 (Linear: BYT-9688).

DiffSchema compares driver-synced metadata (backend/plugin/db/mysql/sync.go) against metadata re-parsed from the schema dump. Since #19905 the parse path is GetDatabaseMetadataOmnicatalogToProto, 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)

  • AUTO_INCREMENT columns report Default: "AUTO_INCREMENT"
  • Nullable columns without an explicit default report Default: "NULL"
  • Static defaults are single-quoted ('0'), expression defaults parenthesized ((uuid())), keyed off the omni DefaultKind; explicit DEFAULT NULL stays NULL
  • 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, matching information_schema
  • RANGE COLUMNS / LIST COLUMNS partitions report the joined column list as the partition expression

Test path fix (why CI never caught this)

TestGetDatabaseMetadataWithTestcontainer does exactly this driver-vs-parser parity comparison — but it called the package-local ANTLR GetDatabaseMetadata, while production registers GetDatabaseMetadataOmni. 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

  • TestGetDatabaseMetadataWithTestcontainer against a real MySQL 8.0 testcontainer: 23/23 subtests pass (was 18/23 once repointed at the omni function)
  • backend/plugin/schema/mysql and backend/plugin/advisor/mysql package tests pass
  • golangci-lint clean, full server build passes

🤖 Generated with Claude Code

…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>
@rebelice rebelice requested a review from a team as a code owner June 10, 2026 07:14
@cla-bot cla-bot Bot added the cla-signed label Jun 10, 2026
@sonarqubecloud

Copy link
Copy Markdown

@rebelice rebelice enabled auto-merge (squash) June 10, 2026 07:16

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread backend/plugin/schema/mysql/walk_through_omni.go
@rebelice rebelice merged commit b8c83e8 into main Jun 10, 2026
16 checks passed
@rebelice rebelice deleted the claude/angry-euler-94c79f branch June 10, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False-positive Schema Diff Between Identical MySQL RDS Databases

2 participants