mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 13:11:32 +00:00
Fix 984915: DSNParser does not check return value of do() calls
This commit is contained in:
@@ -1709,27 +1709,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -1743,26 +1771,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1262,27 +1262,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -1296,26 +1324,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1525,27 +1525,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -1559,26 +1587,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -947,27 +947,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -981,26 +1009,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
60
bin/pt-find
60
bin/pt-find
@@ -237,27 +237,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -271,26 +299,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1381,27 +1381,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -1415,26 +1443,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1970,27 +1970,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -2004,26 +2032,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -237,27 +237,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -271,26 +299,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
60
bin/pt-kill
60
bin/pt-kill
@@ -1406,27 +1406,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -1440,26 +1468,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2217,27 +2217,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -2251,26 +2279,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1406,27 +1406,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -1440,26 +1468,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -237,27 +237,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -271,26 +299,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -237,27 +237,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -271,26 +299,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1262,27 +1262,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -1296,26 +1324,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1406,27 +1406,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -1440,26 +1468,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1262,27 +1262,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -1296,26 +1324,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1525,27 +1525,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -1559,26 +1587,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -237,27 +237,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -271,26 +299,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1381,27 +1381,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -1415,26 +1443,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -237,27 +237,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -271,26 +299,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -237,27 +237,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -271,26 +299,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1262,27 +1262,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -1296,26 +1324,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1934,27 +1934,55 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
my $sql;
|
my $sql;
|
||||||
|
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -1968,26 +1996,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -302,8 +302,27 @@ sub get_dbh {
|
|||||||
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
|
||||||
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
|
||||||
|
|
||||||
eval {
|
$dbh = eval { DBI->connect($cxn_string, $user, $pass, $defaults) };
|
||||||
$dbh = DBI->connect($cxn_string, $user, $pass, $defaults);
|
|
||||||
|
if ( !$dbh && $EVAL_ERROR ) {
|
||||||
|
if ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
||||||
|
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
||||||
|
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
||||||
|
. "the directories that Perl searches for DBD::mysql. If "
|
||||||
|
. "DBD::mysql is not installed, try:\n"
|
||||||
|
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
||||||
|
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
||||||
|
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
||||||
|
}
|
||||||
|
elsif ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
||||||
|
PTDEBUG && _d('Going to try again without utf8 support');
|
||||||
|
delete $defaults->{mysql_enable_utf8};
|
||||||
|
}
|
||||||
|
if ( !$tries ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# If it's a MySQL connection, set some options.
|
# If it's a MySQL connection, set some options.
|
||||||
if ( $cxn_string =~ m/mysql/i ) {
|
if ( $cxn_string =~ m/mysql/i ) {
|
||||||
@@ -315,20 +334,29 @@ sub get_dbh {
|
|||||||
# http://code.google.com/p/maatkit/issues/detail?id=801
|
# http://code.google.com/p/maatkit/issues/detail?id=801
|
||||||
$sql = 'SELECT @@SQL_MODE';
|
$sql = 'SELECT @@SQL_MODE';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
my ($sql_mode) = $dbh->selectrow_array($sql);
|
my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
$sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
|
||||||
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
. '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
|
||||||
. ($sql_mode ? ",$sql_mode" : '')
|
. ($sql_mode ? ",$sql_mode" : '')
|
||||||
. '\'*/';
|
. '\'*/';
|
||||||
PTDEBUG && _d($dbh, $sql);
|
PTDEBUG && _d($dbh, $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
# Set character set and binmode on STDOUT.
|
# Set character set and binmode on STDOUT.
|
||||||
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
|
||||||
$sql = "/*!40101 SET NAMES $charset*/";
|
$sql = "/*!40101 SET NAMES $charset*/";
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
die $EVAL_ERROR;
|
||||||
|
}
|
||||||
PTDEBUG && _d('Enabling charset for STDOUT');
|
PTDEBUG && _d('Enabling charset for STDOUT');
|
||||||
if ( $charset eq 'utf8' ) {
|
if ( $charset eq 'utf8' ) {
|
||||||
binmode(STDOUT, ':utf8')
|
binmode(STDOUT, ':utf8')
|
||||||
@@ -342,26 +370,8 @@ sub get_dbh {
|
|||||||
if ( $self->prop('set-vars') ) {
|
if ( $self->prop('set-vars') ) {
|
||||||
$sql = "SET " . $self->prop('set-vars');
|
$sql = "SET " . $self->prop('set-vars');
|
||||||
PTDEBUG && _d($dbh, ':', $sql);
|
PTDEBUG && _d($dbh, ':', $sql);
|
||||||
$dbh->do($sql);
|
eval { $dbh->do($sql) };
|
||||||
}
|
if ( $EVAL_ERROR ) {
|
||||||
}
|
|
||||||
};
|
|
||||||
if ( !$dbh && $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d($EVAL_ERROR);
|
|
||||||
if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
|
|
||||||
PTDEBUG && _d('Going to try again without utf8 support');
|
|
||||||
delete $defaults->{mysql_enable_utf8};
|
|
||||||
}
|
|
||||||
elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
|
|
||||||
die "Cannot connect to MySQL because the Perl DBD::mysql module is "
|
|
||||||
. "not installed or not found. Run 'perl -MDBD::mysql' to see "
|
|
||||||
. "the directories that Perl searches for DBD::mysql. If "
|
|
||||||
. "DBD::mysql is not installed, try:\n"
|
|
||||||
. " Debian/Ubuntu apt-get install libdbd-mysql-perl\n"
|
|
||||||
. " RHEL/CentOS yum install perl-DBD-MySQL\n"
|
|
||||||
. " OpenSolaris pgk install pkg:/SUNWapu13dbd-mysql\n";
|
|
||||||
}
|
|
||||||
if ( !$tries ) {
|
|
||||||
die $EVAL_ERROR;
|
die $EVAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@ BEGIN {
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
use Test::More tests => 35;
|
use Test::More tests => 37;
|
||||||
|
|
||||||
use DSNParser;
|
use DSNParser;
|
||||||
use OptionParser;
|
use OptionParser;
|
||||||
@@ -542,6 +542,30 @@ foreach my $password_comma ( @password_commas ) {
|
|||||||
test_password_comma_with_auto(@$password_comma);
|
test_password_comma_with_auto(@$password_comma);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# #############################################################################
|
||||||
|
# Bug 984915: SQL calls after creating the dbh aren't checked
|
||||||
|
# #############################################################################
|
||||||
|
|
||||||
|
$dsn = $dp->parse('h=127.1,P=12345,u=msandbox,p=msandbox');
|
||||||
|
my @opts = $dp->get_cxn_params($dsn);
|
||||||
|
$opts[0] .= ";charset=garbage_eh";
|
||||||
|
my ($out, undef) = full_output(sub { $dp->get_dbh(@opts, {}) });
|
||||||
|
|
||||||
|
like(
|
||||||
|
$out,
|
||||||
|
qr/\QUnknown character set/,
|
||||||
|
"get_dbh dies withg an unknown charset"
|
||||||
|
);
|
||||||
|
|
||||||
|
$dp->prop('set-vars', "time_zoen='UTC'");
|
||||||
|
($out, undef) = full_output(sub { $dp->get_dbh($dp->get_cxn_params($dsn), {}) });
|
||||||
|
|
||||||
|
like(
|
||||||
|
$out,
|
||||||
|
qr/\QUnknown system variable 'time_zoen'/,
|
||||||
|
"get_dbh dies withg an unknown charset"
|
||||||
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
Reference in New Issue
Block a user