Fossil SCM

Update the built-in SQLite with the InterlockedCompareExchange fix for Win64.

drh 2014-08-06 14:06 UTC trunk
Commit d600c9f85421c0972231561560cb8410589c9606
2 files changed +96 -97 +1 -1
+96 -97
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -222,11 +222,11 @@
222222
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
223223
** [sqlite_version()] and [sqlite_source_id()].
224224
*/
225225
#define SQLITE_VERSION "3.8.6"
226226
#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"
228228
229229
/*
230230
** CAPI3REF: Run-Time Library Version Numbers
231231
** KEYWORDS: sqlite3_version, sqlite3_sourceid
232232
**
@@ -32208,11 +32208,11 @@
3220832208
3220932209
/*
3221032210
** Some Microsoft compilers lack this definition.
3221132211
*/
3221232212
#ifndef INVALID_FILE_ATTRIBUTES
32213
-# define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
32213
+# define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
3221432214
#endif
3221532215
3221632216
#ifndef FILE_FLAG_MASK
3221732217
# define FILE_FLAG_MASK (0xFF3C0000)
3221832218
#endif
@@ -32258,11 +32258,11 @@
3225832258
#endif
3225932259
const char *zPath; /* Full pathname of this file */
3226032260
int szChunk; /* Chunk size configured by FCNTL_CHUNK_SIZE */
3226132261
#if SQLITE_OS_WINCE
3226232262
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 */
3226432264
HANDLE hShared; /* Shared memory segment used for locking */
3226532265
winceLock local; /* Locks obtained by this instance of winFile */
3226632266
winceLock *shared; /* Global shared lock memory for the file */
3226732267
#endif
3226832268
#if SQLITE_MAX_MMAP_SIZE>0
@@ -33051,14 +33051,16 @@
3305133051
#endif
3305233052
3305333053
#define osCreateFileMappingFromApp ((HANDLE(WINAPI*)(HANDLE, \
3305433054
LPSECURITY_ATTRIBUTES,ULONG,ULONG64,LPCWSTR))aSyscall[75].pCurrent)
3305533055
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
3306033062
3306133063
}; /* End of the overrideable system calls */
3306233064
3306333065
/*
3306433066
** This is the xSetSystemCall() method of sqlite3_vfs for all of the
@@ -33536,11 +33538,11 @@
3353633538
sqlite3_config(SQLITE_CONFIG_MALLOC, sqlite3MemGetWin32());
3353733539
}
3353833540
#endif /* SQLITE_WIN32_MALLOC */
3353933541
3354033542
/*
33541
-** Convert a UTF-8 string to Microsoft Unicode (UTF-16?).
33543
+** Convert a UTF-8 string to Microsoft Unicode (UTF-16?).
3354233544
**
3354333545
** Space to hold the returned string is obtained from malloc.
3354433546
*/
3354533547
static LPWSTR winUtf8ToUnicode(const char *zFilename){
3354633548
int nChar;
@@ -33589,11 +33591,11 @@
3358933591
}
3359033592
3359133593
/*
3359233594
** Convert an ANSI string to Microsoft Unicode, based on the
3359333595
** current codepage settings for file apis.
33594
-**
33596
+**
3359533597
** Space to hold the returned string is obtained
3359633598
** from sqlite3_malloc.
3359733599
*/
3359833600
static LPWSTR winMbcsToUnicode(const char *zFilename){
3359933601
int nByte;
@@ -33663,11 +33665,11 @@
3366333665
sqlite3_free(zTmpWide);
3366433666
return zFilenameUtf8;
3366533667
}
3366633668
3366733669
/*
33668
-** Convert UTF-8 to multibyte character string. Space to hold the
33670
+** Convert UTF-8 to multibyte character string. Space to hold the
3366933671
** returned string is obtained from sqlite3_malloc().
3367033672
*/
3367133673
SQLITE_API char *sqlite3_win32_utf8_to_mbcs(const char *zFilename){
3367233674
char *zFilenameMbcs;
3367333675
LPWSTR zTmpWide;
@@ -33803,15 +33805,15 @@
3380333805
** This function - winLogErrorAtLine() - is only ever called via the macro
3380433806
** winLogError().
3380533807
**
3380633808
** This routine is invoked after an error occurs in an OS function.
3380733809
** 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
3380933811
** FormatMessage.
3381033812
**
3381133813
** 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).
3381333815
** The two subsequent arguments should be the name of the OS function that
3381433816
** failed and the associated file-system path, if any.
3381533817
*/
3381633818
#define winLogError(a,b,c,d) winLogErrorAtLine(a,b,c,d,__LINE__)
3381733819
static int winLogErrorAtLine(
@@ -33838,11 +33840,11 @@
3383833840
return errcode;
3383933841
}
3384033842
3384133843
/*
3384233844
** 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
3384433846
** antivirus software. Also the initial delay before the first retry.
3384533847
** The delay increases linearly with each retry.
3384633848
*/
3384733849
#ifndef SQLITE_WIN32_IOERR_RETRY
3384833850
# define SQLITE_WIN32_IOERR_RETRY 10
@@ -33913,11 +33915,11 @@
3391333915
/*
3391433916
** Log a I/O error retry episode.
3391533917
*/
3391633918
static void winLogIoerr(int nRetry){
3391733919
if( nRetry ){
33918
- sqlite3_log(SQLITE_IOERR,
33920
+ sqlite3_log(SQLITE_IOERR,
3391933921
"delayed %dms for lock/sharing conflict",
3392033922
winIoerrRetryDelay*nRetry*(nRetry+1)/2
3392133923
);
3392233924
}
3392333925
}
@@ -34007,21 +34009,21 @@
3400734009
"winceCreateLock1", zFilename);
3400834010
}
3400934011
3401034012
/* Acquire the mutex before continuing */
3401134013
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
3401434016
** case-sensitive, take advantage of that by uppercasing the mutex name
3401534017
** and using that as the shared filemapping name.
3401634018
*/
3401734019
osCharUpperW(zName);
3401834020
pFile->hShared = osCreateFileMappingW(INVALID_HANDLE_VALUE, NULL,
3401934021
PAGE_READWRITE, 0, sizeof(winceLock),
34020
- zName);
34022
+ zName);
3402134023
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
3402334025
** must be zero-initialized */
3402434026
lastErrno = osGetLastError();
3402534027
if (lastErrno == ERROR_ALREADY_EXISTS){
3402634028
bInit = FALSE;
3402734029
}
@@ -34028,11 +34030,11 @@
3402834030
3402934031
sqlite3_free(zName);
3403034032
3403134033
/* If we succeeded in making the shared memory handle, map it. */
3403234034
if( pFile->hShared ){
34033
- pFile->shared = (winceLock*)osMapViewOfFile(pFile->hShared,
34035
+ pFile->shared = (winceLock*)osMapViewOfFile(pFile->hShared,
3403434036
FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, sizeof(winceLock));
3403534037
/* If mapping failed, close the shared memory handle and erase it */
3403634038
if( !pFile->shared ){
3403734039
pFile->lastErrno = osGetLastError();
3403834040
winLogError(SQLITE_IOERR, pFile->lastErrno,
@@ -34054,11 +34056,11 @@
3405434056
winceMutexRelease(pFile->hMutex);
3405534057
osCloseHandle(pFile->hMutex);
3405634058
pFile->hMutex = NULL;
3405734059
return SQLITE_IOERR;
3405834060
}
34059
-
34061
+
3406034062
/* Initialize the shared memory if we're supposed to */
3406134063
if( bInit ){
3406234064
memset(pFile->shared, 0, sizeof(winceLock));
3406334065
}
3406434066
@@ -34092,17 +34094,17 @@
3409234094
/* De-reference and close our copy of the shared memory handle */
3409334095
osUnmapViewOfFile(pFile->shared);
3409434096
osCloseHandle(pFile->hShared);
3409534097
3409634098
/* Done with the mutex */
34097
- winceMutexRelease(pFile->hMutex);
34099
+ winceMutexRelease(pFile->hMutex);
3409834100
osCloseHandle(pFile->hMutex);
3409934101
pFile->hMutex = NULL;
3410034102
}
3410134103
}
3410234104
34103
-/*
34105
+/*
3410434106
** An implementation of the LockFile() API of Windows for CE
3410534107
*/
3410634108
static BOOL winceLockFile(
3410734109
LPHANDLE phFile,
3410834110
DWORD dwFileOffsetLow,
@@ -34309,12 +34311,12 @@
3430934311
#ifndef INVALID_SET_FILE_POINTER
3431034312
# define INVALID_SET_FILE_POINTER ((DWORD)-1)
3431134313
#endif
3431234314
3431334315
/*
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.
3431634318
** Otherwise, set pFile->lastErrno and return non-zero.
3431734319
*/
3431834320
static int winSeekFile(winFile *pFile, sqlite3_int64 iOffset){
3431934321
#if !SQLITE_OS_WINRT
3432034322
LONG upperBits; /* Most sig. 32 bits of new offset */
@@ -34325,15 +34327,15 @@
3432534327
OSTRACE(("SEEK file=%p, offset=%lld\n", pFile->h, iOffset));
3432634328
3432734329
upperBits = (LONG)((iOffset>>32) & 0x7fffffff);
3432834330
lowerBits = (LONG)(iOffset & 0xffffffff);
3432934331
34330
- /* API oddity: If successful, SetFilePointer() returns a dword
34332
+ /* API oddity: If successful, SetFilePointer() returns a dword
3433134333
** 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
3433534337
** GetLastError().
3433634338
*/
3433734339
dwRet = osSetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
3433834340
3433934341
if( (dwRet==INVALID_SET_FILE_POINTER
@@ -34412,11 +34414,11 @@
3441234414
winceDestroyLock(pFile);
3441334415
if( pFile->zDeleteOnClose ){
3441434416
int cnt = 0;
3441534417
while(
3441634418
osDeleteFileW(pFile->zDeleteOnClose)==0
34417
- && osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff
34419
+ && osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff
3441834420
&& cnt++ < WINCE_DELETION_ATTEMPTS
3441934421
){
3442034422
sqlite3_win32_sleep(100); /* Wait a little before trying again */
3442134423
}
3442234424
sqlite3_free(pFile->zDeleteOnClose);
@@ -35260,11 +35262,11 @@
3526035262
winFile *p = (winFile*)id;
3526135263
return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN |
3526235264
((p->ctrlFlags & WINFILE_PSOW)?SQLITE_IOCAP_POWERSAFE_OVERWRITE:0);
3526335265
}
3526435266
35265
-/*
35267
+/*
3526635268
** Windows will only let you create file view mappings
3526735269
** on allocation size granularity boundaries.
3526835270
** During sqlite3_os_init() we do a GetSystemInfo()
3526935271
** to get the granularity size.
3527035272
*/
@@ -35272,15 +35274,15 @@
3527235274
3527335275
#ifndef SQLITE_OMIT_WAL
3527435276
3527535277
/*
3527635278
** 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
3527835280
** this file, all of which may be shared by multiple threads.
3527935281
**
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()
3528235284
** statements. e.g.
3528335285
**
3528435286
** winShmEnterMutex()
3528535287
** assert( winShmMutexHeld() );
3528635288
** winShmLeaveMutex()
@@ -35306,14 +35308,14 @@
3530635308
**
3530735309
** winShmMutexHeld() must be true when creating or destroying
3530835310
** this object or while reading or writing the following fields:
3530935311
**
3531035312
** nRef
35311
-** pNext
35313
+** pNext
3531235314
**
3531335315
** The following fields are read-only after the object is created:
35314
-**
35316
+**
3531535317
** fid
3531635318
** zFilename
3531735319
**
3531835320
** Either winShmNode.mutex must be held or winShmNode.nRef==0 and
3531935321
** winShmMutexHeld() is true when reading or writing any other field
@@ -35405,11 +35407,11 @@
3540535407
/* Initialize the locking parameters */
3540635408
DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY;
3540735409
if( lockType == _SHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK;
3540835410
rc = winLockFile(&pFile->hFile.h, dwFlags, ofst, 0, nByte, 0);
3540935411
}
35410
-
35412
+
3541135413
if( rc!= 0 ){
3541235414
rc = SQLITE_OK;
3541335415
}else{
3541435416
pFile->lastErrno = osGetLastError();
3541535417
rc = SQLITE_BUSY;
@@ -35501,11 +35503,11 @@
3550135503
sqlite3_free(p);
3550235504
return SQLITE_IOERR_NOMEM;
3550335505
}
3550435506
pNew->zFilename = (char*)&pNew[1];
3550535507
sqlite3_snprintf(nName+15, pNew->zFilename, "%s-shm", pDbFd->zPath);
35506
- sqlite3FileSuffix3(pDbFd->zPath, pNew->zFilename);
35508
+ sqlite3FileSuffix3(pDbFd->zPath, pNew->zFilename);
3550735509
3550835510
/* Look to see if there is an existing winShmNode that can be used.
3550935511
** If no matching winShmNode currently exists, create a new one.
3551035512
*/
3551135513
winShmEnterMutex();
@@ -35538,11 +35540,11 @@
3553835540
if( SQLITE_OK!=rc ){
3553935541
goto shm_open_err;
3554035542
}
3554135543
3554235544
/* 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.
3554435546
*/
3554535547
if( winShmSystemLock(pShmNode, _SHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){
3554635548
rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0);
3554735549
if( rc!=SQLITE_OK ){
3554835550
rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(),
@@ -35567,11 +35569,11 @@
3556735569
3556835570
/* The reference count on pShmNode has already been incremented under
3556935571
** the cover of the winShmEnterMutex() mutex and the pointer from the
3557035572
** new (struct winShm) object to the pShmNode has been set. All that is
3557135573
** 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
3557335575
** mutex.
3557435576
*/
3557535577
sqlite3_mutex_enter(pShmNode->mutex);
3557635578
p->pNext = pShmNode->pFirst;
3557735579
pShmNode->pFirst = p;
@@ -35587,11 +35589,11 @@
3558735589
winShmLeaveMutex();
3558835590
return rc;
3558935591
}
3559035592
3559135593
/*
35592
-** Close a connection to shared-memory. Delete the underlying
35594
+** Close a connection to shared-memory. Delete the underlying
3559335595
** storage if deleteFlag is true.
3559435596
*/
3559535597
static int winShmUnmap(
3559635598
sqlite3_file *fd, /* Database holding shared memory */
3559735599
int deleteFlag /* Delete after closing if true */
@@ -35676,11 +35678,11 @@
3567635678
3567735679
/* Undo the local locks */
3567835680
if( rc==SQLITE_OK ){
3567935681
p->exclMask &= ~mask;
3568035682
p->sharedMask &= ~mask;
35681
- }
35683
+ }
3568235684
}else if( flags & SQLITE_SHM_SHARED ){
3568335685
u16 allShared = 0; /* Union of locks held by connections other than "p" */
3568435686
3568535687
/* Find out which shared locks are already held by sibling connections.
3568635688
** If any sibling already holds an exclusive lock, go ahead and return
@@ -35715,11 +35717,11 @@
3571535717
if( (pX->exclMask & mask)!=0 || (pX->sharedMask & mask)!=0 ){
3571635718
rc = SQLITE_BUSY;
3571735719
break;
3571835720
}
3571935721
}
35720
-
35722
+
3572135723
/* Get the exclusive locks at the system level. Then if successful
3572235724
** also mark the local connection as being locked.
3572335725
*/
3572435726
if( rc==SQLITE_OK ){
3572535727
rc = winShmSystemLock(pShmNode, _SHM_WRLCK, ofst+WIN_SHM_BASE, n);
@@ -35735,11 +35737,11 @@
3573535737
sqlite3ErrName(rc)));
3573635738
return rc;
3573735739
}
3573835740
3573935741
/*
35740
-** Implement a memory barrier or memory fence on shared memory.
35742
+** Implement a memory barrier or memory fence on shared memory.
3574135743
**
3574235744
** All loads and stores begun before the barrier must complete before
3574335745
** any load or store begun after the barrier.
3574435746
*/
3574535747
static void winShmBarrier(
@@ -35750,26 +35752,26 @@
3575035752
winShmEnterMutex();
3575135753
winShmLeaveMutex();
3575235754
}
3575335755
3575435756
/*
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
3575835760
** bytes in size.
3575935761
**
3576035762
** If an error occurs, an error code is returned and *pp is set to NULL.
3576135763
**
3576235764
** Otherwise, if the isWrite parameter is 0 and the requested shared-memory
3576335765
** 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
3576635768
** been allocated, it is allocated by this function.
3576735769
**
3576835770
** 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
3577135773
** memory and SQLITE_OK returned.
3577235774
*/
3577335775
static int winShmMap(
3577435776
sqlite3_file *fd, /* Handle open on database file */
3577535777
int iRegion, /* Region to retrieve */
@@ -35837,21 +35839,21 @@
3583735839
pShmNode->aRegion = apNew;
3583835840
3583935841
while( pShmNode->nRegion<=iRegion ){
3584035842
HANDLE hMap = NULL; /* file-mapping handle */
3584135843
void *pMap = 0; /* Mapped memory region */
35842
-
35844
+
3584335845
#if SQLITE_OS_WINRT
3584435846
hMap = osCreateFileMappingFromApp(pShmNode->hFile.h,
3584535847
NULL, PAGE_READWRITE, nByte, NULL
3584635848
);
3584735849
#elif defined(SQLITE_WIN32_HAS_WIDE)
35848
- hMap = osCreateFileMappingW(pShmNode->hFile.h,
35850
+ hMap = osCreateFileMappingW(pShmNode->hFile.h,
3584935851
NULL, PAGE_READWRITE, 0, nByte, NULL
3585035852
);
3585135853
#elif defined(SQLITE_WIN32_HAS_ANSI)
35852
- hMap = osCreateFileMappingA(pShmNode->hFile.h,
35854
+ hMap = osCreateFileMappingA(pShmNode->hFile.h,
3585335855
NULL, PAGE_READWRITE, 0, nByte, NULL
3585435856
);
3585535857
#endif
3585635858
OSTRACE(("SHM-MAP-CREATE pid=%lu, region=%d, size=%d, rc=%s\n",
3585735859
osGetCurrentProcessId(), pShmNode->nRegion, nByte,
@@ -35944,18 +35946,18 @@
3594435946
return SQLITE_OK;
3594535947
}
3594635948
3594735949
/*
3594835950
** 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
3595135953
** outstanding xFetch() references to it, this function is a no-op.
3595235954
**
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
3595535957
** 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
3595735959
** using SQLITE_FCNTL_MMAP_SIZE, whichever is smaller.
3595835960
**
3595935961
** SQLITE_OK is returned if no error occurs (even if the mapping is not
3596035962
** recreated as a result of outstanding references) or an SQLite error
3596135963
** code otherwise.
@@ -35980,11 +35982,11 @@
3598035982
}
3598135983
if( nMap>pFd->mmapSizeMax ){
3598235984
nMap = pFd->mmapSizeMax;
3598335985
}
3598435986
nMap &= ~(sqlite3_int64)(winSysInfo.dwPageSize - 1);
35985
-
35987
+
3598635988
if( nMap==0 && pFd->mmapSize>0 ){
3598735989
winUnmapfile(pFd);
3598835990
}
3598935991
if( nMap!=pFd->mmapSize ){
3599035992
void *pNew = 0;
@@ -36052,11 +36054,11 @@
3605236054
** If such a pointer can be obtained, store it in *pp and return SQLITE_OK.
3605336055
** Or, if one cannot but no error occurs, set *pp to 0 and return SQLITE_OK.
3605436056
** Finally, if an error does occur, return an SQLite error code. The final
3605536057
** value of *pp is undefined in this case.
3605636058
**
36057
-** If this function does return a pointer, the caller must eventually
36059
+** If this function does return a pointer, the caller must eventually
3605836060
** release the reference by calling winUnfetch().
3605936061
*/
3606036062
static int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){
3606136063
#if SQLITE_MAX_MMAP_SIZE>0
3606236064
winFile *pFd = (winFile*)fd; /* The underlying database file */
@@ -36087,24 +36089,24 @@
3608736089
osGetCurrentProcessId(), fd, pp, *pp));
3608836090
return SQLITE_OK;
3608936091
}
3609036092
3609136093
/*
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
3609336095
** reference obtained by an earlier call to winFetch(). The second
3609436096
** 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.
3609636098
**
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
3609936101
** may now be invalid and should be unmapped.
3610036102
*/
3610136103
static int winUnfetch(sqlite3_file *fd, i64 iOff, void *p){
3610236104
#if SQLITE_MAX_MMAP_SIZE>0
3610336105
winFile *pFd = (winFile*)fd; /* The underlying database file */
3610436106
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
3610636108
** xFetch references. Or, if p!=0 (meaning it is an xFetch reference),
3610736109
** then there must be at least one outstanding. */
3610836110
assert( (p==0)==(pFd->nFetchOut==0) );
3610936111
3611036112
/* If p!=0, it must match the iOff value. */
@@ -36246,11 +36248,11 @@
3624636248
int nMax, nBuf, nDir, nLen;
3624736249
char *zBuf;
3624836250
3624936251
/* It's odd to simulate an io-error here, but really this is just
3625036252
** using the io-error infrastructure to test that SQLite handles this
36251
- ** function failing.
36253
+ ** function failing.
3625236254
*/
3625336255
SimulateIOError( return SQLITE_IOERR );
3625436256
3625536257
/* Allocate a temporary buffer to store the fully qualified file
3625636258
** name for the temporary file. If this fails, we cannot continue.
@@ -36428,11 +36430,11 @@
3642836430
OSTRACE(("TEMP-FILENAME rc=SQLITE_ERROR\n"));
3642936431
return winLogError(SQLITE_ERROR, 0, "winGetTempname4", 0);
3643036432
}
3643136433
3643236434
/*
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
3643436436
** name in the following format:
3643536437
**
3643636438
** "<temporary_directory>/etilqs_XXXXXXXXXXXXXXX\0\0"
3643736439
**
3643836440
** If not, return SQLITE_ERROR. The number 17 is used here in order to
@@ -36531,42 +36533,42 @@
3653136533
int isReadonly = (flags & SQLITE_OPEN_READONLY);
3653236534
int isReadWrite = (flags & SQLITE_OPEN_READWRITE);
3653336535
3653436536
#ifndef NDEBUG
3653536537
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
3653836540
|| eType==SQLITE_OPEN_WAL
3653936541
));
3654036542
#endif
3654136543
3654236544
OSTRACE(("OPEN name=%s, pFile=%p, flags=%x, pOutFlags=%p\n",
3654336545
zUtf8Name, id, flags, pOutFlags));
3654436546
36545
- /* Check the following statements are true:
36547
+ /* Check the following statements are true:
3654636548
**
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
3654836550
** (b) if CREATE is set, then READWRITE must also be set, and
3654936551
** (c) if EXCLUSIVE is set, then CREATE must also be set.
3655036552
** (d) if DELETEONCLOSE is set, then CREATE must also be set.
3655136553
*/
3655236554
assert((isReadonly==0 || isReadWrite==0) && (isReadWrite || isReadonly));
3655336555
assert(isCreate==0 || isReadWrite);
3655436556
assert(isExclusive==0 || isCreate);
3655536557
assert(isDelete==0 || isCreate);
3655636558
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
3655836560
** automatically deleted. Nor are they ever temporary files. */
3655936561
assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_DB );
3656036562
assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_JOURNAL );
3656136563
assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MASTER_JOURNAL );
3656236564
assert( (!isDelete && zName) || eType!=SQLITE_OPEN_WAL );
3656336565
3656436566
/* 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
3656836570
|| eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL
3656936571
);
3657036572
3657136573
assert( pFile!=0 );
3657236574
memset(pFile, 0, sizeof(winFile));
@@ -36577,12 +36579,12 @@
3657736579
sqlite3_log(SQLITE_ERROR,
3657836580
"sqlite3_temp_directory variable should be set for WinRT");
3657936581
}
3658036582
#endif
3658136583
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
3658436586
*/
3658536587
if( !zUtf8Name ){
3658636588
assert( isDelete && !isOpenJournal );
3658736589
rc = winGetTempname(pVfs, &zTmpname);
3658836590
if( rc!=SQLITE_OK ){
@@ -36618,12 +36620,12 @@
3661836620
dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;
3661936621
}else{
3662036622
dwDesiredAccess = GENERIC_READ;
3662136623
}
3662236624
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"
3662536627
** as it is usually understood.
3662636628
*/
3662736629
if( isExclusive ){
3662836630
/* Creates a new file, only if it does not already exist. */
3662936631
/* If the file exists, it fails. */
@@ -36708,11 +36710,11 @@
3670836710
pFile->lastErrno = lastErrno;
3670936711
winLogError(SQLITE_CANTOPEN, pFile->lastErrno, "winOpen", zUtf8Name);
3671036712
sqlite3_free(zConverted);
3671136713
sqlite3_free(zTmpname);
3671236714
if( isReadWrite && !isExclusive ){
36713
- return winOpen(pVfs, zName, id,
36715
+ return winOpen(pVfs, zName, id,
3671436716
((flags|SQLITE_OPEN_READONLY) &
3671536717
~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE)),
3671636718
pOutFlags);
3671736719
}else{
3671836720
return SQLITE_CANTOPEN_BKPT;
@@ -36917,18 +36919,18 @@
3691736919
if( osIsNT() ){
3691836920
int cnt = 0;
3691936921
WIN32_FILE_ATTRIBUTE_DATA sAttrData;
3692036922
memset(&sAttrData, 0, sizeof(sAttrData));
3692136923
while( !(rc = osGetFileAttributesExW((LPCWSTR)zConverted,
36922
- GetFileExInfoStandard,
36924
+ GetFileExInfoStandard,
3692336925
&sAttrData)) && winRetryIoerr(&cnt, &lastErrno) ){}
3692436926
if( rc ){
3692536927
/* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file
3692636928
** as if it does not exist.
3692736929
*/
3692836930
if( flags==SQLITE_ACCESS_EXISTS
36929
- && sAttrData.nFileSizeHigh==0
36931
+ && sAttrData.nFileSizeHigh==0
3693036932
&& sAttrData.nFileSizeLow==0 ){
3693136933
attr = INVALID_FILE_ATTRIBUTES;
3693236934
}else{
3693336935
attr = sAttrData.dwFileAttributes;
3693436936
}
@@ -37023,11 +37025,11 @@
3702337025
sqlite3_vfs *pVfs, /* Pointer to vfs object */
3702437026
const char *zRelative, /* Possibly relative input path */
3702537027
int nFull, /* Size of output buffer in bytes */
3702637028
char *zFull /* Output buffer */
3702737029
){
37028
-
37030
+
3702937031
#if defined(__CYGWIN__)
3703037032
SimulateIOError( return SQLITE_ERROR );
3703137033
UNUSED_PARAMETER(nFull);
3703237034
assert( nFull>=pVfs->mxPathname );
3703337035
if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
@@ -37336,24 +37338,24 @@
3733637338
** the current time and date as a Julian Day number times 86_400_000. In
3733737339
** other words, write into *piNow the number of milliseconds since the Julian
3733837340
** epoch of noon in Greenwich on November 24, 4714 B.C according to the
3733937341
** proleptic Gregorian calendar.
3734037342
**
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
3734237344
** cannot be found.
3734337345
*/
3734437346
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).
3734737349
*/
3734837350
FILETIME ft;
3734937351
static const sqlite3_int64 winFiletimeEpoch = 23058135*(sqlite3_int64)8640000;
3735037352
#ifdef SQLITE_TEST
3735137353
static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000;
3735237354
#endif
3735337355
/* 2^32 - to avoid use of LL and warnings in gcc */
37354
- static const sqlite3_int64 max32BitValue =
37356
+ static const sqlite3_int64 max32BitValue =
3735537357
(sqlite3_int64)2000000000 + (sqlite3_int64)2000000000 +
3735637358
(sqlite3_int64)294967296;
3735737359
3735837360
#if SQLITE_OS_WINCE
3735937361
SYSTEMTIME time;
@@ -37365,11 +37367,11 @@
3736537367
#else
3736637368
osGetSystemTimeAsFileTime( &ft );
3736737369
#endif
3736837370
3736937371
*piNow = winFiletimeEpoch +
37370
- ((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) +
37372
+ ((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) +
3737137373
(sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)10000;
3737237374
3737337375
#ifdef SQLITE_TEST
3737437376
if( sqlite3_current_time ){
3737537377
*piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch;
@@ -37484,11 +37486,11 @@
3748437486
};
3748537487
#endif
3748637488
3748737489
/* Double-check that the aSyscall[] array has been constructed
3748837490
** correctly. See ticket [bb3a86e890c8e96ab] */
37489
- assert( ArraySize(aSyscall)==77 );
37491
+ assert( ArraySize(aSyscall)==76 );
3749037492
3749137493
/* get memory map allocation granularity */
3749237494
memset(&winSysInfo, 0, sizeof(SYSTEM_INFO));
3749337495
#if SQLITE_OS_WINRT
3749437496
osGetNativeSystemInfo(&winSysInfo);
@@ -37502,14 +37504,14 @@
3750237504
3750337505
#if defined(SQLITE_WIN32_HAS_WIDE)
3750437506
sqlite3_vfs_register(&winLongPathVfs, 0);
3750537507
#endif
3750637508
37507
- return SQLITE_OK;
37509
+ return SQLITE_OK;
3750837510
}
3750937511
37510
-SQLITE_API int sqlite3_os_end(void){
37512
+SQLITE_API int sqlite3_os_end(void){
3751137513
#if SQLITE_OS_WINRT
3751237514
if( sleepObj!=NULL ){
3751337515
osCloseHandle(sleepObj);
3751437516
sleepObj = NULL;
3751537517
}
@@ -91665,16 +91667,13 @@
9166591667
** May you do good and not evil.
9166691668
** May you find forgiveness for yourself and forgive others.
9166791669
** May you share freely, never taking more than you give.
9166891670
**
9166991671
*************************************************************************
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.)
9167691675
*/
9167791676
/* #include <stdlib.h> */
9167891677
/* #include <assert.h> */
9167991678
9168091679
/*
9168191680
--- 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 @@
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110110
#define SQLITE_VERSION "3.8.6"
111111
#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"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
118118
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button