Online DDL: support DROP FOREIGN KEY statement #14338
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
For the ongoing, experimental foreign key support, this PR adds support for
ALTER TABLE ... DROP FOREIGN KEY
. As you might see from the change, there's very little to this PR; all the support has been created long ago, but due to an oversight we did not includeDROP FOREIGN KEY
in the logic.Just to explain the change: in Online DDL we actually drop the foreign key on the shadow table. Since foreign key constraints, like check constraints, have schema-level naming scope, the shadow table's foreign key constraint is different than the original's.
Without this PR, a
ALTER TABLE t DROP FOREIGN KEY t_id_fk
fails because it attempts to drop the constraintt_id_fk
from the shadow tables. But on the shadow table the constraint might be named e.g.fk_aulpn7bjeortljhguy86phdn9
. The fix in this PR is to use the constraint mapping between original and shadow table.Related Issue(s)
Tracking: #11975
Checklist
Deployment Notes