sql: alter pk using subset of old pk key columns should always rewrite secondary indexes #84040
Labels
C-bug
Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
T-sql-foundations
SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Describe the problem
Currently when doing
ALTER PRIMARY kEY
, we have smart logic to determine whether to rewrite secondary index or not. Simply put, the logic is based on the rule of how we encode secondary index key/value pair and if the secondary index key/value pair has enough information to construct a primary key to fetch more data. There is one corner case, when we chose not to rewrite, secondary index still has references to columns from the old primary key insuffixKeyColumns
that's not part of new primary key. This is problematic because user could drop the old primary key column since they think they're not needed any more, and that would cause the secondary index to be dropped silently (see this issue)See the repro below for details about the specific issue. This happens in all versions.
To Reproduce
Desired Behavior
We need to rewrite the secondary index in this case even we have enough information to infer a primary key.
The text was updated successfully, but these errors were encountered: