From 53ef6eae5a58035d9e983d1e58347e276da97d8d Mon Sep 17 00:00:00 2001 From: Shlomi Noach Date: Tue, 20 Sep 2016 16:00:07 +0200 Subject: [PATCH 1/3] added tests for column-reorder --- localtests/reorder-columns/create.sql | 26 ++++++++++++++++++++++++ localtests/reorder-columns/extra_args | 1 + localtests/reorder-columns/ghost_columns | 1 + localtests/reorder-columns/orig_columns | 1 + localtests/test.sh | 18 +++++++++------- 5 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 localtests/reorder-columns/create.sql create mode 100644 localtests/reorder-columns/extra_args create mode 100644 localtests/reorder-columns/ghost_columns create mode 100644 localtests/reorder-columns/orig_columns diff --git a/localtests/reorder-columns/create.sql b/localtests/reorder-columns/create.sql new file mode 100644 index 0000000..6d5894a --- /dev/null +++ b/localtests/reorder-columns/create.sql @@ -0,0 +1,26 @@ +drop table if exists gh_ost_test; +create table gh_ost_test ( + id int auto_increment, + c1 int not null, + c2 int not null, + 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 ignore into gh_ost_test values (1, 11, 23); + insert ignore into gh_ost_test values (2, 13, 29); + insert into gh_ost_test values (null, 17, 31); + set @last_insert_id := last_insert_id(); + 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; + delete from gh_ost_test where id=1; + delete from gh_ost_test where c1=13; +end ;; diff --git a/localtests/reorder-columns/extra_args b/localtests/reorder-columns/extra_args new file mode 100644 index 0000000..c3f52c2 --- /dev/null +++ b/localtests/reorder-columns/extra_args @@ -0,0 +1 @@ +--alter="change column c2 c2 int not null after id" diff --git a/localtests/reorder-columns/ghost_columns b/localtests/reorder-columns/ghost_columns new file mode 100644 index 0000000..e1b8708 --- /dev/null +++ b/localtests/reorder-columns/ghost_columns @@ -0,0 +1 @@ +id, c1, c2 diff --git a/localtests/reorder-columns/orig_columns b/localtests/reorder-columns/orig_columns new file mode 100644 index 0000000..e1b8708 --- /dev/null +++ b/localtests/reorder-columns/orig_columns @@ -0,0 +1 @@ +id, c1, c2 diff --git a/localtests/test.sh b/localtests/test.sh index 68588df..f12b66f 100755 --- a/localtests/test.sh +++ b/localtests/test.sh @@ -56,9 +56,13 @@ test_single() { if [ -f $tests_path/$test_name/extra_args ] ; then extra_args=$(cat $tests_path/$test_name/extra_args) fi - columns="*" - if [ -f $tests_path/$test_name/test_columns ] ; then - columns=$(cat $tests_path/$test_name/test_columns) + orig_columns="*" + ghost_columns="*" + if [ -f $tests_path/$test_name/orig_columns ] ; then + orig_columns=$(cat $tests_path/$test_name/orig_columns) + fi + if [ -f $tests_path/$test_name/ghost_columns ] ; then + ghost_columns=$(cat $tests_path/$test_name/ghost_columns) fi # graceful sleep for replica to catch up echo_dot @@ -98,15 +102,15 @@ test_single() { fi echo_dot - orig_checksum=$(gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "select ${columns} from gh_ost_test" -ss | md5sum) - ghost_checksum=$(gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "select ${columns} from _gh_ost_test_gho" -ss | md5sum) + orig_checksum=$(gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "select ${orig_columns} from gh_ost_test" -ss | md5sum) + ghost_checksum=$(gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "select ${ghost_columns} from _gh_ost_test_gho" -ss | md5sum) if [ "$orig_checksum" != "$ghost_checksum" ] ; then echo "ERROR $test_name: checksum mismatch" echo "---" - gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "select ${columns} from gh_ost_test" -ss + gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "select ${orig_columns} from gh_ost_test" -ss echo "---" - gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "select ${columns} from _gh_ost_test_gho" -ss + gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "select ${ghost_columns} from _gh_ost_test_gho" -ss return 1 fi } From 2bf882de1695e54e0914077e48fbf970ddf2eda9 Mon Sep 17 00:00:00 2001 From: Shlomi Noach Date: Wed, 21 Sep 2016 09:01:33 +0200 Subject: [PATCH 2/3] added rename & reorder test --- localtests/rename-reorder-columns/create.sql | 27 +++++++++++++++++++ localtests/rename-reorder-columns/extra_args | 1 + .../rename-reorder-columns/ghost_columns | 1 + .../rename-reorder-columns/orig_columns | 1 + 4 files changed, 30 insertions(+) create mode 100644 localtests/rename-reorder-columns/create.sql create mode 100644 localtests/rename-reorder-columns/extra_args create mode 100644 localtests/rename-reorder-columns/ghost_columns create mode 100644 localtests/rename-reorder-columns/orig_columns diff --git a/localtests/rename-reorder-columns/create.sql b/localtests/rename-reorder-columns/create.sql new file mode 100644 index 0000000..1986242 --- /dev/null +++ b/localtests/rename-reorder-columns/create.sql @@ -0,0 +1,27 @@ +drop table if exists gh_ost_test; +create table gh_ost_test ( + id int auto_increment, + c1 int not null, + c2 int not null, + c3 int not null, + 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 ignore into gh_ost_test values (1, 11, 23, 97); + insert ignore into gh_ost_test values (2, 13, 27, 61); + insert into gh_ost_test values (null, 17, 31, 53); + set @last_insert_id := last_insert_id(); + update gh_ost_test set c1=c1+@last_insert_id, c2=c2+@last_insert_id, c3=c3+@last_insert_id where id=@last_insert_id order by id desc limit 1; + delete from gh_ost_test where id=1; + delete from gh_ost_test where c1=13; -- id=2 +end ;; diff --git a/localtests/rename-reorder-columns/extra_args b/localtests/rename-reorder-columns/extra_args new file mode 100644 index 0000000..e37ce42 --- /dev/null +++ b/localtests/rename-reorder-columns/extra_args @@ -0,0 +1 @@ +--alter="change column c2 c2a int not null, change column c3 c3 int not null after id" --approve-renamed-columns diff --git a/localtests/rename-reorder-columns/ghost_columns b/localtests/rename-reorder-columns/ghost_columns new file mode 100644 index 0000000..a17380e --- /dev/null +++ b/localtests/rename-reorder-columns/ghost_columns @@ -0,0 +1 @@ +id, c1, c2a, c3 diff --git a/localtests/rename-reorder-columns/orig_columns b/localtests/rename-reorder-columns/orig_columns new file mode 100644 index 0000000..f1eeeb7 --- /dev/null +++ b/localtests/rename-reorder-columns/orig_columns @@ -0,0 +1 @@ +id, c1, c2, c3 From 63419b36364414aa165f73fe21761eb54895523a Mon Sep 17 00:00:00 2001 From: Shlomi Noach Date: Wed, 21 Sep 2016 09:45:36 +0200 Subject: [PATCH 3/3] added test for renaming and reordering same column --- localtests/rename-reorder-column/create.sql | 26 +++++++++++++++++++ localtests/rename-reorder-column/extra_args | 1 + .../rename-reorder-column/ghost_columns | 1 + localtests/rename-reorder-column/orig_columns | 1 + 4 files changed, 29 insertions(+) create mode 100644 localtests/rename-reorder-column/create.sql create mode 100644 localtests/rename-reorder-column/extra_args create mode 100644 localtests/rename-reorder-column/ghost_columns create mode 100644 localtests/rename-reorder-column/orig_columns diff --git a/localtests/rename-reorder-column/create.sql b/localtests/rename-reorder-column/create.sql new file mode 100644 index 0000000..d28a7c1 --- /dev/null +++ b/localtests/rename-reorder-column/create.sql @@ -0,0 +1,26 @@ +drop table if exists gh_ost_test; +create table gh_ost_test ( + id int auto_increment, + c1 int not null, + c2 int not null, + 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 ignore into gh_ost_test values (1, 11, 23); + insert ignore into gh_ost_test values (2, 13, 23); + insert into gh_ost_test values (null, 17, 23); + set @last_insert_id := last_insert_id(); + 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; + delete from gh_ost_test where id=1; + delete from gh_ost_test where c1=13; -- id=2 +end ;; diff --git a/localtests/rename-reorder-column/extra_args b/localtests/rename-reorder-column/extra_args new file mode 100644 index 0000000..740efa4 --- /dev/null +++ b/localtests/rename-reorder-column/extra_args @@ -0,0 +1 @@ +--alter="change column c2 c2a int not null after id" --approve-renamed-columns diff --git a/localtests/rename-reorder-column/ghost_columns b/localtests/rename-reorder-column/ghost_columns new file mode 100644 index 0000000..bf608b3 --- /dev/null +++ b/localtests/rename-reorder-column/ghost_columns @@ -0,0 +1 @@ +id, c1, c2a diff --git a/localtests/rename-reorder-column/orig_columns b/localtests/rename-reorder-column/orig_columns new file mode 100644 index 0000000..e1b8708 --- /dev/null +++ b/localtests/rename-reorder-column/orig_columns @@ -0,0 +1 @@ +id, c1, c2