OLD | NEW |
(Empty) | |
| 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 ifcapable !compound { |
| 21 finish_test |
| 22 return |
| 23 } |
| 24 |
| 25 do_test tkt-f7772-1.1 { |
| 26 execsql { |
| 27 CREATE TEMP TABLE t1(x UNIQUE); |
| 28 INSERT INTO t1 VALUES(1); |
| 29 CREATE TABLE t2(x, y); |
| 30 INSERT INTO t2 VALUES(1, 2); |
| 31 CREATE TEMP TABLE t3(w, z); |
| 32 } |
| 33 } {} |
| 34 |
| 35 proc force_rollback {} { |
| 36 catch {db eval {INSERT OR ROLLBACK INTO t1 VALUES(1)}} |
| 37 } |
| 38 db function force_rollback force_rollback |
| 39 |
| 40 do_test tkt-f7772-1.2 { |
| 41 breakpoint |
| 42 catchsql { |
| 43 BEGIN IMMEDIATE; |
| 44 CREATE TABLE xyzzy(abc); |
| 45 SELECT x, force_rollback(), EXISTS(SELECT 1 FROM t3 WHERE w=x) FROM t2; |
| 46 } |
| 47 } {1 {abort due to ROLLBACK}} |
| 48 do_test tkt-f7772-1.3 { |
| 49 sqlite3_get_autocommit db |
| 50 } {1} |
| 51 |
| 52 do_test tkt-f7772-2.1 { |
| 53 execsql { |
| 54 DROP TABLE IF EXISTS t1; |
| 55 DROP TABLE IF EXISTS t2; |
| 56 DROP TABLE IF EXISTS t3; |
| 57 |
| 58 CREATE TEMP TABLE t1(x UNIQUE); |
| 59 INSERT INTO t1 VALUES(1); |
| 60 CREATE TABLE t2(x, y); |
| 61 INSERT INTO t2 VALUES(1, 2); |
| 62 } |
| 63 } {} |
| 64 do_test tkt-f7772-2.2 { |
| 65 execsql { |
| 66 BEGIN IMMEDIATE; |
| 67 CREATE TEMP TABLE t3(w, z); |
| 68 } |
| 69 catchsql { |
| 70 SELECT x, force_rollback(), EXISTS(SELECT 1 FROM t3 WHERE w=x) FROM t2 |
| 71 } |
| 72 } {1 {abort due to ROLLBACK}} |
| 73 do_test tkt-f7772-2.3 { |
| 74 sqlite3_get_autocommit db |
| 75 } {1} |
| 76 |
| 77 do_test tkt-f7772-3.1 { |
| 78 execsql { |
| 79 DROP TABLE IF EXISTS t1; |
| 80 DROP TABLE IF EXISTS t2; |
| 81 DROP TABLE IF EXISTS t3; |
| 82 |
| 83 CREATE TEMP TABLE t1(x); |
| 84 CREATE TABLE t2(x); |
| 85 CREATE TABLE t3(x); |
| 86 |
| 87 INSERT INTO t1 VALUES(1); |
| 88 INSERT INTO t1 VALUES(2); |
| 89 INSERT INTO t2 VALUES(1); |
| 90 INSERT INTO t2 VALUES(2); |
| 91 } |
| 92 } {} |
| 93 |
| 94 proc ins {} { db eval {INSERT INTO t3 VALUES('hello')} } |
| 95 db function ins ins |
| 96 |
| 97 do_test tkt-f7772-3.2 { |
| 98 execsql { |
| 99 SELECT ins() AS x FROM t2 UNION ALL SELECT ins() AS x FROM t1 |
| 100 } |
| 101 } {{} {} {} {}} |
| 102 do_test tkt-f7772-3.3 { |
| 103 execsql { SELECT * FROM t3 } |
| 104 } {hello hello hello hello} |
| 105 |
| 106 finish_test |
OLD | NEW |