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
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
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;
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
Subject: after execute, check inverse of AutoCommit && sqlite3_get_autocommit as well
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.
Subject: autocommit_reverse_state.patch
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));
This appears to have been fully fixed since 1.39. Please resolve.
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.