1 # 2009 October 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 # This file implements regression tests for SQLite library. 12 # 13 # This file implements tests to verify that ticket [f777251dc7a] has been 14 # fixed. 15 # 16 17 set testdir [file dirname $argv0] 18 source $testdir/tester.tcl 19 20 do_test tkt-f7772-1.1 { 21 execsql { 22 CREATE TEMP TABLE t1(x UNIQUE); 23 INSERT INTO t1 VALUES(1); 24 CREATE TABLE t2(x, y); 25 INSERT INTO t2 VALUES(1, 2); 26 CREATE TEMP TABLE t3(w, z); 27 } 28 } {} 29 30 proc force_rollback {} { 31 catch {db eval {INSERT OR ROLLBACK INTO t1 VALUES(1)}} 32 } 33 db function force_rollback force_rollback 34 35 do_test tkt-f7772-1.2 { 36 catchsql { 37 BEGIN IMMEDIATE; 38 SELECT x, force_rollback(), EXISTS(SELECT 1 FROM t3 WHERE w=x) FROM t2; 39 } 40 } {1 {callback requested query abort}} 41 do_test tkt-f7772-1.3 { 42 sqlite3_get_autocommit db 43 } {1} 44 45 do_test tkt-f7772-2.1 { 46 execsql { 47 DROP TABLE IF EXISTS t1; 48 DROP TABLE IF EXISTS t2; 49 DROP TABLE IF EXISTS t3; 50 51 CREATE TEMP TABLE t1(x UNIQUE); 52 INSERT INTO t1 VALUES(1); 53 CREATE TABLE t2(x, y); 54 INSERT INTO t2 VALUES(1, 2); 55 } 56 } {} 57 do_test tkt-f7772-2.2 { 58 execsql { 59 BEGIN IMMEDIATE; 60 CREATE TEMP TABLE t3(w, z); 61 } 62 catchsql { 63 SELECT x, force_rollback(), EXISTS(SELECT 1 FROM t3 WHERE w=x) FROM t2 64 } 65 } {1 {callback requested query abort}} 66 do_test tkt-f7772-2.3 { 67 sqlite3_get_autocommit db 68 } {1} 69 70 do_test tkt-f7772-3.1 { 71 execsql { 72 DROP TABLE IF EXISTS t1; 73 DROP TABLE IF EXISTS t2; 74 DROP TABLE IF EXISTS t3; 75 76 CREATE TEMP TABLE t1(x); 77 CREATE TABLE t2(x); 78 CREATE TABLE t3(x); 79 80 INSERT INTO t1 VALUES(1); 81 INSERT INTO t1 VALUES(2); 82 INSERT INTO t2 VALUES(1); 83 INSERT INTO t2 VALUES(2); 84 } 85 } {} 86 87 proc ins {} { db eval {INSERT INTO t3 VALUES('hello')} } 88 db function ins ins 89 90 do_test tkt-f7772-3.2 { 91 execsql { 92 SELECT ins() AS x FROM t2 UNION ALL SELECT ins() AS x FROM t1 93 } 94 } {{} {} {} {}} 95 do_test tkt-f7772-3.3 { 96 execsql { SELECT * FROM t3 } 97 } {hello hello hello hello} 98 99 finish_test 100