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

📄 lock4.test

📁 sqlite-3.4.1,嵌入式数据库.是一个功能强大的开源数据库,给学习和研发以及小型公司的发展带来了全所未有的好处.
💻 TEST
字号:
# 2007 April 6## The author disclaims copyright to this source code.  In place of# a legal notice, here is a blessing:##    May you do good and not evil.#    May you find forgiveness for yourself and forgive others.#    May you share freely, never taking more than you give.##***********************************************************************# This file implements regression tests for SQLite library.  The# focus of this script is database locks.## $Id: lock4.test,v 1.4 2007/04/06 21:42:22 drh Exp $set testdir [file dirname $argv0]source $testdir/tester.tcl# Initialize the test.db database so that it is non-empty#do_test lock4-1.1 {  db eval {     PRAGMA auto_vacuum=OFF;     CREATE TABLE t1(x);  }  file delete -force test2.db test2.db-journal  sqlite3 db2 test2.db  db2 eval {     PRAGMA auto_vacuum=OFF;     CREATE TABLE t2(x)  }  db2 close  list [file size test.db] [file size test2.db]} {2048 2048}# Create a script to drive a separate process that will##     1.  Create a second database test2.db#     2.  Get an exclusive lock on test2.db#     3.  Add an entry to test.db in table t1, waiting as necessary.#     4.  Commit the change to test2.db.## Meanwhile, this process will:# #     A.  Get an exclusive lock on test.db#     B.  Attempt to read from test2.db but get an SQLITE_BUSY error.#     C.  Commit the changes to test.db thus alloing the other process#         to continue.#do_test lock4-1.2 {  set out [open test2-script.tcl w]  puts $out "set sqlite_pending_byte [set sqlite_pending_byte]"  puts $out {     sqlite3 db2 test2.db     db2 eval {        BEGIN;        INSERT INTO t2 VALUES(2);     }     sqlite3 db test.db     db timeout 1000000     db eval {        INSERT INTO t1 VALUES(2);     }     db2 eval COMMIT     exit  }  close $out  db eval {     BEGIN;     INSERT INTO t1 VALUES(1);  }  exec [info nameofexec] ./test2-script.tcl &  while {![file exists test2.db-journal]} {    after 10  }  sqlite3 db2 test2.db  catchsql {    INSERT INTO t2 VALUES(1)  } db2} {1 {database is locked}}do_test lock4-1.3 {  db eval {     COMMIT;  }  while {[file exists test2.db-journal]} {    after 10  }  db2 eval {     SELECT * FROM t2  }} {2}    do_test lock4-999.1 {  rename db2 {}} {}finish_test

⌨️ 快捷键说明

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