Skip Menu |

This queue is for tickets about the DBI CPAN distribution.

Report information
The Basics
Id: 28957
Status: resolved
Priority: 0/
Queue: DBI

People
Owner: Nobody in particular
Requestors: MARKOV [...] cpan.org
Cc:
AdminCc:

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



Subject: fetchall_arrayref for DBD::File says "Attempt to fetch row from a Non-SELECT statement"
Using DBD::File via DBD::CSV, I think I found the following error. In my program, CSV database is queried using a select: my $sth = $dbh->prepare( <<__QUERY_GLUE ); SELECT NAMESERVERNAAM, IP_ADRES FROM DRS_V_NS_IP_ADRES ORDER BY NAMESERVERNAAM __QUERY_GLUE while(1) { my $rows = $sth->fetchall_arrayref(undef, ROW_CACHE_SIZE); defined $rows && @$rows or return; foreach (@$rows) ... } An error is produced: DBD::CSV::st fetchall_arrayref failed: Attempt to fetch row from a Non-SELECT statement Print statements in the DBD::File and DBI show me the following. The loop is found in DBI line 7675. The first call to fetch_arrayref returns less than ROW_CACHE_SIZE elements. Then DBD::File line 465 finishes the statement. DBD::File line 453 then deletes the data record from the sth. Now, the second call to fetchall_arrayref cannot find the data-record anymore, and produces the error. Probably, the error message is not ok... it should only be produced when there is no data and !$stmt->{'NUM_OF_FIELDS'}.
Fixed in 1.603: Fixed pure-perl fetchall_arrayref with $max_rows argument to not error when fetching after all rows already fetched. (Was fixed for compiled drivers back in DBI 1.31.) Thanks to Mark Overmeer. Thanks!