mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-08 07:29:05 +00:00
PT-2282 - pt-duplicate-key-checker give a "Wide character in print" warning
- Added test case
This commit is contained in:
58
t/pt-duplicate-key-checker/pt-2282.t
Normal file
58
t/pt-duplicate-key-checker/pt-2282.t
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/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 PerconaTest;
|
||||
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 => 3;
|
||||
}
|
||||
|
||||
my $output;
|
||||
my $cnf = "/tmp/12345/my.sandbox.cnf";
|
||||
my $cmd = "$trunk/bin/pt-duplicate-key-checker -F $cnf -h 127.1 --charset=utf8mb4";
|
||||
|
||||
$sb->wipe_clean($dbh);
|
||||
$sb->create_dbs($dbh, ['test']);
|
||||
|
||||
# #############################################################################
|
||||
# PT-2282: pt-duplicate-key-checker give a "Wide character in print" warning
|
||||
# #############################################################################
|
||||
$sb->load_file('master', 't/pt-duplicate-key-checker/samples/pt-2282.sql');
|
||||
$output = `$cmd -d test -t season_pk_historties_60 `;
|
||||
unlike(
|
||||
$output,
|
||||
qr/Wide character in print at/,
|
||||
'No "Wide character in print at" error'
|
||||
);
|
||||
|
||||
like(
|
||||
$output,
|
||||
qr/赛程类型/,
|
||||
'UTF data printed correctly'
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
$sb->wipe_clean($dbh);
|
||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||
exit;
|
21
t/pt-duplicate-key-checker/samples/pt-2282.sql
Normal file
21
t/pt-duplicate-key-checker/samples/pt-2282.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
DROP DATABASE IF EXISTS test;
|
||||
CREATE DATABASE test;
|
||||
USE test;
|
||||
|
||||
CREATE TABLE `season_pk_historties_60` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`season_tagid` varchar(200) NOT NULL,
|
||||
`subject_id` bigint(20) DEFAULT NULL,
|
||||
`account_id` bigint(20) unsigned NOT NULL,
|
||||
`pk_result` text NOT NULL,
|
||||
`created_at` datetime DEFAULT NULL,
|
||||
`schedule_tag_id` varchar(200) DEFAULT '',
|
||||
`schedule_type` int(11) NOT NULL DEFAULT '0' COMMENT '赛程类型',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_account` (`account_id`),
|
||||
KEY `idx_created_at` (`created_at`),
|
||||
KEY `idx_season` (`season_tagid`),
|
||||
KEY `idx_season_subject_account` (`season_tagid`,`subject_id`,`account_id`),
|
||||
KEY `idx_schedule_subject_account` (`schedule_tag_id`,`subject_id`,`account_id`),
|
||||
KEY `idx_account_subject_schedule_type` (`account_id`,`subject_id`,`schedule_type`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
Reference in New Issue
Block a user