Grinnz / Mojo-SQLite

Mojo::SQLite - A tiny Mojolicious wrapper for SQLite
https://metacpan.org/pod/Mojo::SQLite
Other
27 stars 12 forks source link

Results destructor may call finish on a statement handle being used in another query #2

Closed Grinnz closed 9 years ago

Grinnz commented 9 years ago

Statement handles are cached... so the same statement handle may be retrieved for another query, but the destructor for the Results object calls finish on the handle.

my $results = $db->query('select * from foo');
$results = $db->query('select * from foo');
# The assignment causes the first Results object destructor be called, calling finish on the statement handle which is still in use for the second Results object!
Grinnz commented 9 years ago

This only happens if the first $results handle is rendered inactive by retrieving all results or ->finish, so that the second query reuses the cached handle.