mysql: drop keys over excluded columns from the table description - #38737
mysql: drop keys over excluded columns from the table description#38737peterdukelarsen wants to merge 2 commits into
Conversation
`EXCLUDE COLUMNS` removed the column from a MySQL table description but left any unique index over it in `keys`. Planning then emitted a UNIQUE constraint on a column the table does not have and failed with "unknown column in constraint", so a table with a unique index on an excluded column could not be created. Had it been created, the retained key would also have stalled the table once the excluded column or its index was dropped upstream, since schema verification could no longer find it. Prune such keys in `to_desc`, matching what Postgres and SQL Server already do. This affects newly purified statements only; persisted descriptors are unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
QA LLM Review1. HIGH -- Pruning inside
|
…tion Pruning the keys in `to_desc` also changed the description that running sources compare against in `verify_schemas`. A persisted description that still holds a key over an excluded column, which planning admits whenever an earlier nullable UNIQUE constraint short-circuits constraint validation, would then fail `determine_compatibility` on the next upstream DDL and stall. Leave `to_desc` alone and handle such keys where Postgres and SQL Server do. Constraint emission skips them, so the table can be created, and `determine_compatibility` ignores them, so dropping the excluded column or its index upstream is a non-event for new and existing tables alike. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Motivation
EXCLUDE COLUMNSremoved the column from a MySQL table description but left any unique index over it inkeys. Planning then emitted a UNIQUE constraint on a column the table does not have and failed with "unknown column in constraint", so a table with a unique index on an excluded column could not be created. Where planning did admit it (an earlier nullable UNIQUE constraint short-circuits constraint validation), the retained key stalled the table once the excluded column or its index was dropped upstream, since schema verification could no longer find it.Description
Keys over an excluded column are handled where Postgres and SQL Server handle them, and the table description itself is left unchanged.
determine_compatibilityignores keys in the recorded description that span a column the description marks as excluded, so dropping the excluded column or its index upstream is a non-event. This applies to existing tables too, whose persisted descriptions may already hold such keys.Pruning inside
to_descwas considered and rejected:to_descalso produces the upstream side of the runtime comparison, so pruning there would have made every persisted key over an excluded column look dropped on the next upstream DDL.User-visible effect: a MySQL table with a unique index over a column listed in
EXCLUDE COLUMNScan now be created, and dropping that index or column upstream no longer puts the table into an error state.Verification
test/mysql-cdc/35-exclude-columns.tdcreates such tables, checks the excluded key is not recorded, and drops the upstream indexes afterwards, including a key that also spans a nullable included column.keys_over_excluded_columns_are_not_verifiedunit tests the compatibility check directly.🤖 Generated with Claude Code