You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Don't call $sth->finish() when InactiveDestroy is set
DBI already calls dbd_st_finish() before dbd_st_destroy() if the handle
is active. For inactive handles no finish() should be necessary. With
InactiveDestroy set, the handle is always considered inactive. Skipping
finish() could lead to "out of sync" situations and inconsistencies,
however, the attribute is explicitly meant to skip all DB-related
destroy actions, especially for the case when the connection will be
closed anyway.
The only thing which is not cleaned up by finish() is the last result.
This commit fixes the following example:
$dbh->{'AutoInactiveDestroy'} = 1;
my $sth = $dbh->prepare('SELECT id FROM bcwb_maint_types; SELECT SLEEP(1); SELECT text FROM bcwb_maint_types;');
$sth->execute();
my $i = 0;
do {
printf "Result %d\n", ++$i;
while (my $id = $sth->fetchrow_array()) {
print $id, "\n";
}
print "---\n";
if ($i == 1) {
if (my $pid = fork()) {
waitpid($pid, 0);
} else {
exit(0);
}
}
} while ($sth->more_results);
0 commit comments