diff --git a/manifest b/manifest index 1e9eafc39e..f06c0af37a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sfor\ssnapshot_get(),\s_open()\sand\s_free(). -D 2015-12-07T14:33:07.393 +C Merge\sunrelated\sfixes\sfrom\strunk. +D 2015-12-09T16:04:06.348 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc e8fdca1cb89a1b58b5f4d3a130ea9a3d28cb314d @@ -282,7 +282,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 -F src/btree.c d3bdd8462a86492e2ebc9aca4a0168429017de25 +F src/btree.c 81d041421359bbffc091c8a95dd0507aa4f09093 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 F src/btreeInt.h 3ab435ed27adea54d040584b0bcc488ee7db1e38 F src/build.c e83da4d004a4e050c01acbb821ff7a7b1019c29b @@ -292,7 +292,7 @@ F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 F src/date.c fb1c99172017dcc8e237339132c91a21a0788584 F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78 F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da -F src/expr.c cb1a419508e5b27769a91e00e36e94724e7b1d51 +F src/expr.c ccb93d7b7e1ac5d187c9b153bae145933f93ee5c F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 31900763094a3736a5fc887469202eb579fef2d0 F src/func.c fe50a9ab977acc0bb0fcd46741e0071fa388888e @@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8 F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 2563734669b06432cea640cbb4f7e9d543f227b9 +F src/os_unix.c 0ca6d8710366fbb01a275160f018334cd347cbda F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/pager.c 58d2593612acb6b542de6715b4af397ea1fa0a35 @@ -335,21 +335,21 @@ F src/pcache1.c 46a110be31a8d9f9b41431733836822ca0dd27ab F src/pragma.c f3e7147299ca05ef4304a36f1fd6e002729c72c6 F src/pragma.h 3d94aebbebd2089899fecc01909bf2608b39507d F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1 -F src/printf.c ca05561795ad6c2fa47acdd007702586282f7feb +F src/printf.c af589a27b7d40f6f4f704e9eea99f02f18ad6d32 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c a83b41104e6ff69855d03cd0aaa09e93927ec39f F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e F src/select.c f8fded11fc443a9f5a73cc5db069d06b34460e2f -F src/shell.c 2796237990d42e6a5a7beafee65ef70cc8767d21 +F src/shell.c abbc74ea43dbf2f306ea18282d666683fb5efab2 F src/sqlite.h.in fc8a2875a318df1b9dabd82cb00b1ac98081423a F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d -F src/sqliteInt.h 64256d193a16a147d9f6317cc4e095fdd3e0a2e9 +F src/sqliteInt.h 5caacf37a776f9d6178e519cb0b5248ca22a3828 F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e F src/tclsqlite.c d9439b6a910985b7fff43ba6756bcef00de22649 -F src/test1.c de18fc36e0830039058e9829ac201bb203d31718 +F src/test1.c 4f1b42699068b7806af3111786f5ad760c2c1ff7 F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b F src/test3.c a8887dabbbee3059af338f20d290084a63ed1b0f F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e @@ -374,7 +374,7 @@ F src/test_intarray.c 870124b95ec4c645d4eb84f15efb7133528fb1a5 F src/test_intarray.h 9dc57417fb65bc7835cc18548852cc08cc062202 F src/test_journal.c 5360fbe1d1e4416ca36290562fd5a2e3f70f32aa F src/test_loadext.c a5251f956ab6af21e138dc1f9c0399394a510cb4 -F src/test_malloc.c 8e1c2112fa4f543b46c990a8872f9e6d37938744 +F src/test_malloc.c 96df9381a1ff1f6d3805ff7231b9baf1386aaabf F src/test_multiplex.c 6a088d8d9d4aad4bec45dd8878af11b15900702d F src/test_multiplex.h c08e4e8f8651f0c5e0509b138ff4d5b43ed1f5d3 F src/test_mutex.c dbdfaff8580071f2212a0deae3325a93a737819c @@ -408,7 +408,7 @@ F src/vdbe.c 4d75375fa8bf911aa76ab8383d6f7eea0dec0fda F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637 F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca -F src/vdbeaux.c 9a234c9aaab4ad725daf94667cfed441a437c52d +F src/vdbeaux.c 8405f7441cb75c5d1816d1731a041d450e9ff2e9 F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045 F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d @@ -1315,7 +1315,7 @@ F test/where3.test 1ad55ba900bd7747f98b6082e65bd3e442c5004e F test/where4.test 4a371bfcc607f41d233701bdec33ac2972908ba8 F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2 F test/where6.test 5da5a98cec820d488e82708301b96cb8c18a258b -F test/where7.test 5a4b0abc207d71da4deecd734ad8579e8dd40aa8 +F test/where7.test f520bcec2c3d12dc4615623b06b2aec7c2d67e94 F test/where8.test 98eedca0d375fb400b8377269c4b4686582dfb45 F test/where8m.test da346596e19d54f0aba35ebade032a7c47d79739 F test/where9.test 729c3ba9b47e8f9f1aab96bae7dad2a524f1d1a2 @@ -1349,9 +1349,9 @@ F test/wordcount.c 2a0a6c0d0e8e8bbbac1f06d72a6791828c37c0cf F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test cf6748bad89553cc1632be51a6f54e487e4039ac F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 -F tool/GetTclKit.bat 8606413d3035c05373a0d7fae82ebf59ae9e16c3 +F tool/GetTclKit.bat 629d87562e0487c386db630033931d12d62e6372 F tool/addopcodes.tcl 4ca9c3ef196f08da30add5d07ce0c9458dc8c633 -F tool/build-all-msvc.bat e42141ca3c3812315432f9813ef9eb78aa8d99c9 x +F tool/build-all-msvc.bat 204a039f985d5a4f4f9df3a3aa594fd17848c37e x F tool/build-shell.sh 950f47c6174f1eea171319438b93ba67ff5bf367 F tool/cg_anno.tcl 692ce4b8693d59e3a3de77ca97f4139ecfa641b0 x F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 @@ -1409,7 +1409,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 0715eb00aa8891400cd50a15509d3d7b13789626 -R e71fd4e8a4bba215d14ff5f093a4f95d -U dan -Z b314e37499d3a0450136f5ece5d06812 +P 502cc6f353358946080d9bcd335aed526825b88a 901d0b8f3b72e96ffa8e9436993a12980f5ebd51 +R 9b1d7228446872f8d72f41cfd12e515e +U drh +Z 3ae5744205bfcf5cc63a2630633fbd47 diff --git a/manifest.uuid b/manifest.uuid index d3b0195b25..44bc42da2d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -502cc6f353358946080d9bcd335aed526825b88a \ No newline at end of file +362615b4df94358d0264b0991c3090a0878f054c \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 4a51b01d75..34ce8c3592 100644 --- a/src/btree.c +++ b/src/btree.c @@ -7521,8 +7521,13 @@ static int balance_nonroot( ** overflow cell), we can skip updating the pointer map entries. */ if( iOld>=nNew || pNew->pgno!=aPgno[iOld] +#ifdef HAVE_STDINT_H + || (intptr_t)pCell<(intptr_t)aOld + || (intptr_t)pCell>=(intptr_t)&aOld[usableSize] +#else || pCell=&aOld[usableSize] +#endif ){ if( !leafCorrection ){ ptrmapPut(pBt, get4byte(pCell), PTRMAP_BTREE, pNew->pgno, &rc); diff --git a/src/expr.c b/src/expr.c index 8cf018f9d4..8f6377e664 100644 --- a/src/expr.c +++ b/src/expr.c @@ -853,6 +853,7 @@ static int dupedExprSize(Expr *p, int flags){ */ static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){ Expr *pNew = 0; /* Value to return */ + assert( flags==0 || flags==EXPRDUP_REDUCE ); if( p ){ const int isReduced = (flags&EXPRDUP_REDUCE); u8 *zAlloc; @@ -889,7 +890,9 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){ }else{ int nSize = exprStructSize(p); memcpy(zAlloc, p, nSize); - memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize); + if( nSize1 && zDirname[ii]!='/'; ii--); - if( ii>1 ){ + for(ii=(int)strlen(zDirname); ii>0 && zDirname[ii]!='/'; ii--); + if( ii>0 ){ zDirname[ii] = '\0'; - fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0); - if( fd>=0 ){ - OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname)); - } + }else{ + if( zDirname[0]!='/' ) zDirname[0] = '.'; + zDirname[1] = 0; + } + fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0); + if( fd>=0 ){ + OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname)); } *pFd = fd; if( fd>=0 ) return SQLITE_OK; diff --git a/src/printf.c b/src/printf.c index 88bb82e3e3..969950c154 100644 --- a/src/printf.c +++ b/src/printf.c @@ -766,8 +766,9 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){ setStrAccumError(p, STRACCUM_TOOBIG); return N; }else{ - char *zOld = (p->zText==p->zBase ? 0 : p->zText); + char *zOld = p->bMalloced ? p->zText : 0; i64 szNew = p->nChar; + assert( (p->zText==0 || p->zText==p->zBase)==(p->bMalloced==0) ); szNew += N + 1; if( szNew+p->nChar<=p->mxAlloc ){ /* Force exponential buffer size growth as long as it does not overflow, @@ -788,9 +789,10 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){ } if( zNew ){ assert( p->zText!=0 || p->nChar==0 ); - if( zOld==0 && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar); + if( !p->bMalloced && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar); p->zText = zNew; p->nAlloc = sqlite3DbMallocSize(p->db, zNew); + p->bMalloced = 1; }else{ sqlite3StrAccumReset(p); setStrAccumError(p, STRACCUM_NOMEM); @@ -808,6 +810,7 @@ void sqlite3AppendChar(StrAccum *p, int N, char c){ if( p->nChar+(i64)N >= p->nAlloc && (N = sqlite3StrAccumEnlarge(p, N))<=0 ){ return; } + assert( (p->zText==p->zBase)==(p->bMalloced==0) ); while( (N--)>0 ) p->zText[p->nChar++] = c; } @@ -825,6 +828,7 @@ static void SQLITE_NOINLINE enlargeAndAppend(StrAccum *p, const char *z, int N){ memcpy(&p->zText[p->nChar], z, N); p->nChar += N; } + assert( (p->zText==0 || p->zText==p->zBase)==(p->bMalloced==0) ); } /* @@ -860,11 +864,13 @@ void sqlite3StrAccumAppendAll(StrAccum *p, const char *z){ */ char *sqlite3StrAccumFinish(StrAccum *p){ if( p->zText ){ + assert( (p->zText==p->zBase)==(p->bMalloced==0) ); p->zText[p->nChar] = 0; - if( p->mxAlloc>0 && p->zText==p->zBase ){ + if( p->mxAlloc>0 && p->bMalloced==0 ){ p->zText = sqlite3DbMallocRaw(p->db, p->nChar+1 ); if( p->zText ){ memcpy(p->zText, p->zBase, p->nChar+1); + p->bMalloced = 1; }else{ setStrAccumError(p, STRACCUM_NOMEM); } @@ -877,8 +883,10 @@ char *sqlite3StrAccumFinish(StrAccum *p){ ** Reset an StrAccum string. Reclaim all malloced memory. */ void sqlite3StrAccumReset(StrAccum *p){ - if( p->zText!=p->zBase ){ + assert( (p->zText==0 || p->zText==p->zBase)==(p->bMalloced==0) ); + if( p->bMalloced ){ sqlite3DbFree(p->db, p->zText); + p->bMalloced = 0; } p->zText = 0; } @@ -904,6 +912,7 @@ void sqlite3StrAccumInit(StrAccum *p, sqlite3 *db, char *zBase, int n, int mx){ p->nAlloc = n; p->mxAlloc = mx; p->accError = 0; + p->bMalloced = 0; } /* diff --git a/src/shell.c b/src/shell.c index bcad59e806..ff1336a4b7 100644 --- a/src/shell.c +++ b/src/shell.c @@ -525,6 +525,7 @@ struct ShellState { int autoEQP; /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */ int statsOn; /* True to display memory stats before each finalize */ int scanstatsOn; /* True to display scan stats before each finalize */ + int countChanges; /* True to display change counts */ int backslashOn; /* Resolve C-style \x escapes in SQL input text */ int outCount; /* Revert to stdout when reaching zero */ int cnt; /* Number of records displayed so far */ @@ -1785,6 +1786,7 @@ static char zHelp[] = ".backup ?DB? FILE Backup DB (default \"main\") to FILE\n" ".bail on|off Stop after hitting an error. Default OFF\n" ".binary on|off Turn binary output on or off. Default OFF\n" + ".changes on|off Show number of rows changed by SQL\n" ".clone NEWDB Clone data into NEWDB from the existing database\n" ".databases List names and files of attached databases\n" ".dbinfo ?DB? Show status information about the database\n" @@ -2757,6 +2759,15 @@ static int do_meta_command(char *zLine, ShellState *p){ test_breakpoint(); }else + if( c=='c' && n>=3 && strncmp(azArg[0], "changes", n)==0 ){ + if( nArg==2 ){ + p->countChanges = booleanValue(azArg[1]); + }else{ + fprintf(stderr, "Usage: .changes on|off\n"); + rc = 1; + } + }else + if( c=='c' && strncmp(azArg[0], "clone", n)==0 ){ if( nArg==2 ){ tryToClone(p, azArg[1]); @@ -4286,6 +4297,9 @@ static int process_input(ShellState *p, FILE *in){ fprintf(stderr, "%s %s\n", zPrefix, sqlite3_errmsg(p->db)); } errCnt++; + }else if( p->countChanges ){ + fprintf(p->out, "changes: %3d total_changes: %d\n", + sqlite3_changes(p->db), sqlite3_total_changes(p->db)); } nSql = 0; if( p->outCount ){ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 338a573253..0d477dc06f 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2952,6 +2952,7 @@ struct StrAccum { int nAlloc; /* Amount of space allocated in zText */ int mxAlloc; /* Maximum allowed allocation. 0 for no malloc usage */ u8 accError; /* STRACCUM_NOMEM or STRACCUM_TOOBIG */ + u8 bMalloced; /* zText points to allocated space */ }; #define STRACCUM_NOMEM 1 #define STRACCUM_TOOBIG 2 diff --git a/src/test1.c b/src/test1.c index 31f506ea4f..c5e71582bc 100644 --- a/src/test1.c +++ b/src/test1.c @@ -2269,6 +2269,7 @@ static int vfsCurrentTimeInt64( return TCL_OK; } +#ifdef SQLITE_ENABLE_SNAPSHOT /* ** Usage: sqlite3_snapshot_get DB DBNAME */ @@ -2301,7 +2302,9 @@ static int test_snapshot_get( } return TCL_OK; } +#endif /* SQLITE_ENABLE_SNAPSHOT */ +#ifdef SQLITE_ENABLE_SNAPSHOT /* ** Usage: sqlite3_snapshot_open DB DBNAME SNAPSHOT */ @@ -2331,7 +2334,9 @@ static int test_snapshot_open( } return TCL_OK; } +#endif /* SQLITE_ENABLE_SNAPSHOT */ +#ifdef SQLITE_ENABLE_SNAPSHOT /* ** Usage: sqlite3_snapshot_free SNAPSHOT */ @@ -2350,6 +2355,7 @@ static int test_snapshot_free( sqlite3_snapshot_free(pSnapshot); return TCL_OK; } +#endif /* SQLITE_ENABLE_SNAPSHOT */ /* ** Usage: sqlite3_next_stmt DB STMT @@ -5988,13 +5994,13 @@ static int test_sqlite3_log( Tcl_DecrRefCount(logcallback.pObj); logcallback.pObj = 0; logcallback.pInterp = 0; - sqlite3_config(SQLITE_CONFIG_LOG, 0, 0); + sqlite3_config(SQLITE_CONFIG_LOG, (void*)0, (void*)0); } if( objc>1 ){ logcallback.pObj = objv[1]; Tcl_IncrRefCount(logcallback.pObj); logcallback.pInterp = interp; - sqlite3_config(SQLITE_CONFIG_LOG, xLogcallback, 0); + sqlite3_config(SQLITE_CONFIG_LOG, xLogcallback, (void*)0); } return TCL_OK; } diff --git a/src/test_malloc.c b/src/test_malloc.c index a3ff9d205b..aaa640b03a 100644 --- a/src/test_malloc.c +++ b/src/test_malloc.c @@ -222,7 +222,8 @@ static int faultsimInstall(int install){ assert( memcmp(&m2, &memfault.m, sizeof(m2))==0 ); rc = sqlite3_config(SQLITE_CONFIG_MALLOC, &memfault.m); - sqlite3_test_control(SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, 0, 0); + sqlite3_test_control(SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, + (void*)0, (void*)0); } if( rc==SQLITE_OK ){ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 1889aec79f..26d162e93a 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1725,30 +1725,31 @@ void sqlite3VdbeIOTraceSql(Vdbe *p){ ** ** nByte is the number of bytes of space needed. ** -** *ppFrom points to available space and pEnd points to the end of the -** available space. When space is allocated, *ppFrom is advanced past -** the end of the allocated space. +** pFrom points to *pnFrom bytes of available space. New space is allocated +** from the end of the pFrom buffer and *pnFrom is decremented. ** -** *pnByte is a counter of the number of bytes of space that have failed -** to allocate. If there is insufficient space in *ppFrom to satisfy the -** request, then increment *pnByte by the amount of the request. +** *pnNeeded is a counter of the number of bytes of space that have failed +** to allocate. If there is insufficient space in pFrom to satisfy the +** request, then increment *pnNeeded by the amount of the request. */ static void *allocSpace( void *pBuf, /* Where return pointer will be stored */ int nByte, /* Number of bytes to allocate */ - u8 **ppFrom, /* IN/OUT: Allocate from *ppFrom */ - u8 *pEnd, /* Pointer to 1 byte past the end of *ppFrom buffer */ - int *pnByte /* If allocation cannot be made, increment *pnByte */ + u8 *pFrom, /* Memory available for allocation */ + int *pnFrom, /* IN/OUT: Space available at pFrom */ + int *pnNeeded /* If allocation cannot be made, increment *pnByte */ ){ - assert( EIGHT_BYTE_ALIGNMENT(*ppFrom) ); - if( pBuf ) return pBuf; - nByte = ROUND8(nByte); - if( &(*ppFrom)[nByte] <= pEnd ){ - pBuf = (void*)*ppFrom; - *ppFrom += nByte; - }else{ - *pnByte += nByte; + assert( EIGHT_BYTE_ALIGNMENT(pFrom) ); + if( pBuf==0 ){ + nByte = ROUND8(nByte); + if( nByte <= *pnFrom ){ + *pnFrom -= nByte; + pBuf = &pFrom[*pnFrom]; + }else{ + *pnNeeded += nByte; + } } + assert( EIGHT_BYTE_ALIGNMENT(pBuf) ); return pBuf; } @@ -1821,8 +1822,8 @@ void sqlite3VdbeMakeReady( int nArg; /* Number of arguments in subprograms */ int nOnce; /* Number of OP_Once instructions */ int n; /* Loop counter */ + int nFree; /* Available free space */ u8 *zCsr; /* Memory available for allocation */ - u8 *zEnd; /* First byte past allocated memory */ int nByte; /* How much extra memory is needed */ assert( p!=0 ); @@ -1854,14 +1855,15 @@ void sqlite3VdbeMakeReady( ** an array to marshal SQL function arguments in. */ zCsr = (u8*)&p->aOp[p->nOp]; /* Memory avaliable for allocation */ - zEnd = (u8*)&p->aOp[pParse->nOpAlloc]; /* First byte past end of zCsr[] */ + assert( pParse->nOpAlloc*sizeof(Op) <= 0x7fffff00 ); + nFree = (pParse->nOpAlloc - p->nOp)*sizeof(p->aOp[0]); /* Available space */ resolveP2Values(p, &nArg); p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort); if( pParse->explain && nMem<10 ){ nMem = 10; } - memset(zCsr, 0, zEnd-zCsr); + memset(zCsr, 0, nFree); zCsr += (zCsr - (u8*)0)&7; assert( EIGHT_BYTE_ALIGNMENT(zCsr) ); p->expired = 0; @@ -1878,21 +1880,21 @@ void sqlite3VdbeMakeReady( */ do { nByte = 0; - p->aMem = allocSpace(p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte); - p->aVar = allocSpace(p->aVar, nVar*sizeof(Mem), &zCsr, zEnd, &nByte); - p->apArg = allocSpace(p->apArg, nArg*sizeof(Mem*), &zCsr, zEnd, &nByte); - p->azVar = allocSpace(p->azVar, nVar*sizeof(char*), &zCsr, zEnd, &nByte); + p->aMem = allocSpace(p->aMem, nMem*sizeof(Mem), zCsr, &nFree, &nByte); + p->aVar = allocSpace(p->aVar, nVar*sizeof(Mem), zCsr, &nFree, &nByte); + p->apArg = allocSpace(p->apArg, nArg*sizeof(Mem*), zCsr, &nFree, &nByte); + p->azVar = allocSpace(p->azVar, nVar*sizeof(char*), zCsr, &nFree, &nByte); p->apCsr = allocSpace(p->apCsr, nCursor*sizeof(VdbeCursor*), - &zCsr, zEnd, &nByte); - p->aOnceFlag = allocSpace(p->aOnceFlag, nOnce, &zCsr, zEnd, &nByte); + zCsr, &nFree, &nByte); + p->aOnceFlag = allocSpace(p->aOnceFlag, nOnce, zCsr, &nFree, &nByte); #ifdef SQLITE_ENABLE_STMT_SCANSTATUS - p->anExec = allocSpace(p->anExec, p->nOp*sizeof(i64), &zCsr, zEnd, &nByte); + p->anExec = allocSpace(p->anExec, p->nOp*sizeof(i64), zCsr, &nFree, &nByte); #endif if( nByte ){ p->pFree = sqlite3DbMallocZero(db, nByte); } zCsr = p->pFree; - zEnd = &zCsr[nByte]; + nFree = nByte; }while( nByte && !db->mallocFailed ); p->nCursor = nCursor; @@ -3235,7 +3237,7 @@ u32 sqlite3VdbeSerialPut(u8 *buf, Mem *pMem, u32 serial_type){ assert( pMem->n + ((pMem->flags & MEM_Zero)?pMem->u.nZero:0) == (int)sqlite3VdbeSerialTypeLen(serial_type) ); len = pMem->n; - memcpy(buf, pMem->z, len); + if( len>0 ) memcpy(buf, pMem->z, len); return len; } diff --git a/test/where7.test b/test/where7.test index 5032c698b2..00cf5eb278 100644 --- a/test/where7.test +++ b/test/where7.test @@ -47,6 +47,18 @@ do_test where7-1.1 { SELECT * FROM t1; } } {1 2 3 4 2 3 4 5 3 4 6 8 4 5 10 15 5 10 100 1000} +do_execsql_test where7-1.1.1 { + CREATE TABLE t(a); + CREATE INDEX ta ON t(a); + INSERT INTO t(a) VALUES(1),(2); + SELECT * FROM t ORDER BY a; + SELECT * FROM t WHERE a<2 OR a<3 ORDER BY a; + PRAGMA count_changes=ON; + DELETE FROM t WHERE a<2 OR a<3; + SELECT * FROM t; + PRAGMA count_changes=OFF; + DROP TABLE t; +} {1 2 1 2 2} do_test where7-1.2 { count_steps { SELECT a FROM t1 WHERE b=3 OR c=6 ORDER BY a diff --git a/tool/GetTclKit.bat b/tool/GetTclKit.bat index 1ed15ea7f3..84235cf97a 100644 --- a/tool/GetTclKit.bat +++ b/tool/GetTclKit.bat @@ -62,7 +62,7 @@ IF NOT DEFINED TEMP ( %_VECHO% Temp = '%TEMP%' IF NOT DEFINED TCLKIT_URI ( - SET TCLKIT_URI=http://tclsh.com/ + SET TCLKIT_URI=https://tclsh.com/ ) %_VECHO% TclKitUri = '%TCLKIT_URI%' diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat index e081c73b38..87794132b6 100755 --- a/tool/build-all-msvc.bat +++ b/tool/build-all-msvc.bat @@ -320,7 +320,7 @@ REM IF DEFINED UCRTVersion ( SET NUCRTVER=%UCRTVersion% ) ELSE ( - SET NUCRTVER=10.0.10240.0 + SET NUCRTVER=10.0.10586.0 ) REM