mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 13:40:07 +00:00
pt-upgrade: Deal with LOCAL INFILE being disabled
This commit is contained in:
@@ -10990,6 +10990,32 @@ sub main {
|
||||
$host->{name} = $name || 'unknown host';
|
||||
}
|
||||
|
||||
# ########################################################################
|
||||
# If we're comparing rows, check that LOAD DATA LOCAL INFILE works for,
|
||||
# all hosts, or bail out early if it doesn't.
|
||||
# ########################################################################
|
||||
my $compare = $o->get('compare');
|
||||
if ( $compare->{results}
|
||||
&& lc($o->get('compare-results-method')) eq 'rows' )
|
||||
{
|
||||
foreach my $host ( @$hosts ) {
|
||||
local $@;
|
||||
my $sql = "LOAD DATA LOCAL INFILE '/dev/null' INTO TABLE "
|
||||
. "`test`.`pt_not_there`";
|
||||
eval { $host->{dbh}->do($sql); 1 } or do {
|
||||
my $e = $@;
|
||||
my $error_re = qr/\QDBD::mysql::db do failed: The used command is not allowed with this MySQL version [for Statement "LOAD DATA LOCAL INFILE/;
|
||||
if ($e =~ $error_re) {
|
||||
$_->{dbh}->disconnect() for @$hosts;
|
||||
die("Cannot compare rows as LOAD DATA LOCAL INFILE "
|
||||
. "is disabled for $host->{name}. See "
|
||||
. "http://kb.percona.com/troubleshoot-load-data-infile"
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
# ########################################################################
|
||||
# Make some common modules.
|
||||
# ########################################################################
|
||||
@@ -11023,7 +11049,6 @@ sub main {
|
||||
# ########################################################################
|
||||
# Make compare modules in order.
|
||||
# ########################################################################
|
||||
my $compare = $o->get('compare');
|
||||
my @compare_modules;
|
||||
if ( $compare->{results} ) {
|
||||
my $method = lc $o->get('compare-results-method');
|
||||
|
@@ -125,7 +125,7 @@ sub test_disabled_load_data {
|
||||
|
||||
like($output,
|
||||
qr!\Q--bulk-insert cannot work as LOAD DATA LOCAL INFILE is disabled. See http://kb.percona.com/troubleshoot-load-data-infile!,
|
||||
""
|
||||
"--bulk-insert throws an error if LOCAL INFILE is disabled"
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -33,6 +33,8 @@ else {
|
||||
plan tests => 13;
|
||||
}
|
||||
|
||||
my $load_data_is_disabled = PerconaTest::load_data_is_disabled($dbh1);
|
||||
|
||||
my @host_args = ('h=127.1,P=12345', 'P=12348');
|
||||
my @op_args = (qw(-u msandbox -p msandbox),
|
||||
'--compare', 'results,warnings',
|
||||
@@ -64,23 +66,27 @@ ok(
|
||||
'Report for multiple queries (checksum method)'
|
||||
);
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-one.log",
|
||||
"--compare-results-method", "rows") },
|
||||
"$sample/001/select-one-rows.txt"
|
||||
),
|
||||
'Report for a single query (rows method)'
|
||||
);
|
||||
SKIP: {
|
||||
skip "LOAD DATA LOCAL INFILE is disabled", 2 if $load_data_is_disabled;
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-one.log",
|
||||
"--compare-results-method", "rows") },
|
||||
"$sample/001/select-one-rows.txt"
|
||||
),
|
||||
'Report for a single query (rows method)'
|
||||
);
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-everyone.log",
|
||||
"--compare-results-method", "rows") },
|
||||
"$sample/001/select-everyone-rows.txt"
|
||||
),
|
||||
'Report for multiple queries (rows method)'
|
||||
);
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-everyone.log",
|
||||
"--compare-results-method", "rows") },
|
||||
"$sample/001/select-everyone-rows.txt"
|
||||
),
|
||||
'Report for multiple queries (rows method)'
|
||||
);
|
||||
}
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
@@ -107,76 +113,84 @@ $sb->wipe_clean($dbh2);
|
||||
# Issue 951: mk-upgrade "I need a db argument" error with
|
||||
# compare-results-method=rows
|
||||
# #############################################################################
|
||||
$sb->load_file('master', "$sample/002/tables.sql");
|
||||
$sb->load_file('master1', "$sample/002/tables.sql");
|
||||
SKIP: {
|
||||
skip "LOAD DATA LOCAL INFILE is disabled", 4 if $load_data_is_disabled;
|
||||
$sb->load_file('master', "$sample/002/tables.sql");
|
||||
$sb->load_file('master1', "$sample/002/tables.sql");
|
||||
|
||||
# Make a difference on one host so diff_rows() is called.
|
||||
$dbh1->do('insert into test.t values (5)');
|
||||
# Make a difference on one host so diff_rows() is called.
|
||||
$dbh1->do('insert into test.t values (5)');
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_upgrade::main(@op_args, "$log/002/no-db.log",
|
||||
'h=127.1,P=12345,D=test', 'P=12348,D=test',
|
||||
qw(--compare-results-method rows --temp-database test)) },
|
||||
"$sample/002/report-01.txt",
|
||||
),
|
||||
'No db, compare results row, DSN D, --temp-database (issue 951)'
|
||||
);
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_upgrade::main(@op_args, "$log/002/no-db.log",
|
||||
'h=127.1,P=12345,D=test', 'P=12348,D=test',
|
||||
qw(--compare-results-method rows --temp-database test)) },
|
||||
"$sample/002/report-01.txt",
|
||||
),
|
||||
'No db, compare results row, DSN D, --temp-database (issue 951)'
|
||||
);
|
||||
|
||||
$sb->load_file('master', "$sample/002/tables.sql");
|
||||
$sb->load_file('master1', "$sample/002/tables.sql");
|
||||
$dbh1->do('insert into test.t values (5)');
|
||||
$sb->load_file('master', "$sample/002/tables.sql");
|
||||
$sb->load_file('master1', "$sample/002/tables.sql");
|
||||
$dbh1->do('insert into test.t values (5)');
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_upgrade::main(@op_args, "$log/002/no-db.log",
|
||||
'h=127.1,P=12345,D=test', 'P=12348,D=test',
|
||||
qw(--compare-results-method rows --temp-database tmp_db)) },
|
||||
"$sample/002/report-01.txt",
|
||||
),
|
||||
'No db, compare results row, DSN D'
|
||||
);
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_upgrade::main(@op_args, "$log/002/no-db.log",
|
||||
'h=127.1,P=12345,D=test', 'P=12348,D=test',
|
||||
qw(--compare-results-method rows --temp-database tmp_db)) },
|
||||
"$sample/002/report-01.txt",
|
||||
),
|
||||
'No db, compare results row, DSN D'
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
$dbh1->selectall_arrayref('show tables from `test`'),
|
||||
[['t']],
|
||||
"Didn't create temp table in event's db"
|
||||
);
|
||||
is_deeply(
|
||||
$dbh1->selectall_arrayref('show tables from `test`'),
|
||||
[['t']],
|
||||
"Didn't create temp table in event's db"
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
$dbh1->selectall_arrayref('show tables from `tmp_db`'),
|
||||
[['mk_upgrade_left']],
|
||||
"Createed temp table in --temp-database"
|
||||
);
|
||||
is_deeply(
|
||||
$dbh1->selectall_arrayref('show tables from `tmp_db`'),
|
||||
[['mk_upgrade_left']],
|
||||
"Createed temp table in --temp-database"
|
||||
);
|
||||
|
||||
$sb->wipe_clean($dbh1);
|
||||
$sb->wipe_clean($dbh2);
|
||||
|
||||
$sb->wipe_clean($dbh1);
|
||||
$sb->wipe_clean($dbh2);
|
||||
}
|
||||
|
||||
# #############################################################################
|
||||
# Bug 926598: DBD::mysql bug causes pt-upgrade to use wrong
|
||||
# precision (M) and scale (D)
|
||||
# #############################################################################
|
||||
$sb->load_file('master', "$sample/003/tables.sql");
|
||||
$sb->load_file('master1', "$sample/003/tables.sql");
|
||||
SKIP: {
|
||||
skip "LOAD DATA LOCAL INFILE is disabled", 2 if $load_data_is_disabled;
|
||||
|
||||
# Make a difference on one host so diff_rows() is called.
|
||||
$dbh1->do('insert into test.t values (4, 1.00)');
|
||||
$sb->load_file('master', "$sample/003/tables.sql");
|
||||
$sb->load_file('master1', "$sample/003/tables.sql");
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_upgrade::main(@args, "$log/003/double.log",
|
||||
qw(--compare-results-method rows)) },
|
||||
"$sample/003/report001.txt",
|
||||
),
|
||||
'M, D diff (bug 926598)',
|
||||
);
|
||||
# Make a difference on one host so diff_rows() is called.
|
||||
$dbh1->do('insert into test.t values (4, 1.00)');
|
||||
|
||||
my $row = $dbh1->selectrow_arrayref("show create table test.mk_upgrade_left");
|
||||
like(
|
||||
$row->[1],
|
||||
qr/[`"]SUM\(total\)[`"]\s+double\sDEFAULT/i,
|
||||
"No M,D in table def (bug 926598)"
|
||||
);
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_upgrade::main(@args, "$log/003/double.log",
|
||||
qw(--compare-results-method rows)) },
|
||||
"$sample/003/report001.txt",
|
||||
),
|
||||
'M, D diff (bug 926598)',
|
||||
);
|
||||
|
||||
my $row = $dbh1->selectrow_arrayref("show create table test.mk_upgrade_left");
|
||||
like(
|
||||
$row->[1],
|
||||
qr/[`"]SUM\(total\)[`"]\s+double\sDEFAULT/i,
|
||||
"No M,D in table def (bug 926598)"
|
||||
);
|
||||
}
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
|
@@ -29,6 +29,9 @@ if ( !$dbh1 ) {
|
||||
elsif ( !$dbh2 ) {
|
||||
plan skip_all => 'Cannot connect to second sandbox master';
|
||||
}
|
||||
elsif ( PerconaTest::load_data_is_disabled($dbh1) ) {
|
||||
plan skip_all => 'LOAD DATA LOCAL INFILE is disabled';
|
||||
}
|
||||
else {
|
||||
plan tests => 6;
|
||||
}
|
||||
|
Reference in New Issue
Block a user