mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 13:11:32 +00:00
Merged ubuntu-12-64-issues
This commit is contained in:
@@ -103,7 +103,7 @@ sub new {
|
||||
dsn_name => $dp->as_string($dsn, [qw(h P S)]),
|
||||
hostname => '',
|
||||
set => $args{set},
|
||||
NAME_lc => $args{NAME_lc},
|
||||
NAME_lc => defined($args{NAME_lc}) ? $args{NAME_lc} : 1,
|
||||
dbh_set => 0,
|
||||
OptionParser => $o,
|
||||
DSNParser => $dp,
|
||||
|
@@ -336,7 +336,7 @@ sub get_dbh {
|
||||
PTDEBUG && _d($dbh, $sql);
|
||||
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||
if ( $EVAL_ERROR ) {
|
||||
die $EVAL_ERROR;
|
||||
die "Error getting the current SQL_MODE: $EVAL_ERROR";
|
||||
}
|
||||
|
||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||
@@ -346,16 +346,18 @@ sub get_dbh {
|
||||
PTDEBUG && _d($dbh, $sql);
|
||||
eval { $dbh->do($sql) };
|
||||
if ( $EVAL_ERROR ) {
|
||||
die $EVAL_ERROR;
|
||||
die "Error setting SQL_QUOTE_SHOW_CREATE, SQL_MODE"
|
||||
. ($sql_mode ? " and $sql_mode" : '')
|
||||
. ": $EVAL_ERROR";
|
||||
}
|
||||
|
||||
# Set character set and binmode on STDOUT.
|
||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||
$sql = "/*!40101 SET NAMES $charset*/";
|
||||
if ( my ($charset) = $cxn_string =~ m/charset=([\w]+)/ ) {
|
||||
$sql = qq{/*!40101 SET NAMES "$charset"*/};
|
||||
PTDEBUG && _d($dbh, ':', $sql);
|
||||
eval { $dbh->do($sql) };
|
||||
if ( $EVAL_ERROR ) {
|
||||
die $EVAL_ERROR;
|
||||
die "Error setting NAMES to $charset: $EVAL_ERROR";
|
||||
}
|
||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||
if ( $charset eq 'utf8' ) {
|
||||
@@ -367,12 +369,12 @@ sub get_dbh {
|
||||
}
|
||||
}
|
||||
|
||||
if ( $self->prop('set-vars') ) {
|
||||
$sql = "SET " . $self->prop('set-vars');
|
||||
if ( my $var = $self->prop('set-vars') ) {
|
||||
$sql = "SET $var";
|
||||
PTDEBUG && _d($dbh, ':', $sql);
|
||||
eval { $dbh->do($sql) };
|
||||
if ( $EVAL_ERROR ) {
|
||||
die $EVAL_ERROR;
|
||||
die "Error setting $var: $EVAL_ERROR";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -717,12 +717,17 @@ sub full_output {
|
||||
my ( $code, %args ) = @_;
|
||||
die "I need a code argument" unless $code;
|
||||
|
||||
my (undef, $file) = tempfile();
|
||||
open *output_fh, '>', $file
|
||||
or die "Cannot open file $file: $OS_ERROR";
|
||||
local *STDOUT = *output_fh;
|
||||
local (*STDOUT, *STDERR);
|
||||
require IO::File;
|
||||
|
||||
*STDERR = *STDOUT;
|
||||
my (undef, $file) = tempfile();
|
||||
open *STDOUT, '>', $file
|
||||
or die "Cannot open file $file: $OS_ERROR";
|
||||
*STDOUT->autoflush(1);
|
||||
|
||||
open *STDERR, '>', $file
|
||||
or die "Cannot open file $file: $OS_ERROR";
|
||||
*STDERR->autoflush(1);
|
||||
|
||||
my $status;
|
||||
if (my $pid = fork) {
|
||||
@@ -745,7 +750,7 @@ sub full_output {
|
||||
else {
|
||||
exit $code->();
|
||||
}
|
||||
close *output_fh;
|
||||
close $_ or die "Cannot close $_: $OS_ERROR" for qw(STDOUT STDERR);
|
||||
my $output = do { local $/; open my $fh, "<", $file or die $!; <$fh> };
|
||||
|
||||
return ($output, $status);
|
||||
@@ -772,6 +777,19 @@ sub tables_used {
|
||||
return [ sort keys %tables ];
|
||||
}
|
||||
|
||||
sub load_data_is_disabled {
|
||||
my ($dbh) = @_;
|
||||
my $sql = "LOAD DATA LOCAL INFILE '/dev/null' INTO TABLE "
|
||||
. "`t`.`pt_not_there`";
|
||||
local $@;
|
||||
if (!eval { $dbh->do($sql); 1 } ) {
|
||||
my $e = $@;
|
||||
return 1 if $e =~ qr/\QDBD::mysql::db do failed: The used command is not allowed with this MySQL version [for Statement "LOAD DATA LOCAL INFILE/;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
1;
|
||||
}
|
||||
# ###########################################################################
|
||||
|
@@ -15,8 +15,14 @@
|
||||
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
# Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
# ###########################################################################
|
||||
# ReadKeyMini
|
||||
# ReadKeyMini package
|
||||
# ###########################################################################
|
||||
|
||||
# Package: ReadKeyMini
|
||||
# ReadKeyMini is a wrapper around Term::ReadKey. If that's available,
|
||||
# we use ReadMode and GetTerminalSize from there. Otherwise, we use homebrewn
|
||||
# definitions.
|
||||
|
||||
BEGIN {
|
||||
|
||||
package ReadKeyMini;
|
||||
@@ -29,11 +35,6 @@ package ReadKeyMini;
|
||||
# would solve the issue.
|
||||
BEGIN { $INC{"ReadKeyMini.pm"} ||= 1 }
|
||||
|
||||
# Package: ReadKeyMini
|
||||
# ReadKeyMini is a wrapper around Term::ReadKey. If that's available,
|
||||
# we use ReadMode and GetTerminalSize from there. Otherwise, we use homebrewn
|
||||
# definitions.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
use English qw(-no_match_vars);
|
||||
@@ -72,7 +73,7 @@ my %modes = (
|
||||
my $flags;
|
||||
unless ( $PerconaTest::DONT_RESTORE_STDIN ) {
|
||||
$flags = fcntl(STDIN, F_GETFL, 0)
|
||||
or die "can't fcntl F_GETFL: $!";
|
||||
or warn "can't fcntl F_GETFL: $!";
|
||||
}
|
||||
my $term = POSIX::Termios->new();
|
||||
$term->getattr($fd_stdin);
|
||||
@@ -106,7 +107,7 @@ my %modes = (
|
||||
$term->setattr( $fd_stdin, TCSANOW );
|
||||
unless ( $PerconaTest::DONT_RESTORE_STDIN ) {
|
||||
fcntl(STDIN, F_SETFL, $flags)
|
||||
or die "can't fcntl F_SETFL: $!";
|
||||
or warn "can't fcntl F_SETFL: $!";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,16 +169,18 @@ sub _GetTerminalSize {
|
||||
}
|
||||
}
|
||||
|
||||
eval {
|
||||
if ( $rows = `tput lines` ) {
|
||||
chomp($rows);
|
||||
chomp($cols = `tput cols`);
|
||||
}
|
||||
elsif ( my $stty = `stty -a` ) {
|
||||
($rows, $cols) = $stty =~ /([0-9]+) rows; ([0-9]+) columns;/;
|
||||
}
|
||||
};
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
if ( $rows = `tput lines 2>/dev/null` ) {
|
||||
chomp($rows);
|
||||
chomp($cols = `tput cols`);
|
||||
}
|
||||
elsif ( my $stty = `stty -a 2>/dev/null` ) {
|
||||
($rows, $cols) = $stty =~ /([0-9]+) rows; ([0-9]+) columns;/;
|
||||
}
|
||||
else {
|
||||
($cols, $rows) = @ENV{qw( COLUMNS LINES )};
|
||||
$cols ||= 80;
|
||||
$rows ||= 24;
|
||||
}
|
||||
|
||||
return ( $cols, $rows );
|
||||
}
|
||||
|
Reference in New Issue
Block a user