Do not call fetchrow_hashref() if the statement has been exhausted
Created by: muffato
Description
has_next
in Utils::Iterator
calls next
, and expects next
to repeatedly return undef once the iterator has been exhausted.
Utils::SqlHelper
can return an iterator based on the sub below, but the sub calls fetchrow_hashref()
every time it is called, even when the iterator has already reached the end.
So if you build an iterator with SqlHelper, exhaust it, and then call has_next
, you'll get this error
DBD::mysql::st fetchrow_arrayref failed: fetch() without execute() at ensembl/modules/Bio/EnsEMBL/Utils/SqlHelper.pm line 961.
My solution is to check whether the handle is still Active as it is set to false when all the rows have been retrieved (or $sth->finish
) has been called, cf https://metacpan.org/pod/DBI#Active
Testing
Have you added/modified unit tests to test the changes?
Yes.
If so, do the tests pass/fail?
Pass, of course.
Have you run the entire test suite and no regression was detected?
Yes.