Add test cases to improve coverage of VDBE branches. Still some to go.

FossilOrigin-Name: 4cef609d61de272cfdc2b39e1d49c7cd56ec834086bd63095116ff98f4d402bd
This commit is contained in:
dan 2019-04-04 17:58:34 +00:00
parent 80ac9cb3c0
commit b84b38fd89
8 changed files with 198 additions and 13 deletions

View File

@ -1,5 +1,5 @@
C Correctly\sinitialize\sthe\sloadable\sextension\sthunk.
D 2019-04-04T17:39:54.664
C Add\stest\scases\sto\simprove\scoverage\sof\sVDBE\sbranches.\sStill\ssome\sto\sgo.
D 2019-04-04T17:58:34.623
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -662,7 +662,7 @@ F test/auth.test 3310d9c08e928beca42d3eadaaf53cef619d9d275f598565a3758a21ce63138
F test/auth2.test 9eb7fce9f34bf1f50d3f366fb3e606be5a2000a1
F test/auth3.test db21405b95257c24d29273b6b31d0efc59e1d337e3d5804ba2d1fd4897b1ae49
F test/autoanalyze1.test b9cc3f32a990fa56669b668d237c6d53e983554ae80c0604992e18869a0b2dec
F test/autoinc.test 381f494fefa90acd999933829e2934efb6b40906db9d6a39e822e3f7b4c8bf61
F test/autoinc.test 997d6f185f138229dc4251583a1d04816423dddc2fc034871a01aeb1d728cb39
F test/autoindex1.test 96185415f5faacd5b8d7a7f505efddd5abb1f111d58338e9c0b1dc40b87cd3cc
F test/autoindex2.test 12ef578928102baaa0dc23ad397601a2f4ecb0df
F test/autoindex3.test 2dd997d6590438b53e4f715f9278aa91c9299cf3f81246a0915269c35beb790e
@ -796,7 +796,7 @@ F test/default.test 3e46c421eebefd2787c2f96673efabf792d360f3a1d5073918cbe450ce67
F test/delete.test 31832b0c45ecb51a54348c68db173be462985901e6ed7f403d6d7a8f70ab4ef0
F test/delete2.test 3a03f2cca1f9a67ec469915cb8babd6485db43fa
F test/delete3.test 555e84a00a99230b7d049d477a324a631126a6ab
F test/delete4.test 21d2113217eeaacac2d99defe14fe6611615ae86
F test/delete4.test 6aa279f459f4aa792cc251435c3809415c1ecaf9f27dce91675e26f05b503db3
F test/delete_db.test 096d828493c7907f9ea11a7098ea6a0f73edba89406487d5d6cc2228dc4ab8b0
F test/descidx1.test 6d03b44c8538fe0eb4924e19fba10cdd8f3c9240
F test/descidx2.test 9f1a0c83fd57f8667c82310ca21b30a350888b5d
@ -1044,7 +1044,7 @@ F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7
F test/insert.test 9773604f8e1a2595f51488a5643c359d8a11dc55a11cb185910d93387d378458
F test/insert2.test 4d14b8f1b810a41995f6286b64a6943215d52208
F test/insert3.test 1b7db95a03ad9c5013fdf7d6722b6cd66ee55e30
F test/insert4.test 46bead5f39e181850ee56adcf49d3a3157c460c52249211714612ac89fe34835
F test/insert4.test 7802ada6ba8738661b9f6c0e26858d3375b40cc7180289fd350644cd7a08fec9
F test/insert5.test 394f96728d1258f406fe5f5aeb0aaf29487c39a6
F test/insertfault.test ac63d14ea3b49c573673a572f4014b9117383a03e497c58f308b5c776e4a7f74
F test/instr.test 9a8802f28437d8ade53fedfc47b2ca599b4e48ba
@ -1201,7 +1201,7 @@ F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442
F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff
F test/permutations.test b8f0da2f53ef1bd7ff149a140ee625aa7276c94ae15eb9acc2d8ed4af8f22b13
F test/pg_common.tcl 4740dc35190d6acdab14c097783331361301ab504a94d948f6afbb56ce0a51e8
F test/pragma.test c267bf02742c823a191960895b3d52933cebd7beee26757d1ed694f213fcd867
F test/pragma.test cf066fe0f7f5d49f4758de4986407b8676c61aaa7871599340d64f42a8edc352
F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f
F test/pragma3.test 8300aa9c63cff1027006ca34bf413a148abbd6dcd471fa9a1ded322fe18c0df9
F test/pragma4.test 52d8186f9e8d09b87189432cdd401dfa66d0b32445e837fa19046c8ae7621b0e
@ -1552,7 +1552,7 @@ F test/trigger8.test 30cb0530bd7c4728055420e3f739aa00412eafa4
F test/trigger9.test 2226ec795a33b0460ab5cf8891e9054cc7edef41
F test/triggerA.test 837be862d8721f903dba3f3ceff05b32e0bee5214cf6ea3da5fadf12d3650e9d
F test/triggerB.test 56780c031b454abac2340dbb3b71ac5c56c3d7fe
F test/triggerC.test c7fbc3eb241b5a7ba4b0815f76c3708483e91890f9573add12a610c45b2a6022
F test/triggerC.test f1210921924f3a6aaa8c1538115fe56c9c448e8e3033bf0dab38ae78db937c41
F test/triggerD.test 8e7f3921a92a5797d472732108109e44575fa650
F test/triggerE.test ede2e4bce4ba802337bd69d39447fa04a938e06d84a8bfc53c76850fc36ed86d
F test/triggerF.test 5d76f0a8c428ff87a4d5ed52da06f6096a2c787a1e21b846111dfac4123de3ad
@ -1700,7 +1700,7 @@ F test/with2.test e0030e2f0267a910d6c0e4f46f2dfe941c1cc0d4f659ba69b3597728e7e8f1
F test/with3.test 8d26920c88283e0a473ceebd3451554922108ce7b2a6a1157c47eb0a7011212c
F test/with4.test 257be66c0c67fee1defbbac0f685c3465e2cad037f21ce65f23f86084f198205
F test/withM.test 693b61765f2b387b5e3e24a4536e2e82de15ff64
F test/without_rowid1.test 533add9100255e4cc430d371b3ecfb79f11f956b86c3a1b9d34413bf8e482d8f
F test/without_rowid1.test c3f84b1095bdbf24c22c80a0948685ada10ad3bbf421bacad228c7a4cccf22da
F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99
F test/without_rowid3.test ea4b59dd1b0d7f5f5e4b7cca978cdb905752a9d7c57dc4344a591dba765a3691
F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a
@ -1815,7 +1815,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 9cac5ac145d62117c918539baaa8a3c124230e031842e35fa1ba59f658c99518
R 55c45bc6690a22b07dcf30361432b904
U drh
Z 6b0ba30371014dd71e3510d49c147a1e
P 4fca46ded7873d4939d7c6bff363ded41667f2255a4ab624a1a24bebbae733eb
R e06dd790728cfb4840c24aea722adf87
U dan
Z f435b81a4b15ca0f8af2ad1bdda4d9cc

