⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 07busy.t

📁 SinFP是一种新的识别对方计算机操作系统类型的工具
💻 T
字号:
#!perluse Test;BEGIN { plan tests => 8 }use DBI;unlink('foo', 'foo-journal');my $db = DBI->connect('dbi:SQLite:foo', '', '', {    RaiseError => 1,    PrintError => 0,    AutoCommit => 0,});my $db2 = DBI->connect('dbi:SQLite:foo', '', '', {    RaiseError => 1,    PrintError => 0,    AutoCommit => 0,});ok($db2->func(3000, 'busy_timeout'));ok($db->do("CREATE TABLE Blah ( id INTEGER, val VARCHAR )"));ok($db->commit);ok($db->do("INSERT INTO Blah VALUES ( 1, 'Test1' )"));my $start = time;eval {    $db2->do("INSERT INTO Blah VALUES ( 2, 'Test2' )");};ok($@);if ($@) {    print "# insert failed : $@";    $db2->rollback;}$db->commit;ok($db2->do("INSERT INTO Blah VALUES ( 2, 'Test2' )"));$db2->commit;$db2->disconnect;undef($db2);# Now test that two processes can write at once, assuming we commit timely.pipe(READER, WRITER);my $pid = fork;if (!defined($pid)) {    # fork failed    skip("No fork here", 1);    skip("No fork here", 1);    exit;}if ($pid) {    # parent    my $db2 = DBI->connect('dbi:SQLite:foo', '', '',     {        RaiseError => 1,        PrintError => 0,        AutoCommit => 0,    });    my $line = <READER>;    chomp($line);    ok($line, "Ready");    $db2->func(10000, 'busy_timeout');    ok($db2->do("INSERT INTO Blah VALUES (4, 'Test4' )"));    $db2->commit;    exit;}$db->do("INSERT INTO Blah VALUES ( 3, 'Test3' )");print WRITER "Ready\n";sleep(5);$db->commit; 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -