From 7247a3a9aced53f26340da6354147459a0858ed5 Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Thu, 1 Mar 2012 08:20:12 -0800 Subject: [PATCH] Test, ensure pt-table-checksum can handle col names with dots. --- t/pt-table-checksum/basics.t | 36 ++++++++++++++++++++++++++++- t/pt-table-checksum/samples/dot.out | 19 +++++++++++++++ t/pt-table-checksum/samples/dot.sql | 21 +++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 t/pt-table-checksum/samples/dot.out create mode 100644 t/pt-table-checksum/samples/dot.sql diff --git a/t/pt-table-checksum/basics.t b/t/pt-table-checksum/basics.t index bba96cad..95a09402 100644 --- a/t/pt-table-checksum/basics.t +++ b/t/pt-table-checksum/basics.t @@ -41,7 +41,7 @@ elsif ( !@{$master_dbh->selectall_arrayref('show databases like "sakila"')} ) { plan skip_all => 'sakila database is not loaded'; } else { - plan tests => 32; + plan tests => 35; } # The sandbox servers run with lock_wait_timeout=3 and it's not dynamic @@ -420,6 +420,40 @@ is( "Bug 932442: 0 errors" ); +# ############################################################################# +# Bug 821675: can't parse column names containing periods +# ############################################################################# +$sb->load_file('master', "t/pt-table-checksum/samples/dot.sql"); +PerconaTest::wait_for_table($master_dbh, "test.t", "`No.`='ten'"); + +ok( + no_diff( + sub { pt_table_checksum::main(@args, + qw(-t test.t --chunk-size 3 --explain --explain)) + }, + "t/pt-table-checksum/samples/dot.out", + ), + "Bug 821675 (dot): queries" +); + +$output = output( + sub { $exit_status = pt_table_checksum::main(@args, + qw(-t test.t --chunk-size 3 --explain --explain)) }, + stderr => 1, +); + +is( + $exit_status, + 0, + "Bug 821675 (dot): 0 exit" +); + +is( + PerconaTest::count_checksum_results($output, 'errors'), + 0, + "Bug 821675 (dot): 0 errors" +); + # ############################################################################# # Done. # ############################################################################# diff --git a/t/pt-table-checksum/samples/dot.out b/t/pt-table-checksum/samples/dot.out new file mode 100644 index 00000000..003d2880 --- /dev/null +++ b/t/pt-table-checksum/samples/dot.out @@ -0,0 +1,19 @@ +-- +-- test.t +-- + +REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `no.`, `foo.bar`, CONCAT(ISNULL(`foo.bar`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `test`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`no.` >= ?)) AND ((`no.` <= ?)) /*checksum chunk*/ + +REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `test`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`no.` < ?)) ORDER BY `no.` /*past lower chunk*/ + +REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `test`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`no.` > ?)) ORDER BY `no.` /*past upper chunk*/ + +SELECT /*!40001 SQL_NO_CACHE */ `no.` FROM `test`.`t` FORCE INDEX(`PRIMARY`) WHERE ((`no.` >= ?)) ORDER BY `no.` LIMIT ?, 2 /*next chunk boundary*/ + +1 eight four +2 nine seven +3 six three +4 two two +5 eight +6 two + diff --git a/t/pt-table-checksum/samples/dot.sql b/t/pt-table-checksum/samples/dot.sql new file mode 100644 index 00000000..e49933ca --- /dev/null +++ b/t/pt-table-checksum/samples/dot.sql @@ -0,0 +1,21 @@ +drop database if exists test; +create database test; +use test; + +CREATE TABLE t ( + `No.` varchar(16) NOT NULL DEFAULT '', + `foo.bar` varchar(16), + PRIMARY KEY (`No.`) +) ENGINE=MyISAM; + +insert into t values + ('one', 'a'), + ('two', 'a'), + ('three', 'a'), + ('four', 'a'), + ('five', 'a'), + ('six', 'a'), + ('seven', 'a'), + ('eight', 'a'), + ('nine', 'a'), + ('ten', 'a');