Add missing VdbeCoverage() macro. Fix an off-by-one error in partial index

handling.  New test cases.  Ticket [c1e19e12046d23fe]

FossilOrigin-Name: 41cc8e3dab998f7efc898d18837ca7fdac94ea3f89954990c5231456bf725fee
This commit is contained in:
drh 2019-10-26 01:43:14 +00:00
parent a407eccb61
commit 0660884ea0
4 changed files with 67 additions and 10 deletions

View File

@ -1,5 +1,5 @@
C If\sreplace\striggers\sare\srun\sduring\suniqueness\schecking,\sthen\srerun\sall\nuniqueness\schecks\sa\ssecond\stime\susing\sthe\sABORT\salgorithm.\nFix\sfor\sticket\s[c1e19e12046d23fe]
D 2019-10-26T00:04:21.466
C Add\smissing\sVdbeCoverage()\smacro.\s\sFix\san\soff-by-one\serror\sin\spartial\sindex\nhandling.\s\sNew\stest\scases.\s\sTicket\s[c1e19e12046d23fe]
D 2019-10-26T01:43:14.417
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -487,7 +487,7 @@ F src/hash.c 8d7dda241d0ebdafb6ffdeda3149a412d7df75102cecfc1021c98d6219823b19
F src/hash.h 9d56a9079d523b648774c1784b74b89bd93fac7b365210157482e4319a468f38
F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
F src/insert.c 83ccd3f1f45f048bca2dbc0f9c34e8f3a57fdcbc43ddec04a7938090ffb85a9e
F src/insert.c be086d71275a23bce61f3d9ab737ef135562d205ac5be1a4222385bdaa4376b5
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
F src/loadext.c 4ddc65ae13c0d93db0ceedc8b14a28c8c260513448b0eb8c5a2ac375e3b6a85d
F src/main.c 3e01f6a1c96643381b5f9d79e4ff7f2520bc5712197746fb0852283e78cccf66
@ -1061,7 +1061,7 @@ F test/indexexpr1.test c26c8b352311c1deb30642cd0379e5cb94e416c7e9e0885e92d9e0155
F test/indexexpr2.test b580f378423bca443ffab47ada677203cfcf8a60f48a8aa20065f27c8f7739b5
F test/indexfault.test 98d78a8ff1f5335628b62f886a1cb7c7dac1ef6d48fa39c51ec871c87dce9811
F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7
F test/insert.test d15bf96ec2120ecd27cb07be2b44b141a98b4b7f58762a40178f8205f9b9a96a
F test/insert.test 4e3f0de67aac3c5be1f4aaedbcea11638f1b5cdc9a3115be14d19aa9db7623c6
F test/insert2.test 4d14b8f1b810a41995f6286b64a6943215d52208
F test/insert3.test 1b7db95a03ad9c5013fdf7d6722b6cd66ee55e30
F test/insert4.test 7802ada6ba8738661b9f6c0e26858d3375b40cc7180289fd350644cd7a08fec9
@ -1848,7 +1848,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P ea068b099c96b8b9526114732d2a6be186cf381b7329d102778ad25b95510c9e
R cace6824aa8651d52f54d321985ad4c0
P fbac0c65d8464b126d385262d176864add55452ec9e3d5eb76ffee06e820cb9c
R 9e2b0bb43a4e8a1e459a6408a4d01f3f
U drh
Z 1fcf2849ed7e21c156487e77513e1cff
Z 412ed0cb894f7416a9dbba390e20b800

View File

@ -1 +1 @@
fbac0c65d8464b126d385262d176864add55452ec9e3d5eb76ffee06e820cb9c
41cc8e3dab998f7efc898d18837ca7fdac94ea3f89954990c5231456bf725fee

View File

