| | @@ -1162,11 +1162,11 @@ |
| 1162 | 1162 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1163 | 1163 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1164 | 1164 | */ |
| 1165 | 1165 | #define SQLITE_VERSION "3.33.0" |
| 1166 | 1166 | #define SQLITE_VERSION_NUMBER 3033000 |
| 1167 | | -#define SQLITE_SOURCE_ID "2020-07-30 17:37:49 96e3dba2ed3ab0c5b2ecf65a3408633e0767c884d48c270e9ef10ab9fa3ec051" |
| 1167 | +#define SQLITE_SOURCE_ID "2020-08-07 19:52:01 fdc5fb902d7f2d10f73e64fe30c67153b59b26c5d707fc9c354e90967dbcc214" |
| 1168 | 1168 | |
| 1169 | 1169 | /* |
| 1170 | 1170 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1171 | 1171 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1172 | 1172 | ** |
| | @@ -60677,11 +60677,38 @@ |
| 60677 | 60677 | } |
| 60678 | 60678 | } |
| 60679 | 60679 | pWal->apWiData[iPg] = aShare; |
| 60680 | 60680 | nHdr = (iPg==0 ? WALINDEX_HDR_SIZE : 0); |
| 60681 | 60681 | nHdr32 = nHdr / sizeof(u32); |
| 60682 | +#ifndef SQLITE_SAFER_WALINDEX_RECOVERY |
| 60683 | + /* Memcpy() should work fine here, on all reasonable implementations. |
| 60684 | + ** Technically, memcpy() might change the destination to some |
| 60685 | + ** intermediate value before setting to the final value, and that might |
| 60686 | + ** cause a concurrent reader to malfunction. Memcpy() is allowed to |
| 60687 | + ** do that, according to the spec, but no memcpy() implementation that |
| 60688 | + ** we know of actually does that, which is why we say that memcpy() |
| 60689 | + ** is safe for this. Memcpy() is certainly a lot faster. |
| 60690 | + */ |
| 60682 | 60691 | memcpy(&aShare[nHdr32], &aPrivate[nHdr32], WALINDEX_PGSZ-nHdr); |
| 60692 | +#else |
| 60693 | + /* In the event that some platform is found for which memcpy() |
| 60694 | + ** changes the destination to some intermediate value before |
| 60695 | + ** setting the final value, this alternative copy routine is |
| 60696 | + ** provided. |
| 60697 | + */ |
| 60698 | + { |
| 60699 | + int i; |
| 60700 | + for(i=nHdr32; i<WALINDEX_PGSZ/sizeof(u32); i++){ |
| 60701 | + if( aShare[i]!=aPrivate[i] ){ |
| 60702 | + /* Atomic memory operations are not required here because if |
| 60703 | + ** the value needs to be changed, that means it is not being |
| 60704 | + ** accessed concurrently. */ |
| 60705 | + aShare[i] = aPrivate[i]; |
| 60706 | + } |
| 60707 | + } |
| 60708 | + } |
| 60709 | +#endif |
| 60683 | 60710 | if( iFrame<=iLast ) break; |
| 60684 | 60711 | } |
| 60685 | 60712 | |
| 60686 | 60713 | sqlite3_free(aFrame); |
| 60687 | 60714 | } |
| | @@ -61377,14 +61404,21 @@ |
| 61377 | 61404 | i64 nReq = ((i64)mxPage * szPage); |
| 61378 | 61405 | i64 nSize; /* Current size of database file */ |
| 61379 | 61406 | sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_CKPT_START, 0); |
| 61380 | 61407 | rc = sqlite3OsFileSize(pWal->pDbFd, &nSize); |
| 61381 | 61408 | if( rc==SQLITE_OK && nSize<nReq ){ |
| 61382 | | - sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq); |
| 61409 | + if( (nSize+(i64)pWal->hdr.mxFrame*szPage)<nReq ){ |
| 61410 | + /* If the size of the final database is larger than the current |
| 61411 | + ** database plus the amount of data in the wal file, then there |
| 61412 | + ** must be corruption somewhere. */ |
| 61413 | + rc = SQLITE_CORRUPT_BKPT; |
| 61414 | + }else{ |
| 61415 | + sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT,&nReq); |
| 61416 | + } |
| 61383 | 61417 | } |
| 61418 | + |
| 61384 | 61419 | } |
| 61385 | | - |
| 61386 | 61420 | |
| 61387 | 61421 | /* Iterate through the contents of the WAL, copying data to the db file */ |
| 61388 | 61422 | while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){ |
| 61389 | 61423 | i64 iOffset; |
| 61390 | 61424 | assert( walFramePgno(pWal, iFrame)==iDbpage ); |
| | @@ -70387,11 +70421,11 @@ |
| 70387 | 70421 | ** shows that the page 'nearby' is somewhere on the free-list, then |
| 70388 | 70422 | ** the entire-list will be searched for that page. |
| 70389 | 70423 | */ |
| 70390 | 70424 | #ifndef SQLITE_OMIT_AUTOVACUUM |
| 70391 | 70425 | if( eMode==BTALLOC_EXACT ){ |
| 70392 | | - if( ALWAYS(nearby<=mxPage) ){ |
| 70426 | + if( nearby<=mxPage ){ |
| 70393 | 70427 | u8 eType; |
| 70394 | 70428 | assert( nearby>0 ); |
| 70395 | 70429 | assert( pBt->autoVacuum ); |
| 70396 | 70430 | rc = ptrmapGet(pBt, nearby, &eType, 0); |
| 70397 | 70431 | if( rc ) return rc; |
| | @@ -70683,11 +70717,11 @@ |
| 70683 | 70717 | |
| 70684 | 70718 | assert( sqlite3_mutex_held(pBt->mutex) ); |
| 70685 | 70719 | assert( CORRUPT_DB || iPage>1 ); |
| 70686 | 70720 | assert( !pMemPage || pMemPage->pgno==iPage ); |
| 70687 | 70721 | |
| 70688 | | - if( iPage<2 || NEVER(iPage>pBt->nPage) ){ |
| 70722 | + if( iPage<2 || iPage>pBt->nPage ){ |
| 70689 | 70723 | return SQLITE_CORRUPT_BKPT; |
| 70690 | 70724 | } |
| 70691 | 70725 | if( pMemPage ){ |
| 70692 | 70726 | pPage = pMemPage; |
| 70693 | 70727 | sqlite3PagerRef(pPage->pDbPage); |
| | @@ -87556,11 +87590,11 @@ |
| 87556 | 87590 | p1 = pOp->p1; |
| 87557 | 87591 | p2 = pOp->p2; |
| 87558 | 87592 | #ifdef SQLITE_DEBUG |
| 87559 | 87593 | if( aPermute ){ |
| 87560 | 87594 | int k, mx = 0; |
| 87561 | | - for(k=0; k<n; k++) if( aPermute[k]>mx ) mx = aPermute[k]; |
| 87595 | + for(k=0; k<n; k++) if( aPermute[k]>(u32)mx ) mx = aPermute[k]; |
| 87562 | 87596 | assert( p1>0 && p1+mx<=(p->nMem+1 - p->nCursor)+1 ); |
| 87563 | 87597 | assert( p2>0 && p2+mx<=(p->nMem+1 - p->nCursor)+1 ); |
| 87564 | 87598 | }else{ |
| 87565 | 87599 | assert( p1>0 && p1+n<=(p->nMem+1 - p->nCursor)+1 ); |
| 87566 | 87600 | assert( p2>0 && p2+n<=(p->nMem+1 - p->nCursor)+1 ); |
| | @@ -87906,11 +87940,11 @@ |
| 87906 | 87940 | |
| 87907 | 87941 | assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) ); |
| 87908 | 87942 | pDest = &aMem[pOp->p3]; |
| 87909 | 87943 | memAboutToChange(p, pDest); |
| 87910 | 87944 | assert( pC!=0 ); |
| 87911 | | - assert( p2<pC->nField ); |
| 87945 | + assert( p2<(u32)pC->nField ); |
| 87912 | 87946 | aOffset = pC->aOffset; |
| 87913 | 87947 | assert( pC->eCurType!=CURTYPE_VTAB ); |
| 87914 | 87948 | assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow ); |
| 87915 | 87949 | assert( pC->eCurType!=CURTYPE_SORTER ); |
| 87916 | 87950 | |
| | @@ -89095,11 +89129,11 @@ |
| 89095 | 89129 | }else{ |
| 89096 | 89130 | wrFlag = 0; |
| 89097 | 89131 | } |
| 89098 | 89132 | if( pOp->p5 & OPFLAG_P2ISREG ){ |
| 89099 | 89133 | assert( p2>0 ); |
| 89100 | | - assert( p2<=(p->nMem+1 - p->nCursor) ); |
| 89134 | + assert( p2<=(u32)(p->nMem+1 - p->nCursor) ); |
| 89101 | 89135 | assert( pOp->opcode==OP_OpenWrite ); |
| 89102 | 89136 | pIn2 = &aMem[p2]; |
| 89103 | 89137 | assert( memIsValid(pIn2) ); |
| 89104 | 89138 | assert( (pIn2->flags & MEM_Int)!=0 ); |
| 89105 | 89139 | sqlite3VdbeMemIntegerify(pIn2); |
| | @@ -91528,11 +91562,11 @@ |
| 91528 | 91562 | |
| 91529 | 91563 | assert( p->bIsReader ); |
| 91530 | 91564 | nRoot = pOp->p2; |
| 91531 | 91565 | aRoot = pOp->p4.ai; |
| 91532 | 91566 | assert( nRoot>0 ); |
| 91533 | | - assert( aRoot[0]==nRoot ); |
| 91567 | + assert( aRoot[0]==(Pgno)nRoot ); |
| 91534 | 91568 | assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) ); |
| 91535 | 91569 | pnErr = &aMem[pOp->p3]; |
| 91536 | 91570 | assert( (pnErr->flags & MEM_Int)!=0 ); |
| 91537 | 91571 | assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 ); |
| 91538 | 91572 | pIn1 = &aMem[pOp->p1]; |
| | @@ -113187,11 +113221,11 @@ |
| 113187 | 113221 | ** erasing iTable (this can happen with an auto-vacuum database). |
| 113188 | 113222 | */ |
| 113189 | 113223 | static void destroyRootPage(Parse *pParse, int iTable, int iDb){ |
| 113190 | 113224 | Vdbe *v = sqlite3GetVdbe(pParse); |
| 113191 | 113225 | int r1 = sqlite3GetTempReg(pParse); |
| 113192 | | - if( NEVER(iTable<2) ) return; |
| 113226 | + if( iTable<2 ) sqlite3ErrorMsg(pParse, "corrupt schema"); |
| 113193 | 113227 | sqlite3VdbeAddOp3(v, OP_Destroy, iTable, r1, iDb); |
| 113194 | 113228 | sqlite3MayAbort(pParse); |
| 113195 | 113229 | #ifndef SQLITE_OMIT_AUTOVACUUM |
| 113196 | 113230 | /* OP_Destroy stores an in integer r1. If this integer |
| 113197 | 113231 | ** is non-zero, then it is the root page number of a table moved to |
| | @@ -188079,10 +188113,11 @@ |
| 188079 | 188113 | #endif |
| 188080 | 188114 | |
| 188081 | 188115 | /* #include <string.h> */ |
| 188082 | 188116 | /* #include <stdio.h> */ |
| 188083 | 188117 | /* #include <assert.h> */ |
| 188118 | +/* #include <stdlib.h> */ |
| 188084 | 188119 | |
| 188085 | 188120 | /* The following macro is used to suppress compiler warnings. |
| 188086 | 188121 | */ |
| 188087 | 188122 | #ifndef UNUSED_PARAMETER |
| 188088 | 188123 | # define UNUSED_PARAMETER(x) (void)(x) |
| | @@ -188416,10 +188451,27 @@ |
| 188416 | 188451 | */ |
| 188417 | 188452 | #ifndef SQLITE_AMALGAMATION |
| 188418 | 188453 | # define testcase(X) |
| 188419 | 188454 | #endif |
| 188420 | 188455 | |
| 188456 | +/* |
| 188457 | +** Make sure that the compiler intrinsics we desire are enabled when |
| 188458 | +** compiling with an appropriate version of MSVC unless prevented by |
| 188459 | +** the SQLITE_DISABLE_INTRINSIC define. |
| 188460 | +*/ |
| 188461 | +#if !defined(SQLITE_DISABLE_INTRINSIC) |
| 188462 | +# if defined(_MSC_VER) && _MSC_VER>=1400 |
| 188463 | +# if !defined(_WIN32_WCE) |
| 188464 | +/* # include <intrin.h> */ |
| 188465 | +# pragma intrinsic(_byteswap_ulong) |
| 188466 | +# pragma intrinsic(_byteswap_uint64) |
| 188467 | +# else |
| 188468 | +/* # include <cmnintrin.h> */ |
| 188469 | +# endif |
| 188470 | +# endif |
| 188471 | +#endif |
| 188472 | + |
| 188421 | 188473 | /* |
| 188422 | 188474 | ** Macros to determine whether the machine is big or little endian, |
| 188423 | 188475 | ** and whether or not that determination is run-time or compile-time. |
| 188424 | 188476 | ** |
| 188425 | 188477 | ** For best performance, an attempt is made to guess at the byte-order |
| | @@ -225640,11 +225692,11 @@ |
| 225640 | 225692 | int nArg, /* Number of args */ |
| 225641 | 225693 | sqlite3_value **apUnused /* Function arguments */ |
| 225642 | 225694 | ){ |
| 225643 | 225695 | assert( nArg==0 ); |
| 225644 | 225696 | UNUSED_PARAM2(nArg, apUnused); |
| 225645 | | - sqlite3_result_text(pCtx, "fts5: 2020-07-30 17:37:49 96e3dba2ed3ab0c5b2ecf65a3408633e0767c884d48c270e9ef10ab9fa3ec051", -1, SQLITE_TRANSIENT); |
| 225697 | + sqlite3_result_text(pCtx, "fts5: 2020-08-07 19:52:01 fdc5fb902d7f2d10f73e64fe30c67153b59b26c5d707fc9c354e90967dbcc214", -1, SQLITE_TRANSIENT); |
| 225646 | 225698 | } |
| 225647 | 225699 | |
| 225648 | 225700 | /* |
| 225649 | 225701 | ** Return true if zName is the extension on one of the shadow tables used |
| 225650 | 225702 | ** by this module. |
| | @@ -230423,12 +230475,12 @@ |
| 230423 | 230475 | } |
| 230424 | 230476 | #endif /* SQLITE_CORE */ |
| 230425 | 230477 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ |
| 230426 | 230478 | |
| 230427 | 230479 | /************** End of stmt.c ************************************************/ |
| 230428 | | -#if __LINE__!=230428 |
| 230480 | +#if __LINE__!=230480 |
| 230429 | 230481 | #undef SQLITE_SOURCE_ID |
| 230430 | | -#define SQLITE_SOURCE_ID "2020-07-30 17:37:49 96e3dba2ed3ab0c5b2ecf65a3408633e0767c884d48c270e9ef10ab9fa3ealt2" |
| 230482 | +#define SQLITE_SOURCE_ID "2020-08-07 19:52:01 fdc5fb902d7f2d10f73e64fe30c67153b59b26c5d707fc9c354e90967dbcalt2" |
| 230431 | 230483 | #endif |
| 230432 | 230484 | /* Return the source-id for this library */ |
| 230433 | 230485 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
| 230434 | 230486 | /************************** End of sqlite3.c ******************************/ |
| 230435 | 230487 | |