mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-08 14:48:32 -04:00
Fix statistics_info when only unique indexes were requested
This was completely broken before. Now there's a test so it should stay working.
This commit is contained in:
parent
28590db64e
commit
2b2ff06eab
3 changed files with 28 additions and 2 deletions
3
Changes
3
Changes
|
@ -1,5 +1,8 @@
|
||||||
Changes for Perl extension DBD-SQLite
|
Changes for Perl extension DBD-SQLite
|
||||||
|
|
||||||
|
- Fixed statistics_info when only unique indexes were requested (Dave
|
||||||
|
Rolsky++). GitHub #21
|
||||||
|
|
||||||
1.55 2017-01-04
|
1.55 2017-01-04
|
||||||
- Updated SQLite to 3.16.0
|
- Updated SQLite to 3.16.0
|
||||||
|
|
||||||
|
|
|
@ -679,7 +679,7 @@ sub statistics_info {
|
||||||
$sth->execute or return;
|
$sth->execute or return;
|
||||||
while(my $row = $sth->fetchrow_hashref) {
|
while(my $row = $sth->fetchrow_hashref) {
|
||||||
|
|
||||||
next if defined $unique_only && $unique_only && $row->{unique};
|
next if $unique_only && !$row->{unique};
|
||||||
my $quoted_idx = $dbh->quote_identifier($row->{name});
|
my $quoted_idx = $dbh->quote_identifier($row->{name});
|
||||||
for my $db (@$databases) {
|
for my $db (@$databases) {
|
||||||
my $quoted_db = $dbh->quote_identifier($db->{name});
|
my $quoted_db = $dbh->quote_identifier($db->{name});
|
||||||
|
|
|
@ -46,7 +46,7 @@ CREATE TABLE remote.b (
|
||||||
__EOSQL__
|
__EOSQL__
|
||||||
|
|
||||||
|
|
||||||
plan tests => @sql_statements + 33;
|
plan tests => @sql_statements + 48;
|
||||||
|
|
||||||
my $dbh = connect_ok( RaiseError => 1, PrintError => 0, AutoCommit => 1 );
|
my $dbh = connect_ok( RaiseError => 1, PrintError => 0, AutoCommit => 1 );
|
||||||
my $sth;
|
my $sth;
|
||||||
|
@ -97,3 +97,26 @@ for ($stats_data->{a_an}->{2}) {
|
||||||
is($_->{TABLE_SCHEM}, "main", "table schema");
|
is($_->{TABLE_SCHEM}, "main", "table schema");
|
||||||
}
|
}
|
||||||
ok(not(exists $stats_data->{a_ln}->{3}), "only two indexes in a_an index");
|
ok(not(exists $stats_data->{a_ln}->{3}), "only two indexes in a_an index");
|
||||||
|
|
||||||
|
$sth = $dbh->statistics_info(undef, undef, 'a', 'unique only', 0);
|
||||||
|
$stats_data = $sth->fetchall_hashref([ 'INDEX_NAME', 'ORDINAL_POSITION' ]);
|
||||||
|
|
||||||
|
for ($stats_data->{a_an}->{1}) {
|
||||||
|
is($_->{TABLE_NAME}, "a" , "table name");
|
||||||
|
is($_->{COLUMN_NAME}, "fname", "column name");
|
||||||
|
is($_->{TYPE}, "btree", "type");
|
||||||
|
is($_->{ORDINAL_POSITION}, 1, "ordinal position");
|
||||||
|
is($_->{NON_UNIQUE}, 0, "non unique");
|
||||||
|
is($_->{INDEX_NAME}, "a_an", "index name");
|
||||||
|
is($_->{TABLE_SCHEM}, "main", "table schema");
|
||||||
|
}
|
||||||
|
for ($stats_data->{a_an}->{2}) {
|
||||||
|
is($_->{TABLE_NAME}, "a" , "table name");
|
||||||
|
is($_->{COLUMN_NAME}, "lname", "column name");
|
||||||
|
is($_->{TYPE}, "btree", "type");
|
||||||
|
is($_->{ORDINAL_POSITION}, 2, "ordinal position");
|
||||||
|
is($_->{NON_UNIQUE}, 0, "non unique");
|
||||||
|
is($_->{INDEX_NAME}, "a_an", "index name");
|
||||||
|
is($_->{TABLE_SCHEM}, "main", "table schema");
|
||||||
|
}
|
||||||
|
ok(not(exists $stats_data->{a_ln}->{3}), "only two indexes in a_an index");
|
||||||
|
|
Loading…
Add table
Reference in a new issue