@ -1905,7 +1905,7 @@ void sqlite3GenerateConstraintChecks(
if( pIdx->pPartIdxWhere ){
/* Bypass the recheck if this partial index is not defined
** for the current row */
sqlite3VdbeAddOp2(v, OP_IsNull, regIdx, lblRecheckOk);
sqlite3VdbeAddOp2(v, OP_IsNull, regIdx-1, lblRecheckOk);
VdbeCoverage(v);
}
/* Copy the constraint check code from above, except change
@ -1922,6 +1922,7 @@ void sqlite3GenerateConstraintChecks(
sqlite3VdbeAddOp4(v, pOp->opcode, pOp->p1, p2, pOp->p3,
pOp->p4.z, pOp->p4type);
sqlite3VdbeChangeP5(v, pOp->p5);
VdbeCoverageIf(v, p2!=pOp->p2 );
}
nConflictCk--;
pOp++;

View File

@ -515,7 +515,7 @@ do_catchsql_test insert-16.6 {
END;
INSERT INTO p1 VALUES(1, 1);
INSERT INTO c1 VALUES(2, 1);
REPLACE INTO p1 VALUES(3, 1);
REPLACE INTO p1 VALUES(3, 1);2
} {1 {UNIQUE constraint failed: p1.b}}
integrity_check insert-16.7
@ -542,6 +542,62 @@ do_catchsql_test insert-17.3 {
REPLACE INTO t1(rowid,a,b,c) VALUES(200,1,2,3);
} {1 {UNIQUE constraint failed: t1.c}}
integrity_check insert-17.4
do_execsql_test insert-17.5 {
CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
CREATE UNIQUE INDEX t2b ON t2(b);
INSERT INTO t2(a,b) VALUES(1,1),(2,2),(3,3),(4,4);
CREATE TABLE fire(x);
CREATE TRIGGER t2r1 AFTER DELETE ON t2 BEGIN
INSERT INTO fire VALUES(old.a);
END;
UPDATE OR REPLACE t2 SET a=4, b=3 WHERE a=1;
SELECT *, 'x' FROM t2 ORDER BY a;
} {2 2 x 4 3 x}
do_execsql_test insert-17.6 {
SELECT x FROM fire ORDER BY x;
} {3 4}
do_execsql_test insert-17.7 {
DELETE FROM t2;
DELETE FROM fire;
INSERT INTO t2(a,b) VALUES(1,1),(2,2),(3,3),(4,4);
UPDATE OR REPLACE t2 SET a=1, b=3 WHERE a=1;
SELECT *, 'x' FROM t2 ORDER BY a;
} {1 3 x 2 2 x 4 4 x}
do_execsql_test insert-17.8 {
SELECT x FROM fire ORDER BY x;
} {3}
do_execsql_test insert-17.10 {
CREATE TABLE t3(a INTEGER PRIMARY KEY, b INT, c INT, d INT);
CREATE UNIQUE INDEX t3bpi ON t3(b) WHERE c<=d;
CREATE UNIQUE INDEX t3d ON t3(d);
INSERT INTO t3(a,b,c,d) VALUES(1,1,1,1),(2,1,3,2),(3,4,5,6);
CREATE TRIGGER t3r1 AFTER DELETE ON t3 BEGIN
SELECT 'hi';
END;
REPLACE INTO t3(a,b,c,d) VALUES(4,4,8,9);
} {}
do_execsql_test insert-17.11 {
SELECT *, 'x' FROM t3 ORDER BY a;
} {1 1 1 1 x 2 1 3 2 x 4 4 8 9 x}
do_execsql_test insert-17.12 {
REPLACE INTO t3(a,b,c,d) VALUES(5,1,11,2);
SELECT *, 'x' FROM t3 ORDER BY a;
} {1 1 1 1 x 4 4 8 9 x 5 1 11 2 x}
do_execsql_test insert-17.13 {
DELETE FROM t3;
INSERT INTO t3(a,b,c,d) VALUES(1,1,1,1),(2,1,3,2),(3,4,5,6);
DROP TRIGGER t3r1;
CREATE TRIGGER t3r1 AFTER DELETE ON t3 BEGIN
INSERT INTO t3(b,c,d) VALUES(old.b,old.c,old.d);
END;
} {}
do_catchsql_test insert-17.14 {
REPLACE INTO t3(a,b,c,d) VALUES(4,4,8,9);
} {1 {UNIQUE constraint failed: t3.b}}
do_catchsql_test insert-17.15 {
REPLACE INTO t3(a,b,c,d) VALUES(5,1,11,2);
} {1 {UNIQUE constraint failed: t3.d}}
finish_test