From 5119ea4d31ab5f380d8783f91a5fb2d046a8e622 Mon Sep 17 00:00:00 2001 From: Shlomi Noach Date: Tue, 29 Nov 2016 11:08:35 +0100 Subject: [PATCH] added tests to verify no false positives rename-column found --- go/logic/migrator.go | 2 +- localtests/rename-none-column/create.sql | 8 ++++++++ localtests/rename-none-column/extra_args | 1 + localtests/rename-none-comment/create.sql | 8 ++++++++ localtests/rename-none-comment/extra_args | 1 + 5 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 localtests/rename-none-column/create.sql create mode 100644 localtests/rename-none-column/extra_args create mode 100644 localtests/rename-none-comment/create.sql create mode 100644 localtests/rename-none-comment/extra_args diff --git a/go/logic/migrator.go b/go/logic/migrator.go index cf59972..8f61425 100644 --- a/go/logic/migrator.go +++ b/go/logic/migrator.go @@ -229,7 +229,7 @@ func (this *Migrator) validateStatement() (err error) { if this.parser.HasNonTrivialRenames() && !this.migrationContext.SkipRenamedColumns { this.migrationContext.ColumnRenameMap = this.parser.GetNonTrivialRenames() if !this.migrationContext.ApproveRenamedColumns { - return fmt.Errorf("gh-ost believes the ALTER statement renames columns, as follows: %v; as precation, you are asked to confirm gh-ost is correct, and provide with `--approve-renamed-columns`, and we're all happy. Or you can skip renamed columns via `--skip-renamed-columns`, in which case column data may be lost", this.parser.GetNonTrivialRenames()) + return fmt.Errorf("gh-ost believes the ALTER statement renames columns, as follows: %v; as precaution, you are asked to confirm gh-ost is correct, and provide with `--approve-renamed-columns`, and we're all happy. Or you can skip renamed columns via `--skip-renamed-columns`, in which case column data may be lost", this.parser.GetNonTrivialRenames()) } log.Infof("Alter statement has column(s) renamed. gh-ost finds the following renames: %v; --approve-renamed-columns is given and so migration proceeds.", this.parser.GetNonTrivialRenames()) } diff --git a/localtests/rename-none-column/create.sql b/localtests/rename-none-column/create.sql new file mode 100644 index 0000000..1db5081 --- /dev/null +++ b/localtests/rename-none-column/create.sql @@ -0,0 +1,8 @@ +drop table if exists gh_ost_test; +create table gh_ost_test ( + id int auto_increment, + c1 int not null, + primary key (id) +) auto_increment=1; + +drop event if exists gh_ost_test; diff --git a/localtests/rename-none-column/extra_args b/localtests/rename-none-column/extra_args new file mode 100644 index 0000000..889e91a --- /dev/null +++ b/localtests/rename-none-column/extra_args @@ -0,0 +1 @@ +--alter="add column exchange double comment 'exchange rate used for pay in your own currency'" diff --git a/localtests/rename-none-comment/create.sql b/localtests/rename-none-comment/create.sql new file mode 100644 index 0000000..1db5081 --- /dev/null +++ b/localtests/rename-none-comment/create.sql @@ -0,0 +1,8 @@ +drop table if exists gh_ost_test; +create table gh_ost_test ( + id int auto_increment, + c1 int not null, + primary key (id) +) auto_increment=1; + +drop event if exists gh_ost_test; diff --git a/localtests/rename-none-comment/extra_args b/localtests/rename-none-comment/extra_args new file mode 100644 index 0000000..627b220 --- /dev/null +++ b/localtests/rename-none-comment/extra_args @@ -0,0 +1 @@ +--alter="add column exchange_rate double comment 'change rate used for pay in your own currency'"