Fix bug that caused not all "right keys" to be compared in certain cases.

This commit is contained in:
Daniel Nichter
2012-05-14 19:05:32 -06:00
parent 7fc8a3e989
commit e932c89d9e
6 changed files with 94 additions and 4 deletions

View File

@@ -9,7 +9,7 @@ BEGIN {
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More tests => 37;
use Test::More tests => 38;
use DuplicateKeyFinder;
use Quoter;
@@ -729,6 +729,48 @@ is_deeply(
'Issue 1192'
);
# #############################################################################
# https://bugs.launchpad.net/percona-toolkit/+bug/894140
# #############################################################################
$ddl = load_file('t/lib/samples/dupekeys/dupe-cluster-bug-894140.sql');
$dupes = [];
($keys, $ck) = $tp->get_keys($ddl, $opt);
$dk->get_duplicate_keys(
$keys,
clustered_key => $ck,
clustered => 1,
callback => $callback,
tbl_info => { engine => 'InnoDB', ddl => $ddl },
);
is_deeply(
$dupes,
[
{
cols => [ 'row_id' ],
ddl => 'UNIQUE KEY `row_id` (`row_id`),',
dupe_type => 'exact',
duplicate_of => 'PRIMARY',
duplicate_of_cols => [ 'row_id' ],
duplicate_of_ddl => 'PRIMARY KEY (`row_id`),',
key => 'row_id',
reason => 'row_id is a duplicate of PRIMARY',
},
{
cols => [ 'player_id' ],
ddl => 'KEY `player_id_2` (`player_id`)',
dupe_type => 'exact',
duplicate_of => 'player_id',
duplicate_of_cols => [ 'player_id' ],
duplicate_of_ddl => 'UNIQUE KEY `player_id` (`player_id`),',
key => 'player_id_2',
reason => 'player_id_2 is a duplicate of player_id',
},
],
'Finds duplicates OK on uppercase columns',
);
# #############################################################################
# Done.
# #############################################################################

View File

@@ -0,0 +1,8 @@
CREATE TABLE `bug_894140` (
`row_id` bigint(20) NOT NULL AUTO_INCREMENT,
`player_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`row_id`),
UNIQUE KEY `row_id` (`row_id`),
UNIQUE KEY `player_id` (`player_id`),
KEY `player_id_2` (`player_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8