mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-18 08:24:06 +00:00
Add forked Maatkit tools in bin/ and their tests in t/.
This commit is contained in:
102
t/pt-duplicate-key-checker/basics.t
Normal file
102
t/pt-duplicate-key-checker/basics.t
Normal file
@@ -0,0 +1,102 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
BEGIN {
|
||||
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
|
||||
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
|
||||
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
|
||||
};
|
||||
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More;
|
||||
|
||||
use MaatkitTest;
|
||||
use Sandbox;
|
||||
require "$trunk/bin/pt-duplicate-key-checker";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||
my $dbh = $sb->get_dbh_for('master');
|
||||
|
||||
if ( !$dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox master';
|
||||
}
|
||||
else {
|
||||
plan tests => 8;
|
||||
}
|
||||
|
||||
my $output;
|
||||
my $sample = "t/pt-duplicate-key-checker/samples/";
|
||||
my $cnf = "/tmp/12345/my.sandbox.cnf";
|
||||
my $cmd = "$trunk/bin/pt-duplicate-key-checker -F $cnf -h 127.1";
|
||||
my @args = ('-F', $cnf, qw(-h 127.1));
|
||||
|
||||
$sb->wipe_clean($dbh);
|
||||
$sb->create_dbs($dbh, ['test']);
|
||||
|
||||
$output = `$cmd -d mysql -t columns_priv -v`;
|
||||
like($output,
|
||||
qr/PRIMARY \(`Host`,`Db`,`User`,`Table_name`,`Column_name`\)/,
|
||||
'Finds mysql.columns_priv PK'
|
||||
);
|
||||
|
||||
is(`$cmd -d test --nosummary`, '', 'No dupes on clean sandbox');
|
||||
|
||||
$sb->load_file('master', 't/lib/samples/dupe_key.sql', 'test');
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { mk_duplicate_key_checker::main(@args, qw(-d test)) },
|
||||
"$sample/basic_output.txt"),
|
||||
'Default output'
|
||||
);
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { mk_duplicate_key_checker::main(@args, qw(-d test --nosql)) },
|
||||
"$sample/nosql_output.txt"),
|
||||
'--nosql'
|
||||
);
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { mk_duplicate_key_checker::main(@args, qw(-d test --nosummary)) },
|
||||
"$sample/nosummary_output.txt"),
|
||||
'--nosummary'
|
||||
);
|
||||
|
||||
$sb->load_file('master', 't/lib/samples/uppercase_names.sql', 'test');
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { mk_duplicate_key_checker::main(@args, qw(-d test -t UPPER_TEST)) },
|
||||
($sandbox_version ge '5.1' ? "$sample/uppercase_names-51.txt"
|
||||
: "$sample/uppercase_names.txt")
|
||||
),
|
||||
'Issue 306 crash on uppercase column names'
|
||||
);
|
||||
|
||||
$sb->load_file('master', 't/lib/samples/issue_269-1.sql', 'test');
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { mk_duplicate_key_checker::main(@args, qw(-d test -t a)) },
|
||||
"$sample/issue_269.txt"),
|
||||
'No dupes for issue 269'
|
||||
);
|
||||
|
||||
$sb->wipe_clean($dbh);
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { mk_duplicate_key_checker::main(@args, qw(-d test)) },
|
||||
"$sample/nonexistent_db.txt"),
|
||||
'No results for nonexistent db'
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
$sb->wipe_clean($dbh);
|
||||
exit;
|
53
t/pt-duplicate-key-checker/clustered_keys.t
Normal file
53
t/pt-duplicate-key-checker/clustered_keys.t
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
BEGIN {
|
||||
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
|
||||
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
|
||||
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
|
||||
};
|
||||
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More;
|
||||
|
||||
use MaatkitTest;
|
||||
use Sandbox;
|
||||
require "$trunk/bin/pt-duplicate-key-checker";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||
my $dbh = $sb->get_dbh_for('master');
|
||||
|
||||
if ( !$dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox master';
|
||||
}
|
||||
else {
|
||||
plan tests => 1;
|
||||
}
|
||||
|
||||
my $cnf = "/tmp/12345/my.sandbox.cnf";
|
||||
my $sample = "t/pt-duplicate-key-checker/samples/";
|
||||
my @args = ('-F', $cnf, qw(-h 127.1));
|
||||
|
||||
$sb->wipe_clean($dbh);
|
||||
$sb->create_dbs($dbh, ['test']);
|
||||
|
||||
# #############################################################################
|
||||
# Issue 295: Enhance rules for clustered keys in mk-duplicate-key-checker
|
||||
# #############################################################################
|
||||
$sb->load_file('master', 't/pt-duplicate-key-checker/samples/issue_295.sql', 'test');
|
||||
ok(
|
||||
no_diff(
|
||||
sub { mk_duplicate_key_checker::main(@args, qw(-d issue_295)) },
|
||||
($sandbox_version ge '5.1' ? "$sample/issue_295-51.txt"
|
||||
: "$sample/issue_295.txt")
|
||||
),
|
||||
"Shorten, not remove, clustered dupes"
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
$sb->wipe_clean($dbh);
|
||||
exit;
|
54
t/pt-duplicate-key-checker/issue_1192.t
Normal file
54
t/pt-duplicate-key-checker/issue_1192.t
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
BEGIN {
|
||||
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
|
||||
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
|
||||
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
|
||||
};
|
||||
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More;
|
||||
|
||||
use MaatkitTest;
|
||||
use Sandbox;
|
||||
require "$trunk/bin/pt-duplicate-key-checker";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||
my $dbh = $sb->get_dbh_for('master');
|
||||
|
||||
if ( !$dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox master';
|
||||
}
|
||||
else {
|
||||
plan tests => 1;
|
||||
}
|
||||
|
||||
my $output;
|
||||
my $cnf = "/tmp/12345/my.sandbox.cnf";
|
||||
my $cmd = "$trunk/bin/pt-duplicate-key-checker -F $cnf -h 127.1";
|
||||
|
||||
$sb->wipe_clean($dbh);
|
||||
$sb->create_dbs($dbh, ['issue_1192']);
|
||||
|
||||
# #############################################################################
|
||||
# Issue 1192: DROP/ADD leaves structure unchanged
|
||||
# #############################################################################
|
||||
$sb->load_file('master', "t/lib/samples/dupekeys/issue-1192.sql", "issue_1192");
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
"$cmd -d issue_1192 --no-summary",
|
||||
"t/pt-duplicate-key-checker/samples/issue_1192.txt",
|
||||
sed => ["-i -e 's/ (/ (/g'"],
|
||||
),
|
||||
"Keys are sorted lc so left-prefix magic works (issue 1192)"
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
$sb->wipe_clean($dbh);
|
||||
exit;
|
45
t/pt-duplicate-key-checker/issue_298.t
Normal file
45
t/pt-duplicate-key-checker/issue_298.t
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
BEGIN {
|
||||
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
|
||||
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
|
||||
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
|
||||
};
|
||||
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More;
|
||||
|
||||
use MaatkitTest;
|
||||
use Sandbox;
|
||||
require "$trunk/bin/pt-duplicate-key-checker";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||
my $dbh = $sb->get_dbh_for('master');
|
||||
|
||||
if ( !$dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox master';
|
||||
}
|
||||
else {
|
||||
plan tests => 1;
|
||||
}
|
||||
|
||||
my $output;
|
||||
my $cnf = "/tmp/12345/my.sandbox.cnf";
|
||||
my $cmd = "$trunk/bin/pt-duplicate-key-checker -F $cnf -h 127.1";
|
||||
|
||||
$sb->wipe_clean($dbh);
|
||||
|
||||
# #############################################################################
|
||||
# Issue 298: mk-duplicate-key-checker crashes
|
||||
# #############################################################################
|
||||
$output = `$cmd -d mysql -t columns_priv 2>&1`;
|
||||
unlike($output, qr/Use of uninitialized var/, 'Does not crash on undef var');
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
$sb->wipe_clean($dbh);
|
||||
exit;
|
53
t/pt-duplicate-key-checker/issue_331.t
Normal file
53
t/pt-duplicate-key-checker/issue_331.t
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
BEGIN {
|
||||
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
|
||||
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
|
||||
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
|
||||
};
|
||||
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More;
|
||||
|
||||
use MaatkitTest;
|
||||
use Sandbox;
|
||||
require "$trunk/bin/pt-duplicate-key-checker";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||
my $dbh = $sb->get_dbh_for('master');
|
||||
|
||||
if ( !$dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox master';
|
||||
}
|
||||
else {
|
||||
plan tests => 1;
|
||||
}
|
||||
|
||||
my $cnf = "/tmp/12345/my.sandbox.cnf";
|
||||
my $sample = "t/pt-duplicate-key-checker/samples/";
|
||||
my @args = ('-F', $cnf, qw(-h 127.1));
|
||||
|
||||
$sb->wipe_clean($dbh);
|
||||
$sb->create_dbs($dbh, ['test']);
|
||||
|
||||
# #############################################################################
|
||||
# Issue 331: mk-duplicate-key-checker crashes getting size of foreign keys
|
||||
# #############################################################################
|
||||
|
||||
$sb->load_file('master', 't/pt-duplicate-key-checker/samples/issue_331.sql', 'test');
|
||||
ok(
|
||||
no_diff(
|
||||
sub { mk_duplicate_key_checker::main(@args, qw(-d issue_331)) },
|
||||
't/pt-duplicate-key-checker/samples/issue_331.txt',
|
||||
),
|
||||
'Issue 331 crash on fks'
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
$sb->wipe_clean($dbh);
|
||||
exit;
|
51
t/pt-duplicate-key-checker/issue_663.t
Normal file
51
t/pt-duplicate-key-checker/issue_663.t
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
BEGIN {
|
||||
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
|
||||
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
|
||||
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
|
||||
};
|
||||
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More;
|
||||
|
||||
use MaatkitTest;
|
||||
use Sandbox;
|
||||
require "$trunk/bin/pt-duplicate-key-checker";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||
my $dbh = $sb->get_dbh_for('master');
|
||||
|
||||
if ( !$dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox master';
|
||||
}
|
||||
else {
|
||||
plan tests => 1;
|
||||
}
|
||||
|
||||
my $output;
|
||||
my $cnf = "/tmp/12345/my.sandbox.cnf";
|
||||
my $cmd = "$trunk/bin/pt-duplicate-key-checker -F $cnf -h 127.1";
|
||||
|
||||
$sb->wipe_clean($dbh);
|
||||
$sb->create_dbs($dbh, ['test']);
|
||||
|
||||
# #############################################################################
|
||||
# Issue 663: Index length prefix gives uninitialized value
|
||||
# #############################################################################
|
||||
$sb->load_file('master', 't/pt-duplicate-key-checker/samples/issue_663.sql');
|
||||
$output = `$cmd -d issue_663`;
|
||||
like(
|
||||
$output,
|
||||
qr/`xmlerror` text/,
|
||||
'Prints dupe key with prefixed column (issue 663)'
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
$sb->wipe_clean($dbh);
|
||||
exit;
|
21
t/pt-duplicate-key-checker/samples/basic_output.txt
Normal file
21
t/pt-duplicate-key-checker/samples/basic_output.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
# ########################################################################
|
||||
# test.dupe_key
|
||||
# ########################################################################
|
||||
|
||||
# a is a left-prefix of a_2
|
||||
# Key definitions:
|
||||
# KEY `a` (`a`),
|
||||
# KEY `a_2` (`a`,`b`)
|
||||
# Column types:
|
||||
# `a` int(11) default null
|
||||
# `b` int(11) default null
|
||||
# To remove this duplicate index, execute:
|
||||
ALTER TABLE `test`.`dupe_key` DROP INDEX `a`;
|
||||
|
||||
# ########################################################################
|
||||
# Summary of indexes
|
||||
# ########################################################################
|
||||
|
||||
# Size Duplicate Indexes 0
|
||||
# Total Duplicate Indexes 1
|
||||
# Total Indexes 2
|
13
t/pt-duplicate-key-checker/samples/issue_1192.txt
Normal file
13
t/pt-duplicate-key-checker/samples/issue_1192.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
# ########################################################################
|
||||
# issue_1192.issue_1192
|
||||
# ########################################################################
|
||||
|
||||
# a is a duplicate of PRIMARY
|
||||
# Key definitions:
|
||||
# KEY `a` (`a`),
|
||||
# PRIMARY KEY (`a`),
|
||||
# Column types:
|
||||
# `a` int(11) not null default '0'
|
||||
# To remove this duplicate index, execute:
|
||||
ALTER TABLE `issue_1192`.`issue_1192` DROP INDEX `a`;
|
||||
|
5
t/pt-duplicate-key-checker/samples/issue_269.txt
Normal file
5
t/pt-duplicate-key-checker/samples/issue_269.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
# ########################################################################
|
||||
# Summary of indexes
|
||||
# ########################################################################
|
||||
|
||||
# Total Indexes 2
|
21
t/pt-duplicate-key-checker/samples/issue_295-51.txt
Normal file
21
t/pt-duplicate-key-checker/samples/issue_295-51.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
# ########################################################################
|
||||
# issue_295.t
|
||||
# ########################################################################
|
||||
|
||||
# Key b_a ends with a prefix of the clustered index
|
||||
# Key definitions:
|
||||
# KEY `b_a` (`b`,`a`)
|
||||
# PRIMARY KEY (`a`),
|
||||
# Column types:
|
||||
# `b` int(11) not null
|
||||
# `a` int(11) not null
|
||||
# To shorten this duplicate clustered index, execute:
|
||||
ALTER TABLE `issue_295`.`t` DROP INDEX `b_a`, ADD INDEX `b_a` (`b`);
|
||||
|
||||
# ########################################################################
|
||||
# Summary of indexes
|
||||
# ########################################################################
|
||||
|
||||
# Size Duplicate Indexes 8
|
||||
# Total Duplicate Indexes 1
|
||||
# Total Indexes 2
|
11
t/pt-duplicate-key-checker/samples/issue_295.sql
Normal file
11
t/pt-duplicate-key-checker/samples/issue_295.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
DROP DATABASE IF EXISTS issue_295;
|
||||
CREATE DATABASE issue_295;
|
||||
USE issue_295;
|
||||
|
||||
DROP TABLE IF EXISTS `t`;
|
||||
CREATE TABLE `t` (
|
||||
a INT NOT NULL,
|
||||
b INT NOT NULL,
|
||||
PRIMARY KEY (a),
|
||||
INDEX b_a (b, a)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
21
t/pt-duplicate-key-checker/samples/issue_295.txt
Normal file
21
t/pt-duplicate-key-checker/samples/issue_295.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
# ########################################################################
|
||||
# issue_295.t
|
||||
# ########################################################################
|
||||
|
||||
# Key b_a ends with a prefix of the clustered index
|
||||
# Key definitions:
|
||||
# KEY `b_a` (`b`,`a`)
|
||||
# PRIMARY KEY (`a`),
|
||||
# Column types:
|
||||
# `b` int(11) not null
|
||||
# `a` int(11) not null
|
||||
# To shorten this duplicate clustered index, execute:
|
||||
ALTER TABLE `issue_295`.`t` DROP INDEX `b_a`, ADD INDEX `b_a` (`b`);
|
||||
|
||||
# ########################################################################
|
||||
# Summary of indexes
|
||||
# ########################################################################
|
||||
|
||||
# Size Duplicate Indexes 8
|
||||
# Total Duplicate Indexes 1
|
||||
# Total Indexes 2
|
19
t/pt-duplicate-key-checker/samples/issue_331.sql
Normal file
19
t/pt-duplicate-key-checker/samples/issue_331.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
DROP DATABASE IF EXISTS issue_331;
|
||||
CREATE DATABASE issue_331;
|
||||
USE issue_331;
|
||||
|
||||
DROP TABLE IF EXISTS `issue_331_t1`;
|
||||
CREATE TABLE `issue_331_t1` (
|
||||
`t1_id` bigint(20) NOT NULL default '0',
|
||||
`bar` bigint(20) NOT NULL default '0',
|
||||
PRIMARY KEY (`t1_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
DROP TABLE IF EXISTS `issue_331_t2`;
|
||||
CREATE TABLE `issue_331_t2` (
|
||||
`id` bigint(20) NOT NULL default '0',
|
||||
`foo` bigint(20) NOT NULL default '0',
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_1` FOREIGN KEY (`id`) REFERENCES `issue_331_t1` (`t1_id`),
|
||||
CONSTRAINT `fk_2` FOREIGN KEY (`id`) REFERENCES `issue_331_t1` (`t1_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
21
t/pt-duplicate-key-checker/samples/issue_331.txt
Normal file
21
t/pt-duplicate-key-checker/samples/issue_331.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
# ########################################################################
|
||||
# issue_331.issue_331_t2
|
||||
# ########################################################################
|
||||
|
||||
# FOREIGN KEY fk_1 (`id`) REFERENCES `issue_331`.`issue_331_t1` (`t1_id`) is a duplicate of FOREIGN KEY fk_2 (`id`) REFERENCES `issue_331`.`issue_331_t1` (`t1_id`)
|
||||
# Key definitions:
|
||||
# CONSTRAINT `fk_1` FOREIGN KEY (`id`) REFERENCES `issue_331_t1` (`t1_id`)
|
||||
# CONSTRAINT `fk_2` FOREIGN KEY (`id`) REFERENCES `issue_331_t1` (`t1_id`)
|
||||
# Column types:
|
||||
# `id` bigint(20) not null default '0'
|
||||
# To remove this duplicate foreign key, execute:
|
||||
ALTER TABLE `issue_331`.`issue_331_t2` DROP FOREIGN KEY `fk_1`;
|
||||
|
||||
# MySQL uses the PRIMARY index for this foreign key constraint
|
||||
|
||||
# ########################################################################
|
||||
# Summary of indexes
|
||||
# ########################################################################
|
||||
|
||||
# Total Duplicate Indexes 1
|
||||
# Total Indexes 4
|
12
t/pt-duplicate-key-checker/samples/issue_663.sql
Normal file
12
t/pt-duplicate-key-checker/samples/issue_663.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
DROP DATABASE IF EXISTS issue_663;
|
||||
CREATE DATABASE issue_663;
|
||||
USE issue_663;
|
||||
CREATE TABLE `t` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`trx_id` int(10) unsigned default NULL,
|
||||
`dTime` datetime NOT NULL,
|
||||
`xmlerror` text,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx1` (`trx_id`),
|
||||
KEY `idx2` (`trx_id`, `xmlerror`(128), `dTime`)
|
||||
) ENGINE=MyISAM;
|
5
t/pt-duplicate-key-checker/samples/nonexistent_db.txt
Normal file
5
t/pt-duplicate-key-checker/samples/nonexistent_db.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
# ########################################################################
|
||||
# Summary of indexes
|
||||
# ########################################################################
|
||||
|
||||
# Total Indexes 0
|
19
t/pt-duplicate-key-checker/samples/nosql_output.txt
Normal file
19
t/pt-duplicate-key-checker/samples/nosql_output.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
# ########################################################################
|
||||
# test.dupe_key
|
||||
# ########################################################################
|
||||
|
||||
# a is a left-prefix of a_2
|
||||
# Key definitions:
|
||||
# KEY `a` (`a`),
|
||||
# KEY `a_2` (`a`,`b`)
|
||||
# Column types:
|
||||
# `a` int(11) default null
|
||||
# `b` int(11) default null
|
||||
|
||||
# ########################################################################
|
||||
# Summary of indexes
|
||||
# ########################################################################
|
||||
|
||||
# Size Duplicate Indexes 0
|
||||
# Total Duplicate Indexes 1
|
||||
# Total Indexes 2
|
14
t/pt-duplicate-key-checker/samples/nosummary_output.txt
Normal file
14
t/pt-duplicate-key-checker/samples/nosummary_output.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
# ########################################################################
|
||||
# test.dupe_key
|
||||
# ########################################################################
|
||||
|
||||
# a is a left-prefix of a_2
|
||||
# Key definitions:
|
||||
# KEY `a` (`a`),
|
||||
# KEY `a_2` (`a`,`b`)
|
||||
# Column types:
|
||||
# `a` int(11) default null
|
||||
# `b` int(11) default null
|
||||
# To remove this duplicate index, execute:
|
||||
ALTER TABLE `test`.`dupe_key` DROP INDEX `a`;
|
||||
|
20
t/pt-duplicate-key-checker/samples/uppercase_names-51.txt
Normal file
20
t/pt-duplicate-key-checker/samples/uppercase_names-51.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
# ########################################################################
|
||||
# test.UPPER_TEST
|
||||
# ########################################################################
|
||||
|
||||
# A is a duplicate of PRIMARY
|
||||
# Key definitions:
|
||||
# KEY `A` (`A`)
|
||||
# PRIMARY KEY (`A`),
|
||||
# Column types:
|
||||
# `a` int(11) not null default '0'
|
||||
# To remove this duplicate index, execute:
|
||||
ALTER TABLE `test`.`UPPER_TEST` DROP INDEX `A`;
|
||||
|
||||
# ########################################################################
|
||||
# Summary of indexes
|
||||
# ########################################################################
|
||||
|
||||
# Size Duplicate Indexes 0
|
||||
# Total Duplicate Indexes 1
|
||||
# Total Indexes 2
|
20
t/pt-duplicate-key-checker/samples/uppercase_names.txt
Normal file
20
t/pt-duplicate-key-checker/samples/uppercase_names.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
# ########################################################################
|
||||
# test.UPPER_TEST
|
||||
# ########################################################################
|
||||
|
||||
# A is a duplicate of PRIMARY
|
||||
# Key definitions:
|
||||
# KEY `A` (`A`)
|
||||
# PRIMARY KEY (`A`),
|
||||
# Column types:
|
||||
# `a` int(11) not null default '0'
|
||||
# To remove this duplicate index, execute:
|
||||
ALTER TABLE `test`.`UPPER_TEST` DROP INDEX `A`;
|
||||
|
||||
# ########################################################################
|
||||
# Summary of indexes
|
||||
# ########################################################################
|
||||
|
||||
# Size Duplicate Indexes 0
|
||||
# Total Duplicate Indexes 1
|
||||
# Total Indexes 2
|
37
t/pt-duplicate-key-checker/standard_options.t
Normal file
37
t/pt-duplicate-key-checker/standard_options.t
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
BEGIN {
|
||||
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
|
||||
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
|
||||
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
|
||||
};
|
||||
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More tests => 1;
|
||||
|
||||
use MaatkitTest;
|
||||
use Sandbox;
|
||||
require "$trunk/bin/pt-duplicate-key-checker";
|
||||
|
||||
my $output;
|
||||
my $cnf = "/tmp/12345/my.sandbox.cnf";
|
||||
my $cmd = "$trunk/bin/pt-duplicate-key-checker -F $cnf -h 127.1";
|
||||
|
||||
# #########################################################################
|
||||
# Issue 391: Add --pid option to all scripts
|
||||
# #########################################################################
|
||||
`touch /tmp/mk-script.pid`;
|
||||
$output = `$cmd -d issue_295 --pid /tmp/mk-script.pid 2>&1`;
|
||||
like(
|
||||
$output,
|
||||
qr{PID file /tmp/mk-script.pid already exists},
|
||||
'Dies if PID file already exists (issue 391)'
|
||||
);
|
||||
`rm -rf /tmp/mk-script.pid`;
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
exit;
|
Reference in New Issue
Block a user