In the recent roadmap announcement, Tim Bunce wrote: > =head2 Other Enhancements > > * Support non-blocking mode for drivers that can enable it in their > client API.
I have just startedworking with DBI but I'm doing something that would benefit from a non-blocking mode. I would like a $sth->ready() function, which would start false but become true (or throw errors when RaiseError is set) when there is at least one whole row available to fetch, and a $sth->done() function to indicate that there is nothing left to fetch. The fetchrow and fetchall functions would provide as much data as has been made available so far -- fetchrow would return immediately when there is less than a row in the input buffer, fetchall would return all the whole rows that have come in so far. $h->more would be !$h->done So we'd have this: sub CheeseLister(){ $dbh = $DBI->connect($DSN,$username,$password, {RaiseError=>1,NonBlocking=>1}); $sth = $dbh->prepare('SELECT cheese FROM BigTable'); 1 while !$sth->ready; # in case prepare returned early $sth->execute(); # returns as soon as possible print "Here are the cheeses:\n"; my $continuation; $continuation = sub { $sth->ready or return undef; print @{$_},"\n" foreach ( @{$sth->fetchall_arrayref}); $sth->more; # true or false -- is there more? } } ... $CheeseEngine = Cheeselister; while($CheeseEngine()){ ... # do something else while we wait } print "\nThat's all folks!\n"; Does that match other people's thoughts on what nonblocking mode should look like? David Nicol