2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A# 2002 January 29
2N/A#
2N/A# The author disclaims copyright to this source code. In place of
2N/A# a legal notice, here is a blessing:
2N/A#
2N/A# May you do good and not evil.
2N/A# May you find forgiveness for yourself and forgive others.
2N/A# May you share freely, never taking more than you give.
2N/A#
2N/A#***********************************************************************
2N/A# This file implements regression tests for SQLite library.
2N/A#
2N/A# This file implements tests for the conflict resolution extension
2N/A# to SQLite.
2N/A#
2N/A# $Id: conflict.test,v 1.19 2003/08/05 13:13:39 drh Exp $
2N/A
2N/Aset testdir [file dirname $argv0]
2N/Asource $testdir/tester.tcl
2N/A
2N/A# Create tables for the first group of tests.
2N/A#
2N/Ado_test conflict-1.0 {
2N/A execsql {
2N/A CREATE TABLE t1(a, b, c, UNIQUE(a,b));
2N/A CREATE TABLE t2(x);
2N/A SELECT c FROM t1 ORDER BY c;
2N/A }
2N/A} {}
2N/A
2N/A# Six columns of configuration data as follows:
2N/A#
2N/A# i The reference number of the test
2N/A# conf The conflict resolution algorithm on the BEGIN statement
2N/A# cmd An INSERT or REPLACE command to execute against table t1
2N/A# t0 True if there is an error from $cmd
2N/A# t1 Content of "c" column of t1 assuming no error in $cmd
2N/A# t2 Content of "x" column of t2
2N/A#
2N/Aforeach {i conf cmd t0 t1 t2} {
2N/A 1 {} INSERT 1 {} 1
2N/A 2 {} {INSERT OR IGNORE} 0 3 1
2N/A 3 {} {INSERT OR REPLACE} 0 4 1
2N/A 4 {} REPLACE 0 4 1
2N/A 5 {} {INSERT OR FAIL} 1 {} 1
2N/A 6 {} {INSERT OR ABORT} 1 {} 1
2N/A 7 {} {INSERT OR ROLLBACK} 1 {} {}
2N/A 8 IGNORE INSERT 0 3 1
2N/A 9 IGNORE {INSERT OR IGNORE} 0 3 1
2N/A 10 IGNORE {INSERT OR REPLACE} 0 4 1
2N/A 11 IGNORE REPLACE 0 4 1
2N/A 12 IGNORE {INSERT OR FAIL} 1 {} 1
2N/A 13 IGNORE {INSERT OR ABORT} 1 {} 1
2N/A 14 IGNORE {INSERT OR ROLLBACK} 1 {} {}
2N/A 15 REPLACE INSERT 0 4 1
2N/A 16 FAIL INSERT 1 {} 1
2N/A 17 ABORT INSERT 1 {} 1
2N/A 18 ROLLBACK INSERT 1 {} {}
2N/A} {
2N/A do_test conflict-1.$i {
2N/A if {$conf!=""} {set conf "ON CONFLICT $conf"}
2N/A set r0 [catch {execsql [subst {
2N/A DELETE FROM t1;
2N/A DELETE FROM t2;
2N/A INSERT INTO t1 VALUES(1,2,3);
2N/A BEGIN $conf;
2N/A INSERT INTO t2 VALUES(1);
2N/A $cmd INTO t1 VALUES(1,2,4);
2N/A }]} r1]
2N/A catch {execsql {COMMIT}}
2N/A if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}
2N/A set r2 [execsql {SELECT x FROM t2}]
2N/A list $r0 $r1 $r2
2N/A } [list $t0 $t1 $t2]
2N/A}
2N/A
2N/A# Create tables for the first group of tests.
2N/A#
2N/Ado_test conflict-2.0 {
2N/A execsql {
2N/A DROP TABLE t1;
2N/A DROP TABLE t2;
2N/A CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(a,b));
2N/A CREATE TABLE t2(x);
2N/A SELECT c FROM t1 ORDER BY c;
2N/A }
2N/A} {}
2N/A
2N/A# Six columns of configuration data as follows:
2N/A#
2N/A# i The reference number of the test
2N/A# conf The conflict resolution algorithm on the BEGIN statement
2N/A# cmd An INSERT or REPLACE command to execute against table t1
2N/A# t0 True if there is an error from $cmd
2N/A# t1 Content of "c" column of t1 assuming no error in $cmd
2N/A# t2 Content of "x" column of t2
2N/A#
2N/Aforeach {i conf cmd t0 t1 t2} {
2N/A 1 {} INSERT 1 {} 1
2N/A 2 {} {INSERT OR IGNORE} 0 3 1
2N/A 3 {} {INSERT OR REPLACE} 0 4 1
2N/A 4 {} REPLACE 0 4 1
2N/A 5 {} {INSERT OR FAIL} 1 {} 1
2N/A 6 {} {INSERT OR ABORT} 1 {} 1
2N/A 7 {} {INSERT OR ROLLBACK} 1 {} {}
2N/A 8 IGNORE INSERT 0 3 1
2N/A 9 IGNORE {INSERT OR IGNORE} 0 3 1
2N/A 10 IGNORE {INSERT OR REPLACE} 0 4 1
2N/A 11 IGNORE REPLACE 0 4 1
2N/A 12 IGNORE {INSERT OR FAIL} 1 {} 1
2N/A 13 IGNORE {INSERT OR ABORT} 1 {} 1
2N/A 14 IGNORE {INSERT OR ROLLBACK} 1 {} {}
2N/A 15 REPLACE INSERT 0 4 1
2N/A 16 FAIL INSERT 1 {} 1
2N/A 17 ABORT INSERT 1 {} 1
2N/A 18 ROLLBACK INSERT 1 {} {}
2N/A} {
2N/A do_test conflict-2.$i {
2N/A if {$conf!=""} {set conf "ON CONFLICT $conf"}
2N/A set r0 [catch {execsql [subst {
2N/A DELETE FROM t1;
2N/A DELETE FROM t2;
2N/A INSERT INTO t1 VALUES(1,2,3);
2N/A BEGIN $conf;
2N/A INSERT INTO t2 VALUES(1);
2N/A $cmd INTO t1 VALUES(1,2,4);
2N/A }]} r1]
2N/A catch {execsql {COMMIT}}
2N/A if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}
2N/A set r2 [execsql {SELECT x FROM t2}]
2N/A list $r0 $r1 $r2
2N/A } [list $t0 $t1 $t2]
2N/A}
2N/A
2N/A# Create tables for the first group of tests.
2N/A#
2N/Ado_test conflict-3.0 {
2N/A execsql {
2N/A DROP TABLE t1;
2N/A DROP TABLE t2;
2N/A CREATE TABLE t1(a, b, c INTEGER, PRIMARY KEY(c), UNIQUE(a,b));
2N/A CREATE TABLE t2(x);
2N/A SELECT c FROM t1 ORDER BY c;
2N/A }
2N/A} {}
2N/A
2N/A# Six columns of configuration data as follows:
2N/A#
2N/A# i The reference number of the test
2N/A# conf The conflict resolution algorithm on the BEGIN statement
2N/A# cmd An INSERT or REPLACE command to execute against table t1
2N/A# t0 True if there is an error from $cmd
2N/A# t1 Content of "c" column of t1 assuming no error in $cmd
2N/A# t2 Content of "x" column of t2
2N/A#
2N/Aforeach {i conf cmd t0 t1 t2} {
2N/A 1 {} INSERT 1 {} 1
2N/A 2 {} {INSERT OR IGNORE} 0 3 1
2N/A 3 {} {INSERT OR REPLACE} 0 4 1
2N/A 4 {} REPLACE 0 4 1
2N/A 5 {} {INSERT OR FAIL} 1 {} 1
2N/A 6 {} {INSERT OR ABORT} 1 {} 1
2N/A 7 {} {INSERT OR ROLLBACK} 1 {} {}
2N/A 8 IGNORE INSERT 0 3 1
2N/A 9 IGNORE {INSERT OR IGNORE} 0 3 1
2N/A 10 IGNORE {INSERT OR REPLACE} 0 4 1
2N/A 11 IGNORE REPLACE 0 4 1
2N/A 12 IGNORE {INSERT OR FAIL} 1 {} 1
2N/A 13 IGNORE {INSERT OR ABORT} 1 {} 1
2N/A 14 IGNORE {INSERT OR ROLLBACK} 1 {} {}
2N/A 15 REPLACE INSERT 0 4 1
2N/A 16 FAIL INSERT 1 {} 1
2N/A 17 ABORT INSERT 1 {} 1
2N/A 18 ROLLBACK INSERT 1 {} {}
2N/A} {
2N/A do_test conflict-3.$i {
2N/A if {$conf!=""} {set conf "ON CONFLICT $conf"}
2N/A set r0 [catch {execsql [subst {
2N/A DELETE FROM t1;
2N/A DELETE FROM t2;
2N/A INSERT INTO t1 VALUES(1,2,3);
2N/A BEGIN $conf;
2N/A INSERT INTO t2 VALUES(1);
2N/A $cmd INTO t1 VALUES(1,2,4);
2N/A }]} r1]
2N/A catch {execsql {COMMIT}}
2N/A if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}
2N/A set r2 [execsql {SELECT x FROM t2}]
2N/A list $r0 $r1 $r2
2N/A } [list $t0 $t1 $t2]
2N/A}
2N/A
2N/Ado_test conflict-4.0 {
2N/A execsql {
2N/A DROP TABLE t2;
2N/A CREATE TABLE t2(x);
2N/A SELECT x FROM t2;
2N/A }
2N/A} {}
2N/A
2N/A# Six columns of configuration data as follows:
2N/A#
2N/A# i The reference number of the test
2N/A# conf1 The conflict resolution algorithm on the UNIQUE constraint
2N/A# conf2 The conflict resolution algorithm on the BEGIN statement
2N/A# cmd An INSERT or REPLACE command to execute against table t1
2N/A# t0 True if there is an error from $cmd
2N/A# t1 Content of "c" column of t1 assuming no error in $cmd
2N/A# t2 Content of "x" column of t2
2N/A#
2N/Aforeach {i conf1 conf2 cmd t0 t1 t2} {
2N/A 1 {} {} INSERT 1 {} 1
2N/A 2 REPLACE {} INSERT 0 4 1
2N/A 3 IGNORE {} INSERT 0 3 1
2N/A 4 FAIL {} INSERT 1 {} 1
2N/A 5 ABORT {} INSERT 1 {} 1
2N/A 6 ROLLBACK {} INSERT 1 {} {}
2N/A 7 REPLACE {} {INSERT OR IGNORE} 0 3 1
2N/A 8 IGNORE {} {INSERT OR REPLACE} 0 4 1
2N/A 9 FAIL {} {INSERT OR IGNORE} 0 3 1
2N/A 10 ABORT {} {INSERT OR REPLACE} 0 4 1
2N/A 11 ROLLBACK {} {INSERT OR IGNORE } 0 3 1
2N/A 12 REPLACE IGNORE INSERT 0 3 1
2N/A 13 IGNORE REPLACE INSERT 0 4 1
2N/A 14 FAIL IGNORE INSERT 0 3 1
2N/A 15 ABORT REPLACE INSERT 0 4 1
2N/A 16 ROLLBACK IGNORE INSERT 0 3 1
2N/A 12 IGNORE REPLACE INSERT 0 4 1
2N/A 13 IGNORE FAIL INSERT 1 {} 1
2N/A 14 IGNORE ABORT INSERT 1 {} 1
2N/A 15 IGNORE ROLLBACK INSERT 1 {} {}
2N/A} {
2N/A do_test conflict-4.$i {
2N/A if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
2N/A if {$conf2!=""} {set conf2 "ON CONFLICT $conf2"}
2N/A set r0 [catch {execsql [subst {
2N/A DROP TABLE t1;
2N/A CREATE TABLE t1(a,b,c,UNIQUE(a,b) $conf1);
2N/A DELETE FROM t2;
2N/A INSERT INTO t1 VALUES(1,2,3);
2N/A BEGIN $conf2;
2N/A INSERT INTO t2 VALUES(1);
2N/A $cmd INTO t1 VALUES(1,2,4);
2N/A }]} r1]
2N/A catch {execsql {COMMIT}}
2N/A if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}
2N/A set r2 [execsql {SELECT x FROM t2}]
2N/A list $r0 $r1 $r2
2N/A } [list $t0 $t1 $t2]
2N/A}
2N/A
2N/Ado_test conflict-5.0 {
2N/A execsql {
2N/A DROP TABLE t2;
2N/A CREATE TABLE t2(x);
2N/A SELECT x FROM t2;
2N/A }
2N/A} {}
2N/A
2N/A# Six columns of configuration data as follows:
2N/A#
2N/A# i The reference number of the test
2N/A# conf1 The conflict resolution algorithm on the NOT NULL constraint
2N/A# conf2 The conflict resolution algorithm on the BEGIN statement
2N/A# cmd An INSERT or REPLACE command to execute against table t1
2N/A# t0 True if there is an error from $cmd
2N/A# t1 Content of "c" column of t1 assuming no error in $cmd
2N/A# t2 Content of "x" column of t2
2N/A#
2N/Aforeach {i conf1 conf2 cmd t0 t1 t2} {
2N/A 1 {} {} INSERT 1 {} 1
2N/A 2 REPLACE {} INSERT 0 5 1
2N/A 3 IGNORE {} INSERT 0 {} 1
2N/A 4 FAIL {} INSERT 1 {} 1
2N/A 5 ABORT {} INSERT 1 {} 1
2N/A 6 ROLLBACK {} INSERT 1 {} {}
2N/A 7 REPLACE {} {INSERT OR IGNORE} 0 {} 1
2N/A 8 IGNORE {} {INSERT OR REPLACE} 0 5 1
2N/A 9 FAIL {} {INSERT OR IGNORE} 0 {} 1
2N/A 10 ABORT {} {INSERT OR REPLACE} 0 5 1
2N/A 11 ROLLBACK {} {INSERT OR IGNORE} 0 {} 1
2N/A 12 {} {} {INSERT OR IGNORE} 0 {} 1
2N/A 13 {} {} {INSERT OR REPLACE} 0 5 1
2N/A 14 {} {} {INSERT OR FAIL} 1 {} 1
2N/A 15 {} {} {INSERT OR ABORT} 1 {} 1
2N/A 16 {} {} {INSERT OR ROLLBACK} 1 {} {}
2N/A 17 {} IGNORE INSERT 0 {} 1
2N/A 18 {} REPLACE INSERT 0 5 1
2N/A 19 {} FAIL INSERT 1 {} 1
2N/A 20 {} ABORT INSERT 1 {} 1
2N/A 21 {} ROLLBACK INSERT 1 {} {}
2N/A 22 REPLACE FAIL INSERT 1 {} 1
2N/A 23 IGNORE ROLLBACK INSERT 1 {} {}
2N/A} {
2N/A if {$t0} {set t1 {t1.c may not be NULL}}
2N/A do_test conflict-5.$i {
2N/A if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
2N/A if {$conf2!=""} {set conf2 "ON CONFLICT $conf2"}
2N/A set r0 [catch {execsql [subst {
2N/A DROP TABLE t1;
2N/A CREATE TABLE t1(a,b,c NOT NULL $conf1 DEFAULT 5);
2N/A DELETE FROM t2;
2N/A BEGIN $conf2;
2N/A INSERT INTO t2 VALUES(1);
2N/A $cmd INTO t1 VALUES(1,2,NULL);
2N/A }]} r1]
2N/A catch {execsql {COMMIT}}
2N/A if {!$r0} {set r1 [execsql {SELECT c FROM t1}]}
2N/A set r2 [execsql {SELECT x FROM t2}]
2N/A list $r0 $r1 $r2
2N/A } [list $t0 $t1 $t2]
2N/A}
2N/A
2N/Ado_test conflict-6.0 {
2N/A execsql {
2N/A DROP TABLE t2;
2N/A CREATE TABLE t2(a,b,c);
2N/A INSERT INTO t2 VALUES(1,2,1);
2N/A INSERT INTO t2 VALUES(2,3,2);
2N/A INSERT INTO t2 VALUES(3,4,1);
2N/A INSERT INTO t2 VALUES(4,5,4);
2N/A SELECT c FROM t2 ORDER BY b;
2N/A CREATE TABLE t3(x);
2N/A INSERT INTO t3 VALUES(1);
2N/A }
2N/A} {1 2 1 4}
2N/A
2N/A# Six columns of configuration data as follows:
2N/A#
2N/A# i The reference number of the test
2N/A# conf1 The conflict resolution algorithm on the UNIQUE constraint
2N/A# conf2 The conflict resolution algorithm on the BEGIN statement
2N/A# cmd An UPDATE command to execute against table t1
2N/A# t0 True if there is an error from $cmd
2N/A# t1 Content of "b" column of t1 assuming no error in $cmd
2N/A# t2 Content of "x" column of t3
2N/A#
2N/Aforeach {i conf1 conf2 cmd t0 t1 t2} {
2N/A 1 {} {} UPDATE 1 {6 7 8 9} 1
2N/A 2 REPLACE {} UPDATE 0 {7 6 9} 1
2N/A 3 IGNORE {} UPDATE 0 {6 7 3 9} 1
2N/A 4 FAIL {} UPDATE 1 {6 7 3 4} 1
2N/A 5 ABORT {} UPDATE 1 {1 2 3 4} 1
2N/A 6 ROLLBACK {} UPDATE 1 {1 2 3 4} 0
2N/A 7 REPLACE {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1
2N/A 8 IGNORE {} {UPDATE OR REPLACE} 0 {7 6 9} 1
2N/A 9 FAIL {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1
2N/A 10 ABORT {} {UPDATE OR REPLACE} 0 {7 6 9} 1
2N/A 11 ROLLBACK {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1
2N/A 12 {} {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1
2N/A 13 {} {} {UPDATE OR REPLACE} 0 {7 6 9} 1
2N/A 14 {} {} {UPDATE OR FAIL} 1 {6 7 3 4} 1
2N/A 15 {} {} {UPDATE OR ABORT} 1 {1 2 3 4} 1
2N/A 16 {} {} {UPDATE OR ROLLBACK} 1 {1 2 3 4} 0
2N/A 17 {} IGNORE UPDATE 0 {6 7 3 9} 1
2N/A 18 {} REPLACE UPDATE 0 {7 6 9} 1
2N/A 19 {} FAIL UPDATE 1 {6 7 3 4} 1
2N/A 20 {} ABORT UPDATE 1 {1 2 3 4} 1
2N/A 21 {} ROLLBACK UPDATE 1 {1 2 3 4} 0
2N/A 22 REPLACE IGNORE UPDATE 0 {6 7 3 9} 1
2N/A 23 IGNORE REPLACE UPDATE 0 {7 6 9} 1
2N/A 24 REPLACE FAIL UPDATE 1 {6 7 3 4} 1
2N/A 25 IGNORE ABORT UPDATE 1 {1 2 3 4} 1
2N/A 26 REPLACE ROLLBACK UPDATE 1 {1 2 3 4} 0
2N/A} {
2N/A if {$t0} {set t1 {column a is not unique}}
2N/A do_test conflict-6.$i {
2N/A if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
2N/A if {$conf2!=""} {set conf2 "ON CONFLICT $conf2"}
2N/A set r0 [catch {execsql [subst {
2N/A DROP TABLE t1;
2N/A CREATE TABLE t1(a,b,c, UNIQUE(a) $conf1);
2N/A INSERT INTO t1 SELECT * FROM t2;
2N/A UPDATE t3 SET x=0;
2N/A BEGIN $conf2;
2N/A $cmd t3 SET x=1;
2N/A $cmd t1 SET b=b*2;
2N/A $cmd t1 SET a=c+5;
2N/A }]} r1]
2N/A catch {execsql {COMMIT}}
2N/A if {!$r0} {set r1 [execsql {SELECT a FROM t1 ORDER BY b}]}
2N/A set r2 [execsql {SELECT x FROM t3}]
2N/A list $r0 $r1 $r2
2N/A } [list $t0 $t1 $t2]
2N/A}
2N/A
2N/A# Test to make sure a lot of IGNOREs don't cause a stack overflow
2N/A#
2N/Ado_test conflict-7.1 {
2N/A execsql {
2N/A DROP TABLE t1;
2N/A DROP TABLE t2;
2N/A DROP TABLE t3;
2N/A CREATE TABLE t1(a unique, b);
2N/A }
2N/A for {set i 1} {$i<=50} {incr i} {
2N/A execsql "INSERT into t1 values($i,[expr {$i+1}]);"
2N/A }
2N/A execsql {
2N/A SELECT count(*), min(a), max(b) FROM t1;
2N/A }
2N/A} {50 1 51}
2N/Ado_test conflict-7.2 {
2N/A execsql {
2N/A PRAGMA count_changes=on;
2N/A UPDATE OR IGNORE t1 SET a=1000;
2N/A }
2N/A} {1}
2N/Ado_test conflict-7.2.1 {
2N/A db changes
2N/A} {1}
2N/Ado_test conflict-7.3 {
2N/A execsql {
2N/A SELECT b FROM t1 WHERE a=1000;
2N/A }
2N/A} {2}
2N/Ado_test conflict-7.4 {
2N/A execsql {
2N/A SELECT count(*) FROM t1;
2N/A }
2N/A} {50}
2N/Ado_test conflict-7.5 {
2N/A execsql {
2N/A PRAGMA count_changes=on;
2N/A UPDATE OR REPLACE t1 SET a=1001;
2N/A }
2N/A} {50}
2N/Ado_test conflict-7.5.1 {
2N/A db changes
2N/A} {50}
2N/Ado_test conflict-7.6 {
2N/A execsql {
2N/A SELECT b FROM t1 WHERE a=1001;
2N/A }
2N/A} {51}
2N/Ado_test conflict-7.7 {
2N/A execsql {
2N/A SELECT count(*) FROM t1;
2N/A }
2N/A} {1}
2N/Ado_test conflict-7.7.1 {
2N/A db changes
2N/A} {0}
2N/A
2N/A# Make sure the row count is right for rows that are ignored on
2N/A# an insert.
2N/A#
2N/Ado_test conflict-8.1 {
2N/A execsql {
2N/A DELETE FROM t1;
2N/A INSERT INTO t1 VALUES(1,2);
2N/A }
2N/A execsql {
2N/A INSERT OR IGNORE INTO t1 VALUES(2,3);
2N/A }
2N/A} {1}
2N/Ado_test conflict-8.1.1 {
2N/A db changes
2N/A} {1}
2N/Ado_test conflict-8.2 {
2N/A execsql {
2N/A INSERT OR IGNORE INTO t1 VALUES(2,4);
2N/A }
2N/A} {0}
2N/Ado_test conflict-8.2.1 {
2N/A db changes
2N/A} {0}
2N/Ado_test conflict-8.3 {
2N/A execsql {
2N/A INSERT OR REPLACE INTO t1 VALUES(2,4);
2N/A }
2N/A} {1}
2N/Ado_test conflict-8.3.1 {
2N/A db changes
2N/A} {1}
2N/Ado_test conflict-8.4 {
2N/A execsql {
2N/A INSERT OR IGNORE INTO t1 SELECT * FROM t1;
2N/A }
2N/A} {0}
2N/Ado_test conflict-8.4.1 {
2N/A db changes
2N/A} {0}
2N/Ado_test conflict-8.5 {
2N/A execsql {
2N/A INSERT OR IGNORE INTO t1 SELECT a+2,b+2 FROM t1;
2N/A }
2N/A} {2}
2N/Ado_test conflict-8.5.1 {
2N/A db changes
2N/A} {2}
2N/Ado_test conflict-8.6 {
2N/A execsql {
2N/A INSERT OR IGNORE INTO t1 SELECT a+3,b+3 FROM t1;
2N/A }
2N/A} {3}
2N/Ado_test conflict-8.6.1 {
2N/A db changes
2N/A} {3}
2N/A
2N/Aintegrity_check conflict-8.99
2N/A
2N/Ado_test conflict-9.1 {
2N/A execsql {
2N/A PRAGMA count_changes=0;
2N/A CREATE TABLE t2(
2N/A a INTEGER UNIQUE ON CONFLICT IGNORE,
2N/A b INTEGER UNIQUE ON CONFLICT FAIL,
2N/A c INTEGER UNIQUE ON CONFLICT REPLACE,
2N/A d INTEGER UNIQUE ON CONFLICT ABORT,
2N/A e INTEGER UNIQUE ON CONFLICT ROLLBACK
2N/A );
2N/A CREATE TABLE t3(x);
2N/A INSERT INTO t3 VALUES(1);
2N/A SELECT * FROM t3;
2N/A }
2N/A} {1}
2N/Ado_test conflict-9.2 {
2N/A catchsql {
2N/A INSERT INTO t2 VALUES(1,1,1,1,1);
2N/A INSERT INTO t2 VALUES(2,2,2,2,2);
2N/A SELECT * FROM t2;
2N/A }
2N/A} {0 {1 1 1 1 1 2 2 2 2 2}}
2N/Ado_test conflict-9.3 {
2N/A catchsql {
2N/A INSERT INTO t2 VALUES(1,3,3,3,3);
2N/A SELECT * FROM t2;
2N/A }
2N/A} {0 {1 1 1 1 1 2 2 2 2 2}}
2N/Ado_test conflict-9.4 {
2N/A catchsql {
2N/A UPDATE t2 SET a=a+1 WHERE a=1;
2N/A SELECT * FROM t2;
2N/A }
2N/A} {0 {1 1 1 1 1 2 2 2 2 2}}
2N/Ado_test conflict-9.5 {
2N/A catchsql {
2N/A INSERT INTO t2 VALUES(3,1,3,3,3);
2N/A SELECT * FROM t2;
2N/A }
2N/A} {1 {column b is not unique}}
2N/Ado_test conflict-9.6 {
2N/A catchsql {
2N/A UPDATE t2 SET b=b+1 WHERE b=1;
2N/A SELECT * FROM t2;
2N/A }
2N/A} {1 {column b is not unique}}
2N/Ado_test conflict-9.7 {
2N/A catchsql {
2N/A BEGIN;
2N/A UPDATE t3 SET x=x+1;
2N/A INSERT INTO t2 VALUES(3,1,3,3,3);
2N/A SELECT * FROM t2;
2N/A }
2N/A} {1 {column b is not unique}}
2N/Ado_test conflict-9.8 {
2N/A execsql {COMMIT}
2N/A execsql {SELECT * FROM t3}
2N/A} {2}
2N/Ado_test conflict-9.9 {
2N/A catchsql {
2N/A BEGIN;
2N/A UPDATE t3 SET x=x+1;
2N/A UPDATE t2 SET b=b+1 WHERE b=1;
2N/A SELECT * FROM t2;
2N/A }
2N/A} {1 {column b is not unique}}
2N/Ado_test conflict-9.10 {
2N/A execsql {COMMIT}
2N/A execsql {SELECT * FROM t3}
2N/A} {3}
2N/Ado_test conflict-9.11 {
2N/A catchsql {
2N/A INSERT INTO t2 VALUES(3,3,3,1,3);
2N/A SELECT * FROM t2;
2N/A }
2N/A} {1 {column d is not unique}}
2N/Ado_test conflict-9.12 {
2N/A catchsql {
2N/A UPDATE t2 SET d=d+1 WHERE d=1;
2N/A SELECT * FROM t2;
2N/A }
2N/A} {1 {column d is not unique}}
2N/Ado_test conflict-9.13 {
2N/A catchsql {
2N/A BEGIN;
2N/A UPDATE t3 SET x=x+1;
2N/A INSERT INTO t2 VALUES(3,3,3,1,3);
2N/A SELECT * FROM t2;
2N/A }
2N/A} {1 {column d is not unique}}
2N/Ado_test conflict-9.14 {
2N/A execsql {COMMIT}
2N/A execsql {SELECT * FROM t3}
2N/A} {4}
2N/Ado_test conflict-9.15 {
2N/A catchsql {
2N/A BEGIN;
2N/A UPDATE t3 SET x=x+1;
2N/A UPDATE t2 SET d=d+1 WHERE d=1;
2N/A SELECT * FROM t2;
2N/A }
2N/A} {1 {column d is not unique}}
2N/Ado_test conflict-9.16 {
2N/A execsql {COMMIT}
2N/A execsql {SELECT * FROM t3}
2N/A} {5}
2N/Ado_test conflict-9.17 {
2N/A catchsql {
2N/A INSERT INTO t2 VALUES(3,3,3,3,1);
2N/A SELECT * FROM t2;
2N/A }
2N/A} {1 {column e is not unique}}
2N/Ado_test conflict-9.18 {
2N/A catchsql {
2N/A UPDATE t2 SET e=e+1 WHERE e=1;
2N/A SELECT * FROM t2;
2N/A }
2N/A} {1 {column e is not unique}}
2N/Ado_test conflict-9.19 {
2N/A catchsql {
2N/A BEGIN;
2N/A UPDATE t3 SET x=x+1;
2N/A INSERT INTO t2 VALUES(3,3,3,3,1);
2N/A SELECT * FROM t2;
2N/A }
2N/A} {1 {column e is not unique}}
2N/Ado_test conflict-9.20 {
2N/A catch {execsql {COMMIT}}
2N/A execsql {SELECT * FROM t3}
2N/A} {5}
2N/Ado_test conflict-9.21 {
2N/A catchsql {
2N/A BEGIN;
2N/A UPDATE t3 SET x=x+1;
2N/A UPDATE t2 SET e=e+1 WHERE e=1;
2N/A SELECT * FROM t2;
2N/A }
2N/A} {1 {column e is not unique}}
2N/Ado_test conflict-9.22 {
2N/A catch {execsql {COMMIT}}
2N/A execsql {SELECT * FROM t3}
2N/A} {5}
2N/Ado_test conflict-9.23 {
2N/A catchsql {
2N/A INSERT INTO t2 VALUES(3,3,1,3,3);
2N/A SELECT * FROM t2;
2N/A }
2N/A} {0 {2 2 2 2 2 3 3 1 3 3}}
2N/Ado_test conflict-9.24 {
2N/A catchsql {
2N/A UPDATE t2 SET c=c-1 WHERE c=2;
2N/A SELECT * FROM t2;
2N/A }
2N/A} {0 {2 2 1 2 2}}
2N/Ado_test conflict-9.25 {
2N/A catchsql {
2N/A BEGIN;
2N/A UPDATE t3 SET x=x+1;
2N/A INSERT INTO t2 VALUES(3,3,1,3,3);
2N/A SELECT * FROM t2;
2N/A }
2N/A} {0 {3 3 1 3 3}}
2N/Ado_test conflict-9.26 {
2N/A catch {execsql {COMMIT}}
2N/A execsql {SELECT * FROM t3}
2N/A} {6}
2N/A
2N/Ado_test conflict-10.1 {
2N/A catchsql {
2N/A DELETE FROM t1;
2N/A BEGIN ON CONFLICT ROLLBACK;
2N/A INSERT INTO t1 VALUES(1,2);
2N/A INSERT INTO t1 VALUES(1,3);
2N/A COMMIT;
2N/A }
2N/A execsql {SELECT * FROM t1}
2N/A} {}
2N/Ado_test conflict-10.2 {
2N/A catchsql {
2N/A CREATE TABLE t4(x);
2N/A CREATE UNIQUE INDEX t4x ON t4(x);
2N/A BEGIN ON CONFLICT ROLLBACK;
2N/A INSERT INTO t4 VALUES(1);
2N/A INSERT INTO t4 VALUES(1);
2N/A COMMIT;
2N/A }
2N/A execsql {SELECT * FROM t4}
2N/A} {}
2N/A
2N/Aintegrity_check conflict-99.0
2N/A
2N/Afinish_test