mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-27 07:54:58 +00:00
Merged fix-821715-enable-local-infile-in-dsn
This commit is contained in:
@@ -244,7 +244,8 @@ sub get_cxn_params {
|
||||
. join(';', map { "$opts{$_}->{dsn}=$info->{$_}" }
|
||||
grep { defined $info->{$_} }
|
||||
qw(F h P S A))
|
||||
. ';mysql_read_default_group=client';
|
||||
. ';mysql_read_default_group=client'
|
||||
. ($info->{L} ? ';mysql_local_infile=1' : '');
|
||||
}
|
||||
PTDEBUG && _d($dsn);
|
||||
return ($dsn, $info->{u}, $info->{p});
|
||||
@@ -277,6 +278,9 @@ sub get_dbh {
|
||||
mysql_enable_utf8 => ($cxn_string =~ m/charset=utf8/i ? 1 : 0),
|
||||
};
|
||||
@{$defaults}{ keys %$opts } = values %$opts;
|
||||
if (delete $defaults->{L}) { # L for LOAD DATA LOCAL INFILE, our own extension
|
||||
$defaults->{mysql_local_infile} = 1;
|
||||
}
|
||||
|
||||
# Only add this if explicitly set because we're not sure if
|
||||
# mysql_use_result=0 would leave default mysql_store_result
|
||||
|
@@ -138,6 +138,12 @@ our $dsn_opts = [
|
||||
dsn => 'user',
|
||||
copy => 1,
|
||||
},
|
||||
{
|
||||
key => 'L',
|
||||
desc => 'Pass mysql_local_infile to DBD::mysql',
|
||||
dsn => 'mysql_local_infile',
|
||||
copy => 1,
|
||||
},
|
||||
];
|
||||
|
||||
# Runs code, captures and returns its output.
|
||||
@@ -788,7 +794,7 @@ sub tables_used {
|
||||
|
||||
sub can_load_data {
|
||||
my $output = `/tmp/12345/use -e "SELECT * FROM percona_test.load_data" 2>/dev/null`;
|
||||
return ($output || '') =~ /42/;
|
||||
return ($output || '') =~ /1/;
|
||||
}
|
||||
|
||||
1;
|
||||
|
@@ -116,6 +116,10 @@ sub get_dbh_for {
|
||||
my $dp = $self->{DSNParser};
|
||||
my $dsn = $dp->parse('h=127.0.0.1,u=msandbox,p=msandbox,P=' . $port_for{$server});
|
||||
my $dbh;
|
||||
# This is primarily for the benefit of CompareResults, but it's
|
||||
# also quite convenient when using an affected OS
|
||||
$cxn_ops->{L} = 1 if !exists $cxn_ops->{L}
|
||||
&& !$self->can_load_data('master');
|
||||
eval { $dbh = $dp->get_dbh($dp->get_cxn_params($dsn), $cxn_ops) };
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d('Failed to get dbh for', $server, ':', $EVAL_ERROR);
|
||||
@@ -396,6 +400,7 @@ sub clear_genlogs {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
sub is_cluster_node {
|
||||
my ($self, $server) = @_;
|
||||
|
||||
@@ -410,6 +415,12 @@ sub is_cluster_node {
|
||||
: 0;
|
||||
}
|
||||
|
||||
sub can_load_data {
|
||||
my ($self, $server) = @_;
|
||||
my $output = $self->use($server, q{-e "SELECT * FROM percona_test.load_data"});
|
||||
return ($output || '') =~ /1/;
|
||||
}
|
||||
|
||||
1;
|
||||
}
|
||||
# ###########################################################################
|
||||
|
Reference in New Issue
Block a user