-C Cleanup\sand\ssimplification\sof\sconstraint\sprocessing.\s\sSimplifications\nto\sthe\sVM\sfor\sbetter\stest\scoverage.\s(CVS\s4729)
-D 2008-01-19T03:35:59
+C Miscellaneous\scode\ssimplifications\sand\scleanup\sand\stest\scoverage\nenhancements.\s(CVS\s4730)
+D 2008-01-19T20:11:26
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in 30789bf70614bad659351660d76b8e533f3340e9
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f
F mkextw.sh 1a866b53637dab137191341cc875575a5ca110fb
F mkopcodec.awk 3fb9bf077053c968451f4dd03d11661ac373f9d1
-F mkopcodeh.awk 89fab7d28a5ec5313f6ca985d87a31a97ef14bcb
+F mkopcodeh.awk 513946ce4429bf2723aef0d640eb4d2493deb68e
F mkso.sh 24bde4c09e6fe80f718db3c31c068f45e13a2f2c
F publish.sh 1c0658c63d70f182a8f5e17cc28422f1b237f51d
F publish_osx.sh eca87df1e3d43d128d97d3261fd48b3d6877996e
F src/sqliteLimit.h ee4430f88f69bf63527967bb35ca52af7b0ccb1e
F src/table.c 1aeb9eab57b4235db86fe15a35dec76fb445a9c4
F src/tclsqlite.c 9923abeffc9b3d7dad58e92b319661521f60debf
-F src/test1.c 64912c1e65bdc3eccf3b80c5cc092b163831b367
+F src/test1.c cf222abaa6de1919bfd0c8ede4d280e4e368302b
F src/test2.c 77b34303883b9d722c65a6879bb0163a400e3789
F src/test3.c df62cd5c971dc1ae0be0a1842f9df3390934e7a6
F src/test4.c c2c0f5dc907f1346f5d4b65eb5799f11eb9e4071
F src/utf.c ef4b7d83bae533b76c3e1bf635b113fdad86a736
F src/util.c deda8c5a400530e1c27c03619cc4cd1a06fc5281
F src/vacuum.c 3f34f278809bf3eb0b62ec46ff779e9c385b28f0
-F src/vdbe.c 986d1b4034e271c67f8cab0e03a5e459cb288ad7
+F src/vdbe.c 65a3ad903f1c7a0f6e557fdc7671c3cb2d70fa12
F src/vdbe.h 58a7d931ffb704e034b2a725981cfa5bd406fad9
F src/vdbeInt.h 835e6f0337ce89d705ef9a162338788808adc4b7
F src/vdbeapi.c cb8c427a3ab646490c83204a98e94eff03ee2e89
-F src/vdbeaux.c 0d2a9730195d40f7d1156731bc69f240927255c5
+F src/vdbeaux.c e73c4ca5c8a66abfb06b5b543afe2819b55e35bf
F src/vdbeblob.c e386d49d8354aa5a58f0a7f2794303442c149120
F src/vdbefifo.c 334c838c8f42d61a94813d136019ee566b5dc2f6
F src/vdbemem.c e15122efe8868e400c2aba8ea101588944e83317
F src/vtab.c 9924e37cf7f5c527aeabb5da025874af505fb91d
-F src/where.c 0cc6052f73aef0d2ce59505d7ae06d6fbf696025
+F src/where.c 0c18a6d88d78886fd5f3c11ef2cf001321acd918
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
-F test/all.test ee350b9ab15b175fc0a8fb51bf2141ed3a3b9cba
+F test/all.test d12210212bada2bde6d5aeb90969b86c1aa977d2
F test/alter.test 345648dcd1801cc0287cd996076db512d1dcdabe
F test/alter2.test 9d9850064b5c572991ea744a88ea650045f4ac6a
F test/alter3.test 8ce6b9c5605b3cfe7b901f454ecaf174c4f93e31
F test/capi3.test 432fabf9c6402ed8ff1ae291e01f0e04b64df3ea
F test/capi3b.test 664eb55318132f292f2c436f90906f578cad6b97
F test/capi3c.test 0b089837ee65a17dd73ea171c4dee5d7ea79dabb
-F test/cast.test c4780b58b569bab4947458195410ae8791ac216b
+F test/cast.test ce8f14fc80f70b30ed984480cc0d8914a459e8f9
F test/check.test 024ed399600b799160378cf9d9f436bdf5dfd184
F test/collate1.test e3eaa48c21e150814be1a7b852d2a8af24458d04
F test/collate2.test 701d9651c5707024fd86a20649af9ea55e2c0eb8
F test/exclusive.test ebaf72ce9ff8f7ab3a09bf8f58fd65393dfff386
F test/exclusive2.test d13bf66753dca46e61241d35d36ab7c868b0d313
F test/exclusive3.test 0e49c35b7e7cb8e7280b4ce3f0359d30b207d2ff
-F test/expr.test 31082f3f68aa0d07d1d49088d45ed18f4b792486
+F test/expr.test 6e666e5f47fbe6c23295d8c9f2b6c28109bf9ba8
F test/filefmt.test 053b622009fbbb74dd37921ffad374d852c13cd8
F test/fkey1.test dcb4f28eb22d5141f15161d6bdca9a4f58c95729
F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb
F test/fuzz2.test ea38692ce2da99ad79fe0be5eb1a452c1c4d37bb
F test/fuzz_common.tcl ff4bc2dfc465f6878f8e2d819620914365382731
F test/fuzz_malloc.test 166b58dfd77cc04f6afeeaef0cfc1087abf134d1
-F test/hook.test 3870abead2ee75d2c03585c916256ca8b5584679
+F test/hook.test e17d4ed2843ba4ef9b234aa63e6f056bf88f9a19
F test/icu.test e6bfae7f625c88fd14df6f540fe835bdfc1e4329
F test/in.test 763a29007a4850d611ac4441bfa488fb9969ad30
F test/in2.test b1f447f4f0f67e9f83ff931e7e2e30873f9ea055
F test/in3.test 2f829007cc8d25d17b859f7fe882ef2bd2e2eb49
F test/incrblob.test 854c23b7ff8dd3822f675936b22c094655b3c739
F test/incrblob_err.test 5273097dc7c97f9b7008423a6ffd5c80d21923cb
-F test/incrvacuum.test 1ed44535e89a0fa10c48c1aa0a3d48ee72bcc733
+F test/incrvacuum.test 9f49457edc25229e43ed29849d4ce4c3e67387b0
F test/incrvacuum2.test a958e378c193c4012cb3787804d863487f1dfad1
F test/incrvacuum_ioerr.test cb331403b8dea3c5bae6163861ff25037b0df56a
F test/index.test cbf301cdb2da43e4eac636c3400c2439af1834ad
F test/minmax3.test 5b89f055df7ed03334e96eec0efb804afb7de638
F test/misc1.test 1b89c02c4a33b49dee4cd1d20d161aaaba719075
F test/misc2.test 1ee89298de9c16b61454658b24999c403e86afe4
-F test/misc3.test 7bd937e2c62bcc6be71939faf068d506467b1e03
+F test/misc3.test 7952978e14c0a1b52c6fc983af0f4d785d57f065
F test/misc4.test 91e8ed25c092c2bb4e0bb01864631e2930f8d7de
F test/misc5.test b0b4b7e0dd5d40335c8e849e5738d11a40bddc7c
F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91
F test/rdonly.test b34db316525440d3b42c32e83942c02c37d28ef0
F test/reindex.test 38b138abe36bf9a08c791ed44d9f76cd6b97b78b
F test/rollback.test 0bd29070ba2f76da939347773fbda53337ebd61c
-F test/rowid.test d125991eea1ffdea800d48471afd8fc4acc10b01
+F test/rowid.test 1c8fc43c60d273e6ea44dfb992db587f3164312c
F test/safety.test 4a06934e45d03b8b50ebcd8d174eb0367d2fd851
F test/schema.test a8b000723375fd42c68d310091bdbd744fde647c
F test/schema2.test 35e1c9696443d6694c8980c411497c2b5190d32e
F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3
F test/sidedelete.test 736ac1da08b3b1aa62df97fef2fcdb1b660111b9
F test/soak.test 64f9b27fbcdec43335a88c546ce1983e6ba40d7b
-F test/softheap1.test 29cbdb847e63ffef3af5da1e3cd15f44ee11d770
+F test/softheap1.test c9146eda576eedb62192b771293a2115d9af8456
F test/sort.test 0e4456e729e5a92a625907c63dcdedfbe72c5dc5
F test/speed1.test 22e1b27af0683ed44dcd2f93ed817a9c3e65084a
F test/speed2.test 53177056baf6556dcbdcf032bbdfc41c1aa74ded
F test/tableapi.test 92651a95c23cf955e92407928e640536402fa3cc
F test/tclsqlite.test 3fac87cb1059c46b8fa8a60b553f4f1adb0fb6d9
F test/temptable.test 19b851b9e3e64d91e9867619b2a3f5fffee6e125
-F test/tester.tcl 493be4c2f8f4ea561d91c448b37da2d30fedb3f9
+F test/tester.tcl 6a6600646341b910f2fbfd02db1ef0274479366c
F test/thread001.test 8fbd9559da0bbdc273e00318c7fd66c162020af7
F test/thread002.test 2c4ad2c386f60f6fe268cd91c769ee35b3c1fd0b
F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 5aef5b0dd8e44a56f84fbc6f843016bca5101987
-R 07faac02e9ea2890001493a3c96130c4
+P d9ebe9d78c558af050c44ac4437ce0ef8193a4a8
+R 94e60cf83c5be7070b2e0c99c104b013
U drh
-Z 11b35796b0f55998b3b3bad35c703ebb
+Z 37d21009eb42b23cbb42db5cde98321f
-d9ebe9d78c558af050c44ac4437ce0ef8193a4a8
\ No newline at end of file
+af129b6d158cc90ce9752dd6383c1de47f7b3e43
\ No newline at end of file
max = 0
print "/* Automatically generated. Do not edit */"
print "/* See the mkopcodeh.awk script for details */"
+ op["OP_Noop"] = -1;
+ op["OP_Explain"] = -1;
for(name in op){
if( op[name]<0 ){
cnt++
** is not included in the SQLite library. It is used for automated
** 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 "tcl.h"
Tcl_Obj *CONST objv[] /* Command arguments */
){
int i;
+ sqlite3_vfs *pMain;
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++){
apVfs[i] = sqlite3_vfs_find(0);
if( apVfs[i] ){
}
}
assert( 0==sqlite3_vfs_find(0) );
+
+ /* Relink all VFSes in reverse order. */
for(i=sizeof(apVfs)/sizeof(apVfs[0])-1; i>=0; i--){
if( apVfs[i] ){
sqlite3_vfs_register(apVfs[i], 1);
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;
}
** in this file for details. If in doubt, do not deviate from existing
** 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 <ctype.h>
** If there are no records greater than or equal to the key and 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
*/
/* Opcode: MoveGt P1 P2 P3 * *
** Use the value in register P3 as a key. Reposition
** cursor P1 so that it points to the smallest entry that is greater
** 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.
**
** See also: Found, NotFound, Distinct, MoveLt, MoveGe, MoveLe
** Use the value in register P3 as a key. Reposition
** cursor P1 so that it points to the largest entry that is less
** 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.
**
** See also: Found, NotFound, Distinct, MoveGt, MoveGe, MoveLe
** Use the value in register P3 as a key. Reposition
** cursor P1 so that it points to the largest entry that is less than
** 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.
**
** See also: Found, NotFound, Distinct, MoveGt, MoveGe, MoveLt
*pC->pIncrKey = oc==OP_MoveGt || oc==OP_MoveLe;
if( pC->isTable ){
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->rowidIsValid = 0;
pC->deferredMoveto = 1;
break;
}
res = sqlite3BtreeEof(pC->pCursor);
}
}
+ assert( pOp->p2>0 );
if( res ){
- if( pOp->p2>0 ){
- pc = pOp->p2 - 1;
- }else{
- pC->nullRow = 1;
- }
+ pc = pOp->p2 - 1;
}
}
break;
** running ioerr.test and similar failure-recovery test scripts.) */
if( res!=0 ){
pc = pOp->p2 - 1;
- pC->rowidIsValid = 0;
+ assert( pC->rowidIsValid==0 );
}
}
break;
v = db->priorNewRowid;
cnt = 0;
do{
- if( v==0 || cnt>2 ){
+ if( cnt==0 && (v&0xffffff)==v ){
+ v++;
+ }else{
sqlite3Randomness(sizeof(v), &v);
if( cnt<5 ) v &= 0xffffff;
- }else{
- unsigned char r;
- sqlite3Randomness(1, &r);
- v += r + 1;
}
if( v==0 ) continue;
x = intToKey(v);
rx = sqlite3BtreeMoveto(pC->pCursor, 0, (u64)x, 0, &res);
cnt++;
- }while( cnt<1000 && rx==SQLITE_OK && res==0 );
+ }while( cnt<100 && rx==SQLITE_OK && res==0 );
db->priorNewRowid = v;
if( rx==SQLITE_OK && res==0 ){
rc = SQLITE_FULL;
** If the OPFLAG_NCHANGE flag of P2 is set, then the row change count is
** 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: {
int i = pOp->p1;
+ i64 iKey;
Cursor *pC;
+
assert( i>=0 && i<p->nCursor );
pC = p->apCsr[i];
assert( pC!=0 );
- if( pC->pCursor!=0 ){
- i64 iKey;
+ assert( pC->pCursor!=0 ); /* Only valid for real tables, no pseudotables */
- /* If the update-hook will be invoked, set iKey to the rowid of the
- ** row being deleted.
- */
- if( db->xUpdateCallback && pOp->p4.z ){
- assert( pC->isTable );
- if( pC->rowidIsValid ){
- iKey = pC->lastRowid;
- }else{
- rc = sqlite3BtreeKeySize(pC->pCursor, &iKey);
- if( rc ){
- goto abort_due_to_error;
- }
- iKey = keyToInt(iKey);
- }
- }
+ /* If the update-hook will be invoked, set iKey to the rowid of the
+ ** row being deleted.
+ */
+ if( db->xUpdateCallback && pOp->p4.z ){
+ assert( pC->isTable );
+ assert( pC->rowidIsValid ); /* lastRowid set by previous OP_NotFound */
+ iKey = pC->lastRowid;
+ }
- rc = sqlite3VdbeCursorMoveto(pC);
- if( rc ) goto abort_due_to_error;
- rc = sqlite3BtreeDelete(pC->pCursor);
- pC->nextRowidValid = 0;
- pC->cacheStatus = CACHE_STALE;
+ rc = sqlite3VdbeCursorMoveto(pC);
+ if( rc ) goto abort_due_to_error;
+ rc = sqlite3BtreeDelete(pC->pCursor);
+ pC->nextRowidValid = 0;
+ pC->cacheStatus = CACHE_STALE;
- /* Invoke the update-hook if required. */
- if( rc==SQLITE_OK && db->xUpdateCallback && pOp->p4.z ){
- const char *zDb = db->aDb[pC->iDb].zName;
- const char *zTbl = pOp->p4.z;
- db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE, zDb, zTbl, iKey);
- assert( pC->iDb>=0 );
- }
+ /* Invoke the update-hook if required. */
+ if( rc==SQLITE_OK && db->xUpdateCallback && pOp->p4.z ){
+ const char *zDb = db->aDb[pC->iDb].zName;
+ const char *zTbl = pOp->p4.z;
+ db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE, zDb, zTbl, iKey);
+ assert( pC->iDb>=0 );
}
if( pOp->p2 & OPFLAG_NCHANGE ) p->nChange++;
break;
}
#endif
-/* An other opcode is illegal...
+
+/* Opcode: Noop * * * * *
+**
+** Do nothing. This instruction is often useful as a jump
+** destination.
+*/
+/*
+** 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: {
- assert( 0 );
+default: { /* This is really OP_Noop and OP_Explain */
break;
}
*/
void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){
Op *pOp;
- assert( p==0 || p->magic==VDBE_MAGIC_INIT );
- if( p==0 || p->aOp==0 || p->db->mallocFailed ){
+ assert( p!=0 );
+ assert( p->magic==VDBE_MAGIC_INIT );
+ if( p->aOp==0 || p->db->mallocFailed ){
if (n != P4_KEYINFO) {
freeP4(n, (void*)*(char**)&zP4);
}
return;
}
- if( addr<0 || addr>=p->nOp ){
+ assert( addr<p->nOp );
+ if( addr<0 ){
addr = p->nOp - 1;
if( addr<0 ) return;
}
pKeyInfo = sqlite3_malloc( nByte );
pOp->p4.pKeyInfo = pKeyInfo;
if( pKeyInfo ){
- unsigned char *aSortOrder;
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;
if( aSortOrder ){
pKeyInfo->aSortOrder = (unsigned char*)&pKeyInfo->aColl[nField];
memcpy(pKeyInfo->aSortOrder, aSortOrder, nField);
}
+#endif
pOp->p4type = P4_KEYINFO;
}else{
p->db->mallocFailed = 1;
** so is applicable. Because this module is responsible for selecting
** 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"
}
if( !omitTable ){
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);
if( !omitTable ){
r1 = sqlite3GetTempReg(pParse);
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);
}
pLevel->p1 = iIdxCur;
#***********************************************************************
# 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]
source $testdir/tester.tcl
set tail [file tail $testfile]
if {[lsearch -exact $EXCLUDE $tail]>=0} continue
if {[llength $INCLUDE]>0 && [lsearch -exact $INCLUDE $tail]<0} continue
+ reset_prng_state
source $testfile
catch {db close}
if {$sqlite_open_file_count>0} {
# This file implements regression tests for SQLite library. The
# 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]
source $testdir/tester.tcl
execsql {SELECT CAST('123.5abc' AS integer)}
} 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.
#
do_test cast-2.1 {
# This file implements regression tests for SQLite library. The
# 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]
source $testdir/tester.tcl
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.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.46 {i1=32, i2=3} {i1>>i2} {4}
test_expr expr-1.47 {i1=9999999999, i2=8888888888} {i1<i2} 0
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.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.2 {r1=1.23, r2=2.34} {r1-r2} -1.11
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.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.2 {t1='xyz', t2='abc'} {t1<t2} 0
# sqlite_update_hook (tests hook-4-*)
# 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]
source $testdir/tester.tcl
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 {}
ifcapable trigger {
do_test hook-4.2.1 {
# Note: There are also some tests for incremental vacuum and IO
# 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]
source $testdir/tester.tcl
} {22}
do_test incrvacuum-10.5 {
-breakpoint
execsql {
PRAGMA incremental_vacuum("+3");
}
expr [file size test.db] / 1024
} {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
# create a database, thereafter that database defaults to incremental
# This file implements tests for miscellanous features that were
# 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]
source $testdir/tester.tcl
execsql {BEGIN; EXPLAIN ROLLBACK}
catchsql {ROLLBACK}
} {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} {
# focus of this file is testing the magic ROWID column that is
# 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]
source $testdir/tester.tcl
# Test the automatic generation of rowids when the table already contains
# 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 {
execsql {
CREATE TABLE t7(x INTEGER PRIMARY KEY, y);
}
} {a}
do_test rowid-12.2 {
+ db close
+ sqlite3 db test.db
+ save_prng_state
execsql {
INSERT INTO t7 VALUES(NULL,'b');
- SELECT y FROM t7;
+ SELECT x, y FROM t7;
+ }
+} {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');
}
-} {b a}
+} {1 {database or disk is full}}
+
finish_test
# A database corruption bug that occurs in auto_vacuum mode when
# 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]
return
}
+sqlite3_soft_heap_limit -1
+sqlite3_soft_heap_limit 0
sqlite3_soft_heap_limit 5000
do_test softheap1-1.1 {
execsql {
# This file implements some common TCL routines used for regression
# 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
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] {
file delete -force $f
}