Skip Menu |

This queue is for tickets about the DBD-SQLite CPAN distribution.

Report information
The Basics
Id: 122581
Status: resolved
Priority: 0/
Queue: DBD-SQLite

People
Owner: Nobody in particular
Requestors: john.deighan [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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()
On Mon Jul 24 16:17:07 2017, jdeighan wrote: Show quoted text
> 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()
Sorry for the delay. https://github.com/DBD-SQLite/DBD-SQLite/commit/0dbc9d1074317eae93e238835f6b1c0ed29bdd21 should fix this.
On Thu Sep 07 07:18:45 2017, ISHIGAKI wrote: Show quoted text
> On Mon Jul 24 16:17:07 2017, jdeighan wrote:
> > 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()
> > > Sorry for the delay. https://github.com/DBD-SQLite/DBD- > SQLite/commit/0dbc9d1074317eae93e238835f6b1c0ed29bdd21 should fix > this.
Closed as 1.56 with this fix is released. Thanks.