mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 22:28:47 -04:00
DBD-SQLite: now BegunWork (set by begin_work) is handled properly (as requested in DBI::Changes; see notes for 1.20), and this resolved rt #48393.
In fact, it looks like I lost this code by mistake while preparing the previous release. I remember I wrote this before... I added a test for this, but as it requires the perl debugger, it is disabled by default. Wondering if we can do it without calling system() and the likes...
This commit is contained in:
parent
c2f8f58179
commit
6de5c908f7
2 changed files with 67 additions and 0 deletions
10
dbdimp.c
10
dbdimp.c
|
@ -201,6 +201,11 @@ sqlite_db_rollback(SV *dbh, imp_dbh_t *imp_dbh)
|
|||
int retval;
|
||||
char *errmsg;
|
||||
|
||||
if (DBIc_is(imp_dbh, DBIcf_BegunWork)) {
|
||||
DBIc_off(imp_dbh, DBIcf_BegunWork);
|
||||
DBIc_on(imp_dbh, DBIcf_AutoCommit);
|
||||
}
|
||||
|
||||
if (!sqlite3_get_autocommit(imp_dbh->db)) {
|
||||
sqlite_trace(dbh, (imp_xxh_t*)imp_dbh, 2, "ROLLBACK TRAN");
|
||||
if ((retval = sqlite3_exec(imp_dbh->db, "ROLLBACK TRANSACTION",
|
||||
|
@ -229,6 +234,11 @@ sqlite_db_commit(SV *dbh, imp_dbh_t *imp_dbh)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
if (DBIc_is(imp_dbh, DBIcf_BegunWork)) {
|
||||
DBIc_off(imp_dbh, DBIcf_BegunWork);
|
||||
DBIc_on(imp_dbh, DBIcf_AutoCommit);
|
||||
}
|
||||
|
||||
if (!sqlite3_get_autocommit(imp_dbh->db)) {
|
||||
sqlite_trace(dbh, (imp_xxh_t*)imp_dbh, 2, "COMMIT TRAN");
|
||||
if ((retval = sqlite3_exec(imp_dbh->db, "COMMIT TRANSACTION",
|
||||
|
|
57
t/rt_48393_debug_panic_with_commit.t
Normal file
57
t/rt_48393_debug_panic_with_commit.t
Normal file
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
BEGIN {
|
||||
$| = 1;
|
||||
$^W = 1;
|
||||
}
|
||||
|
||||
use t::lib::Test;
|
||||
use Test::More;
|
||||
|
||||
BEGIN {
|
||||
plan skip_all =>
|
||||
'set $ENV{TEST_DBD_SQLITE_WITH_DEBUGGER} '.
|
||||
'to enable this test'
|
||||
unless $ENV{TEST_DBD_SQLITE_WITH_DEBUGGER};
|
||||
}
|
||||
|
||||
use Test::NoWarnings;
|
||||
|
||||
plan tests => 2;
|
||||
|
||||
my $file = 't/panic.pl';
|
||||
open my $fh, '>', $file;
|
||||
print $fh <DATA>;
|
||||
close $fh;
|
||||
|
||||
ok !system("$^X -Mblib -d $file");
|
||||
|
||||
END {
|
||||
unlink $file if $file && -f $file;
|
||||
unlink 'test.db' if -f 'test.db';
|
||||
}
|
||||
|
||||
__DATA__
|
||||
use strict;
|
||||
use warnings;
|
||||
use DBI;
|
||||
|
||||
my $db_file = 'test.db';
|
||||
|
||||
unlink($db_file);
|
||||
die "Could not delete $db_file - $!" if(-e $db_file);
|
||||
|
||||
my $dbh = DBI->connect("dbi:SQLite:dbname=$db_file", undef, undef, {
|
||||
RaiseError => 1, AutoCommit => 1 });
|
||||
|
||||
$dbh->do('CREATE TABLE t1 (id int)');
|
||||
|
||||
$dbh->begin_work or die $dbh->errstr;
|
||||
|
||||
my $sth = $dbh->prepare('INSERT INTO t1 (id) VALUES (1)');
|
||||
$sth->execute;
|
||||
|
||||
# XXX: Panic occurs here when running under the debugger
|
||||
$dbh->commit or die $dbh->errstr;
|
||||
|
Loading…
Add table
Reference in a new issue