Commit 82f27ea5 authored by Anel Husakovic's avatar Anel Husakovic Committed by Daniel Black

MDEV-33187: Make mariadb-hotcopy compatible with DBI:MariaDB

parent d0c80c21
......@@ -189,21 +189,38 @@ $opt{quiet} = 0 if $opt{debug};
$opt{allowold} = 1 if $opt{keepold};
# --- connect to the database ---
## Socket takes precedence.
my $dsn;
$dsn = ";host=" . (defined($opt{host}) ? $opt{host} : "localhost");
$dsn .= ";port=$opt{port}" if $opt{port};
$dsn .= ";mariadb_socket=$opt{socket}" if $opt{socket};
my $prefix= 'mysql';
# use mariadb_read_default_group=mysqlhotcopy so that [client] and
# [mysqlhotcopy] groups will be read from standard options files.
if (eval {DBI->install_driver("MariaDB")}) {
$dsn ="DBI:MariaDB:;";
$prefix= 'mariadb';
}
else {
$dsn = "DBI:mysql:;";
}
my $dbh = DBI->connect("DBI:MariaDB:$dsn;mariadb_read_default_group=mysqlhotcopy",
$opt{user}, $opt{password},
if ($opt{socket} and -S $opt{socket})
{
$dsn .= "${prefix}_socket=$opt{socket}";
}
else
{
RaiseError => 1,
PrintError => 0,
AutoCommit => 1,
});
$dsn .= "host=" . $opt{host};
if ($opt{host} ne "localhost")
{
$dsn .= ";port=". $opt{port};
}
}
$dsn .= ";mariadb_read_default_group=mysqlhotcopy";
# use mariadb_read_default_group=mysqlhotcopy so that [client] and
# [mysqlhotcopy] groups will be read from standard options files.
# make the connection to MariaDB
my $dbh= DBI->connect($dsn, $opt{user}, $opt{password}, { RaiseError => 1, PrintError => 0}) ||
die("Can't make a connection to the MariaDB server.\n The error: $DBI::errstr");
# --- check that checkpoint table exists if specified ---
if ( $opt{checkpoint} ) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment