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}; ...@@ -189,21 +189,38 @@ $opt{quiet} = 0 if $opt{debug};
$opt{allowold} = 1 if $opt{keepold}; $opt{allowold} = 1 if $opt{keepold};
# --- connect to the database --- # --- connect to the database ---
## Socket takes precedence.
my $dsn; my $dsn;
$dsn = ";host=" . (defined($opt{host}) ? $opt{host} : "localhost"); my $prefix= 'mysql';
$dsn .= ";port=$opt{port}" if $opt{port};
$dsn .= ";mariadb_socket=$opt{socket}" if $opt{socket};
# use mariadb_read_default_group=mysqlhotcopy so that [client] and if (eval {DBI->install_driver("MariaDB")}) {
# [mysqlhotcopy] groups will be read from standard options files. $dsn ="DBI:MariaDB:;";
$prefix= 'mariadb';
}
else {
$dsn = "DBI:mysql:;";
}
my $dbh = DBI->connect("DBI:MariaDB:$dsn;mariadb_read_default_group=mysqlhotcopy", if ($opt{socket} and -S $opt{socket})
$opt{user}, $opt{password}, {
$dsn .= "${prefix}_socket=$opt{socket}";
}
else
{ {
RaiseError => 1, $dsn .= "host=" . $opt{host};
PrintError => 0, if ($opt{host} ne "localhost")
AutoCommit => 1, {
}); $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 --- # --- check that checkpoint table exists if specified ---
if ( $opt{checkpoint} ) { 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