pt-upgrade: Deal with LOCAL INFILE being disabled

This commit is contained in:
Brian Fraser
2012-07-11 18:36:43 -03:00
parent e9c9608c33
commit e0d97bbc98
4 changed files with 115 additions and 73 deletions

View File

@@ -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');

View File

@@ -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"
);
}

View File

@@ -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,6 +66,9 @@ ok(
'Report for multiple queries (checksum 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",
@@ -81,6 +86,7 @@ ok(
),
'Report for multiple queries (rows method)'
);
}
ok(
no_diff(
@@ -107,6 +113,8 @@ $sb->wipe_clean($dbh2);
# Issue 951: mk-upgrade "I need a db argument" error with
# compare-results-method=rows
# #############################################################################
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");
@@ -152,10 +160,15 @@ is_deeply(
$sb->wipe_clean($dbh1);
$sb->wipe_clean($dbh2);
}
# #############################################################################
# Bug 926598: DBD::mysql bug causes pt-upgrade to use wrong
# precision (M) and scale (D)
# #############################################################################
SKIP: {
skip "LOAD DATA LOCAL INFILE is disabled", 2 if $load_data_is_disabled;
$sb->load_file('master', "$sample/003/tables.sql");
$sb->load_file('master1', "$sample/003/tables.sql");
@@ -177,6 +190,7 @@ like(
qr/[`"]SUM\(total\)[`"]\s+double\sDEFAULT/i,
"No M,D in table def (bug 926598)"
);
}
# #############################################################################
# Done.

View File

@@ -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;
}