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

📄 capi3b.test

📁 sqlite-3.4.1,嵌入式数据库.是一个功能强大的开源数据库,给学习和研发以及小型公司的发展带来了全所未有的好处.
💻 TEST
字号:
# 2004 September 2## 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 testing the callback-free C/C++ API and in# particular the behavior of sqlite3_step() when trying to commit# with lock contention.## $Id: capi3b.test,v 1.3 2006/01/03 00:33:50 drh Exp $#set testdir [file dirname $argv0]source $testdir/tester.tclset DB [sqlite3_connection_pointer db]sqlite3 db2 test.dbset DB2 [sqlite3_connection_pointer db2]# Create some data in the database#do_test capi3b-1.1 {  execsql {    CREATE TABLE t1(x);    INSERT INTO t1 VALUES(1);    INSERT INTO t1 VALUES(2);    SELECT * FROM t1  }} {1 2}# Make sure the second database connection can see the data#do_test capi3b-1.2 {  execsql {    SELECT * FROM t1  } db2} {1 2}# First database connection acquires a shared lock#do_test capi3b-1.3 {  execsql {    BEGIN;    SELECT * FROM t1;  }} {1 2}# Second database connection tries to write.  The sqlite3_step()# function returns SQLITE_BUSY because it cannot commit.#do_test capi3b-1.4 {  set VM [sqlite3_prepare $DB2 {INSERT INTO t1 VALUES(3)} -1 TAIL]  sqlite3_step $VM} SQLITE_BUSY# The sqlite3_step call can be repeated multiple times.#do_test capi3b-1.5.1 {  sqlite3_step $VM} SQLITE_BUSYdo_test capi3b-1.5.2 {  sqlite3_step $VM} SQLITE_BUSY# The first connection closes its transaction.  This allows the second# connections sqlite3_step to succeed.#do_test capi3b-1.6 {  execsql COMMIT  sqlite3_step $VM} SQLITE_DONEdo_test capi3b-1.7 {  sqlite3_finalize $VM} SQLITE_OKdo_test capi3b-1.8 {  execsql {SELECT * FROM t1} db2} {1 2 3}do_test capi3b-1.9 {  execsql {SELECT * FROM t1}} {1 2 3}# Start doing a SELECT with one connection.  This gets a SHARED lock.# Then do an INSERT with the other connection.  The INSERT should# not be able to complete until the SELECT finishes.#do_test capi3b-2.1 {  set VM1 [sqlite3_prepare $DB {SELECT * FROM t1} -1 TAIL]  sqlite3_step $VM1} SQLITE_ROWdo_test capi3b-2.2 {  sqlite3_column_text $VM1 0} 1do_test capi3b-2.3 {  set VM2 [sqlite3_prepare $DB2 {INSERT INTO t1 VALUES(4)} -1 TAIL]  sqlite3_step $VM2} SQLITE_BUSYdo_test capi3b-2.4 {  sqlite3_step $VM1} SQLITE_ROWdo_test capi3b-2.5 {  sqlite3_column_text $VM1 0} 2do_test capi3b-2.6 {  sqlite3_step $VM2} SQLITE_BUSYdo_test capi3b-2.7 {  sqlite3_step $VM1} SQLITE_ROWdo_test capi3b-2.8 {  sqlite3_column_text $VM1 0} 3do_test capi3b-2.9 {  sqlite3_step $VM2} SQLITE_BUSYdo_test capi3b-2.10 {  sqlite3_step $VM1} SQLITE_DONEdo_test capi3b-2.11 {  sqlite3_step $VM2} SQLITE_DONEdo_test capi3b-2.12 {  sqlite3_finalize $VM1  sqlite3_finalize $VM2  execsql {SELECT * FROM t1}} {1 2 3 4}catch {db2 close}finish_test

⌨️ 快捷键说明

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