mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +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:
20
manifest
20
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Removed\s3rd\s(file)\scolumn\sfrom\sPRAGMA\sdatabase_list\suntil\stests\sare\sfixed.\s(CVS\s974)
|
C Make\ssure\sthe\sON\sCONFLICT\sclause\son\sa\sBEGIN\soverrides\sthe\sconflict\sresolution\nspecified\sby\san\sindex.\s\sThis\sfixes\sa\sbug\sreported\son\sthe\snewsgroup.\s(CVS\s975)
|
||||||
D 2003-05-13T08:01:34
|
D 2003-05-16T02:30:27
|
||||||
F Makefile.in 004acec253ecdde985c8ecd5b7c9accdb210378f
|
F Makefile.in 004acec253ecdde985c8ecd5b7c9accdb210378f
|
||||||
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
|
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
|
||||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||||
@@ -32,7 +32,7 @@ F src/expr.c a666ef5220ca90ebcf40c8ccc783966a345a7616
|
|||||||
F src/func.c 33bbce6acaf9578ac99aa1f689968ccaf2ce43a2
|
F src/func.c 33bbce6acaf9578ac99aa1f689968ccaf2ce43a2
|
||||||
F src/hash.c 058f077c1f36f266581aa16f907a3903abf64aa3
|
F src/hash.c 058f077c1f36f266581aa16f907a3903abf64aa3
|
||||||
F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8
|
F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8
|
||||||
F src/insert.c c230a8c216f6788095d46f0e270406a93aae45af
|
F src/insert.c fac16589e644b2d4bb615c5e782bcfd0453a052a
|
||||||
F src/main.c 16e68905793b118552a9cf43a9f77ca1d9e395a9
|
F src/main.c 16e68905793b118552a9cf43a9f77ca1d9e395a9
|
||||||
F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565
|
F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565
|
||||||
F src/os.c 94b618c0c0a76210e53857d77c96d2f042dc33b1
|
F src/os.c 94b618c0c0a76210e53857d77c96d2f042dc33b1
|
||||||
@@ -73,8 +73,8 @@ F test/btree3.test e597fb59be2ac0ea69c62aaa2064e998e528b665
|
|||||||
F test/btree3rb.test 127efcf5cdfcc352054e7db12622b01cdd8b36ac
|
F test/btree3rb.test 127efcf5cdfcc352054e7db12622b01cdd8b36ac
|
||||||
F test/btree4.test fa955a3d7a8bc91d6084b7f494f9e5d1bdfb15b6
|
F test/btree4.test fa955a3d7a8bc91d6084b7f494f9e5d1bdfb15b6
|
||||||
F test/btree4rb.test ae6f0438512edcb45cf483471cd6070a765963a9
|
F test/btree4rb.test ae6f0438512edcb45cf483471cd6070a765963a9
|
||||||
F test/capi2.test fb94bed9e236074c5e255cfd25e3e32344e24855
|
F test/capi2.test dddfe84d41c876e5339efae41f8e688760454fba
|
||||||
F test/conflict.test 80cf3780c8686b92db4ce0f60bca46a000537327
|
F test/conflict.test 70d38ff29b532813320c17740738a556ee0ec95d
|
||||||
F test/copy.test 73df5ed3112e858e006a8b7ddb4c9bab6a25d0fb
|
F test/copy.test 73df5ed3112e858e006a8b7ddb4c9bab6a25d0fb
|
||||||
F test/delete.test 1586a00574e699a9913bc3403261813e8a93e6b9
|
F test/delete.test 1586a00574e699a9913bc3403261813e8a93e6b9
|
||||||
F test/expr.test 48bc6400627532ec97e233809e33d336468bc84c
|
F test/expr.test 48bc6400627532ec97e233809e33d336468bc84c
|
||||||
@@ -92,7 +92,7 @@ F test/limit.test 9ffb965a0f5bf7152187ef3d8d1249b96e5620bf
|
|||||||
F test/lock.test 388a3a10962d2d571c0c1821cc35bf069ee73473
|
F test/lock.test 388a3a10962d2d571c0c1821cc35bf069ee73473
|
||||||
F test/main.test 6a851b5992c4881a725a3d9647e629199df8de9d
|
F test/main.test 6a851b5992c4881a725a3d9647e629199df8de9d
|
||||||
F test/malloc.test 7ba32a9ebd3aeed52ae4aaa6d42ca37e444536fd
|
F test/malloc.test 7ba32a9ebd3aeed52ae4aaa6d42ca37e444536fd
|
||||||
F test/memdb.test 3acf1453a5705d1aa524d3027667ca3d9c77c69f
|
F test/memdb.test ab1d16eb3179272016b1fe5fa3988e9c2f6c5594
|
||||||
F test/memleak.test a18e6810cae96d2f6f5136920267adbefc8e1e90
|
F test/memleak.test a18e6810cae96d2f6f5136920267adbefc8e1e90
|
||||||
F test/minmax.test b54ac3bc45460a4976b08ef363e05c032418726e
|
F test/minmax.test b54ac3bc45460a4976b08ef363e05c032418726e
|
||||||
F test/misc1.test 865c907df58195364eaf2e69426e9674bc8d1a8c
|
F test/misc1.test 865c907df58195364eaf2e69426e9674bc8d1a8c
|
||||||
@@ -165,7 +165,7 @@ F www/speed.tcl cb4c10a722614aea76d2c51f32ee43400d5951be
|
|||||||
F www/sqlite.tcl 4bd1729e320f5fa9125f0022b281fbe839192125
|
F www/sqlite.tcl 4bd1729e320f5fa9125f0022b281fbe839192125
|
||||||
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
|
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
|
||||||
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
|
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
|
||||||
P f267a8a4ff52eb7ee3ac20a8e3a8ab5fe19e445d
|
P 4183cf97676e64d19978941a7c4a3fe521fcb1fb
|
||||||
R 4c116ad646a5d45f20337623549b2e99
|
R ceda8451adba59b6260a922bc13b596c
|
||||||
U jplyon
|
U drh
|
||||||
Z d2079033f7e558e2136afb4a88150abf
|
Z ca1fb5800fb2c1a110aee865c12a3008
|
||||||
|
@@ -1 +1 @@
|
|||||||
4183cf97676e64d19978941a7c4a3fe521fcb1fb
|
0f92736d1fbe3b587592fe1f26dfb3558cc49727
|
17
src/insert.c
17
src/insert.c
@@ -12,7 +12,7 @@
|
|||||||
** This file contains C code routines that are called by the parser
|
** This file contains C code routines that are called by the parser
|
||||||
** to handle INSERT statements in SQLite.
|
** to handle INSERT statements in SQLite.
|
||||||
**
|
**
|
||||||
** $Id: insert.c,v 1.83 2003/05/02 14:32:13 drh Exp $
|
** $Id: insert.c,v 1.84 2003/05/16 02:30:27 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@@ -668,9 +668,10 @@ void sqliteGenerateConstraintChecks(
|
|||||||
if( onError==OE_None ) continue;
|
if( onError==OE_None ) continue;
|
||||||
if( overrideError!=OE_Default ){
|
if( overrideError!=OE_Default ){
|
||||||
onError = overrideError;
|
onError = overrideError;
|
||||||
}else if( onError==OE_Default ){
|
}else if( pParse->db->onError!=OE_Default ){
|
||||||
onError = pParse->db->onError;
|
onError = pParse->db->onError;
|
||||||
if( onError==OE_Default ) onError = OE_Abort;
|
}else if( onError==OE_Default ){
|
||||||
|
onError = OE_Abort;
|
||||||
}
|
}
|
||||||
if( onError==OE_Replace && pTab->aCol[i].zDflt==0 ){
|
if( onError==OE_Replace && pTab->aCol[i].zDflt==0 ){
|
||||||
onError = OE_Abort;
|
onError = OE_Abort;
|
||||||
@@ -718,9 +719,10 @@ void sqliteGenerateConstraintChecks(
|
|||||||
onError = pTab->keyConf;
|
onError = pTab->keyConf;
|
||||||
if( overrideError!=OE_Default ){
|
if( overrideError!=OE_Default ){
|
||||||
onError = overrideError;
|
onError = overrideError;
|
||||||
}else if( onError==OE_Default ){
|
}else if( pParse->db->onError!=OE_Default ){
|
||||||
onError = pParse->db->onError;
|
onError = pParse->db->onError;
|
||||||
if( onError==OE_Default ) onError = OE_Abort;
|
}else if( onError==OE_Default ){
|
||||||
|
onError = OE_Abort;
|
||||||
}
|
}
|
||||||
if( onError!=OE_Replace ){
|
if( onError!=OE_Replace ){
|
||||||
if( isUpdate ){
|
if( isUpdate ){
|
||||||
@@ -782,9 +784,10 @@ void sqliteGenerateConstraintChecks(
|
|||||||
if( onError==OE_None ) continue; /* pIdx is not a UNIQUE index */
|
if( onError==OE_None ) continue; /* pIdx is not a UNIQUE index */
|
||||||
if( overrideError!=OE_Default ){
|
if( overrideError!=OE_Default ){
|
||||||
onError = overrideError;
|
onError = overrideError;
|
||||||
}else if( onError==OE_Default ){
|
}else if( pParse->db->onError!=OE_Default ){
|
||||||
onError = pParse->db->onError;
|
onError = pParse->db->onError;
|
||||||
if( onError==OE_Default ) onError = OE_Abort;
|
}else if( onError==OE_Default ){
|
||||||
|
onError = OE_Abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check to see if the new index entry will be unique */
|
/* Check to see if the new index entry will be unique */
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
# This file implements regression tests for SQLite library. The
|
# This file implements regression tests for SQLite library. The
|
||||||
# focus of this script testing the callback-free C/C++ API.
|
# 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]
|
set testdir [file dirname $argv0]
|
||||||
@@ -393,7 +393,7 @@ do_test capi2-6.28 {
|
|||||||
do_test capi2-6.99 {
|
do_test capi2-6.99 {
|
||||||
list [catch {sqlite_finalize $VM1} msg] [set msg]
|
list [catch {sqlite_finalize $VM1} msg] [set msg]
|
||||||
} {0 {}}
|
} {0 {}}
|
||||||
execsql {ROLLBACK}
|
catchsql {ROLLBACK}
|
||||||
|
|
||||||
do_test capi2-7.1 {
|
do_test capi2-7.1 {
|
||||||
stepsql $DB {
|
stepsql $DB {
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
# This file implements tests for the conflict resolution extension
|
# This file implements tests for the conflict resolution extension
|
||||||
# to SQLite.
|
# 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]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
@@ -220,11 +220,15 @@ foreach {i conf1 conf2 cmd t0 t1 t2} {
|
|||||||
9 FAIL {} {INSERT OR IGNORE} 0 3 1
|
9 FAIL {} {INSERT OR IGNORE} 0 3 1
|
||||||
10 ABORT {} {INSERT OR REPLACE} 0 4 1
|
10 ABORT {} {INSERT OR REPLACE} 0 4 1
|
||||||
11 ROLLBACK {} {INSERT OR IGNORE } 0 3 1
|
11 ROLLBACK {} {INSERT OR IGNORE } 0 3 1
|
||||||
12 REPLACE IGNORE INSERT 0 4 1
|
12 REPLACE IGNORE INSERT 0 3 1
|
||||||
13 IGNORE REPLACE INSERT 0 3 1
|
13 IGNORE REPLACE INSERT 0 4 1
|
||||||
14 FAIL IGNORE INSERT 1 {} 1
|
14 FAIL IGNORE INSERT 0 3 1
|
||||||
15 ABORT REPLACE INSERT 1 {} 1
|
15 ABORT REPLACE INSERT 0 4 1
|
||||||
16 ROLLBACK IGNORE INSERT 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 {
|
do_test conflict-4.$i {
|
||||||
if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
|
if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
|
||||||
@@ -285,8 +289,8 @@ foreach {i conf1 conf2 cmd t0 t1 t2} {
|
|||||||
19 {} FAIL INSERT 1 {} 1
|
19 {} FAIL INSERT 1 {} 1
|
||||||
20 {} ABORT INSERT 1 {} 1
|
20 {} ABORT INSERT 1 {} 1
|
||||||
21 {} ROLLBACK INSERT 1 {} {}
|
21 {} ROLLBACK INSERT 1 {} {}
|
||||||
22 REPLACE FAIL INSERT 0 5 1
|
22 REPLACE FAIL INSERT 1 {} 1
|
||||||
23 IGNORE ROLLBACK INSERT 0 {} 1
|
23 IGNORE ROLLBACK INSERT 1 {} {}
|
||||||
} {
|
} {
|
||||||
if {$t0} {set t1 {t1.c may not be NULL}}
|
if {$t0} {set t1 {t1.c may not be NULL}}
|
||||||
do_test conflict-5.$i {
|
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
|
19 {} FAIL UPDATE 1 {6 7 3 4} 1
|
||||||
20 {} ABORT UPDATE 1 {1 2 3 4} 1
|
20 {} ABORT UPDATE 1 {1 2 3 4} 1
|
||||||
21 {} ROLLBACK UPDATE 1 {1 2 3 4} 0
|
21 {} ROLLBACK UPDATE 1 {1 2 3 4} 0
|
||||||
22 REPLACE FAIL UPDATE 0 {7 6 9} 1
|
22 REPLACE IGNORE UPDATE 0 {6 7 3 9} 1
|
||||||
23 IGNORE ROLLBACK 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}}
|
if {$t0} {set t1 {uniqueness constraint failed}}
|
||||||
do_test conflict-6.$i {
|
do_test conflict-6.$i {
|
||||||
@@ -660,4 +667,26 @@ do_test conflict-9.26 {
|
|||||||
execsql {SELECT * FROM t3}
|
execsql {SELECT * FROM t3}
|
||||||
} {6}
|
} {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
|
finish_test
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
# This file implements regression tests for SQLite library. The
|
# This file implements regression tests for SQLite library. The
|
||||||
# focus of this script is in-memory database backend.
|
# 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]
|
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
|
19 {} FAIL UPDATE 1 {6 7 3 4} 1
|
||||||
20 {} ABORT UPDATE 1 {1 2 3 4} 1
|
20 {} ABORT UPDATE 1 {1 2 3 4} 1
|
||||||
21 {} ROLLBACK UPDATE 1 {1 2 3 4} 0
|
21 {} ROLLBACK UPDATE 1 {1 2 3 4} 0
|
||||||
22 REPLACE FAIL UPDATE 0 {7 6 9} 1
|
22 REPLACE IGNORE UPDATE 0 {6 7 3 9} 1
|
||||||
23 IGNORE ROLLBACK 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}}
|
if {$t0} {set t1 {uniqueness constraint failed}}
|
||||||
do_test memdb-5.$i {
|
do_test memdb-5.$i {
|
||||||
|
Reference in New Issue
Block a user