Skip to content

Commit

Permalink
MDEV-33187: Make mariadb-hotcopy compatible with DBI:MariaDB
Browse files Browse the repository at this point in the history
  • Loading branch information
an3l authored and grooverdan committed Jan 13, 2024
1 parent d0c80c2 commit 82f27ea
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions scripts/mysqlhotcopy.sh
Expand Up @@ -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} ) {
Expand Down

0 comments on commit 82f27ea

Please sign in to comment.