mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 14:19:10 -04:00
avoid a race condition (to resolve RT#92322)
This commit is contained in:
parent
51f8f7a7c1
commit
9dd2cb6187
3 changed files with 9 additions and 10 deletions
|
@ -11,7 +11,7 @@ use Test::More tests => 8;
|
|||
use DBI;
|
||||
use DBD::SQLite;
|
||||
|
||||
my $dbfile = 'foo';
|
||||
my $dbfile = dbfile('foo');
|
||||
unlink $dbfile if -f $dbfile;
|
||||
|
||||
{
|
||||
|
|
|
@ -11,12 +11,12 @@ use Test::More tests => 17;
|
|||
use DBI;
|
||||
use DBD::SQLite;
|
||||
|
||||
my $dbfile = 'foo';
|
||||
my $dbfile = dbfile('foo');
|
||||
my %uri = (
|
||||
base => 'file:foo',
|
||||
ro => 'file:foo?mode=ro',
|
||||
rw => 'file:foo?mode=rw',
|
||||
rwc => 'file:foo?mode=rwc',
|
||||
base => "file:$dbfile",
|
||||
ro => "file:$dbfile?mode=ro",
|
||||
rw => "file:$dbfile?mode=rw",
|
||||
rwc => "file:$dbfile?mode=rwc",
|
||||
);
|
||||
|
||||
sub cleanup {
|
||||
|
|
|
@ -25,7 +25,7 @@ BEGIN {
|
|||
# Always load the DBI module
|
||||
use DBI ();
|
||||
|
||||
sub dbfile { $dbfiles{$_[0]} }
|
||||
sub dbfile { $dbfiles{$_[0]} ||= (defined $_[0] && length $_[0] && $_[0] ne ':memory:') ? $_[0] . $$ : $_[0] }
|
||||
|
||||
# Delete temporary files
|
||||
sub clean {
|
||||
|
@ -47,9 +47,8 @@ END { clean() }
|
|||
# A simplified connect function for the most common case
|
||||
sub connect_ok {
|
||||
my $attr = { @_ };
|
||||
my $dbfile = defined $attr->{dbfile} ? delete $attr->{dbfile} : ':memory:';
|
||||
$dbfiles{$dbfile} = (defined $dbfile && length $dbfile && $dbfile ne ':memory:') ? $dbfile . $$ : $dbfile;
|
||||
my @params = ( "dbi:SQLite:dbname=$dbfiles{$dbfile}", '', '' );
|
||||
my $dbfile = dbfile(defined $attr->{dbfile} ? delete $attr->{dbfile} : ':memory:');
|
||||
my @params = ( "dbi:SQLite:dbname=$dbfile", '', '' );
|
||||
if ( %$attr ) {
|
||||
push @params, $attr;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue