Skip Menu |
 

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

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

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

Bug Information
Severity: Important
Broken in: 1.38_01
Fixed in: 1.39



Subject: incomplete testing for transaction statements
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1349831657-15704-8"
Content-Length: 0
Content-Type: text/plain; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Length: 346
Download (untitled) / with headers
text/plain 346b
Statements such as "\nCOMMIT" do not reset AutoCommit properly, because you only check for the literal "COMMIT" or "commit". I've attached a test that demonstrates this. I recommend rewriting this part in pure perl and using a regex to match all possible variations of the "BEGIN TRAN" and "COMMIT" statements, with any amount of whitespace.
Subject: sqlite_whitespace_commit.patch
MIME-Version: 1.0
Content-Type: application/octet-stream; name="sqlite_whitespace_commit.patch"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline; filename="sqlite_whitespace_commit.patch"
Content-Transfer-Encoding: base64
Content-Length: 688
Index: t/54_literal_txn.t =================================================================== --- t/54_literal_txn.t (revision 0) +++ t/54_literal_txn.t (working copy) @@ -0,0 +1,29 @@ +#!/usr/bin/perl + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use t::lib::Test qw/connect_ok/; +use Test::More; + +my $dbh = connect_ok(); + +is $dbh->{AutoCommit}, 1, + 'AutoCommit=1 at connection'; + +$dbh->do('BEGIN TRANSACTION'); + +is $dbh->{AutoCommit}, '', + "AutoCommit='' after 'BEGIN TRANSACTION'"; + +$dbh->do("SELECT 1 FROM sqlite_master LIMIT 1"); + +$dbh->do("\nCOMMIT"); + +is $dbh->{AutoCommit}, 1, + 'AutoCommit=1 after "\nCOMMIT"'; + +done_testing;
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-32433-1349877956-1742.80087-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 164
Download (untitled) / with headers
text/plain 164b
Also should note that it should check for SQL comments in these statements as well. E.g., the following is valid: -- my DDL file -- some comment BEGIN TRANSACTION
MIME-Version: 1.0
Subject: after execute, check inverse of AutoCommit && sqlite3_get_autocommit as well
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: multipart/mixed; boundary="----------=_1350621952-31049-21"
Message-ID: <rt-3.8.HEAD-31049-1350621952-1593.80087-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 554
Download (untitled) / with headers
text/plain 554b
After an execute you check that AutoCommit is synchronized with sqlite3_get_autocommit, which is good, but it seems you only do half of the test. Attached is a patch that also checks the condition where !AutoCommit && sqlite3_get_autocommit. It's possible I'm misunderstanding something and this isn't really necessary, if so please let me know. Also it would be good to update the documentation here: https://metacpan.org/source/ADAMK/DBD-SQLite-1.37/lib/DBD/SQLite.pm#L921 since the AutoCommit state actually IS synchronized after every execute.
MIME-Version: 1.0
Subject: autocommit_reverse_state.patch
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: application/octet-stream; name="autocommit_reverse_state.patch"
Content-Disposition: inline; filename="autocommit_reverse_state.patch"
Content-Transfer-Encoding: base64
Content-Length: 655
Index: dbdimp.c =================================================================== --- dbdimp.c (revision 15601) +++ dbdimp.c (working copy) @@ -880,6 +880,10 @@ DBIc_on(imp_dbh, DBIcf_BegunWork); DBIc_off(imp_dbh, DBIcf_AutoCommit); } + else if (!DBIc_is(imp_dbh, DBIcf_AutoCommit) && sqlite3_get_autocommit(imp_dbh->db)) { + DBIc_off(imp_dbh, DBIcf_BegunWork); + DBIc_on(imp_dbh, DBIcf_AutoCommit); + } return 0; /* -> '0E0' in SQLite.xsi */ default: sqlite_error(sth, imp_sth->retval, sqlite3_errmsg(imp_dbh->db));
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.13-15943-1373032839-789.80087-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 65
This appears to have been fully fixed since 1.39. Please resolve.
MIME-Version: 1.0
In-Reply-To: <rt-4.0.13-15943-1373032839-789.80087-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.13-15943-1373032839-789.80087-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.13-18548-1373037632-1401.80087-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 149
Download (untitled) / with headers
text/plain 149b
Thanks for the heads-up. Closed. On Fri Jul 05 23:00:39 2013, RIBASUSHI wrote: Show quoted text
> This appears to have been fully fixed since 1.39. Please resolve.


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.