Subject: | When in async mode, fetchall_arrayref's $slice functionality is broken |
Date: | Sat, 6 Oct 2012 16:36:51 +1000 |
To: | bug-DBD-mysql [...] rt.cpan.org |
From: | Marty <mytram2 [...] gmail.com> |
Description: When in async mode, fetchall_arrayref's $slice functionality is broken because $sth's attributes cannot be fetched.
Environment:
perl 5.12.4
DBI::mysql 4.22
OS: Mac OSX 10.8.2, Linux Mint 12
Here is the code snippet to reproduce it
my $dbh = DBI->connect($dsn, $user, $pass);
my $sth = $dbh->prepare("select sleep(3) as sleep, 3 as number", { async => 1});
$sth->execute;
my $attr = $sth->FETCH('FetchHashKeyName');
print Dumper($attr);
# the NAME attribute is not populated
my $names = $sth->FETCH($attr); # $names is undef. In sync mode, this will be populated with the column names [ 'sleep', 'number']
print Dumper($names), "\n";
until($sth->mysql_async_ready) {
say 'not ready yet!';
sleep 1;
}
my $rows = $sth->fetchall_arrayref( {} ); # Fail with the following error
# Can't use an undefined value as an ARRAY reference at /Library/Perl/5.12/darwin-thread-multi-2level/DBI.pm line 2054.
Thanks