mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Make sure the ON CONFLICT clause on a BEGIN overrides the conflict resolution
specified by an index. This fixes a bug reported on the newsgroup. (CVS 975) FossilOrigin-Name: 0f92736d1fbe3b587592fe1f26dfb3558cc49727
This commit is contained in:
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this script testing the callback-free C/C++ API.
|
||||
#
|
||||
# $Id: capi2.test,v 1.6 2003/03/01 19:53:16 drh Exp $
|
||||
# $Id: capi2.test,v 1.7 2003/05/16 02:30:27 drh Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@ -393,7 +393,7 @@ do_test capi2-6.28 {
|
||||
do_test capi2-6.99 {
|
||||
list [catch {sqlite_finalize $VM1} msg] [set msg]
|
||||
} {0 {}}
|
||||
execsql {ROLLBACK}
|
||||
catchsql {ROLLBACK}
|
||||
|
||||
do_test capi2-7.1 {
|
||||
stepsql $DB {
|
||||
|
@ -13,7 +13,7 @@
|
||||
# This file implements tests for the conflict resolution extension
|
||||
# to SQLite.
|
||||
#
|
||||
# $Id: conflict.test,v 1.16 2003/02/26 13:52:52 drh Exp $
|
||||
# $Id: conflict.test,v 1.17 2003/05/16 02:30:27 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -220,11 +220,15 @@ foreach {i conf1 conf2 cmd t0 t1 t2} {
|
||||
9 FAIL {} {INSERT OR IGNORE} 0 3 1
|
||||
10 ABORT {} {INSERT OR REPLACE} 0 4 1
|
||||
11 ROLLBACK {} {INSERT OR IGNORE } 0 3 1
|
||||
12 REPLACE IGNORE INSERT 0 4 1
|
||||
13 IGNORE REPLACE INSERT 0 3 1
|
||||
14 FAIL IGNORE INSERT 1 {} 1
|
||||
15 ABORT REPLACE INSERT 1 {} 1
|
||||
16 ROLLBACK IGNORE INSERT 1 {} {}
|
||||
12 REPLACE IGNORE INSERT 0 3 1
|
||||
13 IGNORE REPLACE INSERT 0 4 1
|
||||
14 FAIL IGNORE INSERT 0 3 1
|
||||
15 ABORT REPLACE INSERT 0 4 1
|
||||
16 ROLLBACK IGNORE INSERT 0 3 1
|
||||
12 IGNORE REPLACE INSERT 0 4 1
|
||||
13 IGNORE FAIL INSERT 1 {} 1
|
||||
14 IGNORE ABORT INSERT 1 {} 1
|
||||
15 IGNORE ROLLBACK INSERT 1 {} {}
|
||||
} {
|
||||
do_test conflict-4.$i {
|
||||
if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
|
||||
@ -285,8 +289,8 @@ foreach {i conf1 conf2 cmd t0 t1 t2} {
|
||||
19 {} FAIL INSERT 1 {} 1
|
||||
20 {} ABORT INSERT 1 {} 1
|
||||
21 {} ROLLBACK INSERT 1 {} {}
|
||||
22 REPLACE FAIL INSERT 0 5 1
|
||||
23 IGNORE ROLLBACK INSERT 0 {} 1
|
||||
22 REPLACE FAIL INSERT 1 {} 1
|
||||
23 IGNORE ROLLBACK INSERT 1 {} {}
|
||||
} {
|
||||
if {$t0} {set t1 {t1.c may not be NULL}}
|
||||
do_test conflict-5.$i {
|
||||
@ -353,8 +357,11 @@ foreach {i conf1 conf2 cmd t0 t1 t2} {
|
||||
19 {} FAIL UPDATE 1 {6 7 3 4} 1
|
||||
20 {} ABORT UPDATE 1 {1 2 3 4} 1
|
||||
21 {} ROLLBACK UPDATE 1 {1 2 3 4} 0
|
||||
22 REPLACE FAIL UPDATE 0 {7 6 9} 1
|
||||
23 IGNORE ROLLBACK UPDATE 0 {6 7 3 9} 1
|
||||
22 REPLACE IGNORE UPDATE 0 {6 7 3 9} 1
|
||||
23 IGNORE REPLACE UPDATE 0 {7 6 9} 1
|
||||
24 REPLACE FAIL UPDATE 1 {6 7 3 4} 1
|
||||
25 IGNORE ABORT UPDATE 1 {1 2 3 4} 1
|
||||
26 REPLACE ROLLBACK UPDATE 1 {1 2 3 4} 0
|
||||
} {
|
||||
if {$t0} {set t1 {uniqueness constraint failed}}
|
||||
do_test conflict-6.$i {
|
||||
@ -660,4 +667,26 @@ do_test conflict-9.26 {
|
||||
execsql {SELECT * FROM t3}
|
||||
} {6}
|
||||
|
||||
do_test conflict-10.1 {
|
||||
catchsql {
|
||||
DELETE FROM t1;
|
||||
BEGIN ON CONFLICT ROLLBACK;
|
||||
INSERT INTO t1 VALUES(1,2);
|
||||
INSERT INTO t1 VALUES(1,3);
|
||||
COMMIT;
|
||||
}
|
||||
execsql {SELECT * FROM t1}
|
||||
} {}
|
||||
do_test conflict-10.2 {
|
||||
catchsql {
|
||||
CREATE TABLE t4(x);
|
||||
CREATE UNIQUE INDEX t4x ON t4(x);
|
||||
BEGIN ON CONFLICT ROLLBACK;
|
||||
INSERT INTO t4 VALUES(1);
|
||||
INSERT INTO t4 VALUES(1);
|
||||
COMMIT;
|
||||
}
|
||||
execsql {SELECT * FROM t4}
|
||||
} {}
|
||||
|
||||
finish_test
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this script is in-memory database backend.
|
||||
#
|
||||
# $Id: memdb.test,v 1.3 2003/05/02 14:32:15 drh Exp $
|
||||
# $Id: memdb.test,v 1.4 2003/05/16 02:30:27 drh Exp $
|
||||
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@ -247,8 +247,11 @@ foreach {i conf1 conf2 cmd t0 t1 t2} {
|
||||
19 {} FAIL UPDATE 1 {6 7 3 4} 1
|
||||
20 {} ABORT UPDATE 1 {1 2 3 4} 1
|
||||
21 {} ROLLBACK UPDATE 1 {1 2 3 4} 0
|
||||
22 REPLACE FAIL UPDATE 0 {7 6 9} 1
|
||||
23 IGNORE ROLLBACK UPDATE 0 {6 7 3 9} 1
|
||||
22 REPLACE IGNORE UPDATE 0 {6 7 3 9} 1
|
||||
23 IGNORE REPLACE UPDATE 0 {7 6 9} 1
|
||||
24 REPLACE FAIL UPDATE 1 {6 7 3 4} 1
|
||||
25 IGNORE ABORT UPDATE 1 {1 2 3 4} 1
|
||||
26 REPLACE ROLLBACK UPDATE 1 {1 2 3 4} 0
|
||||
} {
|
||||
if {$t0} {set t1 {uniqueness constraint failed}}
|
||||
do_test memdb-5.$i {
|
||||
|
Reference in New Issue
Block a user