]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Make sure the ON CONFLICT clause on a BEGIN overrides the conflict resolution
authordrh <drh@noemail.net>
Fri, 16 May 2003 02:30:27 +0000 (02:30 +0000)
committerdrh <drh@noemail.net>
Fri, 16 May 2003 02:30:27 +0000 (02:30 +0000)
specified by an index.  This fixes a bug reported on the newsgroup. (CVS 975)

FossilOrigin-Name: 0f92736d1fbe3b587592fe1f26dfb3558cc49727

manifest
manifest.uuid
src/insert.c
test/capi2.test
test/conflict.test
test/memdb.test

index c578be3115f4a8dbdebb51ccb95bfd4db238dd54..672a3069f012fefe2941c1ea7726fc1dfe918e28 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Removed\s3rd\s(file)\scolumn\sfrom\sPRAGMA\sdatabase_list\suntil\stests\sare\sfixed.\s(CVS\s974)
-D 2003-05-13T08:01:34
+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-16T02:30:27
 F Makefile.in 004acec253ecdde985c8ecd5b7c9accdb210378f
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -32,7 +32,7 @@ F src/expr.c a666ef5220ca90ebcf40c8ccc783966a345a7616
 F src/func.c 33bbce6acaf9578ac99aa1f689968ccaf2ce43a2
 F src/hash.c 058f077c1f36f266581aa16f907a3903abf64aa3
 F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8
-F src/insert.c c230a8c216f6788095d46f0e270406a93aae45af
+F src/insert.c fac16589e644b2d4bb615c5e782bcfd0453a052a
 F src/main.c 16e68905793b118552a9cf43a9f77ca1d9e395a9
 F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565
 F src/os.c 94b618c0c0a76210e53857d77c96d2f042dc33b1
@@ -73,8 +73,8 @@ F test/btree3.test e597fb59be2ac0ea69c62aaa2064e998e528b665
 F test/btree3rb.test 127efcf5cdfcc352054e7db12622b01cdd8b36ac
 F test/btree4.test fa955a3d7a8bc91d6084b7f494f9e5d1bdfb15b6
 F test/btree4rb.test ae6f0438512edcb45cf483471cd6070a765963a9
-F test/capi2.test fb94bed9e236074c5e255cfd25e3e32344e24855
-F test/conflict.test 80cf3780c8686b92db4ce0f60bca46a000537327
+F test/capi2.test dddfe84d41c876e5339efae41f8e688760454fba
+F test/conflict.test 70d38ff29b532813320c17740738a556ee0ec95d
 F test/copy.test 73df5ed3112e858e006a8b7ddb4c9bab6a25d0fb
 F test/delete.test 1586a00574e699a9913bc3403261813e8a93e6b9
 F test/expr.test 48bc6400627532ec97e233809e33d336468bc84c
@@ -92,7 +92,7 @@ F test/limit.test 9ffb965a0f5bf7152187ef3d8d1249b96e5620bf
 F test/lock.test 388a3a10962d2d571c0c1821cc35bf069ee73473
 F test/main.test 6a851b5992c4881a725a3d9647e629199df8de9d
 F test/malloc.test 7ba32a9ebd3aeed52ae4aaa6d42ca37e444536fd
-F test/memdb.test 3acf1453a5705d1aa524d3027667ca3d9c77c69f
+F test/memdb.test ab1d16eb3179272016b1fe5fa3988e9c2f6c5594
 F test/memleak.test a18e6810cae96d2f6f5136920267adbefc8e1e90
 F test/minmax.test b54ac3bc45460a4976b08ef363e05c032418726e
 F test/misc1.test 865c907df58195364eaf2e69426e9674bc8d1a8c
@@ -165,7 +165,7 @@ F www/speed.tcl cb4c10a722614aea76d2c51f32ee43400d5951be
 F www/sqlite.tcl 4bd1729e320f5fa9125f0022b281fbe839192125
 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P f267a8a4ff52eb7ee3ac20a8e3a8ab5fe19e445d
-R 4c116ad646a5d45f20337623549b2e99
-U jplyon
-Z d2079033f7e558e2136afb4a88150abf
+P 4183cf97676e64d19978941a7c4a3fe521fcb1fb
+R ceda8451adba59b6260a922bc13b596c
+U drh
+Z ca1fb5800fb2c1a110aee865c12a3008
index b7a14f2559a519abe52403110cb4fa15134697c5..f72135b088f095967a8b7d145f1ce5f0c61d3ea1 100644 (file)
@@ -1 +1 @@
-4183cf97676e64d19978941a7c4a3fe521fcb1fb
\ No newline at end of file
+0f92736d1fbe3b587592fe1f26dfb3558cc49727
\ No newline at end of file
index 71a0000902852d6288fa3e2a510bc138f7367378..ce4842535533d4fbbfcfff992f90addae58b80fc 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that are called by the parser
 ** 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"
 
@@ -668,9 +668,10 @@ void sqliteGenerateConstraintChecks(
     if( onError==OE_None ) continue;
     if( overrideError!=OE_Default ){
       onError = overrideError;
-    }else if( onError==OE_Default ){
+    }else if( pParse->db->onError!=OE_Default ){
       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 ){
       onError = OE_Abort;
@@ -718,9 +719,10 @@ void sqliteGenerateConstraintChecks(
     onError = pTab->keyConf;
     if( overrideError!=OE_Default ){
       onError = overrideError;
-    }else if( onError==OE_Default ){
+    }else if( pParse->db->onError!=OE_Default ){
       onError = pParse->db->onError;
-      if( onError==OE_Default ) onError = OE_Abort;
+    }else if( onError==OE_Default ){
+      onError = OE_Abort;
     }
     if( onError!=OE_Replace ){
       if( isUpdate ){
@@ -782,9 +784,10 @@ void sqliteGenerateConstraintChecks(
     if( onError==OE_None ) continue;  /* pIdx is not a UNIQUE index */
     if( overrideError!=OE_Default ){
       onError = overrideError;
-    }else if( onError==OE_Default ){
+    }else if( pParse->db->onError!=OE_Default ){
       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 */
index 3612708d6b0484d27dcefc464a1b857196e214b1..9e003ea6c38f50e81f0d158ebe81428489f82844 100644 (file)
@@ -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 {
index 66678ef65d48cafd4b60ec10bcc9a8ecce84a540..26dcbfe24c9addca34f1e5c42f5b21236567ce33 100644 (file)
@@ -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
index af621960430dc4763924fb4a5b1c5b7923721411..ea3f4f3c9f52038e6393108ed1b911238f9213ac 100644 (file)
@@ -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 {