4
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
5
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
6
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
10
use warnings FATAL => 'all';
11
use English qw(-no_match_vars);
16
require "$trunk/bin/pt-archiver";
18
my $dp = new DSNParser(opts=>$dsn_opts);
19
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
20
my $dbh = $sb->get_dbh_for('master');
23
plan skip_all => 'Cannot connect to sandbox master';
31
my $cnf = "/tmp/12345/my.sandbox.cnf";
33
# #############################################################################
34
# Issue 1152: mk-archiver columns option resulting in null archived table data
35
# #############################################################################
37
$sb->load_file('master', 't/pt-archiver/samples/issue_1225.sql');
38
$dbh->do('set names "utf8"');
39
my $original_rows = $dbh->selectall_arrayref('select * from issue_1225.t where i in (1, 2)');
42
[ [ 1, 'が'], # Your terminal must be UTF8 to see this Japanese character.
49
sub { mk_archiver::main(
50
'--source', 'h=127.1,P=12345,D=issue_1225,t=t,u=msandbox,p=msandbox',
52
qw(--where 1=1 --purge))
54
qr/Character set mismatch/,
59
sub { mk_archiver::main(
60
'--source', 'h=127.1,P=12345,D=issue_1225,t=t,u=msandbox,p=msandbox',
62
qw(--no-check-charset --where 1=1 --purge))
66
my $archived_rows = $dbh->selectall_arrayref('select * from issue_1225.a where i in (1, 2)');
69
$original_rows->[0]->[1] ne $archived_rows->[0]->[1],
70
"UTF8 characters lost when cxn isn't also UTF8"
73
$sb->load_file('master', 't/pt-archiver/samples/issue_1225.sql');
76
sub { mk_archiver::main(
77
'--source', 'h=127.1,P=12345,D=issue_1225,t=t,u=msandbox,p=msandbox',
79
qw(--where 1=1 --purge -A utf8)) # -A utf8 makes it work
83
$archived_rows = $dbh->selectall_arrayref('select * from issue_1225.a where i in (1, 2)');
88
"UTF8 characters preserved when cxn is also UTF8"
91
# #############################################################################
93
# #############################################################################
94
$sb->wipe_clean($dbh);