Subject: | fetchall_arrayref error |
I'm not entirely sure if this is a DBD or DBI problem. But since I cannot replicate it with SQLite I will file this with you... Let me know if I should really file this under DBI instead.
In my test code below, fetchrow_arrayref gives the error:
"DBD::mysql::st fetchall_arrayref failed: fetch() without execute() at ..."
and loops forever.
If I replace [0] with undef in the fetchall_arrayref() call, it works as expected. If I use SQLite, it works as expected.
Thing is, I can see the individual rows of data being fetched when I turn on tracing.
I'm using DBI 1.38, DBD::mysql 2.9003, libmysqlclient12 4.0.16-2, perl 5.8.2. All are the standard packages from debian unstable.
test script:
######
use DBI;
my $dbh = DBI->connect('dbi:mysql:test', 'test', 'test') or die;
# my $dbh = DBI->connect('dbi:SQLite:dbname=testdb', '', '') or die;
$dbh->do($_) for (split /\s*;\s*/, <<'END_OF_SQL');
drop table foo;
create table foo ( bar int );
insert into foo (bar) values (5);
insert into foo (bar) values (4);
insert into foo (bar) values (7);
insert into foo (bar) values (1);
insert into foo (bar) values (3);
END_OF_SQL
my $sth = $dbh->prepare("select bar from foo") or die;
$sth->execute or die;
# fetchall_arrayref(undef, 3) works
while (my $rows = $sth->fetchall_arrayref([0], 3)) {
for (@$rows) {
print "got @$_\n";
}
print "---\n";
}
$sth->finish;
$dbh->disconnect;