Fix the REPLACE conflict resolution so that it falls back to ABORT when

a CHECK constraint fails.  Ticket [c38baa3d969eab794].

FossilOrigin-Name: 4e157b774764b8bafc9fabb88decf54f178b5ff5
This commit is contained in:
drh 2010-08-03 13:08:54 +00:00
parent 9e5f10743d
commit 6dc8490232
4 changed files with 34 additions and 11 deletions

View File

@ -1,8 +1,8 @@
-----BEGIN PGP SIGNED MESSAGE----- -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Hash: SHA1
C Modify\swal2.test\sto\sdisable\stests\srequiring\sTCL\s8.5\sif\sthe\stest\sharness\sis\ncompiled\susing\sTCL\s8.4. C Fix\sthe\sREPLACE\sconflict\sresolution\sso\sthat\sit\sfalls\sback\sto\sABORT\swhen\na\sCHECK\sconstraint\sfails.\s\sTicket\s[c38baa3d969eab794].
D 2010-08-02T10:59:14 D 2010-08-03T13:08:55
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in ec08dc838fd8110fe24c92e5130bcd91cbb1ff2e F Makefile.in ec08dc838fd8110fe24c92e5130bcd91cbb1ff2e
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -133,7 +133,7 @@ F src/global.c 02335177cf6946fe5525c6f0755cf181140debf3
F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af
F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970
F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08
F src/insert.c ba455ebb100283ccc5da03da3498fcbca48ce6bb F src/insert.c a4995747c062256582a90b4f87f716e11b067050
F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e
@ -304,7 +304,7 @@ F test/collate9.test 3adcc799229545940df2f25308dd1ad65869145a
F test/collateA.test b8218ab90d1fa5c59dcf156efabb1b2599c580d6 F test/collateA.test b8218ab90d1fa5c59dcf156efabb1b2599c580d6
F test/colmeta.test 087c42997754b8c648819832241daf724f813322 F test/colmeta.test 087c42997754b8c648819832241daf724f813322
F test/colname.test 08948a4809d22817e0e5de89c7c0a8bd90cb551b F test/colname.test 08948a4809d22817e0e5de89c7c0a8bd90cb551b
F test/conflict.test 0ed68b11f22721052d880ee80bd528a0e0828236 F test/conflict.test f2f2b2950730a9532e11e468070cebf389f5c375
F test/corrupt.test 1a5bef8b2d178859af69814ecedcd37219a89968 F test/corrupt.test 1a5bef8b2d178859af69814ecedcd37219a89968
F test/corrupt2.test 808a28d0ca3b97e9aa8c91cd2b485ea2700b76d1 F test/corrupt2.test 808a28d0ca3b97e9aa8c91cd2b485ea2700b76d1
F test/corrupt3.test a399dacccb91c732f6b071c913e70d195af8c058 F test/corrupt3.test a399dacccb91c732f6b071c913e70d195af8c058
@ -844,14 +844,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P e75b52d156905ce16bedb94f65c01a4640bdfa75 P 016486c7d544dcf9b7422cb0fb9804aa1c418f68
R 4bcc255fd245f0aefdffbbd0dcd527e2 R 3325483e922777e07054f0cb49438593
U drh U drh
Z 73dcbb237530d4b99c645ee151eb2169 Z d4d184e312b9a6c1d14017f77666543c
-----BEGIN PGP SIGNATURE----- -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux) Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFMVqUFoxKgR168RlERAr7YAJ4i7F11zp1UnFfAGpxICAppvxfFxwCfRCKv iD8DBQFMWBTroxKgR168RlERAs2pAJ9ife269/S3Uo4Ju+ipuIdk7AK4VwCeNuGn
nCovMTlO5dRRYoRobLXqmLk= CUQtoV3bUC+VGAu/OWy/3UA=
=2tPU =m2KU
-----END PGP SIGNATURE----- -----END PGP SIGNATURE-----

View File

@ -1 +1 @@
016486c7d544dcf9b7422cb0fb9804aa1c418f68 4e157b774764b8bafc9fabb88decf54f178b5ff5

View File

@ -1220,6 +1220,7 @@ void sqlite3GenerateConstraintChecks(
if( onError==OE_Ignore ){ if( onError==OE_Ignore ){
sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest); sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
}else{ }else{
if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */
sqlite3HaltConstraint(pParse, onError, 0, 0); sqlite3HaltConstraint(pParse, onError, 0, 0);
} }
sqlite3VdbeResolveLabel(v, allOk); sqlite3VdbeResolveLabel(v, allOk);

View File

@ -789,4 +789,26 @@ do_test conflict-12.4 {
} {2 one} } {2 one}
# Ticket [c38baa3d969eab7946dc50ba9d9b4f0057a19437]
# REPLACE works like ABORT on a CHECK constraint.
#
do_test conflict-13.1 {
execsql {
CREATE TABLE t13(a CHECK(a!=2));
BEGIN;
REPLACE INTO t13 VALUES(1);
}
catchsql {
REPLACE INTO t13 VALUES(2);
}
} {1 {constraint failed}}
do_test conflict-13.2 {
execsql {
REPLACE INTO t13 VALUES(3);
COMMIT;
SELECT * FROM t13;
}
} {1 3}
finish_test finish_test