On Fri, Nov 16, 2018 at 10:38 AM <p...@cpan.org> wrote:
> Hi! If you want to list all databases then use DBI's data_sources method:
> https://metacpan.org/pod/DBI#data_sources

And DBD::mysql points to this method for a while:
https://github.com/perl5-dbi/DBD-mysql/blame/9f96fab985327773397a60020f5dcb76dfd8c396/lib/DBD/mysql.pm#L1432

Yet, it never worked for me, while their "legacy" version still does:
$ perl -MData::Dump=dd -MDBI -e 'for $impl (qw[mysql MariaDB]) { $plm
= lc $impl; $dbh =
DBI->connect("dbi:$impl:;${plm}_read_default_group=mysql"); dd {
listdbs => [ eval {$dbh->func("_ListDBs")} ], data_sources => [
$dbh->data_sources ], dbd => "DBD::$impl", dbi_version =>
$DBI::VERSION, dbd_version => ${"DBD::$impl\::VERSION"}, map { $_ =>
$dbh->{"${plm}_$_"} } qw(clientinfo clientversion serverversion) } }'
{
  clientinfo => "8.0.13",
  clientversion => 80013,
  data_sources => [],
  dbd => "DBD::mysql",
  dbd_version => 4.048,
  dbi_version => 1.642,
  listdbs => ["information_schema", "mysql", "performance_schema", "sys"],
  serverversion => 80013,
}
{
  clientinfo => "8.0.13",
  clientversion => 80013,
  data_sources => [
    "DBI:MariaDB:information_schema",
    "DBI:MariaDB:mysql",
    "DBI:MariaDB:performance_schema",
    "DBI:MariaDB:sys",
  ],
  dbd => "DBD::MariaDB",
  dbd_version => "1.00",
  dbi_version => 1.642,
  listdbs => [],
  serverversion => 80013,
}

Pali, seeing that your flavor's data_sources does work, I reckon it
might be yet another update to upstream. I suggest keeping ListDBs
retirement separate though. ;-)

For the sake of discussion –and to disappoint Daniel, sorry– given
this lack of coherence (NOT only at DBD level, e.g. privileges might
be involved), I have not been able to rely on DBI::data_sources,
having to employ DBMS specific queries instead.
e.g. @mysql: while "show databases" usually still works, an
"information_schema" based alternative/fallback could be useful.

Cheers!

Reply via email to