diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-05-25 08:52:21 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-05-25 08:52:21 +0300 |
commit | 1ace1075dc6bb02fe19802334f9d47446a17a79a (patch) | |
tree | ff9d56b6348d083ea17dc72efccb20bbb57640aa /debian/additions | |
parent | 208addf48444c0a36a2cc16cd2558ae694e905d5 (diff) | |
parent | 105647df789af1f0143e5b50e55179598808f7cf (diff) | |
download | mariadb-git-1ace1075dc6bb02fe19802334f9d47446a17a79a.tar.gz |
Merge 10.8 into 10.9
Diffstat (limited to 'debian/additions')
-rwxr-xr-x | debian/additions/mariadb-report | 70 |
1 files changed, 50 insertions, 20 deletions
diff --git a/debian/additions/mariadb-report b/debian/additions/mariadb-report index 5c9761e0710..ff73bb0e17e 100755 --- a/debian/additions/mariadb-report +++ b/debian/additions/mariadb-report @@ -239,26 +239,56 @@ sub get_user_mycnf sub connect_to_MySQL { - print "connect_to_MySQL\n" if $op{debug}; - - my $dsn; - - if($mycnf{'socket'} && -S $mycnf{'socket'}) - { - $dsn = "DBI:MariaDB:mariadb_socket=$mycnf{socket}"; - } - elsif($mycnf{'host'}) - { - $dsn = "DBI:MariaDB:host=$mycnf{host}" . ($mycnf{port} ? ";port=$mycnf{port}" : ""); - } - else - { - $dsn = "DBI:MariaDB:host=localhost"; - } - - print "connect_to_MySQL: DBI DSN: $dsn\n" if $op{debug}; - - $dbh = DBI->connect($dsn, $mycnf{'user'}, $mycnf{'pass'}) or die; + print "connect_to_MySQL\n" if $op{debug}; + + if(my @driverList = grep {/mariadb|mysql/i} DBI->available_drivers()) { + my $dsn; + my $driver = undef; + + if(grep {/mariadb/i} @driverList) + { + $driver = "DBI:MariaDB"; + } + elsif(grep {/mysql/i} @driverList) + { + $driver = "DBI:mysql"; + } + + if($mycnf{'socket'} && -S $mycnf{'socket'}) + { + if(grep {/mariadb/i} @driverList) + { + $dsn = $driver . ":mariadb_socket=$mycnf{socket}"; + } + elsif(grep {/mysql/i} @driverList) + { + $dsn = $driver . ":mysql_socket=$mycnf{socket}"; + } + } + elsif($mycnf{'host'}) + { + $dsn = $driver . ":host=$mycnf{host}" . ($mycnf{port} ? ";port=$mycnf{port}" : ""); + } + else + { + $dsn = $driver . ":host=localhost"; + } + + print "connect_to_MySQL: DBI DSN: " . $dsn . "\n" if $op{debug}; + + $dbh = DBI->connect($dsn, $mycnf{'user'}, $mycnf{'pass'}) or die; + } + else + { + print STDERR "Install Perl 5.x driver: DBD:mysql or DBD:MariaDB\n"; + print STDERR "currently installed Perl DBD drivers:\n"; + foreach my $driver (DBI->available_drivers()) + { + print STDERR " * " . $driver . "\n"; + } + print STDERR "\n"; + die("Exit as no MariaDB DBI driver found!\n"); + } } sub collect_reports |