From cc38a17e501002b6d819c8fbdc6995ad1d1b6994 Mon Sep 17 00:00:00 2001 From: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Date: Thu, 7 Jul 2022 00:22:21 +0300 Subject: [PATCH] compound pk tests (#387) * compound pk tests * more details in failure diff * more elaborate test; the pk-ts one consistently fails * Fix merge conflict Co-authored-by: Shlomi Noach Co-authored-by: Tim Vaillancourt Co-authored-by: Tim Vaillancourt --- localtests/compound-pk-ts/create.sql | 40 ++++++++++++++++++++++++++++ localtests/compound-pk/create.sql | 40 ++++++++++++++++++++++++++++ localtests/test.sh | 2 ++ 3 files changed, 82 insertions(+) create mode 100644 localtests/compound-pk-ts/create.sql create mode 100644 localtests/compound-pk/create.sql diff --git a/localtests/compound-pk-ts/create.sql b/localtests/compound-pk-ts/create.sql new file mode 100644 index 0000000..1bab87a --- /dev/null +++ b/localtests/compound-pk-ts/create.sql @@ -0,0 +1,40 @@ +drop table if exists gh_ost_test; +create table gh_ost_test ( + id int auto_increment, + i int not null, + ts0 timestamp(6) default current_timestamp(6), + updated tinyint unsigned default 0, + primary key(id, ts0) +) 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, sysdate(6), 0); + update gh_ost_test set updated = 1 where i = 11 order by id desc limit 1; + + insert into gh_ost_test values (null, 13, sysdate(6), 0); + update gh_ost_test set updated = 1 where i = 13 order by id desc limit 1; + + insert into gh_ost_test values (null, 17, sysdate(6), 0); + update gh_ost_test set updated = 1 where i = 17 order by id desc limit 1; + + insert into gh_ost_test values (null, 19, sysdate(6), 0); + update gh_ost_test set updated = 1 where i = 19 order by id desc limit 1; + + insert into gh_ost_test values (null, 23, sysdate(6), 0); + update gh_ost_test set updated = 1 where i = 23 order by id desc limit 1; + + insert into gh_ost_test values (null, 29, sysdate(6), 0); + insert into gh_ost_test values (null, 31, sysdate(6), 0); + insert into gh_ost_test values (null, 37, sysdate(6), 0); + insert into gh_ost_test values (null, 41, sysdate(6), 0); + delete from gh_ost_test where i = 31 order by id desc limit 1; +end ;; diff --git a/localtests/compound-pk/create.sql b/localtests/compound-pk/create.sql new file mode 100644 index 0000000..cf838d0 --- /dev/null +++ b/localtests/compound-pk/create.sql @@ -0,0 +1,40 @@ +drop table if exists gh_ost_test; +create table gh_ost_test ( + id int auto_increment, + i int not null, + v varchar(128), + updated tinyint unsigned default 0, + primary key(id, v) +) 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, 'eleven', 0); + update gh_ost_test set updated = 1 where i = 11 order by id desc limit 1; + + insert into gh_ost_test values (null, 13, 'thirteen', 0); + update gh_ost_test set updated = 1 where i = 13 order by id desc limit 1; + + insert into gh_ost_test values (null, 17, 'seventeen', 0); + update gh_ost_test set updated = 1 where i = 17 order by id desc limit 1; + + insert into gh_ost_test values (null, 19, 'nineteen', 0); + update gh_ost_test set updated = 1 where i = 19 order by id desc limit 1; + + insert into gh_ost_test values (null, 23, 'twenty three', 0); + update gh_ost_test set updated = 1 where i = 23 order by id desc limit 1; + + insert into gh_ost_test values (null, 29, 'twenty nine', 0); + insert into gh_ost_test values (null, 31, 'thirty one', 0); + insert into gh_ost_test values (null, 37, 'thirty seven', 0); + insert into gh_ost_test values (null, 41, 'forty one', 0); + delete from gh_ost_test where i = 31 order by id desc limit 1; +end ;; diff --git a/localtests/test.sh b/localtests/test.sh index d8c7a28..f66c813 100755 --- a/localtests/test.sh +++ b/localtests/test.sh @@ -224,6 +224,8 @@ test_single() { ghost_checksum=$(cat $ghost_content_output_file | md5sum) if [ "$orig_checksum" != "$ghost_checksum" ] ; then + gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "select ${orig_columns} from gh_ost_test" -ss > $orig_content_output_file + gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "select ${ghost_columns} from _gh_ost_test_gho" -ss > $ghost_content_output_file echo "ERROR $test_name: checksum mismatch" echo "---" diff $orig_content_output_file $ghost_content_output_file