1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Miscellaneous code simplifications and cleanup and test coverage

enhancements. (CVS 4730)

FossilOrigin-Name: af129b6d158cc90ce9752dd6383c1de47f7b3e43
This commit is contained in:
drh
2008-01-19 20:11:25 +00:00
parent a05a722f23
commit 91fd4d46ad
16 changed files with 289 additions and 91 deletions

View File

@ -1,5 +1,5 @@
C Cleanup\sand\ssimplification\sof\sconstraint\sprocessing.\s\sSimplifications\nto\sthe\sVM\sfor\sbetter\stest\scoverage.\s(CVS\s4729) C Miscellaneous\scode\ssimplifications\sand\scleanup\sand\stest\scoverage\nenhancements.\s(CVS\s4730)
D 2008-01-19T03:35:59 D 2008-01-19T20:11:26
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in 30789bf70614bad659351660d76b8e533f3340e9 F Makefile.in 30789bf70614bad659351660d76b8e533f3340e9
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -69,7 +69,7 @@ F mkdll.sh 5f8438dcac98e795d7df6529159a1ec566de0183
F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f
F mkextw.sh 1a866b53637dab137191341cc875575a5ca110fb F mkextw.sh 1a866b53637dab137191341cc875575a5ca110fb
F mkopcodec.awk 3fb9bf077053c968451f4dd03d11661ac373f9d1 F mkopcodec.awk 3fb9bf077053c968451f4dd03d11661ac373f9d1
F mkopcodeh.awk 89fab7d28a5ec5313f6ca985d87a31a97ef14bcb F mkopcodeh.awk 513946ce4429bf2723aef0d640eb4d2493deb68e
F mkso.sh 24bde4c09e6fe80f718db3c31c068f45e13a2f2c F mkso.sh 24bde4c09e6fe80f718db3c31c068f45e13a2f2c
F publish.sh 1c0658c63d70f182a8f5e17cc28422f1b237f51d F publish.sh 1c0658c63d70f182a8f5e17cc28422f1b237f51d
F publish_osx.sh eca87df1e3d43d128d97d3261fd48b3d6877996e F publish_osx.sh eca87df1e3d43d128d97d3261fd48b3d6877996e
@ -140,7 +140,7 @@ F src/sqliteInt.h 9c3384439e402016037115ad143ed0c3adbd1c93
F src/sqliteLimit.h ee4430f88f69bf63527967bb35ca52af7b0ccb1e F src/sqliteLimit.h ee4430f88f69bf63527967bb35ca52af7b0ccb1e
F src/table.c 1aeb9eab57b4235db86fe15a35dec76fb445a9c4 F src/table.c 1aeb9eab57b4235db86fe15a35dec76fb445a9c4
F src/tclsqlite.c 9923abeffc9b3d7dad58e92b319661521f60debf F src/tclsqlite.c 9923abeffc9b3d7dad58e92b319661521f60debf
F src/test1.c 64912c1e65bdc3eccf3b80c5cc092b163831b367 F src/test1.c cf222abaa6de1919bfd0c8ede4d280e4e368302b
F src/test2.c 77b34303883b9d722c65a6879bb0163a400e3789 F src/test2.c 77b34303883b9d722c65a6879bb0163a400e3789
F src/test3.c df62cd5c971dc1ae0be0a1842f9df3390934e7a6 F src/test3.c df62cd5c971dc1ae0be0a1842f9df3390934e7a6
F src/test4.c c2c0f5dc907f1346f5d4b65eb5799f11eb9e4071 F src/test4.c c2c0f5dc907f1346f5d4b65eb5799f11eb9e4071
@ -168,19 +168,19 @@ F src/update.c 31edd9c9764e80753930bd5f9b43e0edb404636f
F src/utf.c ef4b7d83bae533b76c3e1bf635b113fdad86a736 F src/utf.c ef4b7d83bae533b76c3e1bf635b113fdad86a736
F src/util.c deda8c5a400530e1c27c03619cc4cd1a06fc5281 F src/util.c deda8c5a400530e1c27c03619cc4cd1a06fc5281
F src/vacuum.c 3f34f278809bf3eb0b62ec46ff779e9c385b28f0 F src/vacuum.c 3f34f278809bf3eb0b62ec46ff779e9c385b28f0
F src/vdbe.c 986d1b4034e271c67f8cab0e03a5e459cb288ad7 F src/vdbe.c 65a3ad903f1c7a0f6e557fdc7671c3cb2d70fa12
F src/vdbe.h 58a7d931ffb704e034b2a725981cfa5bd406fad9 F src/vdbe.h 58a7d931ffb704e034b2a725981cfa5bd406fad9
F src/vdbeInt.h 835e6f0337ce89d705ef9a162338788808adc4b7 F src/vdbeInt.h 835e6f0337ce89d705ef9a162338788808adc4b7
F src/vdbeapi.c cb8c427a3ab646490c83204a98e94eff03ee2e89 F src/vdbeapi.c cb8c427a3ab646490c83204a98e94eff03ee2e89
F src/vdbeaux.c 0d2a9730195d40f7d1156731bc69f240927255c5 F src/vdbeaux.c e73c4ca5c8a66abfb06b5b543afe2819b55e35bf
F src/vdbeblob.c e386d49d8354aa5a58f0a7f2794303442c149120 F src/vdbeblob.c e386d49d8354aa5a58f0a7f2794303442c149120
F src/vdbefifo.c 334c838c8f42d61a94813d136019ee566b5dc2f6 F src/vdbefifo.c 334c838c8f42d61a94813d136019ee566b5dc2f6
F src/vdbemem.c e15122efe8868e400c2aba8ea101588944e83317 F src/vdbemem.c e15122efe8868e400c2aba8ea101588944e83317
F src/vtab.c 9924e37cf7f5c527aeabb5da025874af505fb91d F src/vtab.c 9924e37cf7f5c527aeabb5da025874af505fb91d
F src/where.c 0cc6052f73aef0d2ce59505d7ae06d6fbf696025 F src/where.c 0c18a6d88d78886fd5f3c11ef2cf001321acd918
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617 F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/all.test ee350b9ab15b175fc0a8fb51bf2141ed3a3b9cba F test/all.test d12210212bada2bde6d5aeb90969b86c1aa977d2
F test/alter.test 345648dcd1801cc0287cd996076db512d1dcdabe F test/alter.test 345648dcd1801cc0287cd996076db512d1dcdabe
F test/alter2.test 9d9850064b5c572991ea744a88ea650045f4ac6a F test/alter2.test 9d9850064b5c572991ea744a88ea650045f4ac6a
F test/alter3.test 8ce6b9c5605b3cfe7b901f454ecaf174c4f93e31 F test/alter3.test 8ce6b9c5605b3cfe7b901f454ecaf174c4f93e31
@ -222,7 +222,7 @@ F test/capi2.test cc64df7560a96f848f919ea2926c60acf639684b
F test/capi3.test 432fabf9c6402ed8ff1ae291e01f0e04b64df3ea F test/capi3.test 432fabf9c6402ed8ff1ae291e01f0e04b64df3ea
F test/capi3b.test 664eb55318132f292f2c436f90906f578cad6b97 F test/capi3b.test 664eb55318132f292f2c436f90906f578cad6b97
F test/capi3c.test 0b089837ee65a17dd73ea171c4dee5d7ea79dabb F test/capi3c.test 0b089837ee65a17dd73ea171c4dee5d7ea79dabb
F test/cast.test c4780b58b569bab4947458195410ae8791ac216b F test/cast.test ce8f14fc80f70b30ed984480cc0d8914a459e8f9
F test/check.test 024ed399600b799160378cf9d9f436bdf5dfd184 F test/check.test 024ed399600b799160378cf9d9f436bdf5dfd184
F test/collate1.test e3eaa48c21e150814be1a7b852d2a8af24458d04 F test/collate1.test e3eaa48c21e150814be1a7b852d2a8af24458d04
F test/collate2.test 701d9651c5707024fd86a20649af9ea55e2c0eb8 F test/collate2.test 701d9651c5707024fd86a20649af9ea55e2c0eb8
@ -262,7 +262,7 @@ F test/enc3.test 9331988b9d72decec96995c90637e87b00d747a5
F test/exclusive.test ebaf72ce9ff8f7ab3a09bf8f58fd65393dfff386 F test/exclusive.test ebaf72ce9ff8f7ab3a09bf8f58fd65393dfff386
F test/exclusive2.test d13bf66753dca46e61241d35d36ab7c868b0d313 F test/exclusive2.test d13bf66753dca46e61241d35d36ab7c868b0d313
F test/exclusive3.test 0e49c35b7e7cb8e7280b4ce3f0359d30b207d2ff F test/exclusive3.test 0e49c35b7e7cb8e7280b4ce3f0359d30b207d2ff
F test/expr.test 31082f3f68aa0d07d1d49088d45ed18f4b792486 F test/expr.test 6e666e5f47fbe6c23295d8c9f2b6c28109bf9ba8
F test/filefmt.test 053b622009fbbb74dd37921ffad374d852c13cd8 F test/filefmt.test 053b622009fbbb74dd37921ffad374d852c13cd8
F test/fkey1.test dcb4f28eb22d5141f15161d6bdca9a4f58c95729 F test/fkey1.test dcb4f28eb22d5141f15161d6bdca9a4f58c95729
F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb
@ -320,14 +320,14 @@ F test/fuzz.test 62fc19dd36a427777fd671b569df07166548628a
F test/fuzz2.test ea38692ce2da99ad79fe0be5eb1a452c1c4d37bb F test/fuzz2.test ea38692ce2da99ad79fe0be5eb1a452c1c4d37bb
F test/fuzz_common.tcl ff4bc2dfc465f6878f8e2d819620914365382731 F test/fuzz_common.tcl ff4bc2dfc465f6878f8e2d819620914365382731
F test/fuzz_malloc.test 166b58dfd77cc04f6afeeaef0cfc1087abf134d1 F test/fuzz_malloc.test 166b58dfd77cc04f6afeeaef0cfc1087abf134d1
F test/hook.test 3870abead2ee75d2c03585c916256ca8b5584679 F test/hook.test e17d4ed2843ba4ef9b234aa63e6f056bf88f9a19
F test/icu.test e6bfae7f625c88fd14df6f540fe835bdfc1e4329 F test/icu.test e6bfae7f625c88fd14df6f540fe835bdfc1e4329
F test/in.test 763a29007a4850d611ac4441bfa488fb9969ad30 F test/in.test 763a29007a4850d611ac4441bfa488fb9969ad30
F test/in2.test b1f447f4f0f67e9f83ff931e7e2e30873f9ea055 F test/in2.test b1f447f4f0f67e9f83ff931e7e2e30873f9ea055
F test/in3.test 2f829007cc8d25d17b859f7fe882ef2bd2e2eb49 F test/in3.test 2f829007cc8d25d17b859f7fe882ef2bd2e2eb49
F test/incrblob.test 854c23b7ff8dd3822f675936b22c094655b3c739 F test/incrblob.test 854c23b7ff8dd3822f675936b22c094655b3c739
F test/incrblob_err.test 5273097dc7c97f9b7008423a6ffd5c80d21923cb F test/incrblob_err.test 5273097dc7c97f9b7008423a6ffd5c80d21923cb
F test/incrvacuum.test 1ed44535e89a0fa10c48c1aa0a3d48ee72bcc733 F test/incrvacuum.test 9f49457edc25229e43ed29849d4ce4c3e67387b0
F test/incrvacuum2.test a958e378c193c4012cb3787804d863487f1dfad1 F test/incrvacuum2.test a958e378c193c4012cb3787804d863487f1dfad1
F test/incrvacuum_ioerr.test cb331403b8dea3c5bae6163861ff25037b0df56a F test/incrvacuum_ioerr.test cb331403b8dea3c5bae6163861ff25037b0df56a
F test/index.test cbf301cdb2da43e4eac636c3400c2439af1834ad F test/index.test cbf301cdb2da43e4eac636c3400c2439af1834ad
@ -386,7 +386,7 @@ F test/minmax2.test 33504c01a03bd99226144e4b03f7631a274d66e0
F test/minmax3.test 5b89f055df7ed03334e96eec0efb804afb7de638 F test/minmax3.test 5b89f055df7ed03334e96eec0efb804afb7de638
F test/misc1.test 1b89c02c4a33b49dee4cd1d20d161aaaba719075 F test/misc1.test 1b89c02c4a33b49dee4cd1d20d161aaaba719075
F test/misc2.test 1ee89298de9c16b61454658b24999c403e86afe4 F test/misc2.test 1ee89298de9c16b61454658b24999c403e86afe4
F test/misc3.test 7bd937e2c62bcc6be71939faf068d506467b1e03 F test/misc3.test 7952978e14c0a1b52c6fc983af0f4d785d57f065
F test/misc4.test 91e8ed25c092c2bb4e0bb01864631e2930f8d7de F test/misc4.test 91e8ed25c092c2bb4e0bb01864631e2930f8d7de
F test/misc5.test b0b4b7e0dd5d40335c8e849e5738d11a40bddc7c F test/misc5.test b0b4b7e0dd5d40335c8e849e5738d11a40bddc7c
F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91
@ -411,7 +411,7 @@ F test/quote.test 215897dbe8de1a6f701265836d6601cc6ed103e6
F test/rdonly.test b34db316525440d3b42c32e83942c02c37d28ef0 F test/rdonly.test b34db316525440d3b42c32e83942c02c37d28ef0
F test/reindex.test 38b138abe36bf9a08c791ed44d9f76cd6b97b78b F test/reindex.test 38b138abe36bf9a08c791ed44d9f76cd6b97b78b
F test/rollback.test 0bd29070ba2f76da939347773fbda53337ebd61c F test/rollback.test 0bd29070ba2f76da939347773fbda53337ebd61c
F test/rowid.test d125991eea1ffdea800d48471afd8fc4acc10b01 F test/rowid.test 1c8fc43c60d273e6ea44dfb992db587f3164312c
F test/safety.test 4a06934e45d03b8b50ebcd8d174eb0367d2fd851 F test/safety.test 4a06934e45d03b8b50ebcd8d174eb0367d2fd851
F test/schema.test a8b000723375fd42c68d310091bdbd744fde647c F test/schema.test a8b000723375fd42c68d310091bdbd744fde647c
F test/schema2.test 35e1c9696443d6694c8980c411497c2b5190d32e F test/schema2.test 35e1c9696443d6694c8980c411497c2b5190d32e
@ -431,7 +431,7 @@ F test/shared_err.test 202ce115a4bfab2b41da5d4c9431f68a474134a6
F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3
F test/sidedelete.test 736ac1da08b3b1aa62df97fef2fcdb1b660111b9 F test/sidedelete.test 736ac1da08b3b1aa62df97fef2fcdb1b660111b9
F test/soak.test 64f9b27fbcdec43335a88c546ce1983e6ba40d7b F test/soak.test 64f9b27fbcdec43335a88c546ce1983e6ba40d7b
F test/softheap1.test 29cbdb847e63ffef3af5da1e3cd15f44ee11d770 F test/softheap1.test c9146eda576eedb62192b771293a2115d9af8456
F test/sort.test 0e4456e729e5a92a625907c63dcdedfbe72c5dc5 F test/sort.test 0e4456e729e5a92a625907c63dcdedfbe72c5dc5
F test/speed1.test 22e1b27af0683ed44dcd2f93ed817a9c3e65084a F test/speed1.test 22e1b27af0683ed44dcd2f93ed817a9c3e65084a
F test/speed2.test 53177056baf6556dcbdcf032bbdfc41c1aa74ded F test/speed2.test 53177056baf6556dcbdcf032bbdfc41c1aa74ded
@ -446,7 +446,7 @@ F test/table.test 13b1c2e2fb4727b35ee1fb7641fc469214fd2455
F test/tableapi.test 92651a95c23cf955e92407928e640536402fa3cc F test/tableapi.test 92651a95c23cf955e92407928e640536402fa3cc
F test/tclsqlite.test 3fac87cb1059c46b8fa8a60b553f4f1adb0fb6d9 F test/tclsqlite.test 3fac87cb1059c46b8fa8a60b553f4f1adb0fb6d9
F test/temptable.test 19b851b9e3e64d91e9867619b2a3f5fffee6e125 F test/temptable.test 19b851b9e3e64d91e9867619b2a3f5fffee6e125
F test/tester.tcl 493be4c2f8f4ea561d91c448b37da2d30fedb3f9 F test/tester.tcl 6a6600646341b910f2fbfd02db1ef0274479366c
F test/thread001.test 8fbd9559da0bbdc273e00318c7fd66c162020af7 F test/thread001.test 8fbd9559da0bbdc273e00318c7fd66c162020af7
F test/thread002.test 2c4ad2c386f60f6fe268cd91c769ee35b3c1fd0b F test/thread002.test 2c4ad2c386f60f6fe268cd91c769ee35b3c1fd0b
F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35 F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35
@ -607,7 +607,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 5aef5b0dd8e44a56f84fbc6f843016bca5101987 P d9ebe9d78c558af050c44ac4437ce0ef8193a4a8
R 07faac02e9ea2890001493a3c96130c4 R 94e60cf83c5be7070b2e0c99c104b013
U drh U drh
Z 11b35796b0f55998b3b3bad35c703ebb Z 37d21009eb42b23cbb42db5cde98321f

