Index: dbdimp.c =================================================================== --- dbdimp.c (revision 6832) +++ dbdimp.c (working copy) @@ -3160,13 +3160,15 @@ do_error(sth, mysql_stmt_errno(imp_sth->stmt), mysql_stmt_error(imp_sth->stmt)); - if (rc == 100) + if (rc == MYSQL_NO_DATA) { /* Update row_num to affected_rows value */ imp_sth->row_num= mysql_stmt_affected_rows(imp_sth->stmt); imp_sth->fetch_done=1; } + dbd_st_finish(sth, imp_sth); + return Nullav; } @@ -3279,6 +3281,9 @@ if (mysql_errno(&imp_dbh->mysql)) do_error(sth, mysql_errno(&imp_dbh->mysql), mysql_error(&imp_dbh->mysql)); + + dbd_st_finish(sth, imp_sth); + return Nullav; } Index: ChangeLog =================================================================== --- ChangeLog (revision 6832) +++ ChangeLog (working copy) @@ -1,3 +1,7 @@ +2006-08-14 Jim Winstead + * Make sure to call dbd_st_finish when all rows from a statement handle + have been fetched. (Bug #20153) + 2006-06-10 Patrick Galbraith [0] eq "$table")) or print "results not equal to '$table' \n"; + Test($state or $sth->finish) + or DbiError($dbh->err, $dbh->errstr); + Test($state or $sth= $dbh->do("INSERT INTO $table VALUES (1,'1st first value')")) or DbiError($dbh->err, $dbh->errstr); @@ -128,4 +131,19 @@ Test($state or $sth->execute()) or DbiError($dbh->err, $dbh->errstr); + + # Bug #20153: Fetching all data from a statement handle does not mark it + # as finished + Test($state or $sth= $dbh->prepare("SELECT 1 FROM DUAL")) or + DbiError($dbh->err, $dbh->errstr); + Test($state or $sth->execute()) or + DbiError($dbh->err, $dbh->errstr); + Test($state or $sth->fetchrow_arrayref()) or + DbiError($dbh->err, $dbh->errstr); + Test($state or not $sth->fetchrow_arrayref()) or + DbiError($dbh->err, $dbh->errstr); + # Install a handler so that a warning about unfreed resources gets caught + $SIG{__WARN__} = sub { die @_ }; + Test($state or $dbh->disconnect()) or + DbiError($dbh->err, $dbh->errstr); }