Fossil SCM
Update the built-in SQLite to the second 3.8.9 beta.
Commit
47c89f3e7872b0998535b6e7f7efbc16375b5105
Parent
8e9757296ab2539…
2 files changed
+52
-14
+1
-1
+52
-14
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -317,11 +317,11 @@ | ||
| 317 | 317 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 318 | 318 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 319 | 319 | */ |
| 320 | 320 | #define SQLITE_VERSION "3.8.9" |
| 321 | 321 | #define SQLITE_VERSION_NUMBER 3008009 |
| 322 | -#define SQLITE_SOURCE_ID "2015-03-30 23:43:56 395bb3e677a6551b06ba96fc58c393132b93d1e8" | |
| 322 | +#define SQLITE_SOURCE_ID "2015-04-03 20:33:33 4ae9a3acc4eeeb7998769eb856c97c2233476f72" | |
| 323 | 323 | |
| 324 | 324 | /* |
| 325 | 325 | ** CAPI3REF: Run-Time Library Version Numbers |
| 326 | 326 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 327 | 327 | ** |
| @@ -29147,11 +29147,11 @@ | ||
| 29147 | 29147 | */ |
| 29148 | 29148 | static int unixFileControl(sqlite3_file *id, int op, void *pArg){ |
| 29149 | 29149 | unixFile *pFile = (unixFile*)id; |
| 29150 | 29150 | switch( op ){ |
| 29151 | 29151 | case SQLITE_FCNTL_WAL_BLOCK: { |
| 29152 | - pFile->ctrlFlags |= UNIXFILE_BLOCK; | |
| 29152 | + /* pFile->ctrlFlags |= UNIXFILE_BLOCK; // Deferred feature */ | |
| 29153 | 29153 | return SQLITE_OK; |
| 29154 | 29154 | } |
| 29155 | 29155 | case SQLITE_FCNTL_LOCKSTATE: { |
| 29156 | 29156 | *(int*)pArg = pFile->eFileLock; |
| 29157 | 29157 | return SQLITE_OK; |
| @@ -33323,12 +33323,14 @@ | ||
| 33323 | 33323 | |
| 33324 | 33324 | WINBASEAPI LPVOID WINAPI MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, SIZE_T); |
| 33325 | 33325 | #endif /* SQLITE_OS_WINRT */ |
| 33326 | 33326 | |
| 33327 | 33327 | /* |
| 33328 | -** This file mapping API is common to both Win32 and WinRT. | |
| 33328 | +** These file mapping APIs are common to both Win32 and WinRT. | |
| 33329 | 33329 | */ |
| 33330 | + | |
| 33331 | +WINBASEAPI BOOL WINAPI FlushViewOfFile(LPCVOID, SIZE_T); | |
| 33330 | 33332 | WINBASEAPI BOOL WINAPI UnmapViewOfFile(LPCVOID); |
| 33331 | 33333 | #endif /* SQLITE_WIN32_FILEMAPPING_API */ |
| 33332 | 33334 | |
| 33333 | 33335 | /* |
| 33334 | 33336 | ** Some Microsoft compilers lack this definition. |
| @@ -34209,10 +34211,19 @@ | ||
| 34209 | 34211 | #endif |
| 34210 | 34212 | |
| 34211 | 34213 | #define osUuidCreateSequential \ |
| 34212 | 34214 | ((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[78].pCurrent) |
| 34213 | 34215 | |
| 34216 | +#if !defined(SQLITE_NO_SYNC) && SQLITE_MAX_MMAP_SIZE>0 | |
| 34217 | + { "FlushViewOfFile", (SYSCALL)FlushViewOfFile, 0 }, | |
| 34218 | +#else | |
| 34219 | + { "FlushViewOfFile", (SYSCALL)0, 0 }, | |
| 34220 | +#endif | |
| 34221 | + | |
| 34222 | +#define osFlushViewOfFile \ | |
| 34223 | + ((BOOL(WINAPI*)(LPCVOID,SIZE_T))aSyscall[79].pCurrent) | |
| 34224 | + | |
| 34214 | 34225 | }; /* End of the overrideable system calls */ |
| 34215 | 34226 | |
| 34216 | 34227 | /* |
| 34217 | 34228 | ** This is the xSetSystemCall() method of sqlite3_vfs for all of the |
| 34218 | 34229 | ** "win32" VFSes. Return SQLITE_OK opon successfully updating the |
| @@ -35094,11 +35105,11 @@ | ||
| 35094 | 35105 | /* |
| 35095 | 35106 | ** Log a I/O error retry episode. |
| 35096 | 35107 | */ |
| 35097 | 35108 | static void winLogIoerr(int nRetry, int lineno){ |
| 35098 | 35109 | if( nRetry ){ |
| 35099 | - sqlite3_log(SQLITE_IOERR, | |
| 35110 | + sqlite3_log(SQLITE_NOTICE, | |
| 35100 | 35111 | "delayed %dms for lock/sharing conflict at line %d", |
| 35101 | 35112 | winIoerrRetryDelay*nRetry*(nRetry+1)/2, lineno |
| 35102 | 35113 | ); |
| 35103 | 35114 | } |
| 35104 | 35115 | } |
| @@ -35914,10 +35925,26 @@ | ||
| 35914 | 35925 | #ifdef SQLITE_NO_SYNC |
| 35915 | 35926 | OSTRACE(("SYNC-NOP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n", |
| 35916 | 35927 | osGetCurrentProcessId(), pFile, pFile->h)); |
| 35917 | 35928 | return SQLITE_OK; |
| 35918 | 35929 | #else |
| 35930 | +#if SQLITE_MAX_MMAP_SIZE>0 | |
| 35931 | + if( pFile->pMapRegion ){ | |
| 35932 | + if( osFlushViewOfFile(pFile->pMapRegion, 0) ){ | |
| 35933 | + OSTRACE(("SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, " | |
| 35934 | + "rc=SQLITE_OK\n", osGetCurrentProcessId(), | |
| 35935 | + pFile, pFile->pMapRegion)); | |
| 35936 | + }else{ | |
| 35937 | + pFile->lastErrno = osGetLastError(); | |
| 35938 | + OSTRACE(("SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, " | |
| 35939 | + "rc=SQLITE_IOERR_MMAP\n", osGetCurrentProcessId(), | |
| 35940 | + pFile, pFile->pMapRegion)); | |
| 35941 | + return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno, | |
| 35942 | + "winSync1", pFile->zPath); | |
| 35943 | + } | |
| 35944 | + } | |
| 35945 | +#endif | |
| 35919 | 35946 | rc = osFlushFileBuffers(pFile->h); |
| 35920 | 35947 | SimulateIOError( rc=FALSE ); |
| 35921 | 35948 | if( rc ){ |
| 35922 | 35949 | OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n", |
| 35923 | 35950 | osGetCurrentProcessId(), pFile, pFile->h)); |
| @@ -35925,11 +35952,11 @@ | ||
| 35925 | 35952 | }else{ |
| 35926 | 35953 | pFile->lastErrno = osGetLastError(); |
| 35927 | 35954 | OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_FSYNC\n", |
| 35928 | 35955 | osGetCurrentProcessId(), pFile, pFile->h)); |
| 35929 | 35956 | return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno, |
| 35930 | - "winSync", pFile->zPath); | |
| 35957 | + "winSync2", pFile->zPath); | |
| 35931 | 35958 | } |
| 35932 | 35959 | #endif |
| 35933 | 35960 | } |
| 35934 | 35961 | |
| 35935 | 35962 | /* |
| @@ -38699,11 +38726,11 @@ | ||
| 38699 | 38726 | }; |
| 38700 | 38727 | #endif |
| 38701 | 38728 | |
| 38702 | 38729 | /* Double-check that the aSyscall[] array has been constructed |
| 38703 | 38730 | ** correctly. See ticket [bb3a86e890c8e96ab] */ |
| 38704 | - assert( ArraySize(aSyscall)==79 ); | |
| 38731 | + assert( ArraySize(aSyscall)==80 ); | |
| 38705 | 38732 | |
| 38706 | 38733 | /* get memory map allocation granularity */ |
| 38707 | 38734 | memset(&winSysInfo, 0, sizeof(SYSTEM_INFO)); |
| 38708 | 38735 | #if SQLITE_OS_WINRT |
| 38709 | 38736 | osGetNativeSystemInfo(&winSysInfo); |
| @@ -52246,10 +52273,11 @@ | ||
| 52246 | 52273 | u8 noPayload; /* True if internal intKey page (thus w/o data) */ |
| 52247 | 52274 | u8 leaf; /* True if a leaf page */ |
| 52248 | 52275 | u8 hdrOffset; /* 100 for page 1. 0 otherwise */ |
| 52249 | 52276 | u8 childPtrSize; /* 0 if leaf==1. 4 if leaf==0 */ |
| 52250 | 52277 | u8 max1bytePayload; /* min(maxLocal,127) */ |
| 52278 | + u8 bBusy; /* Prevent endless loops on corrupt database files */ | |
| 52251 | 52279 | u16 maxLocal; /* Copy of BtShared.maxLocal or BtShared.maxLeaf */ |
| 52252 | 52280 | u16 minLocal; /* Copy of BtShared.minLocal or BtShared.minLeaf */ |
| 52253 | 52281 | u16 cellOffset; /* Index in aData of first cell pointer */ |
| 52254 | 52282 | u16 nFree; /* Number of free bytes on the page */ |
| 52255 | 52283 | u16 nCell; /* Number of cells on this page, local and ovfl */ |
| @@ -54894,20 +54922,22 @@ | ||
| 54894 | 54922 | ** If this Btree is a candidate for shared cache, try to find an |
| 54895 | 54923 | ** existing BtShared object that we can share with |
| 54896 | 54924 | */ |
| 54897 | 54925 | if( isTempDb==0 && (isMemdb==0 || (vfsFlags&SQLITE_OPEN_URI)!=0) ){ |
| 54898 | 54926 | if( vfsFlags & SQLITE_OPEN_SHAREDCACHE ){ |
| 54927 | + int nFilename = sqlite3Strlen30(zFilename)+1; | |
| 54899 | 54928 | int nFullPathname = pVfs->mxPathname+1; |
| 54900 | - char *zFullPathname = sqlite3Malloc(nFullPathname); | |
| 54929 | + char *zFullPathname = sqlite3Malloc(MAX(nFullPathname,nFilename)); | |
| 54901 | 54930 | MUTEX_LOGIC( sqlite3_mutex *mutexShared; ) |
| 54931 | + | |
| 54902 | 54932 | p->sharable = 1; |
| 54903 | 54933 | if( !zFullPathname ){ |
| 54904 | 54934 | sqlite3_free(p); |
| 54905 | 54935 | return SQLITE_NOMEM; |
| 54906 | 54936 | } |
| 54907 | 54937 | if( isMemdb ){ |
| 54908 | - memcpy(zFullPathname, zFilename, sqlite3Strlen30(zFilename)+1); | |
| 54938 | + memcpy(zFullPathname, zFilename, nFilename); | |
| 54909 | 54939 | }else{ |
| 54910 | 54940 | rc = sqlite3OsFullPathname(pVfs, zFilename, |
| 54911 | 54941 | nFullPathname, zFullPathname); |
| 54912 | 54942 | if( rc ){ |
| 54913 | 54943 | sqlite3_free(zFullPathname); |
| @@ -60913,32 +60943,33 @@ | ||
| 60913 | 60943 | int rc; |
| 60914 | 60944 | unsigned char *pCell; |
| 60915 | 60945 | int i; |
| 60916 | 60946 | int hdr; |
| 60917 | 60947 | u16 szCell; |
| 60918 | - u8 hasChildren; | |
| 60919 | 60948 | |
| 60920 | 60949 | assert( sqlite3_mutex_held(pBt->mutex) ); |
| 60921 | 60950 | if( pgno>btreePagecount(pBt) ){ |
| 60922 | 60951 | return SQLITE_CORRUPT_BKPT; |
| 60923 | 60952 | } |
| 60924 | - | |
| 60925 | 60953 | rc = getAndInitPage(pBt, pgno, &pPage, 0); |
| 60926 | 60954 | if( rc ) return rc; |
| 60927 | - hasChildren = !pPage->leaf; | |
| 60928 | - pPage->leaf = 1; /* Block looping if the database is corrupt */ | |
| 60955 | + if( pPage->bBusy ){ | |
| 60956 | + rc = SQLITE_CORRUPT_BKPT; | |
| 60957 | + goto cleardatabasepage_out; | |
| 60958 | + } | |
| 60959 | + pPage->bBusy = 1; | |
| 60929 | 60960 | hdr = pPage->hdrOffset; |
| 60930 | 60961 | for(i=0; i<pPage->nCell; i++){ |
| 60931 | 60962 | pCell = findCell(pPage, i); |
| 60932 | - if( hasChildren ){ | |
| 60963 | + if( !pPage->leaf ){ | |
| 60933 | 60964 | rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange); |
| 60934 | 60965 | if( rc ) goto cleardatabasepage_out; |
| 60935 | 60966 | } |
| 60936 | 60967 | rc = clearCell(pPage, pCell, &szCell); |
| 60937 | 60968 | if( rc ) goto cleardatabasepage_out; |
| 60938 | 60969 | } |
| 60939 | - if( hasChildren ){ | |
| 60970 | + if( !pPage->leaf ){ | |
| 60940 | 60971 | rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange); |
| 60941 | 60972 | if( rc ) goto cleardatabasepage_out; |
| 60942 | 60973 | }else if( pnChange ){ |
| 60943 | 60974 | assert( pPage->intKey ); |
| 60944 | 60975 | *pnChange += pPage->nCell; |
| @@ -60948,10 +60979,11 @@ | ||
| 60948 | 60979 | }else if( (rc = sqlite3PagerWrite(pPage->pDbPage))==0 ){ |
| 60949 | 60980 | zeroPage(pPage, pPage->aData[hdr] | PTF_LEAF); |
| 60950 | 60981 | } |
| 60951 | 60982 | |
| 60952 | 60983 | cleardatabasepage_out: |
| 60984 | + pPage->bBusy = 0; | |
| 60953 | 60985 | releasePage(pPage); |
| 60954 | 60986 | return rc; |
| 60955 | 60987 | } |
| 60956 | 60988 | |
| 60957 | 60989 | /* |
| @@ -72561,15 +72593,19 @@ | ||
| 72561 | 72593 | }else if( affinity==SQLITE_AFF_TEXT ){ |
| 72562 | 72594 | if( (pIn1->flags & MEM_Str)==0 && (pIn1->flags & (MEM_Int|MEM_Real))!=0 ){ |
| 72563 | 72595 | testcase( pIn1->flags & MEM_Int ); |
| 72564 | 72596 | testcase( pIn1->flags & MEM_Real ); |
| 72565 | 72597 | sqlite3VdbeMemStringify(pIn1, encoding, 1); |
| 72598 | + testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) ); | |
| 72599 | + flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask); | |
| 72566 | 72600 | } |
| 72567 | 72601 | if( (pIn3->flags & MEM_Str)==0 && (pIn3->flags & (MEM_Int|MEM_Real))!=0 ){ |
| 72568 | 72602 | testcase( pIn3->flags & MEM_Int ); |
| 72569 | 72603 | testcase( pIn3->flags & MEM_Real ); |
| 72570 | 72604 | sqlite3VdbeMemStringify(pIn3, encoding, 1); |
| 72605 | + testcase( (flags3&MEM_Dyn) != (pIn3->flags&MEM_Dyn) ); | |
| 72606 | + flags3 = (pIn3->flags & ~MEM_TypeMask) | (flags3 & MEM_TypeMask); | |
| 72571 | 72607 | } |
| 72572 | 72608 | } |
| 72573 | 72609 | assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 ); |
| 72574 | 72610 | if( pIn1->flags & MEM_Zero ){ |
| 72575 | 72611 | sqlite3VdbeMemExpandBlob(pIn1); |
| @@ -72602,11 +72638,13 @@ | ||
| 72602 | 72638 | if( res ){ |
| 72603 | 72639 | pc = pOp->p2-1; |
| 72604 | 72640 | } |
| 72605 | 72641 | } |
| 72606 | 72642 | /* Undo any changes made by applyAffinity() to the input registers. */ |
| 72643 | + assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) ); | |
| 72607 | 72644 | pIn1->flags = flags1; |
| 72645 | + assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) ); | |
| 72608 | 72646 | pIn3->flags = flags3; |
| 72609 | 72647 | break; |
| 72610 | 72648 | } |
| 72611 | 72649 | |
| 72612 | 72650 | /* Opcode: Permutation * * * P4 * |
| 72613 | 72651 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -317,11 +317,11 @@ | |
| 317 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 318 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 319 | */ |
| 320 | #define SQLITE_VERSION "3.8.9" |
| 321 | #define SQLITE_VERSION_NUMBER 3008009 |
| 322 | #define SQLITE_SOURCE_ID "2015-03-30 23:43:56 395bb3e677a6551b06ba96fc58c393132b93d1e8" |
| 323 | |
| 324 | /* |
| 325 | ** CAPI3REF: Run-Time Library Version Numbers |
| 326 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 327 | ** |
| @@ -29147,11 +29147,11 @@ | |
| 29147 | */ |
| 29148 | static int unixFileControl(sqlite3_file *id, int op, void *pArg){ |
| 29149 | unixFile *pFile = (unixFile*)id; |
| 29150 | switch( op ){ |
| 29151 | case SQLITE_FCNTL_WAL_BLOCK: { |
| 29152 | pFile->ctrlFlags |= UNIXFILE_BLOCK; |
| 29153 | return SQLITE_OK; |
| 29154 | } |
| 29155 | case SQLITE_FCNTL_LOCKSTATE: { |
| 29156 | *(int*)pArg = pFile->eFileLock; |
| 29157 | return SQLITE_OK; |
| @@ -33323,12 +33323,14 @@ | |
| 33323 | |
| 33324 | WINBASEAPI LPVOID WINAPI MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, SIZE_T); |
| 33325 | #endif /* SQLITE_OS_WINRT */ |
| 33326 | |
| 33327 | /* |
| 33328 | ** This file mapping API is common to both Win32 and WinRT. |
| 33329 | */ |
| 33330 | WINBASEAPI BOOL WINAPI UnmapViewOfFile(LPCVOID); |
| 33331 | #endif /* SQLITE_WIN32_FILEMAPPING_API */ |
| 33332 | |
| 33333 | /* |
| 33334 | ** Some Microsoft compilers lack this definition. |
| @@ -34209,10 +34211,19 @@ | |
| 34209 | #endif |
| 34210 | |
| 34211 | #define osUuidCreateSequential \ |
| 34212 | ((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[78].pCurrent) |
| 34213 | |
| 34214 | }; /* End of the overrideable system calls */ |
| 34215 | |
| 34216 | /* |
| 34217 | ** This is the xSetSystemCall() method of sqlite3_vfs for all of the |
| 34218 | ** "win32" VFSes. Return SQLITE_OK opon successfully updating the |
| @@ -35094,11 +35105,11 @@ | |
| 35094 | /* |
| 35095 | ** Log a I/O error retry episode. |
| 35096 | */ |
| 35097 | static void winLogIoerr(int nRetry, int lineno){ |
| 35098 | if( nRetry ){ |
| 35099 | sqlite3_log(SQLITE_IOERR, |
| 35100 | "delayed %dms for lock/sharing conflict at line %d", |
| 35101 | winIoerrRetryDelay*nRetry*(nRetry+1)/2, lineno |
| 35102 | ); |
| 35103 | } |
| 35104 | } |
| @@ -35914,10 +35925,26 @@ | |
| 35914 | #ifdef SQLITE_NO_SYNC |
| 35915 | OSTRACE(("SYNC-NOP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n", |
| 35916 | osGetCurrentProcessId(), pFile, pFile->h)); |
| 35917 | return SQLITE_OK; |
| 35918 | #else |
| 35919 | rc = osFlushFileBuffers(pFile->h); |
| 35920 | SimulateIOError( rc=FALSE ); |
| 35921 | if( rc ){ |
| 35922 | OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n", |
| 35923 | osGetCurrentProcessId(), pFile, pFile->h)); |
| @@ -35925,11 +35952,11 @@ | |
| 35925 | }else{ |
| 35926 | pFile->lastErrno = osGetLastError(); |
| 35927 | OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_FSYNC\n", |
| 35928 | osGetCurrentProcessId(), pFile, pFile->h)); |
| 35929 | return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno, |
| 35930 | "winSync", pFile->zPath); |
| 35931 | } |
| 35932 | #endif |
| 35933 | } |
| 35934 | |
| 35935 | /* |
| @@ -38699,11 +38726,11 @@ | |
| 38699 | }; |
| 38700 | #endif |
| 38701 | |
| 38702 | /* Double-check that the aSyscall[] array has been constructed |
| 38703 | ** correctly. See ticket [bb3a86e890c8e96ab] */ |
| 38704 | assert( ArraySize(aSyscall)==79 ); |
| 38705 | |
| 38706 | /* get memory map allocation granularity */ |
| 38707 | memset(&winSysInfo, 0, sizeof(SYSTEM_INFO)); |
| 38708 | #if SQLITE_OS_WINRT |
| 38709 | osGetNativeSystemInfo(&winSysInfo); |
| @@ -52246,10 +52273,11 @@ | |
| 52246 | u8 noPayload; /* True if internal intKey page (thus w/o data) */ |
| 52247 | u8 leaf; /* True if a leaf page */ |
| 52248 | u8 hdrOffset; /* 100 for page 1. 0 otherwise */ |
| 52249 | u8 childPtrSize; /* 0 if leaf==1. 4 if leaf==0 */ |
| 52250 | u8 max1bytePayload; /* min(maxLocal,127) */ |
| 52251 | u16 maxLocal; /* Copy of BtShared.maxLocal or BtShared.maxLeaf */ |
| 52252 | u16 minLocal; /* Copy of BtShared.minLocal or BtShared.minLeaf */ |
| 52253 | u16 cellOffset; /* Index in aData of first cell pointer */ |
| 52254 | u16 nFree; /* Number of free bytes on the page */ |
| 52255 | u16 nCell; /* Number of cells on this page, local and ovfl */ |
| @@ -54894,20 +54922,22 @@ | |
| 54894 | ** If this Btree is a candidate for shared cache, try to find an |
| 54895 | ** existing BtShared object that we can share with |
| 54896 | */ |
| 54897 | if( isTempDb==0 && (isMemdb==0 || (vfsFlags&SQLITE_OPEN_URI)!=0) ){ |
| 54898 | if( vfsFlags & SQLITE_OPEN_SHAREDCACHE ){ |
| 54899 | int nFullPathname = pVfs->mxPathname+1; |
| 54900 | char *zFullPathname = sqlite3Malloc(nFullPathname); |
| 54901 | MUTEX_LOGIC( sqlite3_mutex *mutexShared; ) |
| 54902 | p->sharable = 1; |
| 54903 | if( !zFullPathname ){ |
| 54904 | sqlite3_free(p); |
| 54905 | return SQLITE_NOMEM; |
| 54906 | } |
| 54907 | if( isMemdb ){ |
| 54908 | memcpy(zFullPathname, zFilename, sqlite3Strlen30(zFilename)+1); |
| 54909 | }else{ |
| 54910 | rc = sqlite3OsFullPathname(pVfs, zFilename, |
| 54911 | nFullPathname, zFullPathname); |
| 54912 | if( rc ){ |
| 54913 | sqlite3_free(zFullPathname); |
| @@ -60913,32 +60943,33 @@ | |
| 60913 | int rc; |
| 60914 | unsigned char *pCell; |
| 60915 | int i; |
| 60916 | int hdr; |
| 60917 | u16 szCell; |
| 60918 | u8 hasChildren; |
| 60919 | |
| 60920 | assert( sqlite3_mutex_held(pBt->mutex) ); |
| 60921 | if( pgno>btreePagecount(pBt) ){ |
| 60922 | return SQLITE_CORRUPT_BKPT; |
| 60923 | } |
| 60924 | |
| 60925 | rc = getAndInitPage(pBt, pgno, &pPage, 0); |
| 60926 | if( rc ) return rc; |
| 60927 | hasChildren = !pPage->leaf; |
| 60928 | pPage->leaf = 1; /* Block looping if the database is corrupt */ |
| 60929 | hdr = pPage->hdrOffset; |
| 60930 | for(i=0; i<pPage->nCell; i++){ |
| 60931 | pCell = findCell(pPage, i); |
| 60932 | if( hasChildren ){ |
| 60933 | rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange); |
| 60934 | if( rc ) goto cleardatabasepage_out; |
| 60935 | } |
| 60936 | rc = clearCell(pPage, pCell, &szCell); |
| 60937 | if( rc ) goto cleardatabasepage_out; |
| 60938 | } |
| 60939 | if( hasChildren ){ |
| 60940 | rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange); |
| 60941 | if( rc ) goto cleardatabasepage_out; |
| 60942 | }else if( pnChange ){ |
| 60943 | assert( pPage->intKey ); |
| 60944 | *pnChange += pPage->nCell; |
| @@ -60948,10 +60979,11 @@ | |
| 60948 | }else if( (rc = sqlite3PagerWrite(pPage->pDbPage))==0 ){ |
| 60949 | zeroPage(pPage, pPage->aData[hdr] | PTF_LEAF); |
| 60950 | } |
| 60951 | |
| 60952 | cleardatabasepage_out: |
| 60953 | releasePage(pPage); |
| 60954 | return rc; |
| 60955 | } |
| 60956 | |
| 60957 | /* |
| @@ -72561,15 +72593,19 @@ | |
| 72561 | }else if( affinity==SQLITE_AFF_TEXT ){ |
| 72562 | if( (pIn1->flags & MEM_Str)==0 && (pIn1->flags & (MEM_Int|MEM_Real))!=0 ){ |
| 72563 | testcase( pIn1->flags & MEM_Int ); |
| 72564 | testcase( pIn1->flags & MEM_Real ); |
| 72565 | sqlite3VdbeMemStringify(pIn1, encoding, 1); |
| 72566 | } |
| 72567 | if( (pIn3->flags & MEM_Str)==0 && (pIn3->flags & (MEM_Int|MEM_Real))!=0 ){ |
| 72568 | testcase( pIn3->flags & MEM_Int ); |
| 72569 | testcase( pIn3->flags & MEM_Real ); |
| 72570 | sqlite3VdbeMemStringify(pIn3, encoding, 1); |
| 72571 | } |
| 72572 | } |
| 72573 | assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 ); |
| 72574 | if( pIn1->flags & MEM_Zero ){ |
| 72575 | sqlite3VdbeMemExpandBlob(pIn1); |
| @@ -72602,11 +72638,13 @@ | |
| 72602 | if( res ){ |
| 72603 | pc = pOp->p2-1; |
| 72604 | } |
| 72605 | } |
| 72606 | /* Undo any changes made by applyAffinity() to the input registers. */ |
| 72607 | pIn1->flags = flags1; |
| 72608 | pIn3->flags = flags3; |
| 72609 | break; |
| 72610 | } |
| 72611 | |
| 72612 | /* Opcode: Permutation * * * P4 * |
| 72613 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -317,11 +317,11 @@ | |
| 317 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 318 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 319 | */ |
| 320 | #define SQLITE_VERSION "3.8.9" |
| 321 | #define SQLITE_VERSION_NUMBER 3008009 |
| 322 | #define SQLITE_SOURCE_ID "2015-04-03 20:33:33 4ae9a3acc4eeeb7998769eb856c97c2233476f72" |
| 323 | |
| 324 | /* |
| 325 | ** CAPI3REF: Run-Time Library Version Numbers |
| 326 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 327 | ** |
| @@ -29147,11 +29147,11 @@ | |
| 29147 | */ |
| 29148 | static int unixFileControl(sqlite3_file *id, int op, void *pArg){ |
| 29149 | unixFile *pFile = (unixFile*)id; |
| 29150 | switch( op ){ |
| 29151 | case SQLITE_FCNTL_WAL_BLOCK: { |
| 29152 | /* pFile->ctrlFlags |= UNIXFILE_BLOCK; // Deferred feature */ |
| 29153 | return SQLITE_OK; |
| 29154 | } |
| 29155 | case SQLITE_FCNTL_LOCKSTATE: { |
| 29156 | *(int*)pArg = pFile->eFileLock; |
| 29157 | return SQLITE_OK; |
| @@ -33323,12 +33323,14 @@ | |
| 33323 | |
| 33324 | WINBASEAPI LPVOID WINAPI MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, SIZE_T); |
| 33325 | #endif /* SQLITE_OS_WINRT */ |
| 33326 | |
| 33327 | /* |
| 33328 | ** These file mapping APIs are common to both Win32 and WinRT. |
| 33329 | */ |
| 33330 | |
| 33331 | WINBASEAPI BOOL WINAPI FlushViewOfFile(LPCVOID, SIZE_T); |
| 33332 | WINBASEAPI BOOL WINAPI UnmapViewOfFile(LPCVOID); |
| 33333 | #endif /* SQLITE_WIN32_FILEMAPPING_API */ |
| 33334 | |
| 33335 | /* |
| 33336 | ** Some Microsoft compilers lack this definition. |
| @@ -34209,10 +34211,19 @@ | |
| 34211 | #endif |
| 34212 | |
| 34213 | #define osUuidCreateSequential \ |
| 34214 | ((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[78].pCurrent) |
| 34215 | |
| 34216 | #if !defined(SQLITE_NO_SYNC) && SQLITE_MAX_MMAP_SIZE>0 |
| 34217 | { "FlushViewOfFile", (SYSCALL)FlushViewOfFile, 0 }, |
| 34218 | #else |
| 34219 | { "FlushViewOfFile", (SYSCALL)0, 0 }, |
| 34220 | #endif |
| 34221 | |
| 34222 | #define osFlushViewOfFile \ |
| 34223 | ((BOOL(WINAPI*)(LPCVOID,SIZE_T))aSyscall[79].pCurrent) |
| 34224 | |
| 34225 | }; /* End of the overrideable system calls */ |
| 34226 | |
| 34227 | /* |
| 34228 | ** This is the xSetSystemCall() method of sqlite3_vfs for all of the |
| 34229 | ** "win32" VFSes. Return SQLITE_OK opon successfully updating the |
| @@ -35094,11 +35105,11 @@ | |
| 35105 | /* |
| 35106 | ** Log a I/O error retry episode. |
| 35107 | */ |
| 35108 | static void winLogIoerr(int nRetry, int lineno){ |
| 35109 | if( nRetry ){ |
| 35110 | sqlite3_log(SQLITE_NOTICE, |
| 35111 | "delayed %dms for lock/sharing conflict at line %d", |
| 35112 | winIoerrRetryDelay*nRetry*(nRetry+1)/2, lineno |
| 35113 | ); |
| 35114 | } |
| 35115 | } |
| @@ -35914,10 +35925,26 @@ | |
| 35925 | #ifdef SQLITE_NO_SYNC |
| 35926 | OSTRACE(("SYNC-NOP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n", |
| 35927 | osGetCurrentProcessId(), pFile, pFile->h)); |
| 35928 | return SQLITE_OK; |
| 35929 | #else |
| 35930 | #if SQLITE_MAX_MMAP_SIZE>0 |
| 35931 | if( pFile->pMapRegion ){ |
| 35932 | if( osFlushViewOfFile(pFile->pMapRegion, 0) ){ |
| 35933 | OSTRACE(("SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, " |
| 35934 | "rc=SQLITE_OK\n", osGetCurrentProcessId(), |
| 35935 | pFile, pFile->pMapRegion)); |
| 35936 | }else{ |
| 35937 | pFile->lastErrno = osGetLastError(); |
| 35938 | OSTRACE(("SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, " |
| 35939 | "rc=SQLITE_IOERR_MMAP\n", osGetCurrentProcessId(), |
| 35940 | pFile, pFile->pMapRegion)); |
| 35941 | return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno, |
| 35942 | "winSync1", pFile->zPath); |
| 35943 | } |
| 35944 | } |
| 35945 | #endif |
| 35946 | rc = osFlushFileBuffers(pFile->h); |
| 35947 | SimulateIOError( rc=FALSE ); |
| 35948 | if( rc ){ |
| 35949 | OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n", |
| 35950 | osGetCurrentProcessId(), pFile, pFile->h)); |
| @@ -35925,11 +35952,11 @@ | |
| 35952 | }else{ |
| 35953 | pFile->lastErrno = osGetLastError(); |
| 35954 | OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_FSYNC\n", |
| 35955 | osGetCurrentProcessId(), pFile, pFile->h)); |
| 35956 | return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno, |
| 35957 | "winSync2", pFile->zPath); |
| 35958 | } |
| 35959 | #endif |
| 35960 | } |
| 35961 | |
| 35962 | /* |
| @@ -38699,11 +38726,11 @@ | |
| 38726 | }; |
| 38727 | #endif |
| 38728 | |
| 38729 | /* Double-check that the aSyscall[] array has been constructed |
| 38730 | ** correctly. See ticket [bb3a86e890c8e96ab] */ |
| 38731 | assert( ArraySize(aSyscall)==80 ); |
| 38732 | |
| 38733 | /* get memory map allocation granularity */ |
| 38734 | memset(&winSysInfo, 0, sizeof(SYSTEM_INFO)); |
| 38735 | #if SQLITE_OS_WINRT |
| 38736 | osGetNativeSystemInfo(&winSysInfo); |
| @@ -52246,10 +52273,11 @@ | |
| 52273 | u8 noPayload; /* True if internal intKey page (thus w/o data) */ |
| 52274 | u8 leaf; /* True if a leaf page */ |
| 52275 | u8 hdrOffset; /* 100 for page 1. 0 otherwise */ |
| 52276 | u8 childPtrSize; /* 0 if leaf==1. 4 if leaf==0 */ |
| 52277 | u8 max1bytePayload; /* min(maxLocal,127) */ |
| 52278 | u8 bBusy; /* Prevent endless loops on corrupt database files */ |
| 52279 | u16 maxLocal; /* Copy of BtShared.maxLocal or BtShared.maxLeaf */ |
| 52280 | u16 minLocal; /* Copy of BtShared.minLocal or BtShared.minLeaf */ |
| 52281 | u16 cellOffset; /* Index in aData of first cell pointer */ |
| 52282 | u16 nFree; /* Number of free bytes on the page */ |
| 52283 | u16 nCell; /* Number of cells on this page, local and ovfl */ |
| @@ -54894,20 +54922,22 @@ | |
| 54922 | ** If this Btree is a candidate for shared cache, try to find an |
| 54923 | ** existing BtShared object that we can share with |
| 54924 | */ |
| 54925 | if( isTempDb==0 && (isMemdb==0 || (vfsFlags&SQLITE_OPEN_URI)!=0) ){ |
| 54926 | if( vfsFlags & SQLITE_OPEN_SHAREDCACHE ){ |
| 54927 | int nFilename = sqlite3Strlen30(zFilename)+1; |
| 54928 | int nFullPathname = pVfs->mxPathname+1; |
| 54929 | char *zFullPathname = sqlite3Malloc(MAX(nFullPathname,nFilename)); |
| 54930 | MUTEX_LOGIC( sqlite3_mutex *mutexShared; ) |
| 54931 | |
| 54932 | p->sharable = 1; |
| 54933 | if( !zFullPathname ){ |
| 54934 | sqlite3_free(p); |
| 54935 | return SQLITE_NOMEM; |
| 54936 | } |
| 54937 | if( isMemdb ){ |
| 54938 | memcpy(zFullPathname, zFilename, nFilename); |
| 54939 | }else{ |
| 54940 | rc = sqlite3OsFullPathname(pVfs, zFilename, |
| 54941 | nFullPathname, zFullPathname); |
| 54942 | if( rc ){ |
| 54943 | sqlite3_free(zFullPathname); |
| @@ -60913,32 +60943,33 @@ | |
| 60943 | int rc; |
| 60944 | unsigned char *pCell; |
| 60945 | int i; |
| 60946 | int hdr; |
| 60947 | u16 szCell; |
| 60948 | |
| 60949 | assert( sqlite3_mutex_held(pBt->mutex) ); |
| 60950 | if( pgno>btreePagecount(pBt) ){ |
| 60951 | return SQLITE_CORRUPT_BKPT; |
| 60952 | } |
| 60953 | rc = getAndInitPage(pBt, pgno, &pPage, 0); |
| 60954 | if( rc ) return rc; |
| 60955 | if( pPage->bBusy ){ |
| 60956 | rc = SQLITE_CORRUPT_BKPT; |
| 60957 | goto cleardatabasepage_out; |
| 60958 | } |
| 60959 | pPage->bBusy = 1; |
| 60960 | hdr = pPage->hdrOffset; |
| 60961 | for(i=0; i<pPage->nCell; i++){ |
| 60962 | pCell = findCell(pPage, i); |
| 60963 | if( !pPage->leaf ){ |
| 60964 | rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange); |
| 60965 | if( rc ) goto cleardatabasepage_out; |
| 60966 | } |
| 60967 | rc = clearCell(pPage, pCell, &szCell); |
| 60968 | if( rc ) goto cleardatabasepage_out; |
| 60969 | } |
| 60970 | if( !pPage->leaf ){ |
| 60971 | rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange); |
| 60972 | if( rc ) goto cleardatabasepage_out; |
| 60973 | }else if( pnChange ){ |
| 60974 | assert( pPage->intKey ); |
| 60975 | *pnChange += pPage->nCell; |
| @@ -60948,10 +60979,11 @@ | |
| 60979 | }else if( (rc = sqlite3PagerWrite(pPage->pDbPage))==0 ){ |
| 60980 | zeroPage(pPage, pPage->aData[hdr] | PTF_LEAF); |
| 60981 | } |
| 60982 | |
| 60983 | cleardatabasepage_out: |
| 60984 | pPage->bBusy = 0; |
| 60985 | releasePage(pPage); |
| 60986 | return rc; |
| 60987 | } |
| 60988 | |
| 60989 | /* |
| @@ -72561,15 +72593,19 @@ | |
| 72593 | }else if( affinity==SQLITE_AFF_TEXT ){ |
| 72594 | if( (pIn1->flags & MEM_Str)==0 && (pIn1->flags & (MEM_Int|MEM_Real))!=0 ){ |
| 72595 | testcase( pIn1->flags & MEM_Int ); |
| 72596 | testcase( pIn1->flags & MEM_Real ); |
| 72597 | sqlite3VdbeMemStringify(pIn1, encoding, 1); |
| 72598 | testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) ); |
| 72599 | flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask); |
| 72600 | } |
| 72601 | if( (pIn3->flags & MEM_Str)==0 && (pIn3->flags & (MEM_Int|MEM_Real))!=0 ){ |
| 72602 | testcase( pIn3->flags & MEM_Int ); |
| 72603 | testcase( pIn3->flags & MEM_Real ); |
| 72604 | sqlite3VdbeMemStringify(pIn3, encoding, 1); |
| 72605 | testcase( (flags3&MEM_Dyn) != (pIn3->flags&MEM_Dyn) ); |
| 72606 | flags3 = (pIn3->flags & ~MEM_TypeMask) | (flags3 & MEM_TypeMask); |
| 72607 | } |
| 72608 | } |
| 72609 | assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 ); |
| 72610 | if( pIn1->flags & MEM_Zero ){ |
| 72611 | sqlite3VdbeMemExpandBlob(pIn1); |
| @@ -72602,11 +72638,13 @@ | |
| 72638 | if( res ){ |
| 72639 | pc = pOp->p2-1; |
| 72640 | } |
| 72641 | } |
| 72642 | /* Undo any changes made by applyAffinity() to the input registers. */ |
| 72643 | assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) ); |
| 72644 | pIn1->flags = flags1; |
| 72645 | assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) ); |
| 72646 | pIn3->flags = flags3; |
| 72647 | break; |
| 72648 | } |
| 72649 | |
| 72650 | /* Opcode: Permutation * * * P4 * |
| 72651 |
+1
-1
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -111,11 +111,11 @@ | ||
| 111 | 111 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 112 | 112 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 113 | 113 | */ |
| 114 | 114 | #define SQLITE_VERSION "3.8.9" |
| 115 | 115 | #define SQLITE_VERSION_NUMBER 3008009 |
| 116 | -#define SQLITE_SOURCE_ID "2015-03-30 23:43:56 395bb3e677a6551b06ba96fc58c393132b93d1e8" | |
| 116 | +#define SQLITE_SOURCE_ID "2015-04-03 20:33:33 4ae9a3acc4eeeb7998769eb856c97c2233476f72" | |
| 117 | 117 | |
| 118 | 118 | /* |
| 119 | 119 | ** CAPI3REF: Run-Time Library Version Numbers |
| 120 | 120 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 121 | 121 | ** |
| 122 | 122 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -111,11 +111,11 @@ | |
| 111 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 112 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 113 | */ |
| 114 | #define SQLITE_VERSION "3.8.9" |
| 115 | #define SQLITE_VERSION_NUMBER 3008009 |
| 116 | #define SQLITE_SOURCE_ID "2015-03-30 23:43:56 395bb3e677a6551b06ba96fc58c393132b93d1e8" |
| 117 | |
| 118 | /* |
| 119 | ** CAPI3REF: Run-Time Library Version Numbers |
| 120 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 121 | ** |
| 122 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -111,11 +111,11 @@ | |
| 111 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 112 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 113 | */ |
| 114 | #define SQLITE_VERSION "3.8.9" |
| 115 | #define SQLITE_VERSION_NUMBER 3008009 |
| 116 | #define SQLITE_SOURCE_ID "2015-04-03 20:33:33 4ae9a3acc4eeeb7998769eb856c97c2233476f72" |
| 117 | |
| 118 | /* |
| 119 | ** CAPI3REF: Run-Time Library Version Numbers |
| 120 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 121 | ** |
| 122 |