Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Miscellaneous code simplifications and cleanup and test coverage enhancements. (CVS 4730) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
af129b6d158cc90ce9752dd6383c1de4 |
User & Date: | drh 2008-01-19 20:11:26.000 |
Context
2008-01-19
| ||
23:50 | Additional test coverage improvements. Test coverage now stands at 98.73%. (CVS 4731) (check-in: 010f7b780c user: drh tags: trunk) | |
20:11 | Miscellaneous code simplifications and cleanup and test coverage enhancements. (CVS 4730) (check-in: af129b6d15 user: drh tags: trunk) | |
03:35 | Cleanup and simplification of constraint processing. Simplifications to the VM for better test coverage. (CVS 4729) (check-in: d9ebe9d78c user: drh tags: trunk) | |
Changes
Changes to mkopcodeh.awk.
︙ | ︙ | |||
84 85 86 87 88 89 90 91 92 93 94 95 96 97 | # Assign numbers to all opcodes and output the result. END { cnt = 0 max = 0 print "/* Automatically generated. Do not edit */" print "/* See the mkopcodeh.awk script for details */" for(name in op){ if( op[name]<0 ){ cnt++ while( used[cnt] ) cnt++ op[name] = cnt } used[op[name]] = 1; | > > | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | # Assign numbers to all opcodes and output the result. END { cnt = 0 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++ while( used[cnt] ) cnt++ op[name] = cnt } used[op[name]] = 1; |
︙ | ︙ |
Changes to src/test1.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing all sorts of SQLite interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing all sorts of SQLite interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test1.c,v 1.283 2008/01/19 20:11:26 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include <stdlib.h> #include <string.h> /* |
︙ | ︙ | |||
4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 | static int vfs_unlink_test( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ Tcl_Obj *CONST objv[] /* Command arguments */ ){ int i; sqlite3_vfs *apVfs[20]; for(i=0; i<sizeof(apVfs)/sizeof(apVfs[0]); i++){ apVfs[i] = sqlite3_vfs_find(0); if( apVfs[i] ){ assert( apVfs[i]==sqlite3_vfs_find(apVfs[i]->zName) ); sqlite3_vfs_unregister(apVfs[i]); assert( 0==sqlite3_vfs_find(apVfs[i]->zName) ); } } assert( 0==sqlite3_vfs_find(0) ); 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(0) ); assert( apVfs[i]==sqlite3_vfs_find(apVfs[i]->zName) ); } } return TCL_OK; } /* ** tclcmd: save_prng_state */ static int save_prng_state( | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 | static int vfs_unlink_test( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ 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( apVfs[i]==sqlite3_vfs_find(apVfs[i]->zName) ); sqlite3_vfs_unregister(apVfs[i]); assert( 0==sqlite3_vfs_find(apVfs[i]->zName) ); } } 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(0) ); 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; } /* ** tclcmd: save_prng_state */ static int save_prng_state( |
︙ | ︙ |
Changes to src/vdbe.c.
︙ | ︙ | |||
39 40 41 42 43 44 45 | ** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | ** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** 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.701 2008/01/19 20:11:26 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> #include "vdbeInt.h" /* ** The following global variable is incremented every time a cursor |
︙ | ︙ | |||
2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 | /* Opcode: MoveGe 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 or equal to the key in register P3. ** If there are no records greater than or equal to the key and P2 ** is not zero, then jump to P2. ** ** 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. | > > > > > > > | | | | 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 | /* Opcode: MoveGe 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 or equal to the key in register P3. ** 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 ** then jump to P2. ** ** See also: Found, NotFound, Distinct, MoveLt, MoveGe, MoveLe */ /* Opcode: MoveLt P1 P2 P3 * * ** ** 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 ** then jump to P2. ** ** See also: Found, NotFound, Distinct, MoveGt, MoveGe, MoveLe */ /* Opcode: MoveLe P1 P2 P3 * * ** ** 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 ** then jump to P2. ** ** See also: Found, NotFound, Distinct, MoveGt, MoveGe, MoveLt */ case OP_MoveLt: /* jump, in3 */ case OP_MoveLe: /* jump, in3 */ case OP_MoveGe: /* jump, in3 */ |
︙ | ︙ | |||
2742 2743 2744 2745 2746 2747 2748 | if( pC->pCursor!=0 ){ int res, oc; oc = pOp->opcode; pC->nullRow = 0; *pC->pIncrKey = oc==OP_MoveGt || oc==OP_MoveLe; if( pC->isTable ){ i64 iKey = sqlite3VdbeIntValue(pIn3); | | > > | 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 | if( pC->pCursor!=0 ){ int res, oc; oc = pOp->opcode; pC->nullRow = 0; *pC->pIncrKey = oc==OP_MoveGt || oc==OP_MoveLe; if( pC->isTable ){ i64 iKey = sqlite3VdbeIntValue(pIn3); if( pOp->p2==0 ){ assert( pOp->opcode==OP_MoveGe ); pC->movetoTarget = iKey; pC->rowidIsValid = 0; pC->deferredMoveto = 1; break; } rc = sqlite3BtreeMoveto(pC->pCursor, 0, (u64)iKey, 0, &res); if( rc!=SQLITE_OK ){ goto abort_due_to_error; } |
︙ | ︙ | |||
2789 2790 2791 2792 2793 2794 2795 2796 | }else{ /* res might be negative because the table is empty. Check to ** see if this is the case. */ res = sqlite3BtreeEof(pC->pCursor); } } if( res ){ | > < | < < < | 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 | }else{ /* res might be negative because the table is empty. Check to ** see if this is the case. */ res = sqlite3BtreeEof(pC->pCursor); } } assert( pOp->p2>0 ); if( res ){ pc = pOp->p2 - 1; } } break; } /* Opcode: Found P1 P2 P3 * * ** |
︙ | ︙ | |||
3002 3003 3004 3005 3006 3007 3008 | /* res might be uninitialized if rc!=SQLITE_OK. But if rc!=SQLITE_OK ** processing is about to abort so we really do not care whether or not ** the following jump is taken. (In other words, do not stress over ** the error that valgrind sometimes shows on the next statement when ** running ioerr.test and similar failure-recovery test scripts.) */ if( res!=0 ){ pc = pOp->p2 - 1; | | | 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 | /* res might be uninitialized if rc!=SQLITE_OK. But if rc!=SQLITE_OK ** processing is about to abort so we really do not care whether or not ** the following jump is taken. (In other words, do not stress over ** the error that valgrind sometimes shows on the next statement when ** running ioerr.test and similar failure-recovery test scripts.) */ if( res!=0 ){ pc = pOp->p2 - 1; assert( pC->rowidIsValid==0 ); } } break; } /* Opcode: Sequence P1 P2 * * * ** |
︙ | ︙ | |||
3152 3153 3154 3155 3156 3157 3158 | } } if( pC->useRandomRowid ){ assert( pOp->p3==0 ); /* SQLITE_FULL must have occurred prior to this */ v = db->priorNewRowid; cnt = 0; do{ | < < | > < | | | | 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 | } } if( pC->useRandomRowid ){ assert( pOp->p3==0 ); /* SQLITE_FULL must have occurred prior to this */ v = db->priorNewRowid; cnt = 0; do{ if( cnt==0 && (v&0xffffff)==v ){ v++; }else{ sqlite3Randomness(sizeof(v), &v); if( cnt<5 ) v &= 0xffffff; } if( v==0 ) continue; x = intToKey(v); rx = sqlite3BtreeMoveto(pC->pCursor, 0, (u64)x, 0, &res); cnt++; }while( cnt<100 && rx==SQLITE_OK && res==0 ); db->priorNewRowid = v; if( rx==SQLITE_OK && res==0 ){ rc = SQLITE_FULL; goto abort_due_to_error; } } pC->rowidIsValid = 0; |
︙ | ︙ | |||
3290 3291 3292 3293 3294 3295 3296 | ** record in the table. If it is left pointing at the next record, then ** the next Next instruction will be a no-op. Hence it is OK to delete ** a record from within an Next loop. ** ** If the OPFLAG_NCHANGE flag of P2 is set, then the row change count is ** incremented (otherwise not). ** | | > > > > > > > > | < | | | | | | | < < < < | < | < < | | | | | | | | | | | < | 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 | ** record in the table. If it is left pointing at the next record, then ** the next Next instruction will be a no-op. Hence it is OK to delete ** a record from within an Next loop. ** ** If the OPFLAG_NCHANGE flag of P2 is set, then the row change count is ** incremented (otherwise not). ** ** 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 ); 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 ); 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; /* 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; } /* Opcode: ResetCount P1 * * ** |
︙ | ︙ | |||
4709 4710 4711 4712 4713 4714 4715 | } #endif /* SQLITE_DEBUG */ } break; } #endif | | > > > > > > > > > > | < | 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 | } #endif /* SQLITE_DEBUG */ } break; } #endif /* 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: { /* This is really OP_Noop and OP_Explain */ break; } /***************************************************************************** ** The cases of the switch statement above this line should all be indented ** by 6 spaces. But the left-most 6 spaces have been removed to improve the ** readability. From this point on down, the normal indentation rules are |
︙ | ︙ |
Changes to src/vdbeaux.c.
︙ | ︙ | |||
507 508 509 510 511 512 513 | ** to a string or structure that is guaranteed to exist for the lifetime of ** the Vdbe. In these cases we can just copy the pointer. ** ** If addr<0 then change P4 on the most recently inserted instruction. */ void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){ Op *pOp; | > | | > | | 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 | ** to a string or structure that is guaranteed to exist for the lifetime of ** the Vdbe. In these cases we can just copy the pointer. ** ** If addr<0 then change P4 on the most recently inserted instruction. */ void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){ Op *pOp; 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; } assert( addr<p->nOp ); if( addr<0 ){ addr = p->nOp - 1; if( addr<0 ) return; } pOp = &p->aOp[addr]; freeP4(pOp->p4type, pOp->p4.p); pOp->p4.p = 0; if( n==P4_INT32 ){ |
︙ | ︙ | |||
536 537 538 539 540 541 542 | int nField, nByte; nField = ((KeyInfo*)zP4)->nField; nByte = sizeof(*pKeyInfo) + (nField-1)*sizeof(pKeyInfo->aColl[0]) + nField; pKeyInfo = sqlite3_malloc( nByte ); pOp->p4.pKeyInfo = pKeyInfo; if( pKeyInfo ){ | < > > > > > > > | 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | int nField, nByte; nField = ((KeyInfo*)zP4)->nField; nByte = sizeof(*pKeyInfo) + (nField-1)*sizeof(pKeyInfo->aColl[0]) + nField; pKeyInfo = sqlite3_malloc( nByte ); pOp->p4.pKeyInfo = pKeyInfo; if( pKeyInfo ){ 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; pOp->p4type = P4_NOTUSED; } }else if( n==P4_KEYINFO_HANDOFF ){ pOp->p4.p = (void*)zP4; |
︙ | ︙ |
Changes to src/where.c.
︙ | ︙ | |||
12 13 14 15 16 17 18 | ** This module contains C code that generates VDBE code used to process ** the WHERE clause of SQL statements. This module is reponsible for ** generating the code that loops through a table looking for applicable ** rows. Indices are selected and used to speed the search when doing ** so is applicable. Because this module is responsible for selecting ** indices, you might also think of this module as the "query optimizer". ** | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ** This module contains C code that generates VDBE code used to process ** the WHERE clause of SQL statements. This module is reponsible for ** generating the code that loops through a table looking for applicable ** rows. Indices are selected and used to speed the search when doing ** 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.284 2008/01/19 20:11:26 drh Exp $ */ #include "sqliteInt.h" /* ** The number of bits in a Bitmask. "BMS" means "BitMask Size". */ #define BMS (sizeof(Bitmask)*8) |
︙ | ︙ | |||
2552 2553 2554 2555 2556 2557 2558 | r1 = sqlite3GetTempReg(pParse); if( topLimit | btmLimit ){ sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, nEq, r1); sqlite3VdbeAddOp2(v, OP_IsNull, r1, cont); } if( !omitTable ){ sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, r1); | | | 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 | r1 = sqlite3GetTempReg(pParse); if( topLimit | btmLimit ){ sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, nEq, r1); sqlite3VdbeAddOp2(v, OP_IsNull, r1, cont); } if( !omitTable ){ sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, r1); sqlite3VdbeAddOp3(v, OP_MoveGe, iCur, 0, r1); /* Deferred seek */ } sqlite3ReleaseTempReg(pParse, r1); /* Record the instruction used to terminate the loop. */ pLevel->op = bRev ? OP_Prev : OP_Next; pLevel->p1 = iIdxCur; |
︙ | ︙ | |||
2627 2628 2629 2630 2631 2632 2633 | start = sqlite3VdbeAddOp3(v, OP_IdxGE, iIdxCur, nxt, pLevel->iMem); sqlite3VdbeChangeP5(v, 1); pLevel->op = OP_Next; } if( !omitTable ){ r1 = sqlite3GetTempReg(pParse); sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, r1); | | | 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 | start = sqlite3VdbeAddOp3(v, OP_IdxGE, iIdxCur, nxt, pLevel->iMem); sqlite3VdbeChangeP5(v, 1); pLevel->op = OP_Next; } if( !omitTable ){ r1 = sqlite3GetTempReg(pParse); sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, r1); sqlite3VdbeAddOp3(v, OP_MoveGe, iCur, 0, r1); /* Deferred seek */ sqlite3ReleaseTempReg(pParse, r1); } pLevel->p1 = iIdxCur; pLevel->p2 = start; }else{ /* Case 5: There is no usable index. We must do a complete ** scan of the entire table. |
︙ | ︙ |
Changes to test/all.test.
1 2 3 4 5 6 7 8 9 10 11 12 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file runs all tests. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file runs all tests. # # $Id: all.test,v 1.53 2008/01/19 20:11:26 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl rename finish_test really_finish_test proc finish_test {} { # no-op } |
︙ | ︙ | |||
88 89 90 91 92 93 94 95 96 97 98 99 100 101 | } else { catch {unset ::SETUP_SQL} } foreach testfile [lsort -dictionary [glob $testdir/*.test]] { set tail [file tail $testfile] if {[lsearch -exact $EXCLUDE $tail]>=0} continue if {[llength $INCLUDE]>0 && [lsearch -exact $INCLUDE $tail]<0} continue source $testfile catch {db close} if {$sqlite_open_file_count>0} { puts "$tail did not close all files: $sqlite_open_file_count" incr nErr lappend ::failList $tail set sqlite_open_file_count 0 | > | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | } else { catch {unset ::SETUP_SQL} } foreach testfile [lsort -dictionary [glob $testdir/*.test]] { 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} { puts "$tail did not close all files: $sqlite_open_file_count" incr nErr lappend ::failList $tail set sqlite_open_file_count 0 |
︙ | ︙ |
Changes to test/cast.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2005 June 25 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the CAST operator. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2005 June 25 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the CAST operator. # # $Id: cast.test,v 1.9 2008/01/19 20:11:26 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Only run these tests if the build includes the CAST operator ifcapable !cast { finish_test |
︙ | ︙ | |||
178 179 180 181 182 183 184 185 186 187 188 189 190 191 | } integer do_test cast-1.51 { execsql {SELECT CAST('123.5abc' AS numeric)} } 123.5 do_test cast-1.53 { execsql {SELECT CAST('123.5abc' AS integer)} } 123 # Ticket #1662. Ignore leading spaces in numbers when casting. # do_test cast-2.1 { execsql {SELECT CAST(' 123' AS integer)} } 123 do_test cast-2.2 { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | } integer do_test cast-1.51 { execsql {SELECT CAST('123.5abc' AS numeric)} } 123.5 do_test cast-1.53 { 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 { execsql {SELECT CAST(' 123' AS integer)} } 123 do_test cast-2.2 { |
︙ | ︙ |
Changes to test/expr.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing expressions. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing expressions. # # $Id: expr.test,v 1.61 2008/01/19 20:11:26 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create a table to work with. # execsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)} |
︙ | ︙ | |||
68 69 70 71 72 73 74 75 76 77 78 79 80 81 | test_expr expr-1.40 {i1=1, i2=2} {+(i2+i1)} {3} test_expr expr-1.41 {i1=1, i2=2} {-(i2+i1)} {-3} test_expr expr-1.42 {i1=1, i2=2} {i1|i2} {3} 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.43b {i1=1, i2=2} {4&5} {4} test_expr expr-1.44 {i1=1} {~i1} {-2} 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.48 {i1=9999999999, i2=8888888888} {i1=i2} 0 test_expr expr-1.49 {i1=9999999999, i2=8888888888} {i1>i2} 1 test_expr expr-1.50 {i1=99999999999, i2=99999999998} {i1<i2} 0 test_expr expr-1.51 {i1=99999999999, i2=99999999998} {i1=i2} 0 | > | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | test_expr expr-1.40 {i1=1, i2=2} {+(i2+i1)} {3} test_expr expr-1.41 {i1=1, i2=2} {-(i2+i1)} {-3} test_expr expr-1.42 {i1=1, i2=2} {i1|i2} {3} 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.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.48 {i1=9999999999, i2=8888888888} {i1=i2} 0 test_expr expr-1.49 {i1=9999999999, i2=8888888888} {i1>i2} 1 test_expr expr-1.50 {i1=99999999999, i2=99999999998} {i1<i2} 0 test_expr expr-1.51 {i1=99999999999, i2=99999999998} {i1=i2} 0 |
︙ | ︙ | |||
137 138 139 140 141 142 143 144 145 146 147 148 149 150 | test_expr expr-1.103 {i1=0} {(-2147483648.0 % -1)} 0.0 test_expr expr-1.104 {i1=0} {(-9223372036854775808.0 % -1)} 0.0 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.107 {i1=0} {(1<<63)%-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.3 {r1=1.23, r2=2.34} {r1*r2} 2.8782 set tcl_precision 15 test_expr expr-2.4 {r1=1.23, r2=2.34} {r1/r2} 0.525641025641026 test_expr expr-2.5 {r1=1.23, r2=2.34} {r2/r1} 1.90243902439024 | > > | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | test_expr expr-1.103 {i1=0} {(-2147483648.0 % -1)} 0.0 test_expr expr-1.104 {i1=0} {(-9223372036854775808.0 % -1)} 0.0 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.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.3 {r1=1.23, r2=2.34} {r1*r2} 2.8782 set tcl_precision 15 test_expr expr-2.4 {r1=1.23, r2=2.34} {r1/r2} 0.525641025641026 test_expr expr-2.5 {r1=1.23, r2=2.34} {r2/r1} 1.90243902439024 |
︙ | ︙ | |||
165 166 167 168 169 170 171 172 173 174 175 176 177 178 | test_expr expr-2.20 {r1=2.34, r2=2.34} {r2<>r1} 0 test_expr expr-2.21 {r1=2.34, r2=2.34} {r2==r1} 1 test_expr expr-2.22 {r1=1.23, r2=2.34} {min(r1,r2,r1+r2,r1-r2)} {-1.11} 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.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-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.3 {t1='abc', t2='abc'} {t1<t2} 0 test_expr expr-3.4 {t1='abc', t2='xyz'} {t1<=t2} 1 test_expr expr-3.5 {t1='xyz', t2='abc'} {t1<=t2} 0 test_expr expr-3.6 {t1='abc', t2='abc'} {t1<=t2} 1 | > > | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | test_expr expr-2.20 {r1=2.34, r2=2.34} {r2<>r1} 0 test_expr expr-2.21 {r1=2.34, r2=2.34} {r2==r1} 1 test_expr expr-2.22 {r1=1.23, r2=2.34} {min(r1,r2,r1+r2,r1-r2)} {-1.11} 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.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 test_expr expr-3.3 {t1='abc', t2='abc'} {t1<t2} 0 test_expr expr-3.4 {t1='abc', t2='xyz'} {t1<=t2} 1 test_expr expr-3.5 {t1='xyz', t2='abc'} {t1<=t2} 0 test_expr expr-3.6 {t1='abc', t2='abc'} {t1<=t2} 1 |
︙ | ︙ |
Changes to test/hook.test.
︙ | ︙ | |||
13 14 15 16 17 18 19 | # # The focus of the tests in this file is the following interface: # # sqlite_commit_hook (tests hook-1..hook-3 inclusive) # sqlite_update_hook (tests hook-4-*) # sqlite_rollback_hook (tests hook-5.*) # | | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # # The focus of the tests in this file is the following interface: # # sqlite_commit_hook (tests hook-1..hook-3 inclusive) # sqlite_update_hook (tests hook-4-*) # sqlite_rollback_hook (tests hook-5.*) # # $Id: hook.test,v 1.13 2008/01/19 20:11:26 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl do_test hook-1.2 { db commit_hook } {} |
︙ | ︙ | |||
132 133 134 135 136 137 138 139 140 141 142 143 144 145 | DELETE main t1 2 \ UPDATE main t1 1 \ UPDATE main t1 3 \ DELETE main t1 1 \ DELETE main t1 3 \ DELETE main t1 4 \ ] set ::update_hook {} ifcapable trigger { do_test hook-4.2.1 { catchsql { DROP TABLE t2; } | > > > > > > > > > > > > > > > > > > | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | DELETE main t1 2 \ UPDATE main t1 1 \ UPDATE main t1 3 \ DELETE main t1 1 \ DELETE main t1 3 \ 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 { catchsql { DROP TABLE t2; } |
︙ | ︙ |
Changes to test/incrvacuum.test.
︙ | ︙ | |||
10 11 12 13 14 15 16 | #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the incremental vacuum feature. # # Note: There are also some tests for incremental vacuum and IO # errors in incrvacuum_ioerr.test. # | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the incremental vacuum feature. # # Note: There are also some tests for incremental vacuum and IO # errors in incrvacuum_ioerr.test. # # $Id: incrvacuum.test,v 1.17 2008/01/19 20:11:26 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # If this build of the library does not support auto-vacuum, omit this # whole file. ifcapable {!autovacuum || !pragma} { |
︙ | ︙ | |||
545 546 547 548 549 550 551 | execsql { PRAGMA incremental_vacuum('1'); } expr [file size test.db] / 1024 } {22} do_test incrvacuum-10.5 { | < > > > > > > > > > > > > > | 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 | execsql { PRAGMA incremental_vacuum('1'); } expr [file size test.db] / 1024 } {22} do_test incrvacuum-10.5 { execsql { PRAGMA incremental_vacuum("+3"); } expr [file size test.db] / 1024 } {19} do_test incrvacuum-10.6 { execsql { PRAGMA incremental_vacuum = 1; } expr [file size test.db] / 1024 } {18} do_test incrvacuum-10.7 { # Use a really big number as an argument to incremetal_vacuum. Should # be interpreted as "free all possible space". execsql { PRAGMA incremental_vacuum(2147483649); } 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 |
︙ | ︙ |
Changes to test/misc3.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for miscellanous features that were # left out of other test files. # | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for miscellanous features that were # left out of other test files. # # $Id: misc3.test,v 1.17 2008/01/19 20:11:26 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable {integrityck} { # Ticket #529. Make sure an ABORT does not damage the in-memory cache # that will be used by subsequent statements in the same transaction. |
︙ | ︙ | |||
254 255 256 257 258 259 260 261 262 263 264 265 266 267 | execsql {EXPLAIN COMMIT} catchsql {COMMIT} } {0 {}} do_test misc3-6.3 { execsql {BEGIN; EXPLAIN ROLLBACK} catchsql {ROLLBACK} } {0 {}} } ifcapable {trigger} { # Ticket #640: vdbe stack overflow with a LIMIT clause on a SELECT inside # of a trigger. # do_test misc3-7.1 { | > > > > > > > > > > > > > > > > > > > > | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | execsql {EXPLAIN COMMIT} catchsql {COMMIT} } {0 {}} do_test misc3-6.3 { 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} { # Ticket #640: vdbe stack overflow with a LIMIT clause on a SELECT inside # of a trigger. # do_test misc3-7.1 { |
︙ | ︙ |
Changes to test/rowid.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the magic ROWID column that is # found on all tables. # | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the magic ROWID column that is # found on all tables. # # $Id: rowid.test,v 1.20 2008/01/19 20:11:26 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Basic ROWID functionality tests. # do_test rowid-1.1 { |
︙ | ︙ | |||
653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 | do_test rowid-11.4 { execsql {SELECT rowid, a FROM t5 WHERE rowid<='abc'} } {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8} # Test the automatic generation of rowids when the table already contains # a rowid with the maximum value. # do_test rowid-12.1 { execsql { CREATE TABLE t7(x INTEGER PRIMARY KEY, y); INSERT INTO t7 VALUES(9223372036854775807,'a'); SELECT y FROM t7; } } {a} do_test rowid-12.2 { execsql { INSERT INTO t7 VALUES(NULL,'b'); | > > > > > > > > > | > > > > > > > > > > | | > > > > > > > > | 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 | do_test rowid-11.4 { execsql {SELECT rowid, a FROM t5 WHERE rowid<='abc'} } {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8} # 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); INSERT INTO t7 VALUES(9223372036854775807,'a'); SELECT y FROM t7; } } {a} do_test rowid-12.2 { db close sqlite3 db test.db save_prng_state execsql { INSERT INTO t7 VALUES(NULL,'b'); 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'); } } {1 {database or disk is full}} finish_test |
Changes to test/softheap1.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # # This test script reproduces the problem reported by ticket #2565, # A database corruption bug that occurs in auto_vacuum mode when # the soft_heap_limit is set low enough to be triggered. # | | > > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | # #*********************************************************************** # # This test script reproduces the problem reported by ticket #2565, # 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.4 2008/01/19 20:11:26 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !integrityck { finish_test return } sqlite3_soft_heap_limit -1 sqlite3_soft_heap_limit 0 sqlite3_soft_heap_limit 5000 do_test softheap1-1.1 { execsql { PRAGMA auto_vacuum=1; CREATE TABLE t1(x); INSERT INTO t1 VALUES(hex(randomblob(1000))); BEGIN; |
︙ | ︙ |
Changes to test/tester.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements some common TCL routines used for regression # testing the SQLite library # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements some common TCL routines used for regression # testing the SQLite library # # $Id: tester.tcl,v 1.102 2008/01/19 20:11:26 drh Exp $ set tcl_precision 15 set sqlite_pending_byte 0x0010000 # # Check the command-line arguments for a default soft-heap-limit. |
︙ | ︙ | |||
217 218 219 220 221 222 223 | } } else { puts "All memory allocations freed - no leaks" ifcapable memdebug { sqlite3_memdebug_dump ./memusage.txt } } | | > | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | } } else { puts "All memory allocations freed - no leaks" ifcapable memdebug { sqlite3_memdebug_dump ./memusage.txt } } 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 } foreach f [glob -nocomplain test.db-mj*] { file delete -force $f } exit [expr {$nErr>0}] |
︙ | ︙ |