interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / ext / rbu / rbubusy.test

89 lines · 1599 bytes Raw Blame History
1# 2014 August 30
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
6# May you do good and not evil.
7# May you find forgiveness for yourself and forgive others.
8# May you share freely, never taking more than you give.
9#
10#***********************************************************************
11#
12#
13
14source [file join [file dirname [info script]] rbu_common.tcl]
15ifcapable !rbu { finish_test ; return }
16if_no_rbu_support { finish_test ; return }
17set ::testprefix rbubusy
18
19db close
20sqlite3_shutdown
21test_sqlite3_log xLog
22reset_db
23
24set db_sql {
25 CREATE TABLE t1(a PRIMARY KEY, b, c);
26 INSERT INTO t1 VALUES(1000, 2000, 3000);
27}
28
29set rbu_sql {
30 CREATE TABLE data_t1(a, b, c, rbu_control);
31 INSERT INTO data_t1 VALUES(1, 2, 3, 0);
32 INSERT INTO data_t1 VALUES(4, 5, 6, 0);
33 INSERT INTO data_t1 VALUES(7, 8, 9, 0);
34}
35
36do_test 1.1 {
37 forcedelete rbu.db
38 sqlite3 rbu rbu.db
39 rbu eval $rbu_sql
40 rbu close
41
42 db eval $db_sql
43} {}
44
45do_execsql_test 1.2 {
46 BEGIN;
47 SELECT * FROM t1
48} {1000 2000 3000}
49
50do_test 1.3 {
51 sqlite3rbu rbu test.db rbu.db
52 rbu step
53} {SQLITE_OK}
54
55do_test 1.4 {
56 while 1 {
57 set rc [rbu step]
58 if {$rc!="SQLITE_OK"} break
59 }
60 set rc
61} {SQLITE_BUSY}
62
63do_test 1.5 {
64 rbu step
65} {SQLITE_BUSY}
66
67do_test 1.6 {
68 db eval COMMIT
69 rbu step
70} {SQLITE_BUSY}
71catch { rbu close }
72
73do_test 1.7 {
74 sqlite3rbu rbu test.db rbu.db
75 while 1 {
76 set rc [rbu step]
77 if {$rc!="SQLITE_OK"} break
78 }
79 set rc
80} {SQLITE_DONE}
81
82rbu close
83
84db close
85sqlite3_shutdown
86test_sqlite3_log
87sqlite3_initialize
88finish_test
89