-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve logic to include originalUniqueKey in sharedUniqueKeys (#1453)
Until now, when building the list of SharedUniqueKeys, the code was selecting only the originalUniqueKeys that existed in ghostUniqueKeys list. However, as part of the alter table, it is possible to add more unique keys or even composed primary keys with multiple columns. The new logic keeps the old behaviour (it matches originalUniqueKey with exactly the same ghostUniqueKey) but also supports the cases where the originalUniqueKey is now a subset of one of the new ghostUniqueKeys. If such a case happens, we can still use the originalUniqueKey as normal because a new ghostUniqueKey with the columns of originalUniqueKey plus some new columns is inherently unique just by the columns in the originalUniqueKey, no matter the value in the new columns of the new unique key.
- Loading branch information
Showing
6 changed files
with
31 additions
and
5 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
--alter="drop primary key, add primary key (id, i)" | ||
--alter="drop primary key, add primary key (i)" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
drop table if exists gh_ost_test; | ||
create table gh_ost_test ( | ||
id int auto_increment, | ||
i int not null, | ||
ts timestamp, | ||
primary key(id) | ||
) auto_increment=1; | ||
|
||
drop event if exists gh_ost_test; | ||
delimiter ;; | ||
create event gh_ost_test | ||
on schedule every 1 second | ||
starts current_timestamp | ||
ends current_timestamp + interval 60 second | ||
on completion not preserve | ||
enable | ||
do | ||
begin | ||
insert into gh_ost_test values (null, 11, now()); | ||
insert into gh_ost_test values (null, 13, now()); | ||
insert into gh_ost_test values (null, 17, now()); | ||
end ;; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--alter="drop primary key, add primary key (id, i)" |