View File

@ -1 +1 @@
d9ebe9d78c558af050c44ac4437ce0ef8193a4a8 af129b6d158cc90ce9752dd6383c1de47f7b3e43

View File

@ -88,6 +88,8 @@ END {
max = 0 max = 0
print "/* Automatically generated. Do not edit */" print "/* Automatically generated. Do not edit */"
print "/* See the mkopcodeh.awk script for details */" print "/* See the mkopcodeh.awk script for details */"
op["OP_Noop"] = -1;
op["OP_Explain"] = -1;
for(name in op){ for(name in op){
if( op[name]<0 ){ if( op[name]<0 ){
cnt++ cnt++

View File

@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated ** is not included in the SQLite library. It is used for automated
** testing of the SQLite library. ** testing of the SQLite library.
** **
** $Id: test1.c,v 1.282 2008/01/16 17:46:38 drh Exp $ ** $Id: test1.c,v 1.283 2008/01/19 20:11:26 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "tcl.h" #include "tcl.h"
@ -4220,8 +4220,49 @@ static int vfs_unlink_test(
Tcl_Obj *CONST objv[] /* Command arguments */ Tcl_Obj *CONST objv[] /* Command arguments */
){ ){
int i; int i;
sqlite3_vfs *pMain;
sqlite3_vfs *apVfs[20]; sqlite3_vfs *apVfs[20];
sqlite3_vfs one, two;
sqlite3_vfs_unregister(0); /* Unregister of NULL is harmless */
one.zName = "__one";
two.zName = "__two";
/* Calling sqlite3_vfs_register with 2nd argument of 0 does not
** change the default VFS
*/
pMain = sqlite3_vfs_find(0);
sqlite3_vfs_register(&one, 0);
assert( pMain==0 || pMain==sqlite3_vfs_find(0) );
sqlite3_vfs_register(&two, 0);
assert( pMain==0 || pMain==sqlite3_vfs_find(0) );
/* We can find a VFS by its name */
assert( sqlite3_vfs_find("__one")==&one );
assert( sqlite3_vfs_find("__two")==&two );
/* Calling sqlite_vfs_register with non-zero second parameter changes the
** default VFS, even if the 1st parameter is an existig VFS that is
** previously registered as the non-default.
*/
sqlite3_vfs_register(&one, 1);
assert( sqlite3_vfs_find("__one")==&one );
assert( sqlite3_vfs_find("__two")==&two );
assert( sqlite3_vfs_find(0)==&one );
sqlite3_vfs_register(&two, 1);
assert( sqlite3_vfs_find("__one")==&one );
assert( sqlite3_vfs_find("__two")==&two );
assert( sqlite3_vfs_find(0)==&two );
if( pMain ){
sqlite3_vfs_register(pMain, 1);
assert( sqlite3_vfs_find("__one")==&one );
assert( sqlite3_vfs_find("__two")==&two );
assert( sqlite3_vfs_find(0)==pMain );
}
/* Unlink the default VFS. Repeat until there are no more VFSes
** registered.
*/
for(i=0; i<sizeof(apVfs)/sizeof(apVfs[0]); i++){ for(i=0; i<sizeof(apVfs)/sizeof(apVfs[0]); i++){
apVfs[i] = sqlite3_vfs_find(0); apVfs[i] = sqlite3_vfs_find(0);
if( apVfs[i] ){ if( apVfs[i] ){
@ -4231,6 +4272,8 @@ static int vfs_unlink_test(
} }
} }
assert( 0==sqlite3_vfs_find(0) ); assert( 0==sqlite3_vfs_find(0) );
/* Relink all VFSes in reverse order. */
for(i=sizeof(apVfs)/sizeof(apVfs[0])-1; i>=0; i--){ for(i=sizeof(apVfs)/sizeof(apVfs[0])-1; i>=0; i--){
if( apVfs[i] ){ if( apVfs[i] ){
sqlite3_vfs_register(apVfs[i], 1); sqlite3_vfs_register(apVfs[i], 1);
@ -4238,6 +4281,21 @@ static int vfs_unlink_test(
assert( apVfs[i]==sqlite3_vfs_find(apVfs[i]->zName) ); assert( apVfs[i]==sqlite3_vfs_find(apVfs[i]->zName) );
} }
} }
/* Unregister out sample VFSes. */
sqlite3_vfs_unregister(&one);
sqlite3_vfs_unregister(&two);
/* Unregistering a VFS that is not currently registered is harmless */
sqlite3_vfs_unregister(&one);
sqlite3_vfs_unregister(&two);
assert( sqlite3_vfs_find("__one")==0 );
assert( sqlite3_vfs_find("__two")==0 );
/* We should be left with the original default VFS back as the
** original */
assert( sqlite3_vfs_find(0)==pMain );
return TCL_OK; return TCL_OK;
} }

View File

@ -43,7 +43,7 @@
** in this file for details. If in doubt, do not deviate from existing ** in this file for details. If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code. ** commenting and indentation practices when changing or adding code.
** **
** $Id: vdbe.c,v 1.700 2008/01/19 03:35:59 drh Exp $ ** $Id: vdbe.c,v 1.701 2008/01/19 20:11:26 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@ -2697,6 +2697,13 @@ case OP_Close: {
** If there are no records greater than or equal to the key and P2 ** If there are no records greater than or equal to the key and P2
** is not zero, then jump to P2. ** is not zero, then jump to P2.
** **
** A special feature of this opcode (and different from the
** related OP_MoveGt, OP_MoveLt, and OP_MoveLe) is that if P2 is
** zero and P1 is an SQL table (a b-tree with integer keys) then
** the seek is deferred until it is actually needed. It might be
** the case that the cursor is never accessed. By deferring the
** seek, we avoid unnecessary seeks.
**
** See also: Found, NotFound, Distinct, MoveLt, MoveGt, MoveLe ** See also: Found, NotFound, Distinct, MoveLt, MoveGt, MoveLe
*/ */
/* Opcode: MoveGt P1 P2 P3 * * /* Opcode: MoveGt P1 P2 P3 * *
@ -2704,7 +2711,7 @@ case OP_Close: {
** Use the value in register P3 as a key. Reposition ** Use the value in register P3 as a key. Reposition
** cursor P1 so that it points to the smallest entry that is greater ** cursor P1 so that it points to the smallest entry that is greater
** than the key in register P3. ** than the key in register P3.
** If there are no records greater than the key and P2 is not zero, ** If there are no records greater than the key
** then jump to P2. ** then jump to P2.
** **
** See also: Found, NotFound, Distinct, MoveLt, MoveGe, MoveLe ** See also: Found, NotFound, Distinct, MoveLt, MoveGe, MoveLe
@ -2714,7 +2721,7 @@ case OP_Close: {
** Use the value in register P3 as a key. Reposition ** Use the value in register P3 as a key. Reposition
** cursor P1 so that it points to the largest entry that is less ** cursor P1 so that it points to the largest entry that is less
** than the key in register P3. ** than the key in register P3.
** If there are no records less than the key and P2 is not zero, ** If there are no records less than the key
** then jump to P2. ** then jump to P2.
** **
** See also: Found, NotFound, Distinct, MoveGt, MoveGe, MoveLe ** See also: Found, NotFound, Distinct, MoveGt, MoveGe, MoveLe
@ -2724,7 +2731,7 @@ case OP_Close: {
** Use the value in register P3 as a key. Reposition ** Use the value in register P3 as a key. Reposition
** cursor P1 so that it points to the largest entry that is less than ** cursor P1 so that it points to the largest entry that is less than
** or equal to the key. ** or equal to the key.
** If there are no records less than or eqal to the key and P2 is not zero, ** If there are no records less than or eqal to the key
** then jump to P2. ** then jump to P2.
** **
** See also: Found, NotFound, Distinct, MoveGt, MoveGe, MoveLt ** See also: Found, NotFound, Distinct, MoveGt, MoveGe, MoveLt
@ -2746,8 +2753,10 @@ case OP_MoveGt: { /* jump, in3 */
*pC->pIncrKey = oc==OP_MoveGt || oc==OP_MoveLe; *pC->pIncrKey = oc==OP_MoveGt || oc==OP_MoveLe;
if( pC->isTable ){ if( pC->isTable ){
i64 iKey = sqlite3VdbeIntValue(pIn3); i64 iKey = sqlite3VdbeIntValue(pIn3);
if( pOp->p2==0 && pOp->opcode==OP_MoveGe ){ if( pOp->p2==0 ){
assert( pOp->opcode==OP_MoveGe );
pC->movetoTarget = iKey; pC->movetoTarget = iKey;
pC->rowidIsValid = 0;
pC->deferredMoveto = 1; pC->deferredMoveto = 1;
break; break;
} }
@ -2793,12 +2802,9 @@ case OP_MoveGt: { /* jump, in3 */
res = sqlite3BtreeEof(pC->pCursor); res = sqlite3BtreeEof(pC->pCursor);
} }
} }
assert( pOp->p2>0 );
if( res ){ if( res ){
if( pOp->p2>0 ){ pc = pOp->p2 - 1;
pc = pOp->p2 - 1;
}else{
pC->nullRow = 1;
}
} }
} }
break; break;
@ -3006,7 +3012,7 @@ case OP_NotExists: { /* jump, in3 */
** running ioerr.test and similar failure-recovery test scripts.) */ ** running ioerr.test and similar failure-recovery test scripts.) */
if( res!=0 ){ if( res!=0 ){
pc = pOp->p2 - 1; pc = pOp->p2 - 1;
pC->rowidIsValid = 0; assert( pC->rowidIsValid==0 );
} }
} }
break; break;
@ -3156,19 +3162,17 @@ case OP_NewRowid: { /* out2-prerelease */
v = db->priorNewRowid; v = db->priorNewRowid;
cnt = 0; cnt = 0;
do{ do{
if( v==0 || cnt>2 ){ if( cnt==0 && (v&0xffffff)==v ){
v++;
}else{
sqlite3Randomness(sizeof(v), &v); sqlite3Randomness(sizeof(v), &v);
if( cnt<5 ) v &= 0xffffff; if( cnt<5 ) v &= 0xffffff;
}else{
unsigned char r;
sqlite3Randomness(1, &r);
v += r + 1;
} }
if( v==0 ) continue; if( v==0 ) continue;
x = intToKey(v); x = intToKey(v);
rx = sqlite3BtreeMoveto(pC->pCursor, 0, (u64)x, 0, &res); rx = sqlite3BtreeMoveto(pC->pCursor, 0, (u64)x, 0, &res);
cnt++; cnt++;
}while( cnt<1000 && rx==SQLITE_OK && res==0 ); }while( cnt<100 && rx==SQLITE_OK && res==0 );
db->priorNewRowid = v; db->priorNewRowid = v;
if( rx==SQLITE_OK && res==0 ){ if( rx==SQLITE_OK && res==0 ){
rc = SQLITE_FULL; rc = SQLITE_FULL;
@ -3294,46 +3298,45 @@ case OP_Insert: {
** If the OPFLAG_NCHANGE flag of P2 is set, then the row change count is ** If the OPFLAG_NCHANGE flag of P2 is set, then the row change count is
** incremented (otherwise not). ** incremented (otherwise not).
** **
** If P1 is a pseudo-table, then this instruction is a no-op. ** P1 must not be pseudo-table. It has to be a real table with
** multiple rows.
**
** If P4 is not NULL, then it is the name of the table that P1 is
** pointing to. The update hook will be invoked, if it exists.
** If P4 is not NULL then the P1 cursor must have been positioned
** using OP_NotFound prior to invoking this opcode.
*/ */
case OP_Delete: { case OP_Delete: {
int i = pOp->p1; int i = pOp->p1;
i64 iKey;
Cursor *pC; Cursor *pC;
assert( i>=0 && i<p->nCursor ); assert( i>=0 && i<p->nCursor );
pC = p->apCsr[i]; pC = p->apCsr[i];
assert( pC!=0 ); assert( pC!=0 );
if( pC->pCursor!=0 ){ assert( pC->pCursor!=0 ); /* Only valid for real tables, no pseudotables */
i64 iKey;
/* If the update-hook will be invoked, set iKey to the rowid of the /* If the update-hook will be invoked, set iKey to the rowid of the
** row being deleted. ** row being deleted.
*/ */
if( db->xUpdateCallback && pOp->p4.z ){ if( db->xUpdateCallback && pOp->p4.z ){
assert( pC->isTable ); assert( pC->isTable );
if( pC->rowidIsValid ){ assert( pC->rowidIsValid ); /* lastRowid set by previous OP_NotFound */
iKey = pC->lastRowid; iKey = pC->lastRowid;
}else{ }
rc = sqlite3BtreeKeySize(pC->pCursor, &iKey);
if( rc ){
goto abort_due_to_error;
}
iKey = keyToInt(iKey);
}
}
rc = sqlite3VdbeCursorMoveto(pC); rc = sqlite3VdbeCursorMoveto(pC);
if( rc ) goto abort_due_to_error; if( rc ) goto abort_due_to_error;
rc = sqlite3BtreeDelete(pC->pCursor); rc = sqlite3BtreeDelete(pC->pCursor);
pC->nextRowidValid = 0; pC->nextRowidValid = 0;
pC->cacheStatus = CACHE_STALE; pC->cacheStatus = CACHE_STALE;
/* Invoke the update-hook if required. */ /* Invoke the update-hook if required. */
if( rc==SQLITE_OK && db->xUpdateCallback && pOp->p4.z ){ if( rc==SQLITE_OK && db->xUpdateCallback && pOp->p4.z ){
const char *zDb = db->aDb[pC->iDb].zName; const char *zDb = db->aDb[pC->iDb].zName;
const char *zTbl = pOp->p4.z; const char *zTbl = pOp->p4.z;
db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE, zDb, zTbl, iKey); db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE, zDb, zTbl, iKey);
assert( pC->iDb>=0 ); assert( pC->iDb>=0 );
}
} }
if( pOp->p2 & OPFLAG_NCHANGE ) p->nChange++; if( pOp->p2 & OPFLAG_NCHANGE ) p->nChange++;
break; break;
@ -4713,10 +4716,19 @@ case OP_Trace: {
} }
#endif #endif
/* An other opcode is illegal...
/* Opcode: Noop * * * * *
**
** Do nothing. This instruction is often useful as a jump
** destination.
*/ */
default: { /*
assert( 0 ); ** The magic Explain opcode are only inserted when explain==2 (which
** is to say when the EXPLAIN QUERY PLAN syntax is used.)
** This opcode records information from the optimizer. It is the
** the same as a no-op. This opcodesnever appears in a real VM program.
*/
default: { /* This is really OP_Noop and OP_Explain */
break; break;
} }

View File

@ -511,14 +511,16 @@ void sqlite3VdbeChangeToNoop(Vdbe *p, int addr, int N){
*/ */
void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){ void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){
Op *pOp; Op *pOp;
assert( p==0 || p->magic==VDBE_MAGIC_INIT ); assert( p!=0 );
if( p==0 || p->aOp==0 || p->db->mallocFailed ){ assert( p->magic==VDBE_MAGIC_INIT );
if( p->aOp==0 || p->db->mallocFailed ){
if (n != P4_KEYINFO) { if (n != P4_KEYINFO) {
freeP4(n, (void*)*(char**)&zP4); freeP4(n, (void*)*(char**)&zP4);
} }
return; return;
} }
if( addr<0 || addr>=p->nOp ){ assert( addr<p->nOp );
if( addr<0 ){
addr = p->nOp - 1; addr = p->nOp - 1;
if( addr<0 ) return; if( addr<0 ) return;
} }
@ -540,13 +542,19 @@ void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){
pKeyInfo = sqlite3_malloc( nByte ); pKeyInfo = sqlite3_malloc( nByte );
pOp->p4.pKeyInfo = pKeyInfo; pOp->p4.pKeyInfo = pKeyInfo;
if( pKeyInfo ){ if( pKeyInfo ){
unsigned char *aSortOrder;
memcpy(pKeyInfo, zP4, nByte); memcpy(pKeyInfo, zP4, nByte);
/* In the current implementation, P4_KEYINFO is only ever used on
** KeyInfo structures that have no aSortOrder component. Elements
** with an aSortOrder always use P4_KEYINFO_HANDOFF. So we do not
** need to bother with duplicating the aSortOrder. */
assert( pKeyInfo->aSortOrder==0 );
#if 0
aSortOrder = pKeyInfo->aSortOrder; aSortOrder = pKeyInfo->aSortOrder;
if( aSortOrder ){ if( aSortOrder ){
pKeyInfo->aSortOrder = (unsigned char*)&pKeyInfo->aColl[nField]; pKeyInfo->aSortOrder = (unsigned char*)&pKeyInfo->aColl[nField];
memcpy(pKeyInfo->aSortOrder, aSortOrder, nField); memcpy(pKeyInfo->aSortOrder, aSortOrder, nField);
} }
#endif
pOp->p4type = P4_KEYINFO; pOp->p4type = P4_KEYINFO;
}else{ }else{
p->db->mallocFailed = 1; p->db->mallocFailed = 1;

View File

@ -16,7 +16,7 @@
** so is applicable. Because this module is responsible for selecting ** so is applicable. Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer". ** indices, you might also think of this module as the "query optimizer".
** **
** $Id: where.c,v 1.283 2008/01/17 16:22:15 drh Exp $ ** $Id: where.c,v 1.284 2008/01/19 20:11:26 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@ -2556,7 +2556,7 @@ WhereInfo *sqlite3WhereBegin(
} }
if( !omitTable ){ if( !omitTable ){
sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, r1); sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, r1);
sqlite3VdbeAddOp3(v, OP_MoveGe, iCur, 0, r1); sqlite3VdbeAddOp3(v, OP_MoveGe, iCur, 0, r1); /* Deferred seek */
} }
sqlite3ReleaseTempReg(pParse, r1); sqlite3ReleaseTempReg(pParse, r1);
@ -2631,7 +2631,7 @@ WhereInfo *sqlite3WhereBegin(
if( !omitTable ){ if( !omitTable ){
r1 = sqlite3GetTempReg(pParse); r1 = sqlite3GetTempReg(pParse);
sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, r1); sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, r1);
sqlite3VdbeAddOp3(v, OP_MoveGe, iCur, 0, r1); sqlite3VdbeAddOp3(v, OP_MoveGe, iCur, 0, r1); /* Deferred seek */
sqlite3ReleaseTempReg(pParse, r1); sqlite3ReleaseTempReg(pParse, r1);
} }
pLevel->p1 = iIdxCur; pLevel->p1 = iIdxCur;

View File

@ -10,7 +10,7 @@
#*********************************************************************** #***********************************************************************
# This file runs all tests. # This file runs all tests.
# #
# $Id: all.test,v 1.52 2007/11/27 14:46:42 drh Exp $ # $Id: all.test,v 1.53 2008/01/19 20:11:26 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@ -92,6 +92,7 @@ for {set Counter 0} {$Counter<$COUNT && $nErr==0} {incr Counter} {
set tail [file tail $testfile] set tail [file tail $testfile]
if {[lsearch -exact $EXCLUDE $tail]>=0} continue if {[lsearch -exact $EXCLUDE $tail]>=0} continue
if {[llength $INCLUDE]>0 && [lsearch -exact $INCLUDE $tail]<0} continue if {[llength $INCLUDE]>0 && [lsearch -exact $INCLUDE $tail]<0} continue
reset_prng_state
source $testfile source $testfile
catch {db close} catch {db close}
if {$sqlite_open_file_count>0} { if {$sqlite_open_file_count>0} {

View File

@ -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 file is testing the CAST operator. # focus of this file is testing the CAST operator.
# #
# $Id: cast.test,v 1.8 2007/08/13 15:18:28 drh Exp $ # $Id: cast.test,v 1.9 2008/01/19 20:11:26 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@ -183,6 +183,38 @@ do_test cast-1.53 {
execsql {SELECT CAST('123.5abc' AS integer)} execsql {SELECT CAST('123.5abc' AS integer)}
} 123 } 123
do_test case-1.60 {
execsql {SELECT CAST(null AS REAL)}
} {{}}
do_test case-1.61 {
execsql {SELECT typeof(CAST(null AS REAL))}
} {null}
do_test case-1.62 {
execsql {SELECT CAST(1 AS REAL)}
} {1.0}
do_test case-1.63 {
execsql {SELECT typeof(CAST(1 AS REAL))}
} {real}
do_test case-1.64 {
execsql {SELECT CAST('1' AS REAL)}
} {1.0}
do_test case-1.65 {
execsql {SELECT typeof(CAST('1' AS REAL))}
} {real}
do_test case-1.66 {
execsql {SELECT CAST('abc' AS REAL)}
} {0.0}
do_test case-1.67 {
execsql {SELECT typeof(CAST('abc' AS REAL))}
} {real}
do_test case-1.68 {
execsql {SELECT CAST(x'31' AS REAL)}
} {1.0}
do_test case-1.69 {
execsql {SELECT typeof(CAST(x'31' AS REAL))}
} {real}
# Ticket #1662. Ignore leading spaces in numbers when casting. # Ticket #1662. Ignore leading spaces in numbers when casting.
# #
do_test cast-2.1 { do_test cast-2.1 {

View File

@ -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 file is testing expressions. # focus of this file is testing expressions.
# #
# $Id: expr.test,v 1.60 2008/01/16 18:20:42 danielk1977 Exp $ # $Id: expr.test,v 1.61 2008/01/19 20:11:26 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@ -72,6 +72,7 @@ test_expr expr-1.42b {i1=1, i2=2} {4|2} {6}
test_expr expr-1.43 {i1=1, i2=2} {i1&i2} {0} test_expr expr-1.43 {i1=1, i2=2} {i1&i2} {0}
test_expr expr-1.43b {i1=1, i2=2} {4&5} {4} test_expr expr-1.43b {i1=1, i2=2} {4&5} {4}
test_expr expr-1.44 {i1=1} {~i1} {-2} test_expr expr-1.44 {i1=1} {~i1} {-2}
test_expr expr-1.44b {i1=NULL} {~i1} {{}}
test_expr expr-1.45 {i1=1, i2=3} {i1<<i2} {8} test_expr expr-1.45 {i1=1, i2=3} {i1<<i2} {8}
test_expr expr-1.46 {i1=32, i2=3} {i1>>i2} {4} test_expr expr-1.46 {i1=32, i2=3} {i1>>i2} {4}
test_expr expr-1.47 {i1=9999999999, i2=8888888888} {i1<i2} 0 test_expr expr-1.47 {i1=9999999999, i2=8888888888} {i1<i2} 0
@ -141,6 +142,8 @@ test_expr expr-1.105 {i1=0} {(-9223372036854775808.0 / -1)>1} 1
test_expr expr-1.106 {i1=0} {(1<<63)/-1} -9223372036854775808 test_expr expr-1.106 {i1=0} {(1<<63)/-1} -9223372036854775808
test_expr expr-1.107 {i1=0} {(1<<63)%-1} 0 test_expr expr-1.107 {i1=0} {(1<<63)%-1} 0
test_expr expr-1.108 {i1=0} {1%0} {{}}
test_expr expr-1.109 {i1=0} {1/0} {{}}
test_expr expr-2.1 {r1=1.23, r2=2.34} {r1+r2} 3.57 test_expr expr-2.1 {r1=1.23, r2=2.34} {r1+r2} 3.57
test_expr expr-2.2 {r1=1.23, r2=2.34} {r1-r2} -1.11 test_expr expr-2.2 {r1=1.23, r2=2.34} {r1-r2} -1.11
@ -169,6 +172,8 @@ test_expr expr-2.23 {r1=1.23, r2=2.34} {max(r1,r2,r1+r2,r1-r2)} {3.57}
test_expr expr-2.24 {r1=25.0, r2=11.0} {r1%r2} 3.0 test_expr expr-2.24 {r1=25.0, r2=11.0} {r1%r2} 3.0
test_expr expr-2.25 {r1=1.23, r2=NULL} {coalesce(r1+r2,99.0)} 99.0 test_expr expr-2.25 {r1=1.23, r2=NULL} {coalesce(r1+r2,99.0)} 99.0
test_expr expr-2.26 {r1=1e300, r2=1e300} {coalesce((r1*r2)*0.0,99.0)} 99.0 test_expr expr-2.26 {r1=1e300, r2=1e300} {coalesce((r1*r2)*0.0,99.0)} 99.0
test_expr expr-2.27 {r1=1.1, r2=0.0} {r1/r2} {{}}
test_expr expr-2.28 {r1=1.1, r2=0.0} {r1%r2} {{}}
test_expr expr-3.1 {t1='abc', t2='xyz'} {t1<t2} 1 test_expr expr-3.1 {t1='abc', t2='xyz'} {t1<t2} 1
test_expr expr-3.2 {t1='xyz', t2='abc'} {t1<t2} 0 test_expr expr-3.2 {t1='xyz', t2='abc'} {t1<t2} 0

View File

@ -17,7 +17,7 @@
# sqlite_update_hook (tests hook-4-*) # sqlite_update_hook (tests hook-4-*)
# sqlite_rollback_hook (tests hook-5.*) # sqlite_rollback_hook (tests hook-5.*)
# #
# $Id: hook.test,v 1.12 2007/10/09 08:29:32 danielk1977 Exp $ # $Id: hook.test,v 1.13 2008/01/19 20:11:26 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@ -137,6 +137,24 @@ do_test hook-4.1.2 {
DELETE main t1 4 \ DELETE main t1 4 \
] ]
# Update hook is not invoked for changes to sqlite_master
#
do_test hook-4.1.3 {
set ::update_hook {}
execsql {
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN SELECT RAISE(IGNORE); END;
}
set ::update_hook
} {}
do_test hook-4.1.4 {
set ::update_hook {}
execsql {
DROP TRIGGER r1;
}
set ::update_hook
} {}
set ::update_hook {} set ::update_hook {}
ifcapable trigger { ifcapable trigger {
do_test hook-4.2.1 { do_test hook-4.2.1 {

View File

@ -14,7 +14,7 @@
# Note: There are also some tests for incremental vacuum and IO # Note: There are also some tests for incremental vacuum and IO
# errors in incrvacuum_ioerr.test. # errors in incrvacuum_ioerr.test.
# #
# $Id: incrvacuum.test,v 1.16 2007/12/13 21:54:11 drh Exp $ # $Id: incrvacuum.test,v 1.17 2008/01/19 20:11:26 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@ -549,7 +549,6 @@ do_test incrvacuum-10.4 {
} {22} } {22}
do_test incrvacuum-10.5 { do_test incrvacuum-10.5 {
breakpoint
execsql { execsql {
PRAGMA incremental_vacuum("+3"); PRAGMA incremental_vacuum("+3");
} }
@ -572,6 +571,19 @@ do_test incrvacuum-10.7 {
expr [file size test.db] / 1024 expr [file size test.db] / 1024
} {1} } {1}
do_test incrvacuum-10.8 {
execsql {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(hex(randomblob(1000)));
DROP TABLE t1;
}
# A negative number means free all possible space.
execsql {
PRAGMA incremental_vacuum=-1;
}
expr [file size test.db] / 1024
} {1}
#---------------------------------------------------------------- #----------------------------------------------------------------
# Test that if we set the auto_vacuum mode to 'incremental', then # Test that if we set the auto_vacuum mode to 'incremental', then
# create a database, thereafter that database defaults to incremental # create a database, thereafter that database defaults to incremental

View File

@ -13,7 +13,7 @@
# This file implements tests for miscellanous features that were # This file implements tests for miscellanous features that were
# left out of other test files. # left out of other test files.
# #
# $Id: misc3.test,v 1.16 2005/01/21 03:12:16 danielk1977 Exp $ # $Id: misc3.test,v 1.17 2008/01/19 20:11:26 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@ -258,6 +258,26 @@ ifcapable {explain} {
execsql {BEGIN; EXPLAIN ROLLBACK} execsql {BEGIN; EXPLAIN ROLLBACK}
catchsql {ROLLBACK} catchsql {ROLLBACK}
} {0 {}} } {0 {}}
# Do some additional EXPLAIN operations to exercise the displayP4 logic.
do_test misc3-6.10 {
set x [execsql {
CREATE TABLE ex1(a INTEGER, b TEXT DEFAULT "hello", c);
CREATE UNIQUE INDEX ex1i1 ON ex1(a);
EXPLAIN REINDEX;
}]
regexp { IsUnique \d+ \d+ \d+ \d+ } $x
} {1}
do_test misc3-6.11 {
set x [execsql {
EXPLAIN SELECT a+123456789012, b*4.5678, c FROM ex1 ORDER BY a, b DESC
}]
set y [regexp { 123456789012 } $x]
lappend y [regexp { 4.5678 } $x]
lappend y [regexp { hello } $x]
lappend y [regexp {,-BINARY} $x]
} {1 1 1 1}
} }
ifcapable {trigger} { ifcapable {trigger} {

View File

@ -12,7 +12,7 @@
# focus of this file is testing the magic ROWID column that is # focus of this file is testing the magic ROWID column that is
# found on all tables. # found on all tables.
# #
# $Id: rowid.test,v 1.19 2007/04/25 11:32:30 drh Exp $ # $Id: rowid.test,v 1.20 2008/01/19 20:11:26 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@ -657,6 +657,12 @@ do_test rowid-11.4 {
# Test the automatic generation of rowids when the table already contains # Test the automatic generation of rowids when the table already contains
# a rowid with the maximum value. # a rowid with the maximum value.
# #
# Once the the maximum rowid is taken, rowids are normally chosen at
# random. By by reseting the random number generator, we can cause
# the rowid guessing loop to collide with prior rowids, and test the
# loop out to its limit of 100 iterations. After 100 collisions, the
# rowid guesser gives up and reports SQLITE_FULL.
#
do_test rowid-12.1 { do_test rowid-12.1 {
execsql { execsql {
CREATE TABLE t7(x INTEGER PRIMARY KEY, y); CREATE TABLE t7(x INTEGER PRIMARY KEY, y);
@ -665,10 +671,31 @@ do_test rowid-12.1 {
} }
} {a} } {a}
do_test rowid-12.2 { do_test rowid-12.2 {
db close
sqlite3 db test.db
save_prng_state
execsql { execsql {
INSERT INTO t7 VALUES(NULL,'b'); INSERT INTO t7 VALUES(NULL,'b');
SELECT y FROM t7; SELECT x, y FROM t7;
} }
} {b a} } {1 b 9223372036854775807 a}
execsql {INSERT INTO t7 VALUES(2,'y');}
for {set i 1} {$i<=101} {incr i} {
do_test rowid-12.3.$i {
restore_prng_state
execsql {
INSERT INTO t7 VALUES(NULL,'x');
INSERT OR IGNORE INTO t7 VALUES(last_insert_rowid()+1,'y');
SELECT count(*) FROM t7 WHERE y=='x';
}
} $i
}
do_test rowid-12.4 {
restore_prng_state
catchsql {
INSERT INTO t7 VALUES(NULL,'x');
}
} {1 {database or disk is full}}
finish_test finish_test

View File

@ -13,7 +13,7 @@
# A database corruption bug that occurs in auto_vacuum mode when # A database corruption bug that occurs in auto_vacuum mode when
# the soft_heap_limit is set low enough to be triggered. # the soft_heap_limit is set low enough to be triggered.
# #
# $Id: softheap1.test,v 1.3 2007/09/12 17:01:45 danielk1977 Exp $ # $Id: softheap1.test,v 1.4 2008/01/19 20:11:26 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
@ -24,6 +24,8 @@ ifcapable !integrityck {
return return
} }
sqlite3_soft_heap_limit -1
sqlite3_soft_heap_limit 0
sqlite3_soft_heap_limit 5000 sqlite3_soft_heap_limit 5000
do_test softheap1-1.1 { do_test softheap1-1.1 {
execsql { execsql {

View File

@ -11,7 +11,7 @@
# This file implements some common TCL routines used for regression # This file implements some common TCL routines used for regression
# testing the SQLite library # testing the SQLite library
# #
# $Id: tester.tcl,v 1.101 2008/01/17 02:36:28 drh Exp $ # $Id: tester.tcl,v 1.102 2008/01/19 20:11:26 drh Exp $
set tcl_precision 15 set tcl_precision 15
@ -221,7 +221,8 @@ proc finalize_testing {} {
sqlite3_memdebug_dump ./memusage.txt sqlite3_memdebug_dump ./memusage.txt
} }
} }
puts "Maximum memory usage: [sqlite3_memory_highwater] bytes" puts "Maximum memory usage: [sqlite3_memory_highwater 1] bytes"
puts "Current memory usage: [sqlite3_memory_highwater] bytes"
foreach f [glob -nocomplain test.db-*-journal] { foreach f [glob -nocomplain test.db-*-journal] {
file delete -force $f file delete -force $f
} }