OLD | NEW |
| (Empty) |
1 # 2012 March 23 | |
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 set testdir [file dirname $argv0] | |
14 source $testdir/tester.tcl | |
15 ifcapable {!incrblob} { finish_test ; return } | |
16 set testprefix incrblob4 | |
17 | |
18 proc create_t1 {} { | |
19 execsql { | |
20 PRAGMA page_size = 1024; | |
21 CREATE TABLE t1(k INTEGER PRIMARY KEY, v); | |
22 } | |
23 } | |
24 | |
25 proc populate_t1 {} { | |
26 set data [list a b c d e f g h i j k l m n o p q r s t u v w x y z] | |
27 foreach d $data { | |
28 set blob [string repeat $d 900] | |
29 execsql { INSERT INTO t1(v) VALUES($blob) } | |
30 } | |
31 } | |
32 | |
33 | |
34 do_test 1.1 { | |
35 create_t1 | |
36 populate_t1 | |
37 } {} | |
38 | |
39 do_test 1.2 { | |
40 set blob [db incrblob t1 v 5] | |
41 read $blob 10 | |
42 } {eeeeeeeeee} | |
43 | |
44 do_test 1.3 { | |
45 execsql { DELETE FROM t1 } | |
46 populate_t1 | |
47 } {} | |
48 | |
49 | |
50 | |
51 do_test 2.1 { | |
52 reset_db | |
53 create_t1 | |
54 populate_t1 | |
55 } {} | |
56 | |
57 do_test 2.2 { | |
58 set blob [db incrblob t1 v 10] | |
59 read $blob 10 | |
60 } {jjjjjjjjjj} | |
61 | |
62 do_test 2.3 { | |
63 set new [string repeat % 900] | |
64 execsql { DELETE FROM t1 WHERE k=10 } | |
65 execsql { DELETE FROM t1 WHERE k=9 } | |
66 execsql { INSERT INTO t1(v) VALUES($new) } | |
67 } {} | |
68 | |
69 | |
70 | |
71 do_test 3.1 { | |
72 reset_db | |
73 create_t1 | |
74 populate_t1 | |
75 } {} | |
76 | |
77 do_test 3.2 { | |
78 set blob [db incrblob t1 v 20] | |
79 read $blob 10 | |
80 } {tttttttttt} | |
81 | |
82 do_test 3.3 { | |
83 set new [string repeat % 900] | |
84 execsql { UPDATE t1 SET v = $new WHERE k = 20 } | |
85 execsql { DELETE FROM t1 WHERE k=19 } | |
86 execsql { INSERT INTO t1(v) VALUES($new) } | |
87 } {} | |
88 | |
89 finish_test | |
OLD | NEW |