Skip to content

Support generated columns for move-tables - #1746

Open
ericyan wants to merge 4 commits into
feature/move-tablesfrom
move-tables-generated-columns
Open

Support generated columns for move-tables#1746
ericyan wants to merge 4 commits into
feature/move-tablesfrom
move-tables-generated-columns

Conversation

@ericyan

@ericyan ericyan commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes generated column handling in move-tables mode.

Generated columns support

Move-tables mode set SharedColumns and MappedSharedColumns to the full source column list:

mt.SharedColumns = columns
mt.MappedSharedColumns = columns

Since columns includes generated columns, both the row-copy INSERT and the binlog-driven INSERT/UPDATE named them in their value lists, and MySQL rejected the migration:

Error 3105 (HY000): The value specified for generated column 'x' in table 'y' is not allowed.

Standard migrations avoid this because getSharedColumns() removes generated columns; move-tables mode had no equivalent.

This is fixed by excluding generated columns from the writable set and then route row-copy builders through the filtered list.

Missing column metadata

Investigating the reported schema surfaced a second, independent defect. applyColumnTypes was only ever called on unique-key columns in move-tables mode, so Type, IsUnsigned, Charset, MySQLType, and BinaryOctetLength were empty everywhere else. That silently disabled encoding logic in convertArg and buildColumnsPreparedValues:

Missing metadata Consequence
IsUnsigned BIGINT UNSIGNED values above 2^63 written to the target as negative numbers
Type == JSONColumnType JSON bound as plain ? instead of convert(? using utf8mb4)
BinaryOctetLength Fixed-width BINARY not zero-padded (#909)
MySQLType binary/blob Sent as MYSQL_TYPE_VAR_STRING rather than MYSQL_TYPE_BLOB, producing Warning 1300 under --panic-on-warnings

These column metadata are now populated.


In case this PR introduced Go code changes:

  • contributed code is using same conventions as original code
  • script/cibuild returns with no formatting errors, build errors or unit test errors.

@ericyan
ericyan force-pushed the move-tables-generated-columns branch 3 times, most recently from c46ce5b to 4180c2f Compare July 31, 2026 09:38
@ericyan
ericyan marked this pull request as ready for review July 31, 2026 11:48
@ericyan
ericyan requested a review from timvaillancourt as a code owner July 31, 2026 11:48
Copilot AI review requested due to automatic review settings July 31, 2026 11:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds generated-column and complete metadata support to move-tables migrations.

Changes:

  • Excludes generated columns from row-copy and binlog writes.
  • Populates JSON, unsigned, and binary column metadata.
  • Adds unit and local integration coverage.
Show a summary per file
File Description
go/base/context.go Clarifies writable-column semantics.
go/logic/migrator.go Filters generated columns and loads metadata.
go/logic/migrator_test.go Tests filtering and metadata initialization.
go/logic/applier.go Uses writable columns for row copy.
go/logic/applier_test.go Tests generated-column DML and copying.
localtests/move-tables/generated-columns/create.sql Adds generated-column integration fixture.
localtests/move-tables/generated-columns/tables.txt Registers generated-column fixture.
localtests/move-tables/unsigned/create.sql Adds unsigned-value integration fixture.
localtests/move-tables/unsigned/tables.txt Registers unsigned-value fixture.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 9/9 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@ericyan
ericyan changed the base branch from feature-move-tables to feature/move-tables July 31, 2026 12:44
ericyan added 4 commits July 31, 2026 12:59
Exclude generated columns from move-tables writable column lists during
initial setup and resume. Use the filtered columns for row-copy queries
while preserving the complete column layout for binlog event ordinals.
Populate writable column metadata for fresh and resumed move-table
migrations so JSON, unsigned, and binary values are encoded correctly.
Exercise row copy and concurrent DML with signed, unsigned, and maximum
BIGINT UNSIGNED values.
@ericyan
ericyan force-pushed the move-tables-generated-columns branch from 4180c2f to 6dabbe6 Compare July 31, 2026 12:59
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