Skip to content

Commit 260374a

Browse files
author
Shlomi Noach
authored
Merge branch 'master' into long-table-names
2 parents 39e73e3 + 94a325c commit 260374a

File tree

6 files changed

+66
-8
lines changed

6 files changed

+66
-8
lines changed

go/logic/inspect.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -656,18 +656,21 @@ func (this *Inspector) getSharedUniqueKeys(originalUniqueKeys, ghostUniqueKeys [
656656

657657
// getSharedColumns returns the intersection of two lists of columns in same order as the first list
658658
func (this *Inspector) getSharedColumns(originalColumns, ghostColumns *sql.ColumnList, columnRenameMap map[string]string) (*sql.ColumnList, *sql.ColumnList) {
659-
columnsInGhost := make(map[string]bool)
660-
for _, ghostColumn := range ghostColumns.Names() {
661-
columnsInGhost[ghostColumn] = true
662-
}
663659
sharedColumnNames := []string{}
664660
for _, originalColumn := range originalColumns.Names() {
665661
isSharedColumn := false
666-
if columnsInGhost[originalColumn] || columnsInGhost[columnRenameMap[originalColumn]] {
667-
isSharedColumn = true
662+
for _, ghostColumn := range ghostColumns.Names() {
663+
if strings.EqualFold(originalColumn, ghostColumn) {
664+
isSharedColumn = true
665+
}
666+
if strings.EqualFold(columnRenameMap[originalColumn], ghostColumn) {
667+
isSharedColumn = true
668+
}
668669
}
669-
if this.migrationContext.DroppedColumnsMap[originalColumn] {
670-
isSharedColumn = false
670+
for droppedColumn := range this.migrationContext.DroppedColumnsMap {
671+
if strings.EqualFold(originalColumn, droppedColumn) {
672+
isSharedColumn = false
673+
}
671674
}
672675
if isSharedColumn {
673676
sharedColumnNames = append(sharedColumnNames, originalColumn)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
drop table if exists gh_ost_test;
2+
create table gh_ost_test (
3+
id int auto_increment,
4+
c1 int not null default 0,
5+
c2 int not null default 0,
6+
primary key (id)
7+
) auto_increment=1;
8+
9+
drop event if exists gh_ost_test;
10+
delimiter ;;
11+
create event gh_ost_test
12+
on schedule every 1 second
13+
starts current_timestamp
14+
ends current_timestamp + interval 60 second
15+
on completion not preserve
16+
enable
17+
do
18+
begin
19+
insert ignore into gh_ost_test values (1, 11, 23);
20+
insert ignore into gh_ost_test values (2, 13, 23);
21+
insert into gh_ost_test values (null, 17, 23);
22+
set @last_insert_id := last_insert_id();
23+
update gh_ost_test set c1=c1+@last_insert_id, c2=c2+@last_insert_id where id=@last_insert_id order by id desc limit 1;
24+
delete from gh_ost_test where id=1;
25+
delete from gh_ost_test where c1=13; -- id=2
26+
end ;;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
No shared unique key can be found after ALTER
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--alter="modify ID int"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
drop table if exists gh_ost_test;
2+
create table gh_ost_test (
3+
id int auto_increment,
4+
c1 int not null default 0,
5+
c2 int not null default 0,
6+
primary key (id)
7+
) auto_increment=1;
8+
9+
drop event if exists gh_ost_test;
10+
delimiter ;;
11+
create event gh_ost_test
12+
on schedule every 1 second
13+
starts current_timestamp
14+
ends current_timestamp + interval 60 second
15+
on completion not preserve
16+
enable
17+
do
18+
begin
19+
insert ignore into gh_ost_test values (1, 11, 23);
20+
insert ignore into gh_ost_test values (2, 13, 23);
21+
insert into gh_ost_test values (null, 17, 23);
22+
set @last_insert_id := last_insert_id();
23+
update gh_ost_test set c1=c1+@last_insert_id, c2=c2+@last_insert_id where id=@last_insert_id order by id desc limit 1;
24+
delete from gh_ost_test where id=1;
25+
delete from gh_ost_test where c1=13; -- id=2
26+
end ;;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--alter="modify C2 int not null default 0"

0 commit comments

Comments
 (0)