Fossil SCM
Update the built-in SQLite with the InterlockedCompareExchange fix for Win64.
Commit
d600c9f85421c0972231561560cb8410589c9606
Parent
78fdf9f5b2fa1f1…
2 files changed
+96
-97
+1
-1
+96
-97
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -222,11 +222,11 @@ | ||
| 222 | 222 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 223 | 223 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 224 | 224 | */ |
| 225 | 225 | #define SQLITE_VERSION "3.8.6" |
| 226 | 226 | #define SQLITE_VERSION_NUMBER 3008006 |
| 227 | -#define SQLITE_SOURCE_ID "2014-08-06 00:29:06 0ad1ed8ef0b5fb5d8db44479373b2b93d8fcfd66" | |
| 227 | +#define SQLITE_SOURCE_ID "2014-08-06 11:58:40 5c6bb57d90bad32785d6d9cdf110a825bbc5ec73" | |
| 228 | 228 | |
| 229 | 229 | /* |
| 230 | 230 | ** CAPI3REF: Run-Time Library Version Numbers |
| 231 | 231 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 232 | 232 | ** |
| @@ -32208,11 +32208,11 @@ | ||
| 32208 | 32208 | |
| 32209 | 32209 | /* |
| 32210 | 32210 | ** Some Microsoft compilers lack this definition. |
| 32211 | 32211 | */ |
| 32212 | 32212 | #ifndef INVALID_FILE_ATTRIBUTES |
| 32213 | -# define INVALID_FILE_ATTRIBUTES ((DWORD)-1) | |
| 32213 | +# define INVALID_FILE_ATTRIBUTES ((DWORD)-1) | |
| 32214 | 32214 | #endif |
| 32215 | 32215 | |
| 32216 | 32216 | #ifndef FILE_FLAG_MASK |
| 32217 | 32217 | # define FILE_FLAG_MASK (0xFF3C0000) |
| 32218 | 32218 | #endif |
| @@ -32258,11 +32258,11 @@ | ||
| 32258 | 32258 | #endif |
| 32259 | 32259 | const char *zPath; /* Full pathname of this file */ |
| 32260 | 32260 | int szChunk; /* Chunk size configured by FCNTL_CHUNK_SIZE */ |
| 32261 | 32261 | #if SQLITE_OS_WINCE |
| 32262 | 32262 | LPWSTR zDeleteOnClose; /* Name of file to delete when closing */ |
| 32263 | - HANDLE hMutex; /* Mutex used to control access to shared lock */ | |
| 32263 | + HANDLE hMutex; /* Mutex used to control access to shared lock */ | |
| 32264 | 32264 | HANDLE hShared; /* Shared memory segment used for locking */ |
| 32265 | 32265 | winceLock local; /* Locks obtained by this instance of winFile */ |
| 32266 | 32266 | winceLock *shared; /* Global shared lock memory for the file */ |
| 32267 | 32267 | #endif |
| 32268 | 32268 | #if SQLITE_MAX_MMAP_SIZE>0 |
| @@ -33051,14 +33051,16 @@ | ||
| 33051 | 33051 | #endif |
| 33052 | 33052 | |
| 33053 | 33053 | #define osCreateFileMappingFromApp ((HANDLE(WINAPI*)(HANDLE, \ |
| 33054 | 33054 | LPSECURITY_ATTRIBUTES,ULONG,ULONG64,LPCWSTR))aSyscall[75].pCurrent) |
| 33055 | 33055 | |
| 33056 | - { "InterlockedCompareExchange", (SYSCALL)InterlockedCompareExchange, 0 }, | |
| 33057 | - | |
| 33058 | -#define osInterlockedCompareExchange ((LONG(WINAPI*)(LONG volatile*, \ | |
| 33059 | - LONG,LONG))aSyscall[76].pCurrent) | |
| 33056 | +/* | |
| 33057 | +** NOTE: On some sub-platforms, the InterlockedCompareExchange "function" | |
| 33058 | +** is really just a macro that uses a compiler intrinsic (e.g. x64). | |
| 33059 | +** So do not try to make this is into a redefinable interface. | |
| 33060 | +*/ | |
| 33061 | +#define osInterlockedCompareExchange InterlockedCompareExchange | |
| 33060 | 33062 | |
| 33061 | 33063 | }; /* End of the overrideable system calls */ |
| 33062 | 33064 | |
| 33063 | 33065 | /* |
| 33064 | 33066 | ** This is the xSetSystemCall() method of sqlite3_vfs for all of the |
| @@ -33536,11 +33538,11 @@ | ||
| 33536 | 33538 | sqlite3_config(SQLITE_CONFIG_MALLOC, sqlite3MemGetWin32()); |
| 33537 | 33539 | } |
| 33538 | 33540 | #endif /* SQLITE_WIN32_MALLOC */ |
| 33539 | 33541 | |
| 33540 | 33542 | /* |
| 33541 | -** Convert a UTF-8 string to Microsoft Unicode (UTF-16?). | |
| 33543 | +** Convert a UTF-8 string to Microsoft Unicode (UTF-16?). | |
| 33542 | 33544 | ** |
| 33543 | 33545 | ** Space to hold the returned string is obtained from malloc. |
| 33544 | 33546 | */ |
| 33545 | 33547 | static LPWSTR winUtf8ToUnicode(const char *zFilename){ |
| 33546 | 33548 | int nChar; |
| @@ -33589,11 +33591,11 @@ | ||
| 33589 | 33591 | } |
| 33590 | 33592 | |
| 33591 | 33593 | /* |
| 33592 | 33594 | ** Convert an ANSI string to Microsoft Unicode, based on the |
| 33593 | 33595 | ** current codepage settings for file apis. |
| 33594 | -** | |
| 33596 | +** | |
| 33595 | 33597 | ** Space to hold the returned string is obtained |
| 33596 | 33598 | ** from sqlite3_malloc. |
| 33597 | 33599 | */ |
| 33598 | 33600 | static LPWSTR winMbcsToUnicode(const char *zFilename){ |
| 33599 | 33601 | int nByte; |
| @@ -33663,11 +33665,11 @@ | ||
| 33663 | 33665 | sqlite3_free(zTmpWide); |
| 33664 | 33666 | return zFilenameUtf8; |
| 33665 | 33667 | } |
| 33666 | 33668 | |
| 33667 | 33669 | /* |
| 33668 | -** Convert UTF-8 to multibyte character string. Space to hold the | |
| 33670 | +** Convert UTF-8 to multibyte character string. Space to hold the | |
| 33669 | 33671 | ** returned string is obtained from sqlite3_malloc(). |
| 33670 | 33672 | */ |
| 33671 | 33673 | SQLITE_API char *sqlite3_win32_utf8_to_mbcs(const char *zFilename){ |
| 33672 | 33674 | char *zFilenameMbcs; |
| 33673 | 33675 | LPWSTR zTmpWide; |
| @@ -33803,15 +33805,15 @@ | ||
| 33803 | 33805 | ** This function - winLogErrorAtLine() - is only ever called via the macro |
| 33804 | 33806 | ** winLogError(). |
| 33805 | 33807 | ** |
| 33806 | 33808 | ** This routine is invoked after an error occurs in an OS function. |
| 33807 | 33809 | ** It logs a message using sqlite3_log() containing the current value of |
| 33808 | -** error code and, if possible, the human-readable equivalent from | |
| 33810 | +** error code and, if possible, the human-readable equivalent from | |
| 33809 | 33811 | ** FormatMessage. |
| 33810 | 33812 | ** |
| 33811 | 33813 | ** The first argument passed to the macro should be the error code that |
| 33812 | -** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN). | |
| 33814 | +** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN). | |
| 33813 | 33815 | ** The two subsequent arguments should be the name of the OS function that |
| 33814 | 33816 | ** failed and the associated file-system path, if any. |
| 33815 | 33817 | */ |
| 33816 | 33818 | #define winLogError(a,b,c,d) winLogErrorAtLine(a,b,c,d,__LINE__) |
| 33817 | 33819 | static int winLogErrorAtLine( |
| @@ -33838,11 +33840,11 @@ | ||
| 33838 | 33840 | return errcode; |
| 33839 | 33841 | } |
| 33840 | 33842 | |
| 33841 | 33843 | /* |
| 33842 | 33844 | ** The number of times that a ReadFile(), WriteFile(), and DeleteFile() |
| 33843 | -** will be retried following a locking error - probably caused by | |
| 33845 | +** will be retried following a locking error - probably caused by | |
| 33844 | 33846 | ** antivirus software. Also the initial delay before the first retry. |
| 33845 | 33847 | ** The delay increases linearly with each retry. |
| 33846 | 33848 | */ |
| 33847 | 33849 | #ifndef SQLITE_WIN32_IOERR_RETRY |
| 33848 | 33850 | # define SQLITE_WIN32_IOERR_RETRY 10 |
| @@ -33913,11 +33915,11 @@ | ||
| 33913 | 33915 | /* |
| 33914 | 33916 | ** Log a I/O error retry episode. |
| 33915 | 33917 | */ |
| 33916 | 33918 | static void winLogIoerr(int nRetry){ |
| 33917 | 33919 | if( nRetry ){ |
| 33918 | - sqlite3_log(SQLITE_IOERR, | |
| 33920 | + sqlite3_log(SQLITE_IOERR, | |
| 33919 | 33921 | "delayed %dms for lock/sharing conflict", |
| 33920 | 33922 | winIoerrRetryDelay*nRetry*(nRetry+1)/2 |
| 33921 | 33923 | ); |
| 33922 | 33924 | } |
| 33923 | 33925 | } |
| @@ -34007,21 +34009,21 @@ | ||
| 34007 | 34009 | "winceCreateLock1", zFilename); |
| 34008 | 34010 | } |
| 34009 | 34011 | |
| 34010 | 34012 | /* Acquire the mutex before continuing */ |
| 34011 | 34013 | winceMutexAcquire(pFile->hMutex); |
| 34012 | - | |
| 34013 | - /* Since the names of named mutexes, semaphores, file mappings etc are | |
| 34014 | + | |
| 34015 | + /* Since the names of named mutexes, semaphores, file mappings etc are | |
| 34014 | 34016 | ** case-sensitive, take advantage of that by uppercasing the mutex name |
| 34015 | 34017 | ** and using that as the shared filemapping name. |
| 34016 | 34018 | */ |
| 34017 | 34019 | osCharUpperW(zName); |
| 34018 | 34020 | pFile->hShared = osCreateFileMappingW(INVALID_HANDLE_VALUE, NULL, |
| 34019 | 34021 | PAGE_READWRITE, 0, sizeof(winceLock), |
| 34020 | - zName); | |
| 34022 | + zName); | |
| 34021 | 34023 | |
| 34022 | - /* Set a flag that indicates we're the first to create the memory so it | |
| 34024 | + /* Set a flag that indicates we're the first to create the memory so it | |
| 34023 | 34025 | ** must be zero-initialized */ |
| 34024 | 34026 | lastErrno = osGetLastError(); |
| 34025 | 34027 | if (lastErrno == ERROR_ALREADY_EXISTS){ |
| 34026 | 34028 | bInit = FALSE; |
| 34027 | 34029 | } |
| @@ -34028,11 +34030,11 @@ | ||
| 34028 | 34030 | |
| 34029 | 34031 | sqlite3_free(zName); |
| 34030 | 34032 | |
| 34031 | 34033 | /* If we succeeded in making the shared memory handle, map it. */ |
| 34032 | 34034 | if( pFile->hShared ){ |
| 34033 | - pFile->shared = (winceLock*)osMapViewOfFile(pFile->hShared, | |
| 34035 | + pFile->shared = (winceLock*)osMapViewOfFile(pFile->hShared, | |
| 34034 | 34036 | FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, sizeof(winceLock)); |
| 34035 | 34037 | /* If mapping failed, close the shared memory handle and erase it */ |
| 34036 | 34038 | if( !pFile->shared ){ |
| 34037 | 34039 | pFile->lastErrno = osGetLastError(); |
| 34038 | 34040 | winLogError(SQLITE_IOERR, pFile->lastErrno, |
| @@ -34054,11 +34056,11 @@ | ||
| 34054 | 34056 | winceMutexRelease(pFile->hMutex); |
| 34055 | 34057 | osCloseHandle(pFile->hMutex); |
| 34056 | 34058 | pFile->hMutex = NULL; |
| 34057 | 34059 | return SQLITE_IOERR; |
| 34058 | 34060 | } |
| 34059 | - | |
| 34061 | + | |
| 34060 | 34062 | /* Initialize the shared memory if we're supposed to */ |
| 34061 | 34063 | if( bInit ){ |
| 34062 | 34064 | memset(pFile->shared, 0, sizeof(winceLock)); |
| 34063 | 34065 | } |
| 34064 | 34066 | |
| @@ -34092,17 +34094,17 @@ | ||
| 34092 | 34094 | /* De-reference and close our copy of the shared memory handle */ |
| 34093 | 34095 | osUnmapViewOfFile(pFile->shared); |
| 34094 | 34096 | osCloseHandle(pFile->hShared); |
| 34095 | 34097 | |
| 34096 | 34098 | /* Done with the mutex */ |
| 34097 | - winceMutexRelease(pFile->hMutex); | |
| 34099 | + winceMutexRelease(pFile->hMutex); | |
| 34098 | 34100 | osCloseHandle(pFile->hMutex); |
| 34099 | 34101 | pFile->hMutex = NULL; |
| 34100 | 34102 | } |
| 34101 | 34103 | } |
| 34102 | 34104 | |
| 34103 | -/* | |
| 34105 | +/* | |
| 34104 | 34106 | ** An implementation of the LockFile() API of Windows for CE |
| 34105 | 34107 | */ |
| 34106 | 34108 | static BOOL winceLockFile( |
| 34107 | 34109 | LPHANDLE phFile, |
| 34108 | 34110 | DWORD dwFileOffsetLow, |
| @@ -34309,12 +34311,12 @@ | ||
| 34309 | 34311 | #ifndef INVALID_SET_FILE_POINTER |
| 34310 | 34312 | # define INVALID_SET_FILE_POINTER ((DWORD)-1) |
| 34311 | 34313 | #endif |
| 34312 | 34314 | |
| 34313 | 34315 | /* |
| 34314 | -** Move the current position of the file handle passed as the first | |
| 34315 | -** argument to offset iOffset within the file. If successful, return 0. | |
| 34316 | +** Move the current position of the file handle passed as the first | |
| 34317 | +** argument to offset iOffset within the file. If successful, return 0. | |
| 34316 | 34318 | ** Otherwise, set pFile->lastErrno and return non-zero. |
| 34317 | 34319 | */ |
| 34318 | 34320 | static int winSeekFile(winFile *pFile, sqlite3_int64 iOffset){ |
| 34319 | 34321 | #if !SQLITE_OS_WINRT |
| 34320 | 34322 | LONG upperBits; /* Most sig. 32 bits of new offset */ |
| @@ -34325,15 +34327,15 @@ | ||
| 34325 | 34327 | OSTRACE(("SEEK file=%p, offset=%lld\n", pFile->h, iOffset)); |
| 34326 | 34328 | |
| 34327 | 34329 | upperBits = (LONG)((iOffset>>32) & 0x7fffffff); |
| 34328 | 34330 | lowerBits = (LONG)(iOffset & 0xffffffff); |
| 34329 | 34331 | |
| 34330 | - /* API oddity: If successful, SetFilePointer() returns a dword | |
| 34332 | + /* API oddity: If successful, SetFilePointer() returns a dword | |
| 34331 | 34333 | ** containing the lower 32-bits of the new file-offset. Or, if it fails, |
| 34332 | - ** it returns INVALID_SET_FILE_POINTER. However according to MSDN, | |
| 34333 | - ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine | |
| 34334 | - ** whether an error has actually occurred, it is also necessary to call | |
| 34334 | + ** it returns INVALID_SET_FILE_POINTER. However according to MSDN, | |
| 34335 | + ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine | |
| 34336 | + ** whether an error has actually occurred, it is also necessary to call | |
| 34335 | 34337 | ** GetLastError(). |
| 34336 | 34338 | */ |
| 34337 | 34339 | dwRet = osSetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN); |
| 34338 | 34340 | |
| 34339 | 34341 | if( (dwRet==INVALID_SET_FILE_POINTER |
| @@ -34412,11 +34414,11 @@ | ||
| 34412 | 34414 | winceDestroyLock(pFile); |
| 34413 | 34415 | if( pFile->zDeleteOnClose ){ |
| 34414 | 34416 | int cnt = 0; |
| 34415 | 34417 | while( |
| 34416 | 34418 | osDeleteFileW(pFile->zDeleteOnClose)==0 |
| 34417 | - && osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff | |
| 34419 | + && osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff | |
| 34418 | 34420 | && cnt++ < WINCE_DELETION_ATTEMPTS |
| 34419 | 34421 | ){ |
| 34420 | 34422 | sqlite3_win32_sleep(100); /* Wait a little before trying again */ |
| 34421 | 34423 | } |
| 34422 | 34424 | sqlite3_free(pFile->zDeleteOnClose); |
| @@ -35260,11 +35262,11 @@ | ||
| 35260 | 35262 | winFile *p = (winFile*)id; |
| 35261 | 35263 | return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN | |
| 35262 | 35264 | ((p->ctrlFlags & WINFILE_PSOW)?SQLITE_IOCAP_POWERSAFE_OVERWRITE:0); |
| 35263 | 35265 | } |
| 35264 | 35266 | |
| 35265 | -/* | |
| 35267 | +/* | |
| 35266 | 35268 | ** Windows will only let you create file view mappings |
| 35267 | 35269 | ** on allocation size granularity boundaries. |
| 35268 | 35270 | ** During sqlite3_os_init() we do a GetSystemInfo() |
| 35269 | 35271 | ** to get the granularity size. |
| 35270 | 35272 | */ |
| @@ -35272,15 +35274,15 @@ | ||
| 35272 | 35274 | |
| 35273 | 35275 | #ifndef SQLITE_OMIT_WAL |
| 35274 | 35276 | |
| 35275 | 35277 | /* |
| 35276 | 35278 | ** Helper functions to obtain and relinquish the global mutex. The |
| 35277 | -** global mutex is used to protect the winLockInfo objects used by | |
| 35279 | +** global mutex is used to protect the winLockInfo objects used by | |
| 35278 | 35280 | ** this file, all of which may be shared by multiple threads. |
| 35279 | 35281 | ** |
| 35280 | -** Function winShmMutexHeld() is used to assert() that the global mutex | |
| 35281 | -** is held when required. This function is only used as part of assert() | |
| 35282 | +** Function winShmMutexHeld() is used to assert() that the global mutex | |
| 35283 | +** is held when required. This function is only used as part of assert() | |
| 35282 | 35284 | ** statements. e.g. |
| 35283 | 35285 | ** |
| 35284 | 35286 | ** winShmEnterMutex() |
| 35285 | 35287 | ** assert( winShmMutexHeld() ); |
| 35286 | 35288 | ** winShmLeaveMutex() |
| @@ -35306,14 +35308,14 @@ | ||
| 35306 | 35308 | ** |
| 35307 | 35309 | ** winShmMutexHeld() must be true when creating or destroying |
| 35308 | 35310 | ** this object or while reading or writing the following fields: |
| 35309 | 35311 | ** |
| 35310 | 35312 | ** nRef |
| 35311 | -** pNext | |
| 35313 | +** pNext | |
| 35312 | 35314 | ** |
| 35313 | 35315 | ** The following fields are read-only after the object is created: |
| 35314 | -** | |
| 35316 | +** | |
| 35315 | 35317 | ** fid |
| 35316 | 35318 | ** zFilename |
| 35317 | 35319 | ** |
| 35318 | 35320 | ** Either winShmNode.mutex must be held or winShmNode.nRef==0 and |
| 35319 | 35321 | ** winShmMutexHeld() is true when reading or writing any other field |
| @@ -35405,11 +35407,11 @@ | ||
| 35405 | 35407 | /* Initialize the locking parameters */ |
| 35406 | 35408 | DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY; |
| 35407 | 35409 | if( lockType == _SHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK; |
| 35408 | 35410 | rc = winLockFile(&pFile->hFile.h, dwFlags, ofst, 0, nByte, 0); |
| 35409 | 35411 | } |
| 35410 | - | |
| 35412 | + | |
| 35411 | 35413 | if( rc!= 0 ){ |
| 35412 | 35414 | rc = SQLITE_OK; |
| 35413 | 35415 | }else{ |
| 35414 | 35416 | pFile->lastErrno = osGetLastError(); |
| 35415 | 35417 | rc = SQLITE_BUSY; |
| @@ -35501,11 +35503,11 @@ | ||
| 35501 | 35503 | sqlite3_free(p); |
| 35502 | 35504 | return SQLITE_IOERR_NOMEM; |
| 35503 | 35505 | } |
| 35504 | 35506 | pNew->zFilename = (char*)&pNew[1]; |
| 35505 | 35507 | sqlite3_snprintf(nName+15, pNew->zFilename, "%s-shm", pDbFd->zPath); |
| 35506 | - sqlite3FileSuffix3(pDbFd->zPath, pNew->zFilename); | |
| 35508 | + sqlite3FileSuffix3(pDbFd->zPath, pNew->zFilename); | |
| 35507 | 35509 | |
| 35508 | 35510 | /* Look to see if there is an existing winShmNode that can be used. |
| 35509 | 35511 | ** If no matching winShmNode currently exists, create a new one. |
| 35510 | 35512 | */ |
| 35511 | 35513 | winShmEnterMutex(); |
| @@ -35538,11 +35540,11 @@ | ||
| 35538 | 35540 | if( SQLITE_OK!=rc ){ |
| 35539 | 35541 | goto shm_open_err; |
| 35540 | 35542 | } |
| 35541 | 35543 | |
| 35542 | 35544 | /* Check to see if another process is holding the dead-man switch. |
| 35543 | - ** If not, truncate the file to zero length. | |
| 35545 | + ** If not, truncate the file to zero length. | |
| 35544 | 35546 | */ |
| 35545 | 35547 | if( winShmSystemLock(pShmNode, _SHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){ |
| 35546 | 35548 | rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0); |
| 35547 | 35549 | if( rc!=SQLITE_OK ){ |
| 35548 | 35550 | rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(), |
| @@ -35567,11 +35569,11 @@ | ||
| 35567 | 35569 | |
| 35568 | 35570 | /* The reference count on pShmNode has already been incremented under |
| 35569 | 35571 | ** the cover of the winShmEnterMutex() mutex and the pointer from the |
| 35570 | 35572 | ** new (struct winShm) object to the pShmNode has been set. All that is |
| 35571 | 35573 | ** left to do is to link the new object into the linked list starting |
| 35572 | - ** at pShmNode->pFirst. This must be done while holding the pShmNode->mutex | |
| 35574 | + ** at pShmNode->pFirst. This must be done while holding the pShmNode->mutex | |
| 35573 | 35575 | ** mutex. |
| 35574 | 35576 | */ |
| 35575 | 35577 | sqlite3_mutex_enter(pShmNode->mutex); |
| 35576 | 35578 | p->pNext = pShmNode->pFirst; |
| 35577 | 35579 | pShmNode->pFirst = p; |
| @@ -35587,11 +35589,11 @@ | ||
| 35587 | 35589 | winShmLeaveMutex(); |
| 35588 | 35590 | return rc; |
| 35589 | 35591 | } |
| 35590 | 35592 | |
| 35591 | 35593 | /* |
| 35592 | -** Close a connection to shared-memory. Delete the underlying | |
| 35594 | +** Close a connection to shared-memory. Delete the underlying | |
| 35593 | 35595 | ** storage if deleteFlag is true. |
| 35594 | 35596 | */ |
| 35595 | 35597 | static int winShmUnmap( |
| 35596 | 35598 | sqlite3_file *fd, /* Database holding shared memory */ |
| 35597 | 35599 | int deleteFlag /* Delete after closing if true */ |
| @@ -35676,11 +35678,11 @@ | ||
| 35676 | 35678 | |
| 35677 | 35679 | /* Undo the local locks */ |
| 35678 | 35680 | if( rc==SQLITE_OK ){ |
| 35679 | 35681 | p->exclMask &= ~mask; |
| 35680 | 35682 | p->sharedMask &= ~mask; |
| 35681 | - } | |
| 35683 | + } | |
| 35682 | 35684 | }else if( flags & SQLITE_SHM_SHARED ){ |
| 35683 | 35685 | u16 allShared = 0; /* Union of locks held by connections other than "p" */ |
| 35684 | 35686 | |
| 35685 | 35687 | /* Find out which shared locks are already held by sibling connections. |
| 35686 | 35688 | ** If any sibling already holds an exclusive lock, go ahead and return |
| @@ -35715,11 +35717,11 @@ | ||
| 35715 | 35717 | if( (pX->exclMask & mask)!=0 || (pX->sharedMask & mask)!=0 ){ |
| 35716 | 35718 | rc = SQLITE_BUSY; |
| 35717 | 35719 | break; |
| 35718 | 35720 | } |
| 35719 | 35721 | } |
| 35720 | - | |
| 35722 | + | |
| 35721 | 35723 | /* Get the exclusive locks at the system level. Then if successful |
| 35722 | 35724 | ** also mark the local connection as being locked. |
| 35723 | 35725 | */ |
| 35724 | 35726 | if( rc==SQLITE_OK ){ |
| 35725 | 35727 | rc = winShmSystemLock(pShmNode, _SHM_WRLCK, ofst+WIN_SHM_BASE, n); |
| @@ -35735,11 +35737,11 @@ | ||
| 35735 | 35737 | sqlite3ErrName(rc))); |
| 35736 | 35738 | return rc; |
| 35737 | 35739 | } |
| 35738 | 35740 | |
| 35739 | 35741 | /* |
| 35740 | -** Implement a memory barrier or memory fence on shared memory. | |
| 35742 | +** Implement a memory barrier or memory fence on shared memory. | |
| 35741 | 35743 | ** |
| 35742 | 35744 | ** All loads and stores begun before the barrier must complete before |
| 35743 | 35745 | ** any load or store begun after the barrier. |
| 35744 | 35746 | */ |
| 35745 | 35747 | static void winShmBarrier( |
| @@ -35750,26 +35752,26 @@ | ||
| 35750 | 35752 | winShmEnterMutex(); |
| 35751 | 35753 | winShmLeaveMutex(); |
| 35752 | 35754 | } |
| 35753 | 35755 | |
| 35754 | 35756 | /* |
| 35755 | -** This function is called to obtain a pointer to region iRegion of the | |
| 35756 | -** shared-memory associated with the database file fd. Shared-memory regions | |
| 35757 | -** are numbered starting from zero. Each shared-memory region is szRegion | |
| 35757 | +** This function is called to obtain a pointer to region iRegion of the | |
| 35758 | +** shared-memory associated with the database file fd. Shared-memory regions | |
| 35759 | +** are numbered starting from zero. Each shared-memory region is szRegion | |
| 35758 | 35760 | ** bytes in size. |
| 35759 | 35761 | ** |
| 35760 | 35762 | ** If an error occurs, an error code is returned and *pp is set to NULL. |
| 35761 | 35763 | ** |
| 35762 | 35764 | ** Otherwise, if the isWrite parameter is 0 and the requested shared-memory |
| 35763 | 35765 | ** region has not been allocated (by any client, including one running in a |
| 35764 | -** separate process), then *pp is set to NULL and SQLITE_OK returned. If | |
| 35765 | -** isWrite is non-zero and the requested shared-memory region has not yet | |
| 35766 | +** separate process), then *pp is set to NULL and SQLITE_OK returned. If | |
| 35767 | +** isWrite is non-zero and the requested shared-memory region has not yet | |
| 35766 | 35768 | ** been allocated, it is allocated by this function. |
| 35767 | 35769 | ** |
| 35768 | 35770 | ** If the shared-memory region has already been allocated or is allocated by |
| 35769 | -** this call as described above, then it is mapped into this processes | |
| 35770 | -** address space (if it is not already), *pp is set to point to the mapped | |
| 35771 | +** this call as described above, then it is mapped into this processes | |
| 35772 | +** address space (if it is not already), *pp is set to point to the mapped | |
| 35771 | 35773 | ** memory and SQLITE_OK returned. |
| 35772 | 35774 | */ |
| 35773 | 35775 | static int winShmMap( |
| 35774 | 35776 | sqlite3_file *fd, /* Handle open on database file */ |
| 35775 | 35777 | int iRegion, /* Region to retrieve */ |
| @@ -35837,21 +35839,21 @@ | ||
| 35837 | 35839 | pShmNode->aRegion = apNew; |
| 35838 | 35840 | |
| 35839 | 35841 | while( pShmNode->nRegion<=iRegion ){ |
| 35840 | 35842 | HANDLE hMap = NULL; /* file-mapping handle */ |
| 35841 | 35843 | void *pMap = 0; /* Mapped memory region */ |
| 35842 | - | |
| 35844 | + | |
| 35843 | 35845 | #if SQLITE_OS_WINRT |
| 35844 | 35846 | hMap = osCreateFileMappingFromApp(pShmNode->hFile.h, |
| 35845 | 35847 | NULL, PAGE_READWRITE, nByte, NULL |
| 35846 | 35848 | ); |
| 35847 | 35849 | #elif defined(SQLITE_WIN32_HAS_WIDE) |
| 35848 | - hMap = osCreateFileMappingW(pShmNode->hFile.h, | |
| 35850 | + hMap = osCreateFileMappingW(pShmNode->hFile.h, | |
| 35849 | 35851 | NULL, PAGE_READWRITE, 0, nByte, NULL |
| 35850 | 35852 | ); |
| 35851 | 35853 | #elif defined(SQLITE_WIN32_HAS_ANSI) |
| 35852 | - hMap = osCreateFileMappingA(pShmNode->hFile.h, | |
| 35854 | + hMap = osCreateFileMappingA(pShmNode->hFile.h, | |
| 35853 | 35855 | NULL, PAGE_READWRITE, 0, nByte, NULL |
| 35854 | 35856 | ); |
| 35855 | 35857 | #endif |
| 35856 | 35858 | OSTRACE(("SHM-MAP-CREATE pid=%lu, region=%d, size=%d, rc=%s\n", |
| 35857 | 35859 | osGetCurrentProcessId(), pShmNode->nRegion, nByte, |
| @@ -35944,18 +35946,18 @@ | ||
| 35944 | 35946 | return SQLITE_OK; |
| 35945 | 35947 | } |
| 35946 | 35948 | |
| 35947 | 35949 | /* |
| 35948 | 35950 | ** Memory map or remap the file opened by file-descriptor pFd (if the file |
| 35949 | -** is already mapped, the existing mapping is replaced by the new). Or, if | |
| 35950 | -** there already exists a mapping for this file, and there are still | |
| 35951 | +** is already mapped, the existing mapping is replaced by the new). Or, if | |
| 35952 | +** there already exists a mapping for this file, and there are still | |
| 35951 | 35953 | ** outstanding xFetch() references to it, this function is a no-op. |
| 35952 | 35954 | ** |
| 35953 | -** If parameter nByte is non-negative, then it is the requested size of | |
| 35954 | -** the mapping to create. Otherwise, if nByte is less than zero, then the | |
| 35955 | +** If parameter nByte is non-negative, then it is the requested size of | |
| 35956 | +** the mapping to create. Otherwise, if nByte is less than zero, then the | |
| 35955 | 35957 | ** requested size is the size of the file on disk. The actual size of the |
| 35956 | -** created mapping is either the requested size or the value configured | |
| 35958 | +** created mapping is either the requested size or the value configured | |
| 35957 | 35959 | ** using SQLITE_FCNTL_MMAP_SIZE, whichever is smaller. |
| 35958 | 35960 | ** |
| 35959 | 35961 | ** SQLITE_OK is returned if no error occurs (even if the mapping is not |
| 35960 | 35962 | ** recreated as a result of outstanding references) or an SQLite error |
| 35961 | 35963 | ** code otherwise. |
| @@ -35980,11 +35982,11 @@ | ||
| 35980 | 35982 | } |
| 35981 | 35983 | if( nMap>pFd->mmapSizeMax ){ |
| 35982 | 35984 | nMap = pFd->mmapSizeMax; |
| 35983 | 35985 | } |
| 35984 | 35986 | nMap &= ~(sqlite3_int64)(winSysInfo.dwPageSize - 1); |
| 35985 | - | |
| 35987 | + | |
| 35986 | 35988 | if( nMap==0 && pFd->mmapSize>0 ){ |
| 35987 | 35989 | winUnmapfile(pFd); |
| 35988 | 35990 | } |
| 35989 | 35991 | if( nMap!=pFd->mmapSize ){ |
| 35990 | 35992 | void *pNew = 0; |
| @@ -36052,11 +36054,11 @@ | ||
| 36052 | 36054 | ** If such a pointer can be obtained, store it in *pp and return SQLITE_OK. |
| 36053 | 36055 | ** Or, if one cannot but no error occurs, set *pp to 0 and return SQLITE_OK. |
| 36054 | 36056 | ** Finally, if an error does occur, return an SQLite error code. The final |
| 36055 | 36057 | ** value of *pp is undefined in this case. |
| 36056 | 36058 | ** |
| 36057 | -** If this function does return a pointer, the caller must eventually | |
| 36059 | +** If this function does return a pointer, the caller must eventually | |
| 36058 | 36060 | ** release the reference by calling winUnfetch(). |
| 36059 | 36061 | */ |
| 36060 | 36062 | static int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){ |
| 36061 | 36063 | #if SQLITE_MAX_MMAP_SIZE>0 |
| 36062 | 36064 | winFile *pFd = (winFile*)fd; /* The underlying database file */ |
| @@ -36087,24 +36089,24 @@ | ||
| 36087 | 36089 | osGetCurrentProcessId(), fd, pp, *pp)); |
| 36088 | 36090 | return SQLITE_OK; |
| 36089 | 36091 | } |
| 36090 | 36092 | |
| 36091 | 36093 | /* |
| 36092 | -** If the third argument is non-NULL, then this function releases a | |
| 36094 | +** If the third argument is non-NULL, then this function releases a | |
| 36093 | 36095 | ** reference obtained by an earlier call to winFetch(). The second |
| 36094 | 36096 | ** argument passed to this function must be the same as the corresponding |
| 36095 | -** argument that was passed to the winFetch() invocation. | |
| 36097 | +** argument that was passed to the winFetch() invocation. | |
| 36096 | 36098 | ** |
| 36097 | -** Or, if the third argument is NULL, then this function is being called | |
| 36098 | -** to inform the VFS layer that, according to POSIX, any existing mapping | |
| 36099 | +** Or, if the third argument is NULL, then this function is being called | |
| 36100 | +** to inform the VFS layer that, according to POSIX, any existing mapping | |
| 36099 | 36101 | ** may now be invalid and should be unmapped. |
| 36100 | 36102 | */ |
| 36101 | 36103 | static int winUnfetch(sqlite3_file *fd, i64 iOff, void *p){ |
| 36102 | 36104 | #if SQLITE_MAX_MMAP_SIZE>0 |
| 36103 | 36105 | winFile *pFd = (winFile*)fd; /* The underlying database file */ |
| 36104 | 36106 | |
| 36105 | - /* If p==0 (unmap the entire file) then there must be no outstanding | |
| 36107 | + /* If p==0 (unmap the entire file) then there must be no outstanding | |
| 36106 | 36108 | ** xFetch references. Or, if p!=0 (meaning it is an xFetch reference), |
| 36107 | 36109 | ** then there must be at least one outstanding. */ |
| 36108 | 36110 | assert( (p==0)==(pFd->nFetchOut==0) ); |
| 36109 | 36111 | |
| 36110 | 36112 | /* If p!=0, it must match the iOff value. */ |
| @@ -36246,11 +36248,11 @@ | ||
| 36246 | 36248 | int nMax, nBuf, nDir, nLen; |
| 36247 | 36249 | char *zBuf; |
| 36248 | 36250 | |
| 36249 | 36251 | /* It's odd to simulate an io-error here, but really this is just |
| 36250 | 36252 | ** using the io-error infrastructure to test that SQLite handles this |
| 36251 | - ** function failing. | |
| 36253 | + ** function failing. | |
| 36252 | 36254 | */ |
| 36253 | 36255 | SimulateIOError( return SQLITE_IOERR ); |
| 36254 | 36256 | |
| 36255 | 36257 | /* Allocate a temporary buffer to store the fully qualified file |
| 36256 | 36258 | ** name for the temporary file. If this fails, we cannot continue. |
| @@ -36428,11 +36430,11 @@ | ||
| 36428 | 36430 | OSTRACE(("TEMP-FILENAME rc=SQLITE_ERROR\n")); |
| 36429 | 36431 | return winLogError(SQLITE_ERROR, 0, "winGetTempname4", 0); |
| 36430 | 36432 | } |
| 36431 | 36433 | |
| 36432 | 36434 | /* |
| 36433 | - ** Check that the output buffer is large enough for the temporary file | |
| 36435 | + ** Check that the output buffer is large enough for the temporary file | |
| 36434 | 36436 | ** name in the following format: |
| 36435 | 36437 | ** |
| 36436 | 36438 | ** "<temporary_directory>/etilqs_XXXXXXXXXXXXXXX\0\0" |
| 36437 | 36439 | ** |
| 36438 | 36440 | ** If not, return SQLITE_ERROR. The number 17 is used here in order to |
| @@ -36531,42 +36533,42 @@ | ||
| 36531 | 36533 | int isReadonly = (flags & SQLITE_OPEN_READONLY); |
| 36532 | 36534 | int isReadWrite = (flags & SQLITE_OPEN_READWRITE); |
| 36533 | 36535 | |
| 36534 | 36536 | #ifndef NDEBUG |
| 36535 | 36537 | int isOpenJournal = (isCreate && ( |
| 36536 | - eType==SQLITE_OPEN_MASTER_JOURNAL | |
| 36537 | - || eType==SQLITE_OPEN_MAIN_JOURNAL | |
| 36538 | + eType==SQLITE_OPEN_MASTER_JOURNAL | |
| 36539 | + || eType==SQLITE_OPEN_MAIN_JOURNAL | |
| 36538 | 36540 | || eType==SQLITE_OPEN_WAL |
| 36539 | 36541 | )); |
| 36540 | 36542 | #endif |
| 36541 | 36543 | |
| 36542 | 36544 | OSTRACE(("OPEN name=%s, pFile=%p, flags=%x, pOutFlags=%p\n", |
| 36543 | 36545 | zUtf8Name, id, flags, pOutFlags)); |
| 36544 | 36546 | |
| 36545 | - /* Check the following statements are true: | |
| 36547 | + /* Check the following statements are true: | |
| 36546 | 36548 | ** |
| 36547 | - ** (a) Exactly one of the READWRITE and READONLY flags must be set, and | |
| 36549 | + ** (a) Exactly one of the READWRITE and READONLY flags must be set, and | |
| 36548 | 36550 | ** (b) if CREATE is set, then READWRITE must also be set, and |
| 36549 | 36551 | ** (c) if EXCLUSIVE is set, then CREATE must also be set. |
| 36550 | 36552 | ** (d) if DELETEONCLOSE is set, then CREATE must also be set. |
| 36551 | 36553 | */ |
| 36552 | 36554 | assert((isReadonly==0 || isReadWrite==0) && (isReadWrite || isReadonly)); |
| 36553 | 36555 | assert(isCreate==0 || isReadWrite); |
| 36554 | 36556 | assert(isExclusive==0 || isCreate); |
| 36555 | 36557 | assert(isDelete==0 || isCreate); |
| 36556 | 36558 | |
| 36557 | - /* The main DB, main journal, WAL file and master journal are never | |
| 36559 | + /* The main DB, main journal, WAL file and master journal are never | |
| 36558 | 36560 | ** automatically deleted. Nor are they ever temporary files. */ |
| 36559 | 36561 | assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_DB ); |
| 36560 | 36562 | assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_JOURNAL ); |
| 36561 | 36563 | assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MASTER_JOURNAL ); |
| 36562 | 36564 | assert( (!isDelete && zName) || eType!=SQLITE_OPEN_WAL ); |
| 36563 | 36565 | |
| 36564 | 36566 | /* Assert that the upper layer has set one of the "file-type" flags. */ |
| 36565 | - assert( eType==SQLITE_OPEN_MAIN_DB || eType==SQLITE_OPEN_TEMP_DB | |
| 36566 | - || eType==SQLITE_OPEN_MAIN_JOURNAL || eType==SQLITE_OPEN_TEMP_JOURNAL | |
| 36567 | - || eType==SQLITE_OPEN_SUBJOURNAL || eType==SQLITE_OPEN_MASTER_JOURNAL | |
| 36567 | + assert( eType==SQLITE_OPEN_MAIN_DB || eType==SQLITE_OPEN_TEMP_DB | |
| 36568 | + || eType==SQLITE_OPEN_MAIN_JOURNAL || eType==SQLITE_OPEN_TEMP_JOURNAL | |
| 36569 | + || eType==SQLITE_OPEN_SUBJOURNAL || eType==SQLITE_OPEN_MASTER_JOURNAL | |
| 36568 | 36570 | || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL |
| 36569 | 36571 | ); |
| 36570 | 36572 | |
| 36571 | 36573 | assert( pFile!=0 ); |
| 36572 | 36574 | memset(pFile, 0, sizeof(winFile)); |
| @@ -36577,12 +36579,12 @@ | ||
| 36577 | 36579 | sqlite3_log(SQLITE_ERROR, |
| 36578 | 36580 | "sqlite3_temp_directory variable should be set for WinRT"); |
| 36579 | 36581 | } |
| 36580 | 36582 | #endif |
| 36581 | 36583 | |
| 36582 | - /* If the second argument to this function is NULL, generate a | |
| 36583 | - ** temporary file name to use | |
| 36584 | + /* If the second argument to this function is NULL, generate a | |
| 36585 | + ** temporary file name to use | |
| 36584 | 36586 | */ |
| 36585 | 36587 | if( !zUtf8Name ){ |
| 36586 | 36588 | assert( isDelete && !isOpenJournal ); |
| 36587 | 36589 | rc = winGetTempname(pVfs, &zTmpname); |
| 36588 | 36590 | if( rc!=SQLITE_OK ){ |
| @@ -36618,12 +36620,12 @@ | ||
| 36618 | 36620 | dwDesiredAccess = GENERIC_READ | GENERIC_WRITE; |
| 36619 | 36621 | }else{ |
| 36620 | 36622 | dwDesiredAccess = GENERIC_READ; |
| 36621 | 36623 | } |
| 36622 | 36624 | |
| 36623 | - /* SQLITE_OPEN_EXCLUSIVE is used to make sure that a new file is | |
| 36624 | - ** created. SQLite doesn't use it to indicate "exclusive access" | |
| 36625 | + /* SQLITE_OPEN_EXCLUSIVE is used to make sure that a new file is | |
| 36626 | + ** created. SQLite doesn't use it to indicate "exclusive access" | |
| 36625 | 36627 | ** as it is usually understood. |
| 36626 | 36628 | */ |
| 36627 | 36629 | if( isExclusive ){ |
| 36628 | 36630 | /* Creates a new file, only if it does not already exist. */ |
| 36629 | 36631 | /* If the file exists, it fails. */ |
| @@ -36708,11 +36710,11 @@ | ||
| 36708 | 36710 | pFile->lastErrno = lastErrno; |
| 36709 | 36711 | winLogError(SQLITE_CANTOPEN, pFile->lastErrno, "winOpen", zUtf8Name); |
| 36710 | 36712 | sqlite3_free(zConverted); |
| 36711 | 36713 | sqlite3_free(zTmpname); |
| 36712 | 36714 | if( isReadWrite && !isExclusive ){ |
| 36713 | - return winOpen(pVfs, zName, id, | |
| 36715 | + return winOpen(pVfs, zName, id, | |
| 36714 | 36716 | ((flags|SQLITE_OPEN_READONLY) & |
| 36715 | 36717 | ~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE)), |
| 36716 | 36718 | pOutFlags); |
| 36717 | 36719 | }else{ |
| 36718 | 36720 | return SQLITE_CANTOPEN_BKPT; |
| @@ -36917,18 +36919,18 @@ | ||
| 36917 | 36919 | if( osIsNT() ){ |
| 36918 | 36920 | int cnt = 0; |
| 36919 | 36921 | WIN32_FILE_ATTRIBUTE_DATA sAttrData; |
| 36920 | 36922 | memset(&sAttrData, 0, sizeof(sAttrData)); |
| 36921 | 36923 | while( !(rc = osGetFileAttributesExW((LPCWSTR)zConverted, |
| 36922 | - GetFileExInfoStandard, | |
| 36924 | + GetFileExInfoStandard, | |
| 36923 | 36925 | &sAttrData)) && winRetryIoerr(&cnt, &lastErrno) ){} |
| 36924 | 36926 | if( rc ){ |
| 36925 | 36927 | /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file |
| 36926 | 36928 | ** as if it does not exist. |
| 36927 | 36929 | */ |
| 36928 | 36930 | if( flags==SQLITE_ACCESS_EXISTS |
| 36929 | - && sAttrData.nFileSizeHigh==0 | |
| 36931 | + && sAttrData.nFileSizeHigh==0 | |
| 36930 | 36932 | && sAttrData.nFileSizeLow==0 ){ |
| 36931 | 36933 | attr = INVALID_FILE_ATTRIBUTES; |
| 36932 | 36934 | }else{ |
| 36933 | 36935 | attr = sAttrData.dwFileAttributes; |
| 36934 | 36936 | } |
| @@ -37023,11 +37025,11 @@ | ||
| 37023 | 37025 | sqlite3_vfs *pVfs, /* Pointer to vfs object */ |
| 37024 | 37026 | const char *zRelative, /* Possibly relative input path */ |
| 37025 | 37027 | int nFull, /* Size of output buffer in bytes */ |
| 37026 | 37028 | char *zFull /* Output buffer */ |
| 37027 | 37029 | ){ |
| 37028 | - | |
| 37030 | + | |
| 37029 | 37031 | #if defined(__CYGWIN__) |
| 37030 | 37032 | SimulateIOError( return SQLITE_ERROR ); |
| 37031 | 37033 | UNUSED_PARAMETER(nFull); |
| 37032 | 37034 | assert( nFull>=pVfs->mxPathname ); |
| 37033 | 37035 | if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ |
| @@ -37336,24 +37338,24 @@ | ||
| 37336 | 37338 | ** the current time and date as a Julian Day number times 86_400_000. In |
| 37337 | 37339 | ** other words, write into *piNow the number of milliseconds since the Julian |
| 37338 | 37340 | ** epoch of noon in Greenwich on November 24, 4714 B.C according to the |
| 37339 | 37341 | ** proleptic Gregorian calendar. |
| 37340 | 37342 | ** |
| 37341 | -** On success, return SQLITE_OK. Return SQLITE_ERROR if the time and date | |
| 37343 | +** On success, return SQLITE_OK. Return SQLITE_ERROR if the time and date | |
| 37342 | 37344 | ** cannot be found. |
| 37343 | 37345 | */ |
| 37344 | 37346 | static int winCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *piNow){ |
| 37345 | - /* FILETIME structure is a 64-bit value representing the number of | |
| 37346 | - 100-nanosecond intervals since January 1, 1601 (= JD 2305813.5). | |
| 37347 | + /* FILETIME structure is a 64-bit value representing the number of | |
| 37348 | + 100-nanosecond intervals since January 1, 1601 (= JD 2305813.5). | |
| 37347 | 37349 | */ |
| 37348 | 37350 | FILETIME ft; |
| 37349 | 37351 | static const sqlite3_int64 winFiletimeEpoch = 23058135*(sqlite3_int64)8640000; |
| 37350 | 37352 | #ifdef SQLITE_TEST |
| 37351 | 37353 | static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000; |
| 37352 | 37354 | #endif |
| 37353 | 37355 | /* 2^32 - to avoid use of LL and warnings in gcc */ |
| 37354 | - static const sqlite3_int64 max32BitValue = | |
| 37356 | + static const sqlite3_int64 max32BitValue = | |
| 37355 | 37357 | (sqlite3_int64)2000000000 + (sqlite3_int64)2000000000 + |
| 37356 | 37358 | (sqlite3_int64)294967296; |
| 37357 | 37359 | |
| 37358 | 37360 | #if SQLITE_OS_WINCE |
| 37359 | 37361 | SYSTEMTIME time; |
| @@ -37365,11 +37367,11 @@ | ||
| 37365 | 37367 | #else |
| 37366 | 37368 | osGetSystemTimeAsFileTime( &ft ); |
| 37367 | 37369 | #endif |
| 37368 | 37370 | |
| 37369 | 37371 | *piNow = winFiletimeEpoch + |
| 37370 | - ((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) + | |
| 37372 | + ((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) + | |
| 37371 | 37373 | (sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)10000; |
| 37372 | 37374 | |
| 37373 | 37375 | #ifdef SQLITE_TEST |
| 37374 | 37376 | if( sqlite3_current_time ){ |
| 37375 | 37377 | *piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch; |
| @@ -37484,11 +37486,11 @@ | ||
| 37484 | 37486 | }; |
| 37485 | 37487 | #endif |
| 37486 | 37488 | |
| 37487 | 37489 | /* Double-check that the aSyscall[] array has been constructed |
| 37488 | 37490 | ** correctly. See ticket [bb3a86e890c8e96ab] */ |
| 37489 | - assert( ArraySize(aSyscall)==77 ); | |
| 37491 | + assert( ArraySize(aSyscall)==76 ); | |
| 37490 | 37492 | |
| 37491 | 37493 | /* get memory map allocation granularity */ |
| 37492 | 37494 | memset(&winSysInfo, 0, sizeof(SYSTEM_INFO)); |
| 37493 | 37495 | #if SQLITE_OS_WINRT |
| 37494 | 37496 | osGetNativeSystemInfo(&winSysInfo); |
| @@ -37502,14 +37504,14 @@ | ||
| 37502 | 37504 | |
| 37503 | 37505 | #if defined(SQLITE_WIN32_HAS_WIDE) |
| 37504 | 37506 | sqlite3_vfs_register(&winLongPathVfs, 0); |
| 37505 | 37507 | #endif |
| 37506 | 37508 | |
| 37507 | - return SQLITE_OK; | |
| 37509 | + return SQLITE_OK; | |
| 37508 | 37510 | } |
| 37509 | 37511 | |
| 37510 | -SQLITE_API int sqlite3_os_end(void){ | |
| 37512 | +SQLITE_API int sqlite3_os_end(void){ | |
| 37511 | 37513 | #if SQLITE_OS_WINRT |
| 37512 | 37514 | if( sleepObj!=NULL ){ |
| 37513 | 37515 | osCloseHandle(sleepObj); |
| 37514 | 37516 | sleepObj = NULL; |
| 37515 | 37517 | } |
| @@ -91665,16 +91667,13 @@ | ||
| 91665 | 91667 | ** May you do good and not evil. |
| 91666 | 91668 | ** May you find forgiveness for yourself and forgive others. |
| 91667 | 91669 | ** May you share freely, never taking more than you give. |
| 91668 | 91670 | ** |
| 91669 | 91671 | ************************************************************************* |
| 91670 | -** This file contains the C functions that implement various SQL | |
| 91671 | -** functions of SQLite. | |
| 91672 | -** | |
| 91673 | -** There is only one exported symbol in this file - the function | |
| 91674 | -** sqliteRegisterBuildinFunctions() found at the bottom of the file. | |
| 91675 | -** All other code has file scope. | |
| 91672 | +** This file contains the C-language implementions for many of the SQL | |
| 91673 | +** functions of SQLite. (Some function, and in particular the date and | |
| 91674 | +** time functions, are implemented separately.) | |
| 91676 | 91675 | */ |
| 91677 | 91676 | /* #include <stdlib.h> */ |
| 91678 | 91677 | /* #include <assert.h> */ |
| 91679 | 91678 | |
| 91680 | 91679 | /* |
| 91681 | 91680 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -222,11 +222,11 @@ | |
| 222 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 223 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 224 | */ |
| 225 | #define SQLITE_VERSION "3.8.6" |
| 226 | #define SQLITE_VERSION_NUMBER 3008006 |
| 227 | #define SQLITE_SOURCE_ID "2014-08-06 00:29:06 0ad1ed8ef0b5fb5d8db44479373b2b93d8fcfd66" |
| 228 | |
| 229 | /* |
| 230 | ** CAPI3REF: Run-Time Library Version Numbers |
| 231 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 232 | ** |
| @@ -32208,11 +32208,11 @@ | |
| 32208 | |
| 32209 | /* |
| 32210 | ** Some Microsoft compilers lack this definition. |
| 32211 | */ |
| 32212 | #ifndef INVALID_FILE_ATTRIBUTES |
| 32213 | # define INVALID_FILE_ATTRIBUTES ((DWORD)-1) |
| 32214 | #endif |
| 32215 | |
| 32216 | #ifndef FILE_FLAG_MASK |
| 32217 | # define FILE_FLAG_MASK (0xFF3C0000) |
| 32218 | #endif |
| @@ -32258,11 +32258,11 @@ | |
| 32258 | #endif |
| 32259 | const char *zPath; /* Full pathname of this file */ |
| 32260 | int szChunk; /* Chunk size configured by FCNTL_CHUNK_SIZE */ |
| 32261 | #if SQLITE_OS_WINCE |
| 32262 | LPWSTR zDeleteOnClose; /* Name of file to delete when closing */ |
| 32263 | HANDLE hMutex; /* Mutex used to control access to shared lock */ |
| 32264 | HANDLE hShared; /* Shared memory segment used for locking */ |
| 32265 | winceLock local; /* Locks obtained by this instance of winFile */ |
| 32266 | winceLock *shared; /* Global shared lock memory for the file */ |
| 32267 | #endif |
| 32268 | #if SQLITE_MAX_MMAP_SIZE>0 |
| @@ -33051,14 +33051,16 @@ | |
| 33051 | #endif |
| 33052 | |
| 33053 | #define osCreateFileMappingFromApp ((HANDLE(WINAPI*)(HANDLE, \ |
| 33054 | LPSECURITY_ATTRIBUTES,ULONG,ULONG64,LPCWSTR))aSyscall[75].pCurrent) |
| 33055 | |
| 33056 | { "InterlockedCompareExchange", (SYSCALL)InterlockedCompareExchange, 0 }, |
| 33057 | |
| 33058 | #define osInterlockedCompareExchange ((LONG(WINAPI*)(LONG volatile*, \ |
| 33059 | LONG,LONG))aSyscall[76].pCurrent) |
| 33060 | |
| 33061 | }; /* End of the overrideable system calls */ |
| 33062 | |
| 33063 | /* |
| 33064 | ** This is the xSetSystemCall() method of sqlite3_vfs for all of the |
| @@ -33536,11 +33538,11 @@ | |
| 33536 | sqlite3_config(SQLITE_CONFIG_MALLOC, sqlite3MemGetWin32()); |
| 33537 | } |
| 33538 | #endif /* SQLITE_WIN32_MALLOC */ |
| 33539 | |
| 33540 | /* |
| 33541 | ** Convert a UTF-8 string to Microsoft Unicode (UTF-16?). |
| 33542 | ** |
| 33543 | ** Space to hold the returned string is obtained from malloc. |
| 33544 | */ |
| 33545 | static LPWSTR winUtf8ToUnicode(const char *zFilename){ |
| 33546 | int nChar; |
| @@ -33589,11 +33591,11 @@ | |
| 33589 | } |
| 33590 | |
| 33591 | /* |
| 33592 | ** Convert an ANSI string to Microsoft Unicode, based on the |
| 33593 | ** current codepage settings for file apis. |
| 33594 | ** |
| 33595 | ** Space to hold the returned string is obtained |
| 33596 | ** from sqlite3_malloc. |
| 33597 | */ |
| 33598 | static LPWSTR winMbcsToUnicode(const char *zFilename){ |
| 33599 | int nByte; |
| @@ -33663,11 +33665,11 @@ | |
| 33663 | sqlite3_free(zTmpWide); |
| 33664 | return zFilenameUtf8; |
| 33665 | } |
| 33666 | |
| 33667 | /* |
| 33668 | ** Convert UTF-8 to multibyte character string. Space to hold the |
| 33669 | ** returned string is obtained from sqlite3_malloc(). |
| 33670 | */ |
| 33671 | SQLITE_API char *sqlite3_win32_utf8_to_mbcs(const char *zFilename){ |
| 33672 | char *zFilenameMbcs; |
| 33673 | LPWSTR zTmpWide; |
| @@ -33803,15 +33805,15 @@ | |
| 33803 | ** This function - winLogErrorAtLine() - is only ever called via the macro |
| 33804 | ** winLogError(). |
| 33805 | ** |
| 33806 | ** This routine is invoked after an error occurs in an OS function. |
| 33807 | ** It logs a message using sqlite3_log() containing the current value of |
| 33808 | ** error code and, if possible, the human-readable equivalent from |
| 33809 | ** FormatMessage. |
| 33810 | ** |
| 33811 | ** The first argument passed to the macro should be the error code that |
| 33812 | ** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN). |
| 33813 | ** The two subsequent arguments should be the name of the OS function that |
| 33814 | ** failed and the associated file-system path, if any. |
| 33815 | */ |
| 33816 | #define winLogError(a,b,c,d) winLogErrorAtLine(a,b,c,d,__LINE__) |
| 33817 | static int winLogErrorAtLine( |
| @@ -33838,11 +33840,11 @@ | |
| 33838 | return errcode; |
| 33839 | } |
| 33840 | |
| 33841 | /* |
| 33842 | ** The number of times that a ReadFile(), WriteFile(), and DeleteFile() |
| 33843 | ** will be retried following a locking error - probably caused by |
| 33844 | ** antivirus software. Also the initial delay before the first retry. |
| 33845 | ** The delay increases linearly with each retry. |
| 33846 | */ |
| 33847 | #ifndef SQLITE_WIN32_IOERR_RETRY |
| 33848 | # define SQLITE_WIN32_IOERR_RETRY 10 |
| @@ -33913,11 +33915,11 @@ | |
| 33913 | /* |
| 33914 | ** Log a I/O error retry episode. |
| 33915 | */ |
| 33916 | static void winLogIoerr(int nRetry){ |
| 33917 | if( nRetry ){ |
| 33918 | sqlite3_log(SQLITE_IOERR, |
| 33919 | "delayed %dms for lock/sharing conflict", |
| 33920 | winIoerrRetryDelay*nRetry*(nRetry+1)/2 |
| 33921 | ); |
| 33922 | } |
| 33923 | } |
| @@ -34007,21 +34009,21 @@ | |
| 34007 | "winceCreateLock1", zFilename); |
| 34008 | } |
| 34009 | |
| 34010 | /* Acquire the mutex before continuing */ |
| 34011 | winceMutexAcquire(pFile->hMutex); |
| 34012 | |
| 34013 | /* Since the names of named mutexes, semaphores, file mappings etc are |
| 34014 | ** case-sensitive, take advantage of that by uppercasing the mutex name |
| 34015 | ** and using that as the shared filemapping name. |
| 34016 | */ |
| 34017 | osCharUpperW(zName); |
| 34018 | pFile->hShared = osCreateFileMappingW(INVALID_HANDLE_VALUE, NULL, |
| 34019 | PAGE_READWRITE, 0, sizeof(winceLock), |
| 34020 | zName); |
| 34021 | |
| 34022 | /* Set a flag that indicates we're the first to create the memory so it |
| 34023 | ** must be zero-initialized */ |
| 34024 | lastErrno = osGetLastError(); |
| 34025 | if (lastErrno == ERROR_ALREADY_EXISTS){ |
| 34026 | bInit = FALSE; |
| 34027 | } |
| @@ -34028,11 +34030,11 @@ | |
| 34028 | |
| 34029 | sqlite3_free(zName); |
| 34030 | |
| 34031 | /* If we succeeded in making the shared memory handle, map it. */ |
| 34032 | if( pFile->hShared ){ |
| 34033 | pFile->shared = (winceLock*)osMapViewOfFile(pFile->hShared, |
| 34034 | FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, sizeof(winceLock)); |
| 34035 | /* If mapping failed, close the shared memory handle and erase it */ |
| 34036 | if( !pFile->shared ){ |
| 34037 | pFile->lastErrno = osGetLastError(); |
| 34038 | winLogError(SQLITE_IOERR, pFile->lastErrno, |
| @@ -34054,11 +34056,11 @@ | |
| 34054 | winceMutexRelease(pFile->hMutex); |
| 34055 | osCloseHandle(pFile->hMutex); |
| 34056 | pFile->hMutex = NULL; |
| 34057 | return SQLITE_IOERR; |
| 34058 | } |
| 34059 | |
| 34060 | /* Initialize the shared memory if we're supposed to */ |
| 34061 | if( bInit ){ |
| 34062 | memset(pFile->shared, 0, sizeof(winceLock)); |
| 34063 | } |
| 34064 | |
| @@ -34092,17 +34094,17 @@ | |
| 34092 | /* De-reference and close our copy of the shared memory handle */ |
| 34093 | osUnmapViewOfFile(pFile->shared); |
| 34094 | osCloseHandle(pFile->hShared); |
| 34095 | |
| 34096 | /* Done with the mutex */ |
| 34097 | winceMutexRelease(pFile->hMutex); |
| 34098 | osCloseHandle(pFile->hMutex); |
| 34099 | pFile->hMutex = NULL; |
| 34100 | } |
| 34101 | } |
| 34102 | |
| 34103 | /* |
| 34104 | ** An implementation of the LockFile() API of Windows for CE |
| 34105 | */ |
| 34106 | static BOOL winceLockFile( |
| 34107 | LPHANDLE phFile, |
| 34108 | DWORD dwFileOffsetLow, |
| @@ -34309,12 +34311,12 @@ | |
| 34309 | #ifndef INVALID_SET_FILE_POINTER |
| 34310 | # define INVALID_SET_FILE_POINTER ((DWORD)-1) |
| 34311 | #endif |
| 34312 | |
| 34313 | /* |
| 34314 | ** Move the current position of the file handle passed as the first |
| 34315 | ** argument to offset iOffset within the file. If successful, return 0. |
| 34316 | ** Otherwise, set pFile->lastErrno and return non-zero. |
| 34317 | */ |
| 34318 | static int winSeekFile(winFile *pFile, sqlite3_int64 iOffset){ |
| 34319 | #if !SQLITE_OS_WINRT |
| 34320 | LONG upperBits; /* Most sig. 32 bits of new offset */ |
| @@ -34325,15 +34327,15 @@ | |
| 34325 | OSTRACE(("SEEK file=%p, offset=%lld\n", pFile->h, iOffset)); |
| 34326 | |
| 34327 | upperBits = (LONG)((iOffset>>32) & 0x7fffffff); |
| 34328 | lowerBits = (LONG)(iOffset & 0xffffffff); |
| 34329 | |
| 34330 | /* API oddity: If successful, SetFilePointer() returns a dword |
| 34331 | ** containing the lower 32-bits of the new file-offset. Or, if it fails, |
| 34332 | ** it returns INVALID_SET_FILE_POINTER. However according to MSDN, |
| 34333 | ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine |
| 34334 | ** whether an error has actually occurred, it is also necessary to call |
| 34335 | ** GetLastError(). |
| 34336 | */ |
| 34337 | dwRet = osSetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN); |
| 34338 | |
| 34339 | if( (dwRet==INVALID_SET_FILE_POINTER |
| @@ -34412,11 +34414,11 @@ | |
| 34412 | winceDestroyLock(pFile); |
| 34413 | if( pFile->zDeleteOnClose ){ |
| 34414 | int cnt = 0; |
| 34415 | while( |
| 34416 | osDeleteFileW(pFile->zDeleteOnClose)==0 |
| 34417 | && osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff |
| 34418 | && cnt++ < WINCE_DELETION_ATTEMPTS |
| 34419 | ){ |
| 34420 | sqlite3_win32_sleep(100); /* Wait a little before trying again */ |
| 34421 | } |
| 34422 | sqlite3_free(pFile->zDeleteOnClose); |
| @@ -35260,11 +35262,11 @@ | |
| 35260 | winFile *p = (winFile*)id; |
| 35261 | return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN | |
| 35262 | ((p->ctrlFlags & WINFILE_PSOW)?SQLITE_IOCAP_POWERSAFE_OVERWRITE:0); |
| 35263 | } |
| 35264 | |
| 35265 | /* |
| 35266 | ** Windows will only let you create file view mappings |
| 35267 | ** on allocation size granularity boundaries. |
| 35268 | ** During sqlite3_os_init() we do a GetSystemInfo() |
| 35269 | ** to get the granularity size. |
| 35270 | */ |
| @@ -35272,15 +35274,15 @@ | |
| 35272 | |
| 35273 | #ifndef SQLITE_OMIT_WAL |
| 35274 | |
| 35275 | /* |
| 35276 | ** Helper functions to obtain and relinquish the global mutex. The |
| 35277 | ** global mutex is used to protect the winLockInfo objects used by |
| 35278 | ** this file, all of which may be shared by multiple threads. |
| 35279 | ** |
| 35280 | ** Function winShmMutexHeld() is used to assert() that the global mutex |
| 35281 | ** is held when required. This function is only used as part of assert() |
| 35282 | ** statements. e.g. |
| 35283 | ** |
| 35284 | ** winShmEnterMutex() |
| 35285 | ** assert( winShmMutexHeld() ); |
| 35286 | ** winShmLeaveMutex() |
| @@ -35306,14 +35308,14 @@ | |
| 35306 | ** |
| 35307 | ** winShmMutexHeld() must be true when creating or destroying |
| 35308 | ** this object or while reading or writing the following fields: |
| 35309 | ** |
| 35310 | ** nRef |
| 35311 | ** pNext |
| 35312 | ** |
| 35313 | ** The following fields are read-only after the object is created: |
| 35314 | ** |
| 35315 | ** fid |
| 35316 | ** zFilename |
| 35317 | ** |
| 35318 | ** Either winShmNode.mutex must be held or winShmNode.nRef==0 and |
| 35319 | ** winShmMutexHeld() is true when reading or writing any other field |
| @@ -35405,11 +35407,11 @@ | |
| 35405 | /* Initialize the locking parameters */ |
| 35406 | DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY; |
| 35407 | if( lockType == _SHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK; |
| 35408 | rc = winLockFile(&pFile->hFile.h, dwFlags, ofst, 0, nByte, 0); |
| 35409 | } |
| 35410 | |
| 35411 | if( rc!= 0 ){ |
| 35412 | rc = SQLITE_OK; |
| 35413 | }else{ |
| 35414 | pFile->lastErrno = osGetLastError(); |
| 35415 | rc = SQLITE_BUSY; |
| @@ -35501,11 +35503,11 @@ | |
| 35501 | sqlite3_free(p); |
| 35502 | return SQLITE_IOERR_NOMEM; |
| 35503 | } |
| 35504 | pNew->zFilename = (char*)&pNew[1]; |
| 35505 | sqlite3_snprintf(nName+15, pNew->zFilename, "%s-shm", pDbFd->zPath); |
| 35506 | sqlite3FileSuffix3(pDbFd->zPath, pNew->zFilename); |
| 35507 | |
| 35508 | /* Look to see if there is an existing winShmNode that can be used. |
| 35509 | ** If no matching winShmNode currently exists, create a new one. |
| 35510 | */ |
| 35511 | winShmEnterMutex(); |
| @@ -35538,11 +35540,11 @@ | |
| 35538 | if( SQLITE_OK!=rc ){ |
| 35539 | goto shm_open_err; |
| 35540 | } |
| 35541 | |
| 35542 | /* Check to see if another process is holding the dead-man switch. |
| 35543 | ** If not, truncate the file to zero length. |
| 35544 | */ |
| 35545 | if( winShmSystemLock(pShmNode, _SHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){ |
| 35546 | rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0); |
| 35547 | if( rc!=SQLITE_OK ){ |
| 35548 | rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(), |
| @@ -35567,11 +35569,11 @@ | |
| 35567 | |
| 35568 | /* The reference count on pShmNode has already been incremented under |
| 35569 | ** the cover of the winShmEnterMutex() mutex and the pointer from the |
| 35570 | ** new (struct winShm) object to the pShmNode has been set. All that is |
| 35571 | ** left to do is to link the new object into the linked list starting |
| 35572 | ** at pShmNode->pFirst. This must be done while holding the pShmNode->mutex |
| 35573 | ** mutex. |
| 35574 | */ |
| 35575 | sqlite3_mutex_enter(pShmNode->mutex); |
| 35576 | p->pNext = pShmNode->pFirst; |
| 35577 | pShmNode->pFirst = p; |
| @@ -35587,11 +35589,11 @@ | |
| 35587 | winShmLeaveMutex(); |
| 35588 | return rc; |
| 35589 | } |
| 35590 | |
| 35591 | /* |
| 35592 | ** Close a connection to shared-memory. Delete the underlying |
| 35593 | ** storage if deleteFlag is true. |
| 35594 | */ |
| 35595 | static int winShmUnmap( |
| 35596 | sqlite3_file *fd, /* Database holding shared memory */ |
| 35597 | int deleteFlag /* Delete after closing if true */ |
| @@ -35676,11 +35678,11 @@ | |
| 35676 | |
| 35677 | /* Undo the local locks */ |
| 35678 | if( rc==SQLITE_OK ){ |
| 35679 | p->exclMask &= ~mask; |
| 35680 | p->sharedMask &= ~mask; |
| 35681 | } |
| 35682 | }else if( flags & SQLITE_SHM_SHARED ){ |
| 35683 | u16 allShared = 0; /* Union of locks held by connections other than "p" */ |
| 35684 | |
| 35685 | /* Find out which shared locks are already held by sibling connections. |
| 35686 | ** If any sibling already holds an exclusive lock, go ahead and return |
| @@ -35715,11 +35717,11 @@ | |
| 35715 | if( (pX->exclMask & mask)!=0 || (pX->sharedMask & mask)!=0 ){ |
| 35716 | rc = SQLITE_BUSY; |
| 35717 | break; |
| 35718 | } |
| 35719 | } |
| 35720 | |
| 35721 | /* Get the exclusive locks at the system level. Then if successful |
| 35722 | ** also mark the local connection as being locked. |
| 35723 | */ |
| 35724 | if( rc==SQLITE_OK ){ |
| 35725 | rc = winShmSystemLock(pShmNode, _SHM_WRLCK, ofst+WIN_SHM_BASE, n); |
| @@ -35735,11 +35737,11 @@ | |
| 35735 | sqlite3ErrName(rc))); |
| 35736 | return rc; |
| 35737 | } |
| 35738 | |
| 35739 | /* |
| 35740 | ** Implement a memory barrier or memory fence on shared memory. |
| 35741 | ** |
| 35742 | ** All loads and stores begun before the barrier must complete before |
| 35743 | ** any load or store begun after the barrier. |
| 35744 | */ |
| 35745 | static void winShmBarrier( |
| @@ -35750,26 +35752,26 @@ | |
| 35750 | winShmEnterMutex(); |
| 35751 | winShmLeaveMutex(); |
| 35752 | } |
| 35753 | |
| 35754 | /* |
| 35755 | ** This function is called to obtain a pointer to region iRegion of the |
| 35756 | ** shared-memory associated with the database file fd. Shared-memory regions |
| 35757 | ** are numbered starting from zero. Each shared-memory region is szRegion |
| 35758 | ** bytes in size. |
| 35759 | ** |
| 35760 | ** If an error occurs, an error code is returned and *pp is set to NULL. |
| 35761 | ** |
| 35762 | ** Otherwise, if the isWrite parameter is 0 and the requested shared-memory |
| 35763 | ** region has not been allocated (by any client, including one running in a |
| 35764 | ** separate process), then *pp is set to NULL and SQLITE_OK returned. If |
| 35765 | ** isWrite is non-zero and the requested shared-memory region has not yet |
| 35766 | ** been allocated, it is allocated by this function. |
| 35767 | ** |
| 35768 | ** If the shared-memory region has already been allocated or is allocated by |
| 35769 | ** this call as described above, then it is mapped into this processes |
| 35770 | ** address space (if it is not already), *pp is set to point to the mapped |
| 35771 | ** memory and SQLITE_OK returned. |
| 35772 | */ |
| 35773 | static int winShmMap( |
| 35774 | sqlite3_file *fd, /* Handle open on database file */ |
| 35775 | int iRegion, /* Region to retrieve */ |
| @@ -35837,21 +35839,21 @@ | |
| 35837 | pShmNode->aRegion = apNew; |
| 35838 | |
| 35839 | while( pShmNode->nRegion<=iRegion ){ |
| 35840 | HANDLE hMap = NULL; /* file-mapping handle */ |
| 35841 | void *pMap = 0; /* Mapped memory region */ |
| 35842 | |
| 35843 | #if SQLITE_OS_WINRT |
| 35844 | hMap = osCreateFileMappingFromApp(pShmNode->hFile.h, |
| 35845 | NULL, PAGE_READWRITE, nByte, NULL |
| 35846 | ); |
| 35847 | #elif defined(SQLITE_WIN32_HAS_WIDE) |
| 35848 | hMap = osCreateFileMappingW(pShmNode->hFile.h, |
| 35849 | NULL, PAGE_READWRITE, 0, nByte, NULL |
| 35850 | ); |
| 35851 | #elif defined(SQLITE_WIN32_HAS_ANSI) |
| 35852 | hMap = osCreateFileMappingA(pShmNode->hFile.h, |
| 35853 | NULL, PAGE_READWRITE, 0, nByte, NULL |
| 35854 | ); |
| 35855 | #endif |
| 35856 | OSTRACE(("SHM-MAP-CREATE pid=%lu, region=%d, size=%d, rc=%s\n", |
| 35857 | osGetCurrentProcessId(), pShmNode->nRegion, nByte, |
| @@ -35944,18 +35946,18 @@ | |
| 35944 | return SQLITE_OK; |
| 35945 | } |
| 35946 | |
| 35947 | /* |
| 35948 | ** Memory map or remap the file opened by file-descriptor pFd (if the file |
| 35949 | ** is already mapped, the existing mapping is replaced by the new). Or, if |
| 35950 | ** there already exists a mapping for this file, and there are still |
| 35951 | ** outstanding xFetch() references to it, this function is a no-op. |
| 35952 | ** |
| 35953 | ** If parameter nByte is non-negative, then it is the requested size of |
| 35954 | ** the mapping to create. Otherwise, if nByte is less than zero, then the |
| 35955 | ** requested size is the size of the file on disk. The actual size of the |
| 35956 | ** created mapping is either the requested size or the value configured |
| 35957 | ** using SQLITE_FCNTL_MMAP_SIZE, whichever is smaller. |
| 35958 | ** |
| 35959 | ** SQLITE_OK is returned if no error occurs (even if the mapping is not |
| 35960 | ** recreated as a result of outstanding references) or an SQLite error |
| 35961 | ** code otherwise. |
| @@ -35980,11 +35982,11 @@ | |
| 35980 | } |
| 35981 | if( nMap>pFd->mmapSizeMax ){ |
| 35982 | nMap = pFd->mmapSizeMax; |
| 35983 | } |
| 35984 | nMap &= ~(sqlite3_int64)(winSysInfo.dwPageSize - 1); |
| 35985 | |
| 35986 | if( nMap==0 && pFd->mmapSize>0 ){ |
| 35987 | winUnmapfile(pFd); |
| 35988 | } |
| 35989 | if( nMap!=pFd->mmapSize ){ |
| 35990 | void *pNew = 0; |
| @@ -36052,11 +36054,11 @@ | |
| 36052 | ** If such a pointer can be obtained, store it in *pp and return SQLITE_OK. |
| 36053 | ** Or, if one cannot but no error occurs, set *pp to 0 and return SQLITE_OK. |
| 36054 | ** Finally, if an error does occur, return an SQLite error code. The final |
| 36055 | ** value of *pp is undefined in this case. |
| 36056 | ** |
| 36057 | ** If this function does return a pointer, the caller must eventually |
| 36058 | ** release the reference by calling winUnfetch(). |
| 36059 | */ |
| 36060 | static int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){ |
| 36061 | #if SQLITE_MAX_MMAP_SIZE>0 |
| 36062 | winFile *pFd = (winFile*)fd; /* The underlying database file */ |
| @@ -36087,24 +36089,24 @@ | |
| 36087 | osGetCurrentProcessId(), fd, pp, *pp)); |
| 36088 | return SQLITE_OK; |
| 36089 | } |
| 36090 | |
| 36091 | /* |
| 36092 | ** If the third argument is non-NULL, then this function releases a |
| 36093 | ** reference obtained by an earlier call to winFetch(). The second |
| 36094 | ** argument passed to this function must be the same as the corresponding |
| 36095 | ** argument that was passed to the winFetch() invocation. |
| 36096 | ** |
| 36097 | ** Or, if the third argument is NULL, then this function is being called |
| 36098 | ** to inform the VFS layer that, according to POSIX, any existing mapping |
| 36099 | ** may now be invalid and should be unmapped. |
| 36100 | */ |
| 36101 | static int winUnfetch(sqlite3_file *fd, i64 iOff, void *p){ |
| 36102 | #if SQLITE_MAX_MMAP_SIZE>0 |
| 36103 | winFile *pFd = (winFile*)fd; /* The underlying database file */ |
| 36104 | |
| 36105 | /* If p==0 (unmap the entire file) then there must be no outstanding |
| 36106 | ** xFetch references. Or, if p!=0 (meaning it is an xFetch reference), |
| 36107 | ** then there must be at least one outstanding. */ |
| 36108 | assert( (p==0)==(pFd->nFetchOut==0) ); |
| 36109 | |
| 36110 | /* If p!=0, it must match the iOff value. */ |
| @@ -36246,11 +36248,11 @@ | |
| 36246 | int nMax, nBuf, nDir, nLen; |
| 36247 | char *zBuf; |
| 36248 | |
| 36249 | /* It's odd to simulate an io-error here, but really this is just |
| 36250 | ** using the io-error infrastructure to test that SQLite handles this |
| 36251 | ** function failing. |
| 36252 | */ |
| 36253 | SimulateIOError( return SQLITE_IOERR ); |
| 36254 | |
| 36255 | /* Allocate a temporary buffer to store the fully qualified file |
| 36256 | ** name for the temporary file. If this fails, we cannot continue. |
| @@ -36428,11 +36430,11 @@ | |
| 36428 | OSTRACE(("TEMP-FILENAME rc=SQLITE_ERROR\n")); |
| 36429 | return winLogError(SQLITE_ERROR, 0, "winGetTempname4", 0); |
| 36430 | } |
| 36431 | |
| 36432 | /* |
| 36433 | ** Check that the output buffer is large enough for the temporary file |
| 36434 | ** name in the following format: |
| 36435 | ** |
| 36436 | ** "<temporary_directory>/etilqs_XXXXXXXXXXXXXXX\0\0" |
| 36437 | ** |
| 36438 | ** If not, return SQLITE_ERROR. The number 17 is used here in order to |
| @@ -36531,42 +36533,42 @@ | |
| 36531 | int isReadonly = (flags & SQLITE_OPEN_READONLY); |
| 36532 | int isReadWrite = (flags & SQLITE_OPEN_READWRITE); |
| 36533 | |
| 36534 | #ifndef NDEBUG |
| 36535 | int isOpenJournal = (isCreate && ( |
| 36536 | eType==SQLITE_OPEN_MASTER_JOURNAL |
| 36537 | || eType==SQLITE_OPEN_MAIN_JOURNAL |
| 36538 | || eType==SQLITE_OPEN_WAL |
| 36539 | )); |
| 36540 | #endif |
| 36541 | |
| 36542 | OSTRACE(("OPEN name=%s, pFile=%p, flags=%x, pOutFlags=%p\n", |
| 36543 | zUtf8Name, id, flags, pOutFlags)); |
| 36544 | |
| 36545 | /* Check the following statements are true: |
| 36546 | ** |
| 36547 | ** (a) Exactly one of the READWRITE and READONLY flags must be set, and |
| 36548 | ** (b) if CREATE is set, then READWRITE must also be set, and |
| 36549 | ** (c) if EXCLUSIVE is set, then CREATE must also be set. |
| 36550 | ** (d) if DELETEONCLOSE is set, then CREATE must also be set. |
| 36551 | */ |
| 36552 | assert((isReadonly==0 || isReadWrite==0) && (isReadWrite || isReadonly)); |
| 36553 | assert(isCreate==0 || isReadWrite); |
| 36554 | assert(isExclusive==0 || isCreate); |
| 36555 | assert(isDelete==0 || isCreate); |
| 36556 | |
| 36557 | /* The main DB, main journal, WAL file and master journal are never |
| 36558 | ** automatically deleted. Nor are they ever temporary files. */ |
| 36559 | assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_DB ); |
| 36560 | assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_JOURNAL ); |
| 36561 | assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MASTER_JOURNAL ); |
| 36562 | assert( (!isDelete && zName) || eType!=SQLITE_OPEN_WAL ); |
| 36563 | |
| 36564 | /* Assert that the upper layer has set one of the "file-type" flags. */ |
| 36565 | assert( eType==SQLITE_OPEN_MAIN_DB || eType==SQLITE_OPEN_TEMP_DB |
| 36566 | || eType==SQLITE_OPEN_MAIN_JOURNAL || eType==SQLITE_OPEN_TEMP_JOURNAL |
| 36567 | || eType==SQLITE_OPEN_SUBJOURNAL || eType==SQLITE_OPEN_MASTER_JOURNAL |
| 36568 | || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL |
| 36569 | ); |
| 36570 | |
| 36571 | assert( pFile!=0 ); |
| 36572 | memset(pFile, 0, sizeof(winFile)); |
| @@ -36577,12 +36579,12 @@ | |
| 36577 | sqlite3_log(SQLITE_ERROR, |
| 36578 | "sqlite3_temp_directory variable should be set for WinRT"); |
| 36579 | } |
| 36580 | #endif |
| 36581 | |
| 36582 | /* If the second argument to this function is NULL, generate a |
| 36583 | ** temporary file name to use |
| 36584 | */ |
| 36585 | if( !zUtf8Name ){ |
| 36586 | assert( isDelete && !isOpenJournal ); |
| 36587 | rc = winGetTempname(pVfs, &zTmpname); |
| 36588 | if( rc!=SQLITE_OK ){ |
| @@ -36618,12 +36620,12 @@ | |
| 36618 | dwDesiredAccess = GENERIC_READ | GENERIC_WRITE; |
| 36619 | }else{ |
| 36620 | dwDesiredAccess = GENERIC_READ; |
| 36621 | } |
| 36622 | |
| 36623 | /* SQLITE_OPEN_EXCLUSIVE is used to make sure that a new file is |
| 36624 | ** created. SQLite doesn't use it to indicate "exclusive access" |
| 36625 | ** as it is usually understood. |
| 36626 | */ |
| 36627 | if( isExclusive ){ |
| 36628 | /* Creates a new file, only if it does not already exist. */ |
| 36629 | /* If the file exists, it fails. */ |
| @@ -36708,11 +36710,11 @@ | |
| 36708 | pFile->lastErrno = lastErrno; |
| 36709 | winLogError(SQLITE_CANTOPEN, pFile->lastErrno, "winOpen", zUtf8Name); |
| 36710 | sqlite3_free(zConverted); |
| 36711 | sqlite3_free(zTmpname); |
| 36712 | if( isReadWrite && !isExclusive ){ |
| 36713 | return winOpen(pVfs, zName, id, |
| 36714 | ((flags|SQLITE_OPEN_READONLY) & |
| 36715 | ~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE)), |
| 36716 | pOutFlags); |
| 36717 | }else{ |
| 36718 | return SQLITE_CANTOPEN_BKPT; |
| @@ -36917,18 +36919,18 @@ | |
| 36917 | if( osIsNT() ){ |
| 36918 | int cnt = 0; |
| 36919 | WIN32_FILE_ATTRIBUTE_DATA sAttrData; |
| 36920 | memset(&sAttrData, 0, sizeof(sAttrData)); |
| 36921 | while( !(rc = osGetFileAttributesExW((LPCWSTR)zConverted, |
| 36922 | GetFileExInfoStandard, |
| 36923 | &sAttrData)) && winRetryIoerr(&cnt, &lastErrno) ){} |
| 36924 | if( rc ){ |
| 36925 | /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file |
| 36926 | ** as if it does not exist. |
| 36927 | */ |
| 36928 | if( flags==SQLITE_ACCESS_EXISTS |
| 36929 | && sAttrData.nFileSizeHigh==0 |
| 36930 | && sAttrData.nFileSizeLow==0 ){ |
| 36931 | attr = INVALID_FILE_ATTRIBUTES; |
| 36932 | }else{ |
| 36933 | attr = sAttrData.dwFileAttributes; |
| 36934 | } |
| @@ -37023,11 +37025,11 @@ | |
| 37023 | sqlite3_vfs *pVfs, /* Pointer to vfs object */ |
| 37024 | const char *zRelative, /* Possibly relative input path */ |
| 37025 | int nFull, /* Size of output buffer in bytes */ |
| 37026 | char *zFull /* Output buffer */ |
| 37027 | ){ |
| 37028 | |
| 37029 | #if defined(__CYGWIN__) |
| 37030 | SimulateIOError( return SQLITE_ERROR ); |
| 37031 | UNUSED_PARAMETER(nFull); |
| 37032 | assert( nFull>=pVfs->mxPathname ); |
| 37033 | if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ |
| @@ -37336,24 +37338,24 @@ | |
| 37336 | ** the current time and date as a Julian Day number times 86_400_000. In |
| 37337 | ** other words, write into *piNow the number of milliseconds since the Julian |
| 37338 | ** epoch of noon in Greenwich on November 24, 4714 B.C according to the |
| 37339 | ** proleptic Gregorian calendar. |
| 37340 | ** |
| 37341 | ** On success, return SQLITE_OK. Return SQLITE_ERROR if the time and date |
| 37342 | ** cannot be found. |
| 37343 | */ |
| 37344 | static int winCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *piNow){ |
| 37345 | /* FILETIME structure is a 64-bit value representing the number of |
| 37346 | 100-nanosecond intervals since January 1, 1601 (= JD 2305813.5). |
| 37347 | */ |
| 37348 | FILETIME ft; |
| 37349 | static const sqlite3_int64 winFiletimeEpoch = 23058135*(sqlite3_int64)8640000; |
| 37350 | #ifdef SQLITE_TEST |
| 37351 | static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000; |
| 37352 | #endif |
| 37353 | /* 2^32 - to avoid use of LL and warnings in gcc */ |
| 37354 | static const sqlite3_int64 max32BitValue = |
| 37355 | (sqlite3_int64)2000000000 + (sqlite3_int64)2000000000 + |
| 37356 | (sqlite3_int64)294967296; |
| 37357 | |
| 37358 | #if SQLITE_OS_WINCE |
| 37359 | SYSTEMTIME time; |
| @@ -37365,11 +37367,11 @@ | |
| 37365 | #else |
| 37366 | osGetSystemTimeAsFileTime( &ft ); |
| 37367 | #endif |
| 37368 | |
| 37369 | *piNow = winFiletimeEpoch + |
| 37370 | ((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) + |
| 37371 | (sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)10000; |
| 37372 | |
| 37373 | #ifdef SQLITE_TEST |
| 37374 | if( sqlite3_current_time ){ |
| 37375 | *piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch; |
| @@ -37484,11 +37486,11 @@ | |
| 37484 | }; |
| 37485 | #endif |
| 37486 | |
| 37487 | /* Double-check that the aSyscall[] array has been constructed |
| 37488 | ** correctly. See ticket [bb3a86e890c8e96ab] */ |
| 37489 | assert( ArraySize(aSyscall)==77 ); |
| 37490 | |
| 37491 | /* get memory map allocation granularity */ |
| 37492 | memset(&winSysInfo, 0, sizeof(SYSTEM_INFO)); |
| 37493 | #if SQLITE_OS_WINRT |
| 37494 | osGetNativeSystemInfo(&winSysInfo); |
| @@ -37502,14 +37504,14 @@ | |
| 37502 | |
| 37503 | #if defined(SQLITE_WIN32_HAS_WIDE) |
| 37504 | sqlite3_vfs_register(&winLongPathVfs, 0); |
| 37505 | #endif |
| 37506 | |
| 37507 | return SQLITE_OK; |
| 37508 | } |
| 37509 | |
| 37510 | SQLITE_API int sqlite3_os_end(void){ |
| 37511 | #if SQLITE_OS_WINRT |
| 37512 | if( sleepObj!=NULL ){ |
| 37513 | osCloseHandle(sleepObj); |
| 37514 | sleepObj = NULL; |
| 37515 | } |
| @@ -91665,16 +91667,13 @@ | |
| 91665 | ** May you do good and not evil. |
| 91666 | ** May you find forgiveness for yourself and forgive others. |
| 91667 | ** May you share freely, never taking more than you give. |
| 91668 | ** |
| 91669 | ************************************************************************* |
| 91670 | ** This file contains the C functions that implement various SQL |
| 91671 | ** functions of SQLite. |
| 91672 | ** |
| 91673 | ** There is only one exported symbol in this file - the function |
| 91674 | ** sqliteRegisterBuildinFunctions() found at the bottom of the file. |
| 91675 | ** All other code has file scope. |
| 91676 | */ |
| 91677 | /* #include <stdlib.h> */ |
| 91678 | /* #include <assert.h> */ |
| 91679 | |
| 91680 | /* |
| 91681 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -222,11 +222,11 @@ | |
| 222 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 223 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 224 | */ |
| 225 | #define SQLITE_VERSION "3.8.6" |
| 226 | #define SQLITE_VERSION_NUMBER 3008006 |
| 227 | #define SQLITE_SOURCE_ID "2014-08-06 11:58:40 5c6bb57d90bad32785d6d9cdf110a825bbc5ec73" |
| 228 | |
| 229 | /* |
| 230 | ** CAPI3REF: Run-Time Library Version Numbers |
| 231 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 232 | ** |
| @@ -32208,11 +32208,11 @@ | |
| 32208 | |
| 32209 | /* |
| 32210 | ** Some Microsoft compilers lack this definition. |
| 32211 | */ |
| 32212 | #ifndef INVALID_FILE_ATTRIBUTES |
| 32213 | # define INVALID_FILE_ATTRIBUTES ((DWORD)-1) |
| 32214 | #endif |
| 32215 | |
| 32216 | #ifndef FILE_FLAG_MASK |
| 32217 | # define FILE_FLAG_MASK (0xFF3C0000) |
| 32218 | #endif |
| @@ -32258,11 +32258,11 @@ | |
| 32258 | #endif |
| 32259 | const char *zPath; /* Full pathname of this file */ |
| 32260 | int szChunk; /* Chunk size configured by FCNTL_CHUNK_SIZE */ |
| 32261 | #if SQLITE_OS_WINCE |
| 32262 | LPWSTR zDeleteOnClose; /* Name of file to delete when closing */ |
| 32263 | HANDLE hMutex; /* Mutex used to control access to shared lock */ |
| 32264 | HANDLE hShared; /* Shared memory segment used for locking */ |
| 32265 | winceLock local; /* Locks obtained by this instance of winFile */ |
| 32266 | winceLock *shared; /* Global shared lock memory for the file */ |
| 32267 | #endif |
| 32268 | #if SQLITE_MAX_MMAP_SIZE>0 |
| @@ -33051,14 +33051,16 @@ | |
| 33051 | #endif |
| 33052 | |
| 33053 | #define osCreateFileMappingFromApp ((HANDLE(WINAPI*)(HANDLE, \ |
| 33054 | LPSECURITY_ATTRIBUTES,ULONG,ULONG64,LPCWSTR))aSyscall[75].pCurrent) |
| 33055 | |
| 33056 | /* |
| 33057 | ** NOTE: On some sub-platforms, the InterlockedCompareExchange "function" |
| 33058 | ** is really just a macro that uses a compiler intrinsic (e.g. x64). |
| 33059 | ** So do not try to make this is into a redefinable interface. |
| 33060 | */ |
| 33061 | #define osInterlockedCompareExchange InterlockedCompareExchange |
| 33062 | |
| 33063 | }; /* End of the overrideable system calls */ |
| 33064 | |
| 33065 | /* |
| 33066 | ** This is the xSetSystemCall() method of sqlite3_vfs for all of the |
| @@ -33536,11 +33538,11 @@ | |
| 33538 | sqlite3_config(SQLITE_CONFIG_MALLOC, sqlite3MemGetWin32()); |
| 33539 | } |
| 33540 | #endif /* SQLITE_WIN32_MALLOC */ |
| 33541 | |
| 33542 | /* |
| 33543 | ** Convert a UTF-8 string to Microsoft Unicode (UTF-16?). |
| 33544 | ** |
| 33545 | ** Space to hold the returned string is obtained from malloc. |
| 33546 | */ |
| 33547 | static LPWSTR winUtf8ToUnicode(const char *zFilename){ |
| 33548 | int nChar; |
| @@ -33589,11 +33591,11 @@ | |
| 33591 | } |
| 33592 | |
| 33593 | /* |
| 33594 | ** Convert an ANSI string to Microsoft Unicode, based on the |
| 33595 | ** current codepage settings for file apis. |
| 33596 | ** |
| 33597 | ** Space to hold the returned string is obtained |
| 33598 | ** from sqlite3_malloc. |
| 33599 | */ |
| 33600 | static LPWSTR winMbcsToUnicode(const char *zFilename){ |
| 33601 | int nByte; |
| @@ -33663,11 +33665,11 @@ | |
| 33665 | sqlite3_free(zTmpWide); |
| 33666 | return zFilenameUtf8; |
| 33667 | } |
| 33668 | |
| 33669 | /* |
| 33670 | ** Convert UTF-8 to multibyte character string. Space to hold the |
| 33671 | ** returned string is obtained from sqlite3_malloc(). |
| 33672 | */ |
| 33673 | SQLITE_API char *sqlite3_win32_utf8_to_mbcs(const char *zFilename){ |
| 33674 | char *zFilenameMbcs; |
| 33675 | LPWSTR zTmpWide; |
| @@ -33803,15 +33805,15 @@ | |
| 33805 | ** This function - winLogErrorAtLine() - is only ever called via the macro |
| 33806 | ** winLogError(). |
| 33807 | ** |
| 33808 | ** This routine is invoked after an error occurs in an OS function. |
| 33809 | ** It logs a message using sqlite3_log() containing the current value of |
| 33810 | ** error code and, if possible, the human-readable equivalent from |
| 33811 | ** FormatMessage. |
| 33812 | ** |
| 33813 | ** The first argument passed to the macro should be the error code that |
| 33814 | ** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN). |
| 33815 | ** The two subsequent arguments should be the name of the OS function that |
| 33816 | ** failed and the associated file-system path, if any. |
| 33817 | */ |
| 33818 | #define winLogError(a,b,c,d) winLogErrorAtLine(a,b,c,d,__LINE__) |
| 33819 | static int winLogErrorAtLine( |
| @@ -33838,11 +33840,11 @@ | |
| 33840 | return errcode; |
| 33841 | } |
| 33842 | |
| 33843 | /* |
| 33844 | ** The number of times that a ReadFile(), WriteFile(), and DeleteFile() |
| 33845 | ** will be retried following a locking error - probably caused by |
| 33846 | ** antivirus software. Also the initial delay before the first retry. |
| 33847 | ** The delay increases linearly with each retry. |
| 33848 | */ |
| 33849 | #ifndef SQLITE_WIN32_IOERR_RETRY |
| 33850 | # define SQLITE_WIN32_IOERR_RETRY 10 |
| @@ -33913,11 +33915,11 @@ | |
| 33915 | /* |
| 33916 | ** Log a I/O error retry episode. |
| 33917 | */ |
| 33918 | static void winLogIoerr(int nRetry){ |
| 33919 | if( nRetry ){ |
| 33920 | sqlite3_log(SQLITE_IOERR, |
| 33921 | "delayed %dms for lock/sharing conflict", |
| 33922 | winIoerrRetryDelay*nRetry*(nRetry+1)/2 |
| 33923 | ); |
| 33924 | } |
| 33925 | } |
| @@ -34007,21 +34009,21 @@ | |
| 34009 | "winceCreateLock1", zFilename); |
| 34010 | } |
| 34011 | |
| 34012 | /* Acquire the mutex before continuing */ |
| 34013 | winceMutexAcquire(pFile->hMutex); |
| 34014 | |
| 34015 | /* Since the names of named mutexes, semaphores, file mappings etc are |
| 34016 | ** case-sensitive, take advantage of that by uppercasing the mutex name |
| 34017 | ** and using that as the shared filemapping name. |
| 34018 | */ |
| 34019 | osCharUpperW(zName); |
| 34020 | pFile->hShared = osCreateFileMappingW(INVALID_HANDLE_VALUE, NULL, |
| 34021 | PAGE_READWRITE, 0, sizeof(winceLock), |
| 34022 | zName); |
| 34023 | |
| 34024 | /* Set a flag that indicates we're the first to create the memory so it |
| 34025 | ** must be zero-initialized */ |
| 34026 | lastErrno = osGetLastError(); |
| 34027 | if (lastErrno == ERROR_ALREADY_EXISTS){ |
| 34028 | bInit = FALSE; |
| 34029 | } |
| @@ -34028,11 +34030,11 @@ | |
| 34030 | |
| 34031 | sqlite3_free(zName); |
| 34032 | |
| 34033 | /* If we succeeded in making the shared memory handle, map it. */ |
| 34034 | if( pFile->hShared ){ |
| 34035 | pFile->shared = (winceLock*)osMapViewOfFile(pFile->hShared, |
| 34036 | FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, sizeof(winceLock)); |
| 34037 | /* If mapping failed, close the shared memory handle and erase it */ |
| 34038 | if( !pFile->shared ){ |
| 34039 | pFile->lastErrno = osGetLastError(); |
| 34040 | winLogError(SQLITE_IOERR, pFile->lastErrno, |
| @@ -34054,11 +34056,11 @@ | |
| 34056 | winceMutexRelease(pFile->hMutex); |
| 34057 | osCloseHandle(pFile->hMutex); |
| 34058 | pFile->hMutex = NULL; |
| 34059 | return SQLITE_IOERR; |
| 34060 | } |
| 34061 | |
| 34062 | /* Initialize the shared memory if we're supposed to */ |
| 34063 | if( bInit ){ |
| 34064 | memset(pFile->shared, 0, sizeof(winceLock)); |
| 34065 | } |
| 34066 | |
| @@ -34092,17 +34094,17 @@ | |
| 34094 | /* De-reference and close our copy of the shared memory handle */ |
| 34095 | osUnmapViewOfFile(pFile->shared); |
| 34096 | osCloseHandle(pFile->hShared); |
| 34097 | |
| 34098 | /* Done with the mutex */ |
| 34099 | winceMutexRelease(pFile->hMutex); |
| 34100 | osCloseHandle(pFile->hMutex); |
| 34101 | pFile->hMutex = NULL; |
| 34102 | } |
| 34103 | } |
| 34104 | |
| 34105 | /* |
| 34106 | ** An implementation of the LockFile() API of Windows for CE |
| 34107 | */ |
| 34108 | static BOOL winceLockFile( |
| 34109 | LPHANDLE phFile, |
| 34110 | DWORD dwFileOffsetLow, |
| @@ -34309,12 +34311,12 @@ | |
| 34311 | #ifndef INVALID_SET_FILE_POINTER |
| 34312 | # define INVALID_SET_FILE_POINTER ((DWORD)-1) |
| 34313 | #endif |
| 34314 | |
| 34315 | /* |
| 34316 | ** Move the current position of the file handle passed as the first |
| 34317 | ** argument to offset iOffset within the file. If successful, return 0. |
| 34318 | ** Otherwise, set pFile->lastErrno and return non-zero. |
| 34319 | */ |
| 34320 | static int winSeekFile(winFile *pFile, sqlite3_int64 iOffset){ |
| 34321 | #if !SQLITE_OS_WINRT |
| 34322 | LONG upperBits; /* Most sig. 32 bits of new offset */ |
| @@ -34325,15 +34327,15 @@ | |
| 34327 | OSTRACE(("SEEK file=%p, offset=%lld\n", pFile->h, iOffset)); |
| 34328 | |
| 34329 | upperBits = (LONG)((iOffset>>32) & 0x7fffffff); |
| 34330 | lowerBits = (LONG)(iOffset & 0xffffffff); |
| 34331 | |
| 34332 | /* API oddity: If successful, SetFilePointer() returns a dword |
| 34333 | ** containing the lower 32-bits of the new file-offset. Or, if it fails, |
| 34334 | ** it returns INVALID_SET_FILE_POINTER. However according to MSDN, |
| 34335 | ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine |
| 34336 | ** whether an error has actually occurred, it is also necessary to call |
| 34337 | ** GetLastError(). |
| 34338 | */ |
| 34339 | dwRet = osSetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN); |
| 34340 | |
| 34341 | if( (dwRet==INVALID_SET_FILE_POINTER |
| @@ -34412,11 +34414,11 @@ | |
| 34414 | winceDestroyLock(pFile); |
| 34415 | if( pFile->zDeleteOnClose ){ |
| 34416 | int cnt = 0; |
| 34417 | while( |
| 34418 | osDeleteFileW(pFile->zDeleteOnClose)==0 |
| 34419 | && osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff |
| 34420 | && cnt++ < WINCE_DELETION_ATTEMPTS |
| 34421 | ){ |
| 34422 | sqlite3_win32_sleep(100); /* Wait a little before trying again */ |
| 34423 | } |
| 34424 | sqlite3_free(pFile->zDeleteOnClose); |
| @@ -35260,11 +35262,11 @@ | |
| 35262 | winFile *p = (winFile*)id; |
| 35263 | return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN | |
| 35264 | ((p->ctrlFlags & WINFILE_PSOW)?SQLITE_IOCAP_POWERSAFE_OVERWRITE:0); |
| 35265 | } |
| 35266 | |
| 35267 | /* |
| 35268 | ** Windows will only let you create file view mappings |
| 35269 | ** on allocation size granularity boundaries. |
| 35270 | ** During sqlite3_os_init() we do a GetSystemInfo() |
| 35271 | ** to get the granularity size. |
| 35272 | */ |
| @@ -35272,15 +35274,15 @@ | |
| 35274 | |
| 35275 | #ifndef SQLITE_OMIT_WAL |
| 35276 | |
| 35277 | /* |
| 35278 | ** Helper functions to obtain and relinquish the global mutex. The |
| 35279 | ** global mutex is used to protect the winLockInfo objects used by |
| 35280 | ** this file, all of which may be shared by multiple threads. |
| 35281 | ** |
| 35282 | ** Function winShmMutexHeld() is used to assert() that the global mutex |
| 35283 | ** is held when required. This function is only used as part of assert() |
| 35284 | ** statements. e.g. |
| 35285 | ** |
| 35286 | ** winShmEnterMutex() |
| 35287 | ** assert( winShmMutexHeld() ); |
| 35288 | ** winShmLeaveMutex() |
| @@ -35306,14 +35308,14 @@ | |
| 35308 | ** |
| 35309 | ** winShmMutexHeld() must be true when creating or destroying |
| 35310 | ** this object or while reading or writing the following fields: |
| 35311 | ** |
| 35312 | ** nRef |
| 35313 | ** pNext |
| 35314 | ** |
| 35315 | ** The following fields are read-only after the object is created: |
| 35316 | ** |
| 35317 | ** fid |
| 35318 | ** zFilename |
| 35319 | ** |
| 35320 | ** Either winShmNode.mutex must be held or winShmNode.nRef==0 and |
| 35321 | ** winShmMutexHeld() is true when reading or writing any other field |
| @@ -35405,11 +35407,11 @@ | |
| 35407 | /* Initialize the locking parameters */ |
| 35408 | DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY; |
| 35409 | if( lockType == _SHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK; |
| 35410 | rc = winLockFile(&pFile->hFile.h, dwFlags, ofst, 0, nByte, 0); |
| 35411 | } |
| 35412 | |
| 35413 | if( rc!= 0 ){ |
| 35414 | rc = SQLITE_OK; |
| 35415 | }else{ |
| 35416 | pFile->lastErrno = osGetLastError(); |
| 35417 | rc = SQLITE_BUSY; |
| @@ -35501,11 +35503,11 @@ | |
| 35503 | sqlite3_free(p); |
| 35504 | return SQLITE_IOERR_NOMEM; |
| 35505 | } |
| 35506 | pNew->zFilename = (char*)&pNew[1]; |
| 35507 | sqlite3_snprintf(nName+15, pNew->zFilename, "%s-shm", pDbFd->zPath); |
| 35508 | sqlite3FileSuffix3(pDbFd->zPath, pNew->zFilename); |
| 35509 | |
| 35510 | /* Look to see if there is an existing winShmNode that can be used. |
| 35511 | ** If no matching winShmNode currently exists, create a new one. |
| 35512 | */ |
| 35513 | winShmEnterMutex(); |
| @@ -35538,11 +35540,11 @@ | |
| 35540 | if( SQLITE_OK!=rc ){ |
| 35541 | goto shm_open_err; |
| 35542 | } |
| 35543 | |
| 35544 | /* Check to see if another process is holding the dead-man switch. |
| 35545 | ** If not, truncate the file to zero length. |
| 35546 | */ |
| 35547 | if( winShmSystemLock(pShmNode, _SHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){ |
| 35548 | rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0); |
| 35549 | if( rc!=SQLITE_OK ){ |
| 35550 | rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(), |
| @@ -35567,11 +35569,11 @@ | |
| 35569 | |
| 35570 | /* The reference count on pShmNode has already been incremented under |
| 35571 | ** the cover of the winShmEnterMutex() mutex and the pointer from the |
| 35572 | ** new (struct winShm) object to the pShmNode has been set. All that is |
| 35573 | ** left to do is to link the new object into the linked list starting |
| 35574 | ** at pShmNode->pFirst. This must be done while holding the pShmNode->mutex |
| 35575 | ** mutex. |
| 35576 | */ |
| 35577 | sqlite3_mutex_enter(pShmNode->mutex); |
| 35578 | p->pNext = pShmNode->pFirst; |
| 35579 | pShmNode->pFirst = p; |
| @@ -35587,11 +35589,11 @@ | |
| 35589 | winShmLeaveMutex(); |
| 35590 | return rc; |
| 35591 | } |
| 35592 | |
| 35593 | /* |
| 35594 | ** Close a connection to shared-memory. Delete the underlying |
| 35595 | ** storage if deleteFlag is true. |
| 35596 | */ |
| 35597 | static int winShmUnmap( |
| 35598 | sqlite3_file *fd, /* Database holding shared memory */ |
| 35599 | int deleteFlag /* Delete after closing if true */ |
| @@ -35676,11 +35678,11 @@ | |
| 35678 | |
| 35679 | /* Undo the local locks */ |
| 35680 | if( rc==SQLITE_OK ){ |
| 35681 | p->exclMask &= ~mask; |
| 35682 | p->sharedMask &= ~mask; |
| 35683 | } |
| 35684 | }else if( flags & SQLITE_SHM_SHARED ){ |
| 35685 | u16 allShared = 0; /* Union of locks held by connections other than "p" */ |
| 35686 | |
| 35687 | /* Find out which shared locks are already held by sibling connections. |
| 35688 | ** If any sibling already holds an exclusive lock, go ahead and return |
| @@ -35715,11 +35717,11 @@ | |
| 35717 | if( (pX->exclMask & mask)!=0 || (pX->sharedMask & mask)!=0 ){ |
| 35718 | rc = SQLITE_BUSY; |
| 35719 | break; |
| 35720 | } |
| 35721 | } |
| 35722 | |
| 35723 | /* Get the exclusive locks at the system level. Then if successful |
| 35724 | ** also mark the local connection as being locked. |
| 35725 | */ |
| 35726 | if( rc==SQLITE_OK ){ |
| 35727 | rc = winShmSystemLock(pShmNode, _SHM_WRLCK, ofst+WIN_SHM_BASE, n); |
| @@ -35735,11 +35737,11 @@ | |
| 35737 | sqlite3ErrName(rc))); |
| 35738 | return rc; |
| 35739 | } |
| 35740 | |
| 35741 | /* |
| 35742 | ** Implement a memory barrier or memory fence on shared memory. |
| 35743 | ** |
| 35744 | ** All loads and stores begun before the barrier must complete before |
| 35745 | ** any load or store begun after the barrier. |
| 35746 | */ |
| 35747 | static void winShmBarrier( |
| @@ -35750,26 +35752,26 @@ | |
| 35752 | winShmEnterMutex(); |
| 35753 | winShmLeaveMutex(); |
| 35754 | } |
| 35755 | |
| 35756 | /* |
| 35757 | ** This function is called to obtain a pointer to region iRegion of the |
| 35758 | ** shared-memory associated with the database file fd. Shared-memory regions |
| 35759 | ** are numbered starting from zero. Each shared-memory region is szRegion |
| 35760 | ** bytes in size. |
| 35761 | ** |
| 35762 | ** If an error occurs, an error code is returned and *pp is set to NULL. |
| 35763 | ** |
| 35764 | ** Otherwise, if the isWrite parameter is 0 and the requested shared-memory |
| 35765 | ** region has not been allocated (by any client, including one running in a |
| 35766 | ** separate process), then *pp is set to NULL and SQLITE_OK returned. If |
| 35767 | ** isWrite is non-zero and the requested shared-memory region has not yet |
| 35768 | ** been allocated, it is allocated by this function. |
| 35769 | ** |
| 35770 | ** If the shared-memory region has already been allocated or is allocated by |
| 35771 | ** this call as described above, then it is mapped into this processes |
| 35772 | ** address space (if it is not already), *pp is set to point to the mapped |
| 35773 | ** memory and SQLITE_OK returned. |
| 35774 | */ |
| 35775 | static int winShmMap( |
| 35776 | sqlite3_file *fd, /* Handle open on database file */ |
| 35777 | int iRegion, /* Region to retrieve */ |
| @@ -35837,21 +35839,21 @@ | |
| 35839 | pShmNode->aRegion = apNew; |
| 35840 | |
| 35841 | while( pShmNode->nRegion<=iRegion ){ |
| 35842 | HANDLE hMap = NULL; /* file-mapping handle */ |
| 35843 | void *pMap = 0; /* Mapped memory region */ |
| 35844 | |
| 35845 | #if SQLITE_OS_WINRT |
| 35846 | hMap = osCreateFileMappingFromApp(pShmNode->hFile.h, |
| 35847 | NULL, PAGE_READWRITE, nByte, NULL |
| 35848 | ); |
| 35849 | #elif defined(SQLITE_WIN32_HAS_WIDE) |
| 35850 | hMap = osCreateFileMappingW(pShmNode->hFile.h, |
| 35851 | NULL, PAGE_READWRITE, 0, nByte, NULL |
| 35852 | ); |
| 35853 | #elif defined(SQLITE_WIN32_HAS_ANSI) |
| 35854 | hMap = osCreateFileMappingA(pShmNode->hFile.h, |
| 35855 | NULL, PAGE_READWRITE, 0, nByte, NULL |
| 35856 | ); |
| 35857 | #endif |
| 35858 | OSTRACE(("SHM-MAP-CREATE pid=%lu, region=%d, size=%d, rc=%s\n", |
| 35859 | osGetCurrentProcessId(), pShmNode->nRegion, nByte, |
| @@ -35944,18 +35946,18 @@ | |
| 35946 | return SQLITE_OK; |
| 35947 | } |
| 35948 | |
| 35949 | /* |
| 35950 | ** Memory map or remap the file opened by file-descriptor pFd (if the file |
| 35951 | ** is already mapped, the existing mapping is replaced by the new). Or, if |
| 35952 | ** there already exists a mapping for this file, and there are still |
| 35953 | ** outstanding xFetch() references to it, this function is a no-op. |
| 35954 | ** |
| 35955 | ** If parameter nByte is non-negative, then it is the requested size of |
| 35956 | ** the mapping to create. Otherwise, if nByte is less than zero, then the |
| 35957 | ** requested size is the size of the file on disk. The actual size of the |
| 35958 | ** created mapping is either the requested size or the value configured |
| 35959 | ** using SQLITE_FCNTL_MMAP_SIZE, whichever is smaller. |
| 35960 | ** |
| 35961 | ** SQLITE_OK is returned if no error occurs (even if the mapping is not |
| 35962 | ** recreated as a result of outstanding references) or an SQLite error |
| 35963 | ** code otherwise. |
| @@ -35980,11 +35982,11 @@ | |
| 35982 | } |
| 35983 | if( nMap>pFd->mmapSizeMax ){ |
| 35984 | nMap = pFd->mmapSizeMax; |
| 35985 | } |
| 35986 | nMap &= ~(sqlite3_int64)(winSysInfo.dwPageSize - 1); |
| 35987 | |
| 35988 | if( nMap==0 && pFd->mmapSize>0 ){ |
| 35989 | winUnmapfile(pFd); |
| 35990 | } |
| 35991 | if( nMap!=pFd->mmapSize ){ |
| 35992 | void *pNew = 0; |
| @@ -36052,11 +36054,11 @@ | |
| 36054 | ** If such a pointer can be obtained, store it in *pp and return SQLITE_OK. |
| 36055 | ** Or, if one cannot but no error occurs, set *pp to 0 and return SQLITE_OK. |
| 36056 | ** Finally, if an error does occur, return an SQLite error code. The final |
| 36057 | ** value of *pp is undefined in this case. |
| 36058 | ** |
| 36059 | ** If this function does return a pointer, the caller must eventually |
| 36060 | ** release the reference by calling winUnfetch(). |
| 36061 | */ |
| 36062 | static int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){ |
| 36063 | #if SQLITE_MAX_MMAP_SIZE>0 |
| 36064 | winFile *pFd = (winFile*)fd; /* The underlying database file */ |
| @@ -36087,24 +36089,24 @@ | |
| 36089 | osGetCurrentProcessId(), fd, pp, *pp)); |
| 36090 | return SQLITE_OK; |
| 36091 | } |
| 36092 | |
| 36093 | /* |
| 36094 | ** If the third argument is non-NULL, then this function releases a |
| 36095 | ** reference obtained by an earlier call to winFetch(). The second |
| 36096 | ** argument passed to this function must be the same as the corresponding |
| 36097 | ** argument that was passed to the winFetch() invocation. |
| 36098 | ** |
| 36099 | ** Or, if the third argument is NULL, then this function is being called |
| 36100 | ** to inform the VFS layer that, according to POSIX, any existing mapping |
| 36101 | ** may now be invalid and should be unmapped. |
| 36102 | */ |
| 36103 | static int winUnfetch(sqlite3_file *fd, i64 iOff, void *p){ |
| 36104 | #if SQLITE_MAX_MMAP_SIZE>0 |
| 36105 | winFile *pFd = (winFile*)fd; /* The underlying database file */ |
| 36106 | |
| 36107 | /* If p==0 (unmap the entire file) then there must be no outstanding |
| 36108 | ** xFetch references. Or, if p!=0 (meaning it is an xFetch reference), |
| 36109 | ** then there must be at least one outstanding. */ |
| 36110 | assert( (p==0)==(pFd->nFetchOut==0) ); |
| 36111 | |
| 36112 | /* If p!=0, it must match the iOff value. */ |
| @@ -36246,11 +36248,11 @@ | |
| 36248 | int nMax, nBuf, nDir, nLen; |
| 36249 | char *zBuf; |
| 36250 | |
| 36251 | /* It's odd to simulate an io-error here, but really this is just |
| 36252 | ** using the io-error infrastructure to test that SQLite handles this |
| 36253 | ** function failing. |
| 36254 | */ |
| 36255 | SimulateIOError( return SQLITE_IOERR ); |
| 36256 | |
| 36257 | /* Allocate a temporary buffer to store the fully qualified file |
| 36258 | ** name for the temporary file. If this fails, we cannot continue. |
| @@ -36428,11 +36430,11 @@ | |
| 36430 | OSTRACE(("TEMP-FILENAME rc=SQLITE_ERROR\n")); |
| 36431 | return winLogError(SQLITE_ERROR, 0, "winGetTempname4", 0); |
| 36432 | } |
| 36433 | |
| 36434 | /* |
| 36435 | ** Check that the output buffer is large enough for the temporary file |
| 36436 | ** name in the following format: |
| 36437 | ** |
| 36438 | ** "<temporary_directory>/etilqs_XXXXXXXXXXXXXXX\0\0" |
| 36439 | ** |
| 36440 | ** If not, return SQLITE_ERROR. The number 17 is used here in order to |
| @@ -36531,42 +36533,42 @@ | |
| 36533 | int isReadonly = (flags & SQLITE_OPEN_READONLY); |
| 36534 | int isReadWrite = (flags & SQLITE_OPEN_READWRITE); |
| 36535 | |
| 36536 | #ifndef NDEBUG |
| 36537 | int isOpenJournal = (isCreate && ( |
| 36538 | eType==SQLITE_OPEN_MASTER_JOURNAL |
| 36539 | || eType==SQLITE_OPEN_MAIN_JOURNAL |
| 36540 | || eType==SQLITE_OPEN_WAL |
| 36541 | )); |
| 36542 | #endif |
| 36543 | |
| 36544 | OSTRACE(("OPEN name=%s, pFile=%p, flags=%x, pOutFlags=%p\n", |
| 36545 | zUtf8Name, id, flags, pOutFlags)); |
| 36546 | |
| 36547 | /* Check the following statements are true: |
| 36548 | ** |
| 36549 | ** (a) Exactly one of the READWRITE and READONLY flags must be set, and |
| 36550 | ** (b) if CREATE is set, then READWRITE must also be set, and |
| 36551 | ** (c) if EXCLUSIVE is set, then CREATE must also be set. |
| 36552 | ** (d) if DELETEONCLOSE is set, then CREATE must also be set. |
| 36553 | */ |
| 36554 | assert((isReadonly==0 || isReadWrite==0) && (isReadWrite || isReadonly)); |
| 36555 | assert(isCreate==0 || isReadWrite); |
| 36556 | assert(isExclusive==0 || isCreate); |
| 36557 | assert(isDelete==0 || isCreate); |
| 36558 | |
| 36559 | /* The main DB, main journal, WAL file and master journal are never |
| 36560 | ** automatically deleted. Nor are they ever temporary files. */ |
| 36561 | assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_DB ); |
| 36562 | assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_JOURNAL ); |
| 36563 | assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MASTER_JOURNAL ); |
| 36564 | assert( (!isDelete && zName) || eType!=SQLITE_OPEN_WAL ); |
| 36565 | |
| 36566 | /* Assert that the upper layer has set one of the "file-type" flags. */ |
| 36567 | assert( eType==SQLITE_OPEN_MAIN_DB || eType==SQLITE_OPEN_TEMP_DB |
| 36568 | || eType==SQLITE_OPEN_MAIN_JOURNAL || eType==SQLITE_OPEN_TEMP_JOURNAL |
| 36569 | || eType==SQLITE_OPEN_SUBJOURNAL || eType==SQLITE_OPEN_MASTER_JOURNAL |
| 36570 | || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL |
| 36571 | ); |
| 36572 | |
| 36573 | assert( pFile!=0 ); |
| 36574 | memset(pFile, 0, sizeof(winFile)); |
| @@ -36577,12 +36579,12 @@ | |
| 36579 | sqlite3_log(SQLITE_ERROR, |
| 36580 | "sqlite3_temp_directory variable should be set for WinRT"); |
| 36581 | } |
| 36582 | #endif |
| 36583 | |
| 36584 | /* If the second argument to this function is NULL, generate a |
| 36585 | ** temporary file name to use |
| 36586 | */ |
| 36587 | if( !zUtf8Name ){ |
| 36588 | assert( isDelete && !isOpenJournal ); |
| 36589 | rc = winGetTempname(pVfs, &zTmpname); |
| 36590 | if( rc!=SQLITE_OK ){ |
| @@ -36618,12 +36620,12 @@ | |
| 36620 | dwDesiredAccess = GENERIC_READ | GENERIC_WRITE; |
| 36621 | }else{ |
| 36622 | dwDesiredAccess = GENERIC_READ; |
| 36623 | } |
| 36624 | |
| 36625 | /* SQLITE_OPEN_EXCLUSIVE is used to make sure that a new file is |
| 36626 | ** created. SQLite doesn't use it to indicate "exclusive access" |
| 36627 | ** as it is usually understood. |
| 36628 | */ |
| 36629 | if( isExclusive ){ |
| 36630 | /* Creates a new file, only if it does not already exist. */ |
| 36631 | /* If the file exists, it fails. */ |
| @@ -36708,11 +36710,11 @@ | |
| 36710 | pFile->lastErrno = lastErrno; |
| 36711 | winLogError(SQLITE_CANTOPEN, pFile->lastErrno, "winOpen", zUtf8Name); |
| 36712 | sqlite3_free(zConverted); |
| 36713 | sqlite3_free(zTmpname); |
| 36714 | if( isReadWrite && !isExclusive ){ |
| 36715 | return winOpen(pVfs, zName, id, |
| 36716 | ((flags|SQLITE_OPEN_READONLY) & |
| 36717 | ~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE)), |
| 36718 | pOutFlags); |
| 36719 | }else{ |
| 36720 | return SQLITE_CANTOPEN_BKPT; |
| @@ -36917,18 +36919,18 @@ | |
| 36919 | if( osIsNT() ){ |
| 36920 | int cnt = 0; |
| 36921 | WIN32_FILE_ATTRIBUTE_DATA sAttrData; |
| 36922 | memset(&sAttrData, 0, sizeof(sAttrData)); |
| 36923 | while( !(rc = osGetFileAttributesExW((LPCWSTR)zConverted, |
| 36924 | GetFileExInfoStandard, |
| 36925 | &sAttrData)) && winRetryIoerr(&cnt, &lastErrno) ){} |
| 36926 | if( rc ){ |
| 36927 | /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file |
| 36928 | ** as if it does not exist. |
| 36929 | */ |
| 36930 | if( flags==SQLITE_ACCESS_EXISTS |
| 36931 | && sAttrData.nFileSizeHigh==0 |
| 36932 | && sAttrData.nFileSizeLow==0 ){ |
| 36933 | attr = INVALID_FILE_ATTRIBUTES; |
| 36934 | }else{ |
| 36935 | attr = sAttrData.dwFileAttributes; |
| 36936 | } |
| @@ -37023,11 +37025,11 @@ | |
| 37025 | sqlite3_vfs *pVfs, /* Pointer to vfs object */ |
| 37026 | const char *zRelative, /* Possibly relative input path */ |
| 37027 | int nFull, /* Size of output buffer in bytes */ |
| 37028 | char *zFull /* Output buffer */ |
| 37029 | ){ |
| 37030 | |
| 37031 | #if defined(__CYGWIN__) |
| 37032 | SimulateIOError( return SQLITE_ERROR ); |
| 37033 | UNUSED_PARAMETER(nFull); |
| 37034 | assert( nFull>=pVfs->mxPathname ); |
| 37035 | if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ |
| @@ -37336,24 +37338,24 @@ | |
| 37338 | ** the current time and date as a Julian Day number times 86_400_000. In |
| 37339 | ** other words, write into *piNow the number of milliseconds since the Julian |
| 37340 | ** epoch of noon in Greenwich on November 24, 4714 B.C according to the |
| 37341 | ** proleptic Gregorian calendar. |
| 37342 | ** |
| 37343 | ** On success, return SQLITE_OK. Return SQLITE_ERROR if the time and date |
| 37344 | ** cannot be found. |
| 37345 | */ |
| 37346 | static int winCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *piNow){ |
| 37347 | /* FILETIME structure is a 64-bit value representing the number of |
| 37348 | 100-nanosecond intervals since January 1, 1601 (= JD 2305813.5). |
| 37349 | */ |
| 37350 | FILETIME ft; |
| 37351 | static const sqlite3_int64 winFiletimeEpoch = 23058135*(sqlite3_int64)8640000; |
| 37352 | #ifdef SQLITE_TEST |
| 37353 | static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000; |
| 37354 | #endif |
| 37355 | /* 2^32 - to avoid use of LL and warnings in gcc */ |
| 37356 | static const sqlite3_int64 max32BitValue = |
| 37357 | (sqlite3_int64)2000000000 + (sqlite3_int64)2000000000 + |
| 37358 | (sqlite3_int64)294967296; |
| 37359 | |
| 37360 | #if SQLITE_OS_WINCE |
| 37361 | SYSTEMTIME time; |
| @@ -37365,11 +37367,11 @@ | |
| 37367 | #else |
| 37368 | osGetSystemTimeAsFileTime( &ft ); |
| 37369 | #endif |
| 37370 | |
| 37371 | *piNow = winFiletimeEpoch + |
| 37372 | ((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) + |
| 37373 | (sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)10000; |
| 37374 | |
| 37375 | #ifdef SQLITE_TEST |
| 37376 | if( sqlite3_current_time ){ |
| 37377 | *piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch; |
| @@ -37484,11 +37486,11 @@ | |
| 37486 | }; |
| 37487 | #endif |
| 37488 | |
| 37489 | /* Double-check that the aSyscall[] array has been constructed |
| 37490 | ** correctly. See ticket [bb3a86e890c8e96ab] */ |
| 37491 | assert( ArraySize(aSyscall)==76 ); |
| 37492 | |
| 37493 | /* get memory map allocation granularity */ |
| 37494 | memset(&winSysInfo, 0, sizeof(SYSTEM_INFO)); |
| 37495 | #if SQLITE_OS_WINRT |
| 37496 | osGetNativeSystemInfo(&winSysInfo); |
| @@ -37502,14 +37504,14 @@ | |
| 37504 | |
| 37505 | #if defined(SQLITE_WIN32_HAS_WIDE) |
| 37506 | sqlite3_vfs_register(&winLongPathVfs, 0); |
| 37507 | #endif |
| 37508 | |
| 37509 | return SQLITE_OK; |
| 37510 | } |
| 37511 | |
| 37512 | SQLITE_API int sqlite3_os_end(void){ |
| 37513 | #if SQLITE_OS_WINRT |
| 37514 | if( sleepObj!=NULL ){ |
| 37515 | osCloseHandle(sleepObj); |
| 37516 | sleepObj = NULL; |
| 37517 | } |
| @@ -91665,16 +91667,13 @@ | |
| 91667 | ** May you do good and not evil. |
| 91668 | ** May you find forgiveness for yourself and forgive others. |
| 91669 | ** May you share freely, never taking more than you give. |
| 91670 | ** |
| 91671 | ************************************************************************* |
| 91672 | ** This file contains the C-language implementions for many of the SQL |
| 91673 | ** functions of SQLite. (Some function, and in particular the date and |
| 91674 | ** time functions, are implemented separately.) |
| 91675 | */ |
| 91676 | /* #include <stdlib.h> */ |
| 91677 | /* #include <assert.h> */ |
| 91678 | |
| 91679 | /* |
| 91680 |
+1
-1
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -107,11 +107,11 @@ | ||
| 107 | 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | 109 | */ |
| 110 | 110 | #define SQLITE_VERSION "3.8.6" |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3008006 |
| 112 | -#define SQLITE_SOURCE_ID "2014-08-06 00:29:06 0ad1ed8ef0b5fb5d8db44479373b2b93d8fcfd66" | |
| 112 | +#define SQLITE_SOURCE_ID "2014-08-06 11:58:40 5c6bb57d90bad32785d6d9cdf110a825bbc5ec73" | |
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | 117 | ** |
| 118 | 118 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.8.6" |
| 111 | #define SQLITE_VERSION_NUMBER 3008006 |
| 112 | #define SQLITE_SOURCE_ID "2014-08-06 00:29:06 0ad1ed8ef0b5fb5d8db44479373b2b93d8fcfd66" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.8.6" |
| 111 | #define SQLITE_VERSION_NUMBER 3008006 |
| 112 | #define SQLITE_SOURCE_ID "2014-08-06 11:58:40 5c6bb57d90bad32785d6d9cdf110a825bbc5ec73" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |