-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: fix bug causing sequenceIDs to be duplicated on column descriptors
Previously, there was a bug in the `ALTER SEQUENCE ... OWNED BY ...` command that could cause sequence IDs to appear on more than one column descriptor's 'OwnsSequenceIDs' field. This was problematic as the dropping logic requires a sequence ID only be present on one column descriptor's `OwnsSequenceIDs' field. The field would get corrupted whenever ownership was altered between columns of the same table. This was because we would read a table descriptor before executing the removal code, but the removal would modify the same table descriptor. This would make the table descriptor read earlier stale, as the old owner's column descriptor still referenced the sequence ID. This would mean that when a new owner was added to a different column, the schema change that was written would have the sequence ID on two different column descriptor's `OwnsSequenceIDs` field. This patch fixes that by forcing the `addSequenceOwner` to resolve the most recent version of the table descriptor instead of being passed it. Fixes #50711 Release note (bug fix): Previously, if there was a table `t(a int, b int)`, and a sequence `seq` that was first owned by `t.a` and then altered to be owned by `t.b`, it would make the table `t` impossible to drop. This is now fixed.
- Loading branch information
1 parent
0b6e118
commit 106d9b5
Showing
3 changed files
with
172 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters