Skip to content

Commit 322d897

Browse files
author
Shlomi Noach
authored
Merge pull request #333 from github/no-unique-key
fix: bailing out on no PRIMARY/UNIQUE KEY
2 parents 28557a6 + 3fd85ee commit 322d897

5 files changed

Lines changed: 12 additions & 3 deletions

File tree

go/logic/inspect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (this *Inspector) InspectTableColumnsAndUniqueKeys(tableName string) (colum
9595

9696
func (this *Inspector) InspectOriginalTable() (err error) {
9797
this.migrationContext.OriginalTableColumns, this.migrationContext.OriginalTableUniqueKeys, err = this.InspectTableColumnsAndUniqueKeys(this.migrationContext.OriginalTableName)
98-
if err == nil {
98+
if err != nil {
9999
return err
100100
}
101101
return nil

go/sql/parser_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,11 @@ func TestTokenizeAlterStatement(t *testing.T) {
9898
{
9999
alterStatement := "add column t int, add column e enum('a','b','c')"
100100
tokens, _ := parser.tokenizeAlterStatement(alterStatement)
101-
log.Errorf("%#v", tokens)
102101
test.S(t).ExpectTrue(reflect.DeepEqual(tokens, []string{"add column t int", "add column e enum('a','b','c')"}))
103102
}
104103
{
105104
alterStatement := "add column t int(11), add column e enum('a','b','c')"
106105
tokens, _ := parser.tokenizeAlterStatement(alterStatement)
107-
log.Errorf("%#v", tokens)
108106
test.S(t).ExpectTrue(reflect.DeepEqual(tokens, []string{"add column t int(11)", "add column e enum('a','b','c')"}))
109107
}
110108
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
drop table if exists gh_ost_test;
2+
create table gh_ost_test (
3+
i int not null,
4+
ts timestamp default current_timestamp,
5+
dt datetime,
6+
key i_idx(i)
7+
) auto_increment=1;
8+
9+
drop event if exists gh_ost_test;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
No PRIMARY nor UNIQUE key found in table
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--alter="add column v varchar(32)"

0 commit comments

Comments
 (0)