Commit ff8dc1d
committed
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);1 parent b1f4834 commit ff8dc1d
1 file changed
+2
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5441 | 5441 | | |
5442 | 5442 | | |
5443 | 5443 | | |
5444 | | - | |
5445 | | - | |
5446 | | - | |
5447 | | - | |
5448 | | - | |
5449 | | - | |
5450 | | - | |
| 5444 | + | |
| 5445 | + | |
5451 | 5446 | | |
5452 | 5447 | | |
5453 | 5448 | | |
| |||
0 commit comments