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 #***********************************************************************
11 # This file implements regression tests for SQLite library.
13 # This file implements tests to verify that ticket [f777251dc7a] has been
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
25 do_test tkt-f7772-1.1 {
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);
35 proc force_rollback {} {
36 catch {db eval {INSERT OR ROLLBACK INTO t1 VALUES(1)}}
38 db function force_rollback force_rollback
40 do_test tkt-f7772-1.2 {
44 CREATE TABLE xyzzy(abc);
45 SELECT x, force_rollback(), EXISTS(SELECT 1 FROM t3 WHERE w=x) FROM t2;
47 } {1 {abort due to ROLLBACK}}
48 do_test tkt-f7772-1.3 {
49 sqlite3_get_autocommit db
52 do_test tkt-f7772-2.1 {
54 DROP TABLE IF EXISTS t1;
55 DROP TABLE IF EXISTS t2;
56 DROP TABLE IF EXISTS t3;
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);
64 do_test tkt-f7772-2.2 {
67 CREATE TEMP TABLE t3(w, z);
70 SELECT x, force_rollback(), EXISTS(SELECT 1 FROM t3 WHERE w=x) FROM t2
72 } {1 {abort due to ROLLBACK}}
73 do_test tkt-f7772-2.3 {
74 sqlite3_get_autocommit db
77 do_test tkt-f7772-3.1 {
79 DROP TABLE IF EXISTS t1;
80 DROP TABLE IF EXISTS t2;
81 DROP TABLE IF EXISTS t3;
83 CREATE TEMP TABLE t1(x);
87 INSERT INTO t1 VALUES(1);
88 INSERT INTO t1 VALUES(2);
89 INSERT INTO t2 VALUES(1);
90 INSERT INTO t2 VALUES(2);
94 proc ins {} { db eval {INSERT INTO t3 VALUES('hello')} }
97 do_test tkt-f7772-3.2 {
99 SELECT ins() AS x FROM t2 UNION ALL SELECT ins() AS x FROM t1
102 do_test tkt-f7772-3.3 {
103 execsql { SELECT * FROM t3 }
104 } {hello hello hello hello}