Debian Codegraph @

ext/rbu/rbu13.test

raw
1 # 2015 February 16
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 # Test an RBU update that features lots of different rbu_control strings
13 # for UPDATE statements. This tests RBU's internal UPDATE statement cache.
14 #
15
16 source [file join [file dirname [info script]] rbu_common.tcl]
17 if_no_rbu_support { finish_test ; return }
18 source $testdir/lock_common.tcl
19 set ::testprefix rbu13
20
21 do_execsql_test 1.0 {
22 CREATE TABLE t1(a PRIMARY KEY, b, c, d, e, f, g, h);
23 WITH ii(i) AS (SELECT 0 UNION ALL SELECT i+1 FROM ii WHERE i<127)
24 INSERT INTO t1 SELECT i, 0, 0, 0, 0, 0, 0, 0 FROM ii;
25 }
26
27 forcedelete rbu.db
28 do_execsql_test 1.1 {
29 ATTACH 'rbu.db' AS rbu;
30 CREATE TABLE rbu.data_t1(a, b, c, d, e, f, g, h, rbu_control);
31 }
32
33 do_test 1.2 {
34 for {set i 0} {$i<128} {incr i} {
35 set control "."
36 for {set bit 6} {$bit>=0} {incr bit -1} {
37 if { $i & (1<<$bit) } {
38 append control "x"
39 } else {
40 append control "."
41 }
42 }
43 execsql { INSERT INTO data_t1 VALUES($i, 1, 1, 1, 1, 1, 1, 1, $control) }
44 }
45 } {}
46
47 do_test 1.3 {
48 sqlite3rbu rbu test.db rbu.db
49 while 1 {
50 set rc [rbu step]
51 if {$rc!="SQLITE_OK"} break
52 }
53 rbu close
54 } {SQLITE_DONE}
55
56 do_execsql_test 1.4 {
57 SELECT count(*) FROM t1 WHERE
58 a == ( (b<<6) + (c<<5) + (d<<4) + (e<<3) + (f<<2) + (g<<1) + (h<<0) )
59 } {128}
60
61
62 finish_test