Subject: | statistics_info() doesn't work correctly |
Date: | Mon, 24 Jul 2017 07:16:46 +0000 |
To: | bug-DBD-SQLite [...] rt.cpan.org |
From: | John Deighan <john.deighan [...] gmail.com> |
At least, that's my interpretation. You pass a table name to the function.
If you don't specify the correct case of the table name, you will receive
an empty array. This is totally unlike other functions, like table_info().
In the file DBD/SQLite.pm, inside the function named statistics_info(), I
see the following:
my $tables = $dbh->selectall_arrayref("SELECT name FROM
$master_table WHERE type = ?", undef, "table") or return;
for my $table_ref (@$tables) {
my $tbname = $table_ref->[0];
next if defined $table && $table ne '%' && $table ne $tbname;
...etc.
Now, one of the differences between DBI's table_info() and
statistics_info() is that the table parameter passed to table_info() is a
SQL pattern, i.e. it's used with "where <tablename> like <parameter>".
Since SQL is case-insensitive, this allows any case to be used. However,
the table name passed to statistics_info() is not, so I think that's what's
responsible for this behavior (and is also the reason I don't understand
the comparison with '%' above). Unfortunately, the DBI docs aren't really
clear about whether the table name passed to statistics_info() should or
should not be case sensitive. But, to be consistent, I think that the
comparison above should be case-insensitive, i.e. something like
"uc($table) ne uc($tbname)". I don't see the need for the comparison to
'%', though maybe it doesn't hurt anything except that it kind of implies
that you can use the '%' character in a table name for a wild card match,
which you explicitly cannot.
FYI:
Windows 10
ActivePerl 5.16.3 x64
DBD::SQLite v. 1.54 (I had to install it via CPAN since the ActiveState
repository doesn't yet have this version, which includes statistics_info()