1bb37fdc7Sdrh# 2002 January 29 2bb37fdc7Sdrh# 3bb37fdc7Sdrh# The author disclaims copyright to this source code. In place of 4bb37fdc7Sdrh# a legal notice, here is a blessing: 5bb37fdc7Sdrh# 6bb37fdc7Sdrh# May you do good and not evil. 7bb37fdc7Sdrh# May you find forgiveness for yourself and forgive others. 8bb37fdc7Sdrh# May you share freely, never taking more than you give. 9bb37fdc7Sdrh# 10bb37fdc7Sdrh#*********************************************************************** 11bb37fdc7Sdrh# This file implements regression tests for SQLite library. 12bb37fdc7Sdrh# 13bb37fdc7Sdrh# This file implements tests for the conflict resolution extension 14bb37fdc7Sdrh# to SQLite. 15bb37fdc7Sdrh# 16*1dd397f0Sdrh# $Id: conflict.test,v 1.6 2002/02/03 03:34:09 drh Exp $ 17bb37fdc7Sdrh 18bb37fdc7Sdrhset testdir [file dirname $argv0] 19bb37fdc7Sdrhsource $testdir/tester.tcl 20bb37fdc7Sdrh 210d65dc0eSdrh# Create tables for the first group of tests. 22bb37fdc7Sdrh# 230d65dc0eSdrhdo_test conflict-1.0 { 24bb37fdc7Sdrh execsql { 25bb37fdc7Sdrh CREATE TABLE t1(a, b, c, UNIQUE(a,b)); 260d65dc0eSdrh CREATE TABLE t2(x); 27bb37fdc7Sdrh SELECT c FROM t1 ORDER BY c; 28bb37fdc7Sdrh } 290d65dc0eSdrh} {} 30bb37fdc7Sdrh 310d65dc0eSdrh# Six columns of configuration data as follows: 320d65dc0eSdrh# 330d65dc0eSdrh# i The reference number of the test 340d65dc0eSdrh# conf The conflict resolution algorithm on the BEGIN statement 350d65dc0eSdrh# cmd An INSERT or REPLACE command to execute against table t1 360d65dc0eSdrh# t0 True if there is an error from $cmd 370d65dc0eSdrh# t1 Content of "c" column of t1 assuming no error in $cmd 380d65dc0eSdrh# t2 Content of "x" column of t2 390d65dc0eSdrh# 400d65dc0eSdrhforeach {i conf cmd t0 t1 t2} { 410d65dc0eSdrh 1 {} INSERT 1 {} 1 420d65dc0eSdrh 2 {} {INSERT OR IGNORE} 0 3 1 430d65dc0eSdrh 3 {} {INSERT OR REPLACE} 0 4 1 440d65dc0eSdrh 4 {} REPLACE 0 4 1 450d65dc0eSdrh 5 {} {INSERT OR FAIL} 1 {} 1 460d65dc0eSdrh 6 {} {INSERT OR ABORT} 1 {} 1 470d65dc0eSdrh 7 {} {INSERT OR ROLLBACK} 1 {} {} 480d65dc0eSdrh 8 IGNORE INSERT 0 3 1 490d65dc0eSdrh 9 IGNORE {INSERT OR IGNORE} 0 3 1 500d65dc0eSdrh 10 IGNORE {INSERT OR REPLACE} 0 4 1 510d65dc0eSdrh 11 IGNORE REPLACE 0 4 1 520d65dc0eSdrh 12 IGNORE {INSERT OR FAIL} 1 {} 1 530d65dc0eSdrh 13 IGNORE {INSERT OR ABORT} 1 {} 1 540d65dc0eSdrh 14 IGNORE {INSERT OR ROLLBACK} 1 {} {} 550d65dc0eSdrh 15 REPLACE INSERT 0 4 1 560d65dc0eSdrh 16 FAIL INSERT 1 {} 1 570d65dc0eSdrh 17 ABORT INSERT 1 {} 1 580d65dc0eSdrh 18 ROLLBACK INSERT 1 {} {} 590d65dc0eSdrh} { 600d65dc0eSdrh do_test conflict-1.$i { 610d65dc0eSdrh if {$conf!=""} {set conf "ON CONFLICT $conf"} 620d65dc0eSdrh set r0 [catch {execsql [subst { 63bb37fdc7Sdrh DELETE FROM t1; 640d65dc0eSdrh DELETE FROM t2; 65bb37fdc7Sdrh INSERT INTO t1 VALUES(1,2,3); 660d65dc0eSdrh BEGIN $conf; 670d65dc0eSdrh INSERT INTO t2 VALUES(1); 680d65dc0eSdrh $cmd INTO t1 VALUES(1,2,4); 690d65dc0eSdrh }]} r1] 700d65dc0eSdrh execsql {COMMIT} 710d65dc0eSdrh if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]} 720d65dc0eSdrh set r2 [execsql {SELECT x FROM t2}] 730d65dc0eSdrh list $r0 $r1 $r2 740d65dc0eSdrh } [list $t0 $t1 $t2] 75bb37fdc7Sdrh} 76bb37fdc7Sdrh 770d65dc0eSdrh# Create tables for the first group of tests. 780d65dc0eSdrh# 790d65dc0eSdrhdo_test conflict-2.0 { 80ef6764a1Sdrh execsql { 81ef6764a1Sdrh DROP TABLE t1; 82ef6764a1Sdrh DROP TABLE t2; 830d65dc0eSdrh CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(a,b)); 840d65dc0eSdrh CREATE TABLE t2(x); 85ef6764a1Sdrh SELECT c FROM t1 ORDER BY c; 86ef6764a1Sdrh } 870d65dc0eSdrh} {} 88ef6764a1Sdrh 890d65dc0eSdrh# Six columns of configuration data as follows: 900d65dc0eSdrh# 910d65dc0eSdrh# i The reference number of the test 920d65dc0eSdrh# conf The conflict resolution algorithm on the BEGIN statement 930d65dc0eSdrh# cmd An INSERT or REPLACE command to execute against table t1 940d65dc0eSdrh# t0 True if there is an error from $cmd 950d65dc0eSdrh# t1 Content of "c" column of t1 assuming no error in $cmd 960d65dc0eSdrh# t2 Content of "x" column of t2 970d65dc0eSdrh# 980d65dc0eSdrhforeach {i conf cmd t0 t1 t2} { 990d65dc0eSdrh 1 {} INSERT 1 {} 1 1000d65dc0eSdrh 2 {} {INSERT OR IGNORE} 0 3 1 1010d65dc0eSdrh 3 {} {INSERT OR REPLACE} 0 4 1 1020d65dc0eSdrh 4 {} REPLACE 0 4 1 1030d65dc0eSdrh 5 {} {INSERT OR FAIL} 1 {} 1 1040d65dc0eSdrh 6 {} {INSERT OR ABORT} 1 {} 1 1050d65dc0eSdrh 7 {} {INSERT OR ROLLBACK} 1 {} {} 1060d65dc0eSdrh 8 IGNORE INSERT 0 3 1 1070d65dc0eSdrh 9 IGNORE {INSERT OR IGNORE} 0 3 1 1080d65dc0eSdrh 10 IGNORE {INSERT OR REPLACE} 0 4 1 1090d65dc0eSdrh 11 IGNORE REPLACE 0 4 1 1100d65dc0eSdrh 12 IGNORE {INSERT OR FAIL} 1 {} 1 1110d65dc0eSdrh 13 IGNORE {INSERT OR ABORT} 1 {} 1 1120d65dc0eSdrh 14 IGNORE {INSERT OR ROLLBACK} 1 {} {} 1130d65dc0eSdrh 15 REPLACE INSERT 0 4 1 1140d65dc0eSdrh 16 FAIL INSERT 1 {} 1 1150d65dc0eSdrh 17 ABORT INSERT 1 {} 1 1160d65dc0eSdrh 18 ROLLBACK INSERT 1 {} {} 1170d65dc0eSdrh} { 1180d65dc0eSdrh do_test conflict-2.$i { 1190d65dc0eSdrh if {$conf!=""} {set conf "ON CONFLICT $conf"} 1200d65dc0eSdrh set r0 [catch {execsql [subst { 121ef6764a1Sdrh DELETE FROM t1; 1220d65dc0eSdrh DELETE FROM t2; 123ef6764a1Sdrh INSERT INTO t1 VALUES(1,2,3); 1240d65dc0eSdrh BEGIN $conf; 1250d65dc0eSdrh INSERT INTO t2 VALUES(1); 1260d65dc0eSdrh $cmd INTO t1 VALUES(1,2,4); 1270d65dc0eSdrh }]} r1] 1280d65dc0eSdrh execsql {COMMIT} 1290d65dc0eSdrh if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]} 1300d65dc0eSdrh set r2 [execsql {SELECT x FROM t2}] 1310d65dc0eSdrh list $r0 $r1 $r2 1320d65dc0eSdrh } [list $t0 $t1 $t2] 133ef6764a1Sdrh} 1340d65dc0eSdrh 1350d65dc0eSdrh# Create tables for the first group of tests. 1360d65dc0eSdrh# 1370d65dc0eSdrhdo_test conflict-3.0 { 1380d65dc0eSdrh execsql { 1390d65dc0eSdrh DROP TABLE t1; 1400d65dc0eSdrh DROP TABLE t2; 1410d65dc0eSdrh CREATE TABLE t1(a, b, c INTEGER PRIMARY KEY, UNIQUE(a,b)); 1420d65dc0eSdrh CREATE TABLE t2(x); 143ef6764a1Sdrh SELECT c FROM t1 ORDER BY c; 144ef6764a1Sdrh } 1450d65dc0eSdrh} {} 1460d65dc0eSdrh 1470d65dc0eSdrh# Six columns of configuration data as follows: 1480d65dc0eSdrh# 1490d65dc0eSdrh# i The reference number of the test 1500d65dc0eSdrh# conf The conflict resolution algorithm on the BEGIN statement 1510d65dc0eSdrh# cmd An INSERT or REPLACE command to execute against table t1 1520d65dc0eSdrh# t0 True if there is an error from $cmd 1530d65dc0eSdrh# t1 Content of "c" column of t1 assuming no error in $cmd 1540d65dc0eSdrh# t2 Content of "x" column of t2 1550d65dc0eSdrh# 1560d65dc0eSdrhforeach {i conf cmd t0 t1 t2} { 1570d65dc0eSdrh 1 {} INSERT 1 {} 1 1580d65dc0eSdrh 2 {} {INSERT OR IGNORE} 0 3 1 1590d65dc0eSdrh 3 {} {INSERT OR REPLACE} 0 4 1 1600d65dc0eSdrh 4 {} REPLACE 0 4 1 1610d65dc0eSdrh 5 {} {INSERT OR FAIL} 1 {} 1 1620d65dc0eSdrh 6 {} {INSERT OR ABORT} 1 {} 1 1630d65dc0eSdrh 7 {} {INSERT OR ROLLBACK} 1 {} {} 1640d65dc0eSdrh 8 IGNORE INSERT 0 3 1 1650d65dc0eSdrh 9 IGNORE {INSERT OR IGNORE} 0 3 1 1660d65dc0eSdrh 10 IGNORE {INSERT OR REPLACE} 0 4 1 1670d65dc0eSdrh 11 IGNORE REPLACE 0 4 1 1680d65dc0eSdrh 12 IGNORE {INSERT OR FAIL} 1 {} 1 1690d65dc0eSdrh 13 IGNORE {INSERT OR ABORT} 1 {} 1 1700d65dc0eSdrh 14 IGNORE {INSERT OR ROLLBACK} 1 {} {} 1710d65dc0eSdrh 15 REPLACE INSERT 0 4 1 1720d65dc0eSdrh 16 FAIL INSERT 1 {} 1 1730d65dc0eSdrh 17 ABORT INSERT 1 {} 1 1740d65dc0eSdrh 18 ROLLBACK INSERT 1 {} {} 1750d65dc0eSdrh} { 1760d65dc0eSdrh do_test conflict-3.$i { 1770d65dc0eSdrh if {$conf!=""} {set conf "ON CONFLICT $conf"} 1780d65dc0eSdrh set r0 [catch {execsql [subst { 1790d65dc0eSdrh DELETE FROM t1; 1800d65dc0eSdrh DELETE FROM t2; 1810d65dc0eSdrh INSERT INTO t1 VALUES(1,2,3); 1820d65dc0eSdrh BEGIN $conf; 1830d65dc0eSdrh INSERT INTO t2 VALUES(1); 1840d65dc0eSdrh $cmd INTO t1 VALUES(1,2,4); 1850d65dc0eSdrh }]} r1] 1860d65dc0eSdrh execsql {COMMIT} 1870d65dc0eSdrh if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]} 1880d65dc0eSdrh set r2 [execsql {SELECT x FROM t2}] 1890d65dc0eSdrh list $r0 $r1 $r2 1900d65dc0eSdrh } [list $t0 $t1 $t2] 191ef6764a1Sdrh} 1920d65dc0eSdrh 1930d65dc0eSdrhdo_test conflict-4.0 { 1940d65dc0eSdrh execsql { 1950d65dc0eSdrh DROP TABLE t2; 1960d65dc0eSdrh CREATE TABLE t2(x); 1970d65dc0eSdrh SELECT x FROM t2; 198ef6764a1Sdrh } 1990d65dc0eSdrh} {} 2000d65dc0eSdrh 2010d65dc0eSdrh# Six columns of configuration data as follows: 2020d65dc0eSdrh# 2030d65dc0eSdrh# i The reference number of the test 2040d65dc0eSdrh# conf1 The conflict resolution algorithm on the UNIQUE constraint 2050d65dc0eSdrh# conf2 The conflict resolution algorithm on the BEGIN statement 2060d65dc0eSdrh# cmd An INSERT or REPLACE command to execute against table t1 2070d65dc0eSdrh# t0 True if there is an error from $cmd 2080d65dc0eSdrh# t1 Content of "c" column of t1 assuming no error in $cmd 2090d65dc0eSdrh# t2 Content of "x" column of t2 2100d65dc0eSdrh# 2110d65dc0eSdrhforeach {i conf1 conf2 cmd t0 t1 t2} { 2120d65dc0eSdrh 1 {} {} INSERT 1 {} 1 2130d65dc0eSdrh 2 REPLACE {} INSERT 0 4 1 2140d65dc0eSdrh 3 IGNORE {} INSERT 0 3 1 2150d65dc0eSdrh 4 FAIL {} INSERT 1 {} 1 2160d65dc0eSdrh 5 ABORT {} INSERT 1 {} 1 2170d65dc0eSdrh 6 ROLLBACK {} INSERT 1 {} {} 2180d65dc0eSdrh 7 REPLACE {} {INSERT OR IGNORE} 0 3 1 2190d65dc0eSdrh 8 IGNORE {} {INSERT OR REPLACE} 0 4 1 2200d65dc0eSdrh 9 FAIL {} {INSERT OR IGNORE} 0 3 1 2210d65dc0eSdrh 10 ABORT {} {INSERT OR REPLACE} 0 4 1 2220d65dc0eSdrh 11 ROLLBACK {} {INSERT OR IGNORE } 0 3 1 2230d65dc0eSdrh 12 REPLACE IGNORE INSERT 0 4 1 2240d65dc0eSdrh 13 IGNORE REPLACE INSERT 0 3 1 2250d65dc0eSdrh 14 FAIL IGNORE INSERT 1 {} 1 2260d65dc0eSdrh 15 ABORT REPLACE INSERT 1 {} 1 2270d65dc0eSdrh 16 ROLLBACK IGNORE INSERT 1 {} {} 2280d65dc0eSdrh} { 2290d65dc0eSdrh do_test conflict-4.$i { 2300d65dc0eSdrh if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"} 2310d65dc0eSdrh if {$conf2!=""} {set conf2 "ON CONFLICT $conf2"} 2320d65dc0eSdrh set r0 [catch {execsql [subst { 2330d65dc0eSdrh DROP TABLE t1; 2340d65dc0eSdrh CREATE TABLE t1(a,b,c,UNIQUE(a,b) $conf1); 2350d65dc0eSdrh DELETE FROM t2; 2360d65dc0eSdrh INSERT INTO t1 VALUES(1,2,3); 2370d65dc0eSdrh BEGIN $conf2; 2380d65dc0eSdrh INSERT INTO t2 VALUES(1); 2390d65dc0eSdrh $cmd INTO t1 VALUES(1,2,4); 2400d65dc0eSdrh }]} r1] 2410d65dc0eSdrh execsql {COMMIT} 2420d65dc0eSdrh if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]} 2430d65dc0eSdrh set r2 [execsql {SELECT x FROM t2}] 2440d65dc0eSdrh list $r0 $r1 $r2 2450d65dc0eSdrh } [list $t0 $t1 $t2] 246ef6764a1Sdrh} 2470d65dc0eSdrh 2480d65dc0eSdrhdo_test conflict-5.0 { 2490d65dc0eSdrh execsql { 2500d65dc0eSdrh DROP TABLE t2; 2510d65dc0eSdrh CREATE TABLE t2(x); 2520d65dc0eSdrh SELECT x FROM t2; 2530d65dc0eSdrh } 2540d65dc0eSdrh} {} 2550d65dc0eSdrh 2560d65dc0eSdrh# Six columns of configuration data as follows: 2570d65dc0eSdrh# 2580d65dc0eSdrh# i The reference number of the test 2590d65dc0eSdrh# conf1 The conflict resolution algorithm on the NOT NULL constraint 2600d65dc0eSdrh# conf2 The conflict resolution algorithm on the BEGIN statement 2610d65dc0eSdrh# cmd An INSERT or REPLACE command to execute against table t1 2620d65dc0eSdrh# t0 True if there is an error from $cmd 2630d65dc0eSdrh# t1 Content of "c" column of t1 assuming no error in $cmd 2640d65dc0eSdrh# t2 Content of "x" column of t2 2650d65dc0eSdrh# 2660d65dc0eSdrhforeach {i conf1 conf2 cmd t0 t1 t2} { 2670d65dc0eSdrh 1 {} {} INSERT 1 {} 1 2680d65dc0eSdrh 2 REPLACE {} INSERT 0 5 1 2690d65dc0eSdrh 3 IGNORE {} INSERT 0 {} 1 2700d65dc0eSdrh 4 FAIL {} INSERT 1 {} 1 2710d65dc0eSdrh 5 ABORT {} INSERT 1 {} 1 2720d65dc0eSdrh 6 ROLLBACK {} INSERT 1 {} {} 2730d65dc0eSdrh 7 REPLACE {} {INSERT OR IGNORE} 0 {} 1 2740d65dc0eSdrh 8 IGNORE {} {INSERT OR REPLACE} 0 5 1 2750d65dc0eSdrh 9 FAIL {} {INSERT OR IGNORE} 0 {} 1 2760d65dc0eSdrh 10 ABORT {} {INSERT OR REPLACE} 0 5 1 2770d65dc0eSdrh 11 ROLLBACK {} {INSERT OR IGNORE} 0 {} 1 2780d65dc0eSdrh 12 {} {} {INSERT OR IGNORE} 0 {} 1 2790d65dc0eSdrh 13 {} {} {INSERT OR REPLACE} 0 5 1 2800d65dc0eSdrh 14 {} {} {INSERT OR FAIL} 1 {} 1 2810d65dc0eSdrh 15 {} {} {INSERT OR ABORT} 1 {} 1 2820d65dc0eSdrh 16 {} {} {INSERT OR ROLLBACK} 1 {} {} 2830d65dc0eSdrh 17 {} IGNORE INSERT 0 {} 1 2840d65dc0eSdrh 18 {} REPLACE INSERT 0 5 1 2850d65dc0eSdrh 19 {} FAIL INSERT 1 {} 1 2860d65dc0eSdrh 20 {} ABORT INSERT 1 {} 1 2870d65dc0eSdrh 21 {} ROLLBACK INSERT 1 {} {} 2880d65dc0eSdrh 22 REPLACE FAIL INSERT 0 5 1 2890d65dc0eSdrh 23 IGNORE ROLLBACK INSERT 0 {} 1 2900d65dc0eSdrh} { 2910d65dc0eSdrh if {$t0} {set t1 {constraint failed}} 2920d65dc0eSdrh do_test conflict-5.$i { 2930d65dc0eSdrh if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"} 2940d65dc0eSdrh if {$conf2!=""} {set conf2 "ON CONFLICT $conf2"} 2950d65dc0eSdrh set r0 [catch {execsql [subst { 2960d65dc0eSdrh DROP TABLE t1; 2970d65dc0eSdrh CREATE TABLE t1(a,b,c NOT NULL $conf1 DEFAULT 5); 2980d65dc0eSdrh DELETE FROM t2; 2990d65dc0eSdrh BEGIN $conf2; 3000d65dc0eSdrh INSERT INTO t2 VALUES(1); 3010d65dc0eSdrh $cmd INTO t1 VALUES(1,2,NULL); 3020d65dc0eSdrh }]} r1] 3030d65dc0eSdrh execsql {COMMIT} 3040d65dc0eSdrh if {!$r0} {set r1 [execsql {SELECT c FROM t1}]} 3050d65dc0eSdrh set r2 [execsql {SELECT x FROM t2}] 3060d65dc0eSdrh list $r0 $r1 $r2 3070d65dc0eSdrh } [list $t0 $t1 $t2] 3080d65dc0eSdrh} 3090d65dc0eSdrh 3100d65dc0eSdrhdo_test conflict-6.0 { 3110d65dc0eSdrh execsql { 3120d65dc0eSdrh DROP TABLE t2; 3130d65dc0eSdrh CREATE TABLE t2(a,b,c); 3140d65dc0eSdrh INSERT INTO t2 VALUES(1,2,1); 3150d65dc0eSdrh INSERT INTO t2 VALUES(2,3,2); 3160d65dc0eSdrh INSERT INTO t2 VALUES(3,4,1); 3170d65dc0eSdrh INSERT INTO t2 VALUES(4,5,4); 3180d65dc0eSdrh SELECT c FROM t2 ORDER BY b; 3190d65dc0eSdrh CREATE TABLE t3(x); 3200d65dc0eSdrh INSERT INTO t3 VALUES(1); 3210d65dc0eSdrh } 3220d65dc0eSdrh} {1 2 1 4} 3230d65dc0eSdrh 3240d65dc0eSdrh# Six columns of configuration data as follows: 3250d65dc0eSdrh# 3260d65dc0eSdrh# i The reference number of the test 3270d65dc0eSdrh# conf1 The conflict resolution algorithm on the UNIQUE constraint 3280d65dc0eSdrh# conf2 The conflict resolution algorithm on the BEGIN statement 3290d65dc0eSdrh# cmd An UPDATE command to execute against table t1 3300d65dc0eSdrh# t0 True if there is an error from $cmd 3310d65dc0eSdrh# t1 Content of "b" column of t1 assuming no error in $cmd 3320d65dc0eSdrh# t2 Content of "x" column of t3 3330d65dc0eSdrh# 3340d65dc0eSdrhforeach {i conf1 conf2 cmd t0 t1 t2} { 3350d65dc0eSdrh 1 {} {} UPDATE 1 {6 7 8 9} 1 3360d65dc0eSdrh 2 REPLACE {} UPDATE 0 {7 6 9} 1 3370d65dc0eSdrh 3 IGNORE {} UPDATE 0 {6 7 3 9} 1 3380d65dc0eSdrh 4 FAIL {} UPDATE 1 {6 7 3 4} 1 3390d65dc0eSdrh 5 ABORT {} UPDATE 1 {1 2 3 4} 1 3400d65dc0eSdrh 6 ROLLBACK {} UPDATE 1 {1 2 3 4} 0 3410d65dc0eSdrh 7 REPLACE {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1 3420d65dc0eSdrh 8 IGNORE {} {UPDATE OR REPLACE} 0 {7 6 9} 1 3430d65dc0eSdrh 9 FAIL {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1 3440d65dc0eSdrh 10 ABORT {} {UPDATE OR REPLACE} 0 {7 6 9} 1 3450d65dc0eSdrh 11 ROLLBACK {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1 3460d65dc0eSdrh 12 {} {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1 3470d65dc0eSdrh 13 {} {} {UPDATE OR REPLACE} 0 {7 6 9} 1 3480d65dc0eSdrh 14 {} {} {UPDATE OR FAIL} 1 {6 7 3 4} 1 3490d65dc0eSdrh 15 {} {} {UPDATE OR ABORT} 1 {1 2 3 4} 1 3500d65dc0eSdrh 16 {} {} {UPDATE OR ROLLBACK} 1 {1 2 3 4} 0 3510d65dc0eSdrh 17 {} IGNORE UPDATE 0 {6 7 3 9} 1 3520d65dc0eSdrh 18 {} REPLACE UPDATE 0 {7 6 9} 1 3530d65dc0eSdrh 19 {} FAIL UPDATE 1 {6 7 3 4} 1 3540d65dc0eSdrh 20 {} ABORT UPDATE 1 {1 2 3 4} 1 3550d65dc0eSdrh 21 {} ROLLBACK UPDATE 1 {1 2 3 4} 0 3560d65dc0eSdrh 22 REPLACE FAIL UPDATE 0 {7 6 9} 1 3570d65dc0eSdrh 23 IGNORE ROLLBACK UPDATE 0 {6 7 3 9} 1 3580d65dc0eSdrh} { 3590d65dc0eSdrh if {$t0} {set t1 {constraint failed}} 3600d65dc0eSdrh do_test conflict-6.$i { 3610d65dc0eSdrh if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"} 3620d65dc0eSdrh if {$conf2!=""} {set conf2 "ON CONFLICT $conf2"} 3630d65dc0eSdrh set r0 [catch {execsql [subst { 3640d65dc0eSdrh DROP TABLE t1; 3650d65dc0eSdrh CREATE TABLE t1(a,b,c, UNIQUE(a) $conf1); 3660d65dc0eSdrh INSERT INTO t1 SELECT * FROM t2; 3670d65dc0eSdrh UPDATE t3 SET x=0; 3680d65dc0eSdrh BEGIN $conf2; 3690d65dc0eSdrh $cmd t3 SET x=1; 370*1dd397f0Sdrh $cmd t1 SET b=b*2; 3710d65dc0eSdrh $cmd t1 SET a=c+5; 3720d65dc0eSdrh }]} r1] 3730d65dc0eSdrh execsql {COMMIT} 3740d65dc0eSdrh if {!$r0} {set r1 [execsql {SELECT a FROM t1 ORDER BY b}]} 3750d65dc0eSdrh set r2 [execsql {SELECT x FROM t3}] 3760d65dc0eSdrh list $r0 $r1 $r2 3770d65dc0eSdrh } [list $t0 $t1 $t2] 3780d65dc0eSdrh} 379ef6764a1Sdrh 380bb37fdc7Sdrh 381bb37fdc7Sdrhfinish_test 382