3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
15 set ::testprefix rollback2
17 proc int2hex {i} { format %.2X $i }
18 db func int2hex int2hex
21 SELECT int2hex(0), int2hex(100), int2hex(255)
24 CREATE TABLE t1(i, h);
25 CREATE INDEX i1 ON t1(h);
29 SELECT a+1, int2hex(a+1) FROM data WHERE a<40
31 INSERT INTO t1 SELECT * FROM data;
35 proc do_rollback_test {tn args} {
39 set A(-rollback) ROLLBACK
42 foreach k [array names O] {
43 if {[info exists A($k)]==0} { error "unknown option: $k" }
47 for {set iRollback 0} 1 {incr iRollback} {
48 catch { db eval ROLLBACK }
53 db eval $A(-select) x {
54 if {$i==$iRollback} { db eval $A(-rollback) }
55 foreach k $x(*) { lappend res $x($k) }
59 do_test $tn.$iRollback [list set {} $res] [list {*}$A(-result)]
60 if {$i < $iRollback} break
64 do_rollback_test 2 -setup {
66 DELETE FROM t1 WHERE (i%2)==1;
68 SELECT i FROM t1 WHERE (i%2)==0
70 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40