Lines 806-814
sub _new_dbh
Link Here
|
806 |
my $db_port = $context->config("port") || ''; |
806 |
my $db_port = $context->config("port") || ''; |
807 |
my $db_user = $context->config("user"); |
807 |
my $db_user = $context->config("user"); |
808 |
my $db_passwd = $context->config("pass"); |
808 |
my $db_passwd = $context->config("pass"); |
809 |
# MJR added or die here, as we can't work without dbh |
809 |
my $db_mysql_socket = $context->config("mysql_socket") || ''; |
810 |
my $dbh = DBI->connect("DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port", |
810 |
|
811 |
$db_user, $db_passwd, {'RaiseError' => $ENV{DEBUG}?1:0 }) or die $DBI::errstr; |
811 |
my $dbh; |
|
|
812 |
#if a unix socket is given use that instead of TCP (as it is way faster!) ONLY Mysql-derivatives |
813 |
# Instead of dying, just warn about the error because we can fall back to a TCP-connection. |
814 |
if ($db_mysql_socket && ($db_driver =~ /mysql/i || $db_driver =~ /mariadb/i)) { |
815 |
# MJR added or die here, as we can't work without dbh |
816 |
$dbh = DBI->connect("DBI:$db_driver:dbname=$db_name;mysql_socket=$db_mysql_socket", |
817 |
$db_user, $db_passwd, {'RaiseError' => $ENV{DEBUG}?1:0 }) or warn $DBI::errstr; |
818 |
} |
819 |
#Try making a TCP connection |
820 |
if ((! defined ($dbh)) && $db_host) { |
821 |
# MJR added or die here, as we can't work without dbh |
822 |
$dbh = DBI->connect("DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port", |
823 |
$db_user, $db_passwd, {'RaiseError' => $ENV{DEBUG}?1:0 }) or die $DBI::errstr; |
824 |
} |
812 |
|
825 |
|
813 |
# Check for the existence of a systempreference table; if we don't have this, we don't |
826 |
# Check for the existence of a systempreference table; if we don't have this, we don't |
814 |
# have a valid database and should not set RaiseError in order to allow the installer |
827 |
# have a valid database and should not set RaiseError in order to allow the installer |