Discussion:
[PATCH 1/2] Document interaction $sth->finish and ROLLBACK
Yuriy M. Kaminskiy
2011-10-14 18:31:37 UTC
Permalink
---
lib/DBD/SQLite.pm | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/lib/DBD/SQLite.pm b/lib/DBD/SQLite.pm
index 094b588..5abaaaa 100644
--- a/lib/DBD/SQLite.pm
+++ b/lib/DBD/SQLite.pm
@@ -952,6 +952,31 @@ Note that this works only when all of the connections use the same
(non-deferred) transaction. See L<http://sqlite.org/lockingv3.html>
for locking details.

+=head2 C<< $sth->finish >> and Transaction Rollback
+
+Contrary to documentation on L<DBI/finish>, finishing active
+C<SELECT> statements is not optional with sqlite, otherwise
+C<ROLLBACK> will fail.
+
+ $sth = $dbh->prepare("SELECT * FROM t");
+ $dbh->begin_work;
+ eval {
+ $sth->execute;
+ $row = $sth->fetch;
+ ...
+ die "For some reason";
+ ...
+ };
+ if($@) {
+ $dbh->rollback; # UNEXPECTEDLY FAILS!
+ } else {
+ $dbh->commit;
+ }
+
+With database modification statements returning no data
+(C<INSERT>/C<DELETE>/C<UPDATE>), C<< $sth->finish >> is optional
+(and no-op), as with other DBI drivers.
+
=head2 Processing Multiple Statements At A Time

L<DBI>'s statement handle is not supposed to process multiple
--
1.7.6.4


--------------080806060901080604090503
Content-Type: text/x-diff;
name="0002-Add-workaround-to-reset-all-statements-on-dbh-rollba.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename*0="0002-Add-workaround-to-reset-all-statements-on-dbh-rollba.pa";
filename*1="tch"
Loading...