Skip to content

mysql: convert BIT to UInt64 in binary type path for new mirrors#4423

Merged
dtunikov merged 1 commit into
mainfrom
fix/dbi-800/mysql-bit-to-uint64
Jun 15, 2026
Merged

mysql: convert BIT to UInt64 in binary type path for new mirrors#4423
dtunikov merged 1 commit into
mainfrom
fix/dbi-800/mysql-bit-to-uint64

Conversation

@dtunikov

Copy link
Copy Markdown
Collaborator

What

qkindFromMysqlType (the binary binlog / QRep type-conversion path) mapped MySQL BIT to Int64, while QkindFromMysqlColumnType (the information_schema / DDL text path) already mapped it to UInt64. This made BIT columns that flow through the binary path inconsistent with the rest of the system.

The binary path is reached for:

  • columns discovered via TABLE_MAP_EVENT without a captured DDL event (e.g. gh-ost / online-schema-change migrations) — processTableMapEventSchema
  • the QRep watermark column type
  • the QRecordSchemaFromMysqlFields fallback for columns absent from the table schema

A plain ALTER TABLE ... ADD COLUMN bit(...) is not affected — it's captured as a DDL query event and already routes through the UInt64 text path.

Change

  • Map BIT to UInt64 in qkindFromMysqlType, gated behind a new InternalVersion_MySQLConvertBitToUInt64.
  • Thread the mirror version through qkindFromMysqlType / QRecordSchemaFromMysqlFields and their callers (CDC, QRep, e2e helper).
  • Add a unit test covering the version gate.

Why gate it

The destination column type is fixed when a column is first created. An existing mirror that already materialized a BIT column as Int64 via the binary path would break if the code started emitting UInt64 values into that Int64 column on upgrade (schema deltas add columns, they don't retype existing ones). Gating on InternalVersion keeps existing mirrors on their previous behavior and gives only new mirrors the consistent UInt64 mapping.

Testing

  • New unit test TestQkindFromMysqlType_Bit asserts Int64 below the gate version and UInt64 at/above it.
  • go build ./... and the connectors/mysql unit tests pass.

Note: a normal full-table BIT e2e test does not exercise this path, since in-schema BIT columns resolve their type via the ungated text path. The meaningful behavioral difference is limited to the gh-ost/TABLE_MAP_EVENT-detected-column and QRep cases described above.

🤖 Generated with Claude Code

The binary binlog/QRep type conversion (qkindFromMysqlType) mapped BIT to
Int64, while the information_schema text path (QkindFromMysqlColumnType)
already mapped it to UInt64. This left BIT columns discovered via the
binary path inconsistent with the rest of the system — most visibly
gh-ost/TABLE_MAP_EVENT-detected columns and QRep watermark/fallback paths.

Gate the new UInt64 mapping behind InternalVersion_MySQLConvertBitToUInt64
so existing mirrors keep their previously-materialized destination column
type, and only new mirrors get the consistent UInt64 behavior. Thread the
mirror version through qkindFromMysqlType / QRecordSchemaFromMysqlFields and
their callers (CDC, QRep, e2e helper). Add a unit test covering the gate.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@dtunikov
dtunikov requested a review from a team as a code owner June 15, 2026 15:50
@claude

claude Bot commented Jun 15, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@dtunikov
dtunikov merged commit 59f8c11 into main Jun 15, 2026
16 checks passed
@dtunikov
dtunikov deleted the fix/dbi-800/mysql-bit-to-uint64 branch June 15, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants