Skip Menu |
 

This queue is for tickets about the DBD-SQLite CPAN distribution.

Report information
The Basics
Id: 52573
Status: resolved
Priority: 0/
Queue: DBD-SQLite

People
Owner: Nobody in particular
Requestors: DDICK [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.27
Fixed in: (no value)



Subject: Manual Transaction handling seems to be broken
Download (untitled) / with headers
text/plain 446b
The sqlite_st_execute function tests whether it should issue a "BEGIN TRANSACTION" statement on the users behalf. However, the test is based on the settings of AutoCommit. It does not test if the user is sending a manual transaction statement such as "BEGIN EXCLUSIVE TRANSACTION". Sqlite forbids starting two transactions at a time, so the user is unable to use the exclusive transaction setting. I've included a test to show this happening.
Subject: manual_exclusive_lock.t
#! /usr/bin/perl -w use DBI(); use DBD::SQLite 1.27; MAIN: { my ($test_database_path) = "locking_test.sdb"; my ($dbh) = DBI->connect("dbi:SQLite:$test_database_path", "", "", { 'AutoCommit' => 0, 'RaiseError' => 1, 'PrintError' => 0 }); my ($sql) = "BEGIN EXCLUSIVE TRANSACTION"; my ($sth) = $dbh->prepare($sql); $sth->execute(); unless (unlink($test_database_path)) { die("Failed to clean up '$test_database_path':$!"); } }
This is hopefully fixed in 0.28_01. Please test it against your applications/libraries and reopen this if you have further problems. Thanks. -K

On 2009-12-08 Tue 18:33:37, DDICK wrote:
Show quoted text
> The sqlite_st_execute function tests whether it should issue a "BEGIN
> TRANSACTION" statement on the users behalf. However, the test is based
> on the settings of AutoCommit. It does not test if the user is sending
> a manual transaction statement such as "BEGIN EXCLUSIVE TRANSACTION".
> Sqlite forbids starting two transactions at a time, so the user is
> unable to use the exclusive transaction setting. I've included a test
> to show this happening.

Thank you very much for this patch.  However, while it solves the original problem, another issue remains with manual transactions.  If you issue a BEGIN TRANSACTION manually and then rollback the transaction, the AutoCommit flag gets set to 1 regardless of it's original value.  See the attached test.
Subject: rollback.pl
Download rollback.pl
text/x-perl 319b
#! /usr/bin/perl use DBI(); use DBD::SQLite 1.28; use strict; use warnings; my ($dbh) = DBI->connect('dbi:SQLite:dbname=test', undef, undef, { 'AutoCommit' => 0 }); $dbh->do("BEGIN TRANSACTION"); die("Confused") unless($dbh->{'AutoCommit'} == 0); $dbh->rollback(); die("Screaming") unless($dbh->{'AutoCommit'} == 0);
Download (untitled) / with headers
text/plain 491b
Sorry for the late reply. I think this is fixed in 1.29 released last month. If the issue still lingers, reopen this. Thanks. - K On 2009-12-31 Thu 03:18:18, DDICK wrote: Show quoted text
> Thank you very much for this patch. However, while it solves the > original > problem, another issue remains with manual transactions. If you issue > a BEGIN > TRANSACTION manually and then rollback the transaction, the AutoCommit > flag > gets set to 1 regardless of it's original value. See the attached > test.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.