View File

@ -1 +1 @@
4fca46ded7873d4939d7c6bff363ded41667f2255a4ab624a1a24bebbae733eb
4cef609d61de272cfdc2b39e1d49c7cd56ec834086bd63095116ff98f4d402bd

View File

@ -16,6 +16,7 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix autoinc
# If the library is not compiled with autoincrement support then
# skip all tests in this file.
@ -856,4 +857,27 @@ do_test autoinc-12.7 {
lappend res $msg
} {0 ok}
#--------------------------------------------------------------------------
reset_db
do_execsql_test 13.0 {
CREATE TABLE t1(i INTEGER PRIMARY KEY AUTOINCREMENT, j);
CREATE TABLE t2(i INTEGER PRIMARY KEY AUTOINCREMENT, j);
CREATE TABLE t3(i INTEGER PRIMARY KEY AUTOINCREMENT, j);
INSERT INTO t1 VALUES(NULL, 1);
INSERT INTO t2 VALUES(NULL, 2);
INSERT INTO t3 VALUES(NULL, 3);
SELECT name FROM sqlite_sequence;
} {t1 t2 t3}
do_execsql_test 13.1 {
UPDATE sqlite_sequence SET name=NULL WHERE name='t2';
INSERT INTO t3 VALUES(NULL, 4);
DELETE FROM t3;
INSERT INTO t3 VALUES(NULL, 5);
SELECT * FROM t3;
} {3 5}
finish_test

View File

@ -183,5 +183,82 @@ do_execsql_test 6.1 {
SELECT x FROM t2;
} {5}
#-------------------------------------------------------------------------
# Test the effect of failing to find a table row based on an index key
# within a DELETE. Either because the db is corrupt, or a trigger on another
# row already deleted the entry, or because a BEFORE trigger on the current
# row has already deleted it.
#
do_execsql_test 7.1.0 {
CREATE TABLE t3(id INT PRIMARY KEY, a, b) WITHOUT ROWID;
CREATE INDEX t3a ON t3(a);
CREATE INDEX t3b ON t3(b);
INSERT INTO t3 VALUES(1, 1, 1);
INSERT INTO t3 VALUES(2, 2, 2);
INSERT INTO t3 VALUES(3, 3, 3);
INSERT INTO t3 VALUES(4, 4, 1);
}
do_execsql_test 7.1.1 {
DELETE FROM t3 WHERE a=4 OR b=1;
}
do_execsql_test 7.1.2 {
SELECT * FROM t3;
} { 2 2 2 3 3 3 }
do_execsql_test 7.2.0 {
CREATE TABLE t4(a PRIMARY KEY, b) WITHOUT ROWID;
CREATE INDEX t4i ON t4(b);
INSERT INTO t4 VALUES(1, 'hello');
INSERT INTO t4 VALUES(2, 'world');
CREATE TABLE t5(a PRIMARY KEY, b) WITHOUT ROWID;
CREATE INDEX t5i ON t5(b);
INSERT INTO t5 VALUES(1, 'hello');
INSERT INTO t5 VALUES(3, 'world');
PRAGMA writable_schema = 1;
UPDATE sqlite_master SET rootpage = (
SELECT rootpage FROM sqlite_master WHERE name = 't5'
) WHERE name = 't4';
}
db close
sqlite3 db test.db
do_execsql_test 7.2.1 {
DELETE FROM t4 WHERE b='world'
}
reset_db
do_execsql_test 7.3.0 {
CREATE TABLE t3(id INT PRIMARY KEY, a, b) WITHOUT ROWID;
INSERT INTO t3 VALUES(1, 2, 3);
INSERT INTO t3 VALUES(4, 5, 6);
INSERT INTO t3 VALUES(7, 8, 9);
CREATE TRIGGER t3t BEFORE DELETE ON t3 BEGIN
DELETE FROM t3 WHERE id=old.id+3;
END;
}
do_execsql_test 7.3.1 {
DELETE FROM t3 WHERE a IN(2, 5, 8);
SELECT * FROM t3;
} {}
do_execsql_test 7.3.2 {
DROP TRIGGER t3t;
INSERT INTO t3 VALUES(1, 2, 3);
INSERT INTO t3 VALUES(4, 5, 6);
INSERT INTO t3 VALUES(7, 8, 9);
CREATE TRIGGER t3t BEFORE DELETE ON t3 BEGIN
DELETE FROM t3 WHERE id=old.id;
END;
}
do_execsql_test 7.3.3 {
DELETE FROM t3 WHERE a IN(2, 5, 8);
SELECT * FROM t3;
} {}
finish_test

View File

@ -598,5 +598,25 @@ do_test 10.3 {
set sqlite3_xferopt_count
} {1}
#-------------------------------------------------------------------------
# xfer transfer between tables where the source has an empty partial index.
#
do_execsql_test 11.0 {
CREATE TABLE t9(a, b, c);
CREATE INDEX t9a ON t9(a);
CREATE INDEX t9b ON t9(b) WHERE c=0;
INSERT INTO t9 VALUES(1, 1, 1);
INSERT INTO t9 VALUES(2, 2, 2);
INSERT INTO t9 VALUES(3, 3, 3);
CREATE TABLE t10(a, b, c);
CREATE INDEX t10a ON t10(a);
CREATE INDEX t10b ON t10(b) WHERE c=0;
INSERT INTO t10 SELECT * FROM t9;
SELECT * FROM t10;
PRAGMA integrity_check;
} {1 1 1 2 2 2 3 3 3 ok}
finish_test

View File

@ -251,6 +251,31 @@ do_test pragma-1.14.4 {
PRAGMA synchronous;
}
} {2}
do_execsql_test 1.15.1 {
PRAGMA default_cache_size = 0;
}
do_execsql_test 1.15.2 {
PRAGMA default_cache_size;
} $DFLT_CACHE_SZ
do_execsql_test 1.15.3 {
PRAGMA default_cache_size = -500;
}
do_execsql_test 1.15.4 {
PRAGMA default_cache_size;
} 500
do_execsql_test 1.15.3 {
PRAGMA default_cache_size = 500;
}
do_execsql_test 1.15.4 {
PRAGMA default_cache_size;
} 500
db close
hexio_write test.db 48 FFFFFF00
sqlite3 db test.db
do_execsql_test 1.15.4 {
PRAGMA default_cache_size;
} 256
} ;# ifcapable pager_pragmas
# Test turning "flag" pragmas on and off.

View File

@ -1057,5 +1057,19 @@ do_catchsql_test 16.2 {
HAVING raise(ABORT, 'msg');
} {1 {RAISE() may only be used within a trigger-program}}
#-------------------------------------------------------------------------
# Datatype mismatch on IPK when there are BEFORE triggers.
#
do_execsql_test 17.0 {
CREATE TABLE xyz(x INTEGER PRIMARY KEY, y, z);
CREATE TRIGGER xyz_tr BEFORE INSERT ON xyz BEGIN
SELECT new.x;
END;
}
do_catchsql_test 17.1 {
INSERT INTO xyz VALUES('hello', 2, 3);
} {1 {datatype mismatch}}
finish_test

View File

@ -355,5 +355,30 @@ do_execsql_test 10.1 {
DELETE FROM t2 WHERE b=1
}
#-------------------------------------------------------------------------
# UNIQUE constraint violation in an UPDATE with a multi-column PK.
#
reset_db
do_execsql_test 10.0 {
CREATE TABLE t1(a, b, c UNIQUE, PRIMARY KEY(a, b)) WITHOUT ROWID;
INSERT INTO t1 VALUES('a', 'a', 1);
INSERT INTO t1 VALUES('a', 'b', 2);
INSERT INTO t1 VALUES('b', 'a', 3);
INSERT INTO t1 VALUES('b', 'b', 4);
}
do_catchsql_test 10.1 {
UPDATE t1 SET c=1 WHERE (a, b) = ('a', 'a');
} {0 {}}
do_catchsql_test 10.2 {
UPDATE t1 SET c=1 WHERE (a, b) = ('a', 'b');
} {1 {UNIQUE constraint failed: t1.c}}
do_catchsql_test 10.3 {
UPDATE t1 SET c=1 WHERE (a, b) = ('b', 'a');
} {1 {UNIQUE constraint failed: t1.c}}
do_catchsql_test 10.4 {
UPDATE t1 SET c=1 WHERE (a, b) = ('b', 'b');
} {1 {UNIQUE constraint failed: t1.c}}
finish_test