Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Update to SQlite 3.7.6.3 [ed1da510a2]. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
9067143122d3b1e60b093da050d48dd1 |
User & Date: | shaneh 2011-06-02 15:17:57 |
Original Comment: | Update to SQlite 3.7.6.3 [ed1da510a2]. |
Context
2011-06-02
| ||
15:31 | Update the version number to 1.0.73.0. check-in: e7dae3da63 user: shaneh tags: trunk | |
15:17 | Update to SQlite 3.7.6.3 [ed1da510a2]. check-in: 9067143122 user: shaneh tags: trunk | |
2011-05-24
| ||
01:39 | Minor optimization to GetBytes() to avoid calling sqlite3_column_blob() on null destination buffers. Fix for [8c1650482e]. check-in: a97d149d1e user: shaneh tags: trunk | |
Changes
Changes to SQLite.Interop/src/core/sqlite3.c.
1 1 /****************************************************************************** 2 2 ** This file is an amalgamation of many separate C source files from SQLite 3 -** version 3.7.6.1. By combining all the individual C code files into this 3 +** version 3.7.6.3. By combining all the individual C code files into this 4 4 ** single large file, the entire code can be compiled as a single translation 5 5 ** unit. This allows many compilers to do optimizations that would not be 6 6 ** possible if the files were compiled separately. Performance improvements 7 7 ** of 5% or more are commonly seen when SQLite is compiled as a single 8 8 ** translation unit. 9 9 ** 10 10 ** This file is all you need to compile SQLite. To use SQLite in other ................................................................................ 646 646 ** string contains the date and time of the check-in (UTC) and an SHA1 647 647 ** hash of the entire source tree. 648 648 ** 649 649 ** See also: [sqlite3_libversion()], 650 650 ** [sqlite3_libversion_number()], [sqlite3_sourceid()], 651 651 ** [sqlite_version()] and [sqlite_source_id()]. 652 652 */ 653 -#define SQLITE_VERSION "3.7.6.1" 653 +#define SQLITE_VERSION "3.7.6.3" 654 654 #define SQLITE_VERSION_NUMBER 3007006 655 -#define SQLITE_SOURCE_ID "2011-04-27 18:08:42 1bd1484cd7e09709d87aa84b82e87597d00a4162" 655 +#define SQLITE_SOURCE_ID "2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e" 656 656 657 657 /* 658 658 ** CAPI3REF: Run-Time Library Version Numbers 659 659 ** KEYWORDS: sqlite3_version, sqlite3_sourceid 660 660 ** 661 661 ** These interfaces provide the same information as the [SQLITE_VERSION], 662 662 ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros ................................................................................ 991 991 #define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8)) 992 992 #define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8)) 993 993 #define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8)) 994 994 #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8)) 995 995 #define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8)) 996 996 #define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8)) 997 997 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8)) 998 -#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8)) 999 -#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8)) 1000 998 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) 1001 999 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) 1002 1000 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) 1003 1001 1004 1002 /* 1005 1003 ** CAPI3REF: Flags For File Open Operations 1006 1004 ** ................................................................................ 17948 17946 int nFull; 17949 17947 void *p; 17950 17948 assert( sqlite3_mutex_held(mem0.mutex) ); 17951 17949 nFull = sqlite3GlobalConfig.m.xRoundup(n); 17952 17950 sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, n); 17953 17951 if( mem0.alarmCallback!=0 ){ 17954 17952 int nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); 17955 - if( nUsed >= mem0.alarmThreshold - nFull ){ 17953 + if( nUsed+nFull >= mem0.alarmThreshold ){ 17956 17954 mem0.nearlyFull = 1; 17957 17955 sqlite3MallocAlarm(nFull); 17958 17956 }else{ 17959 17957 mem0.nearlyFull = 0; 17960 17958 } 17961 17959 } 17962 17960 p = sqlite3GlobalConfig.m.xMalloc(nFull); ................................................................................ 18189 18187 sqlite3_free(p); 18190 18188 } 18191 18189 18192 18190 /* 18193 18191 ** Change the size of an existing memory allocation 18194 18192 */ 18195 18193 SQLITE_PRIVATE void *sqlite3Realloc(void *pOld, int nBytes){ 18196 - int nOld, nNew, nDiff; 18194 + int nOld, nNew; 18197 18195 void *pNew; 18198 18196 if( pOld==0 ){ 18199 18197 return sqlite3Malloc(nBytes); /* IMP: R-28354-25769 */ 18200 18198 } 18201 18199 if( nBytes<=0 ){ 18202 18200 sqlite3_free(pOld); /* IMP: R-31593-10574 */ 18203 18201 return 0; ................................................................................ 18212 18210 ** xRoundup. */ 18213 18211 nNew = sqlite3GlobalConfig.m.xRoundup(nBytes); 18214 18212 if( nOld==nNew ){ 18215 18213 pNew = pOld; 18216 18214 }else if( sqlite3GlobalConfig.bMemstat ){ 18217 18215 sqlite3_mutex_enter(mem0.mutex); 18218 18216 sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, nBytes); 18219 - nDiff = nNew - nOld; 18220 - if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED) >= 18221 - mem0.alarmThreshold-nDiff ){ 18217 + if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED)+nNew-nOld >= 18218 + mem0.alarmThreshold ){ 18222 18219 sqlite3MallocAlarm(nNew-nOld); 18223 18220 } 18224 18221 assert( sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP) ); 18225 18222 assert( sqlite3MemdebugNoType(pOld, ~MEMTYPE_HEAP) ); 18226 18223 pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew); 18227 18224 if( pNew==0 && mem0.alarmCallback ){ 18228 18225 sqlite3MallocAlarm(nBytes); 18229 18226 pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew); 18230 18227 } 18231 18228 if( pNew ){ 18232 18229 nNew = sqlite3MallocSize(pNew); 18233 - sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nDiff); 18230 + sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nNew-nOld); 18234 18231 } 18235 18232 sqlite3_mutex_leave(mem0.mutex); 18236 18233 }else{ 18237 18234 pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew); 18238 18235 } 18239 18236 assert( EIGHT_BYTE_ALIGNMENT(pNew) ); /* IMP: R-04675-44850 */ 18240 18237 return pNew; ................................................................................ 24400 24397 */ 24401 24398 #if SQLITE_THREADSAFE 24402 24399 #define threadid pthread_self() 24403 24400 #else 24404 24401 #define threadid 0 24405 24402 #endif 24406 24403 24407 -/* 24408 -** Different Unix systems declare open() in different ways. Same use 24409 -** open(const char*,int,mode_t). Others use open(const char*,int,...). 24410 -** The difference is important when using a pointer to the function. 24411 -** 24412 -** The safest way to deal with the problem is to always use this wrapper 24413 -** which always has the same well-defined interface. 24414 -*/ 24415 -static int posixOpen(const char *zFile, int flags, int mode){ 24416 - return open(zFile, flags, mode); 24417 -} 24418 - 24419 24404 /* 24420 24405 ** Many system calls are accessed through pointer-to-functions so that 24421 24406 ** they may be overridden at runtime to facilitate fault injection during 24422 24407 ** testing and sandboxing. The following array holds the names and pointers 24423 24408 ** to all overrideable system calls. 24424 24409 */ 24425 24410 static struct unix_syscall { 24426 24411 const char *zName; /* Name of the sytem call */ 24427 24412 sqlite3_syscall_ptr pCurrent; /* Current value of the system call */ 24428 24413 sqlite3_syscall_ptr pDefault; /* Default value */ 24429 24414 } aSyscall[] = { 24430 - { "open", (sqlite3_syscall_ptr)posixOpen, 0 }, 24431 -#define osOpen ((int(*)(const char*,int,int))aSyscall[0].pCurrent) 24415 + { "open", (sqlite3_syscall_ptr)open, 0 }, 24416 +#define osOpen ((int(*)(const char*,int,...))aSyscall[0].pCurrent) 24432 24417 24433 24418 { "close", (sqlite3_syscall_ptr)close, 0 }, 24434 24419 #define osClose ((int(*)(int))aSyscall[1].pCurrent) 24435 24420 24436 24421 { "access", (sqlite3_syscall_ptr)access, 0 }, 24437 24422 #define osAccess ((int(*)(const char*,int))aSyscall[2].pCurrent) 24438 24423 ................................................................................ 24461 24446 24462 24447 { "fcntl", (sqlite3_syscall_ptr)fcntl, 0 }, 24463 24448 #define osFcntl ((int(*)(int,int,...))aSyscall[7].pCurrent) 24464 24449 24465 24450 { "read", (sqlite3_syscall_ptr)read, 0 }, 24466 24451 #define osRead ((ssize_t(*)(int,void*,size_t))aSyscall[8].pCurrent) 24467 24452 24468 -#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE 24453 +#if defined(USE_PREAD) || defined(SQLITE_ENABLE_LOCKING_STYLE) 24469 24454 { "pread", (sqlite3_syscall_ptr)pread, 0 }, 24470 24455 #else 24471 24456 { "pread", (sqlite3_syscall_ptr)0, 0 }, 24472 24457 #endif 24473 24458 #define osPread ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[9].pCurrent) 24474 24459 24475 24460 #if defined(USE_PREAD64) ................................................................................ 24478 24463 { "pread64", (sqlite3_syscall_ptr)0, 0 }, 24479 24464 #endif 24480 24465 #define osPread64 ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[10].pCurrent) 24481 24466 24482 24467 { "write", (sqlite3_syscall_ptr)write, 0 }, 24483 24468 #define osWrite ((ssize_t(*)(int,const void*,size_t))aSyscall[11].pCurrent) 24484 24469 24485 -#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE 24470 +#if defined(USE_PREAD) || defined(SQLITE_ENABLE_LOCKING_STYLE) 24486 24471 { "pwrite", (sqlite3_syscall_ptr)pwrite, 0 }, 24487 24472 #else 24488 24473 { "pwrite", (sqlite3_syscall_ptr)0, 0 }, 24489 24474 #endif 24490 24475 #define osPwrite ((ssize_t(*)(int,const void*,size_t,off_t))\ 24491 24476 aSyscall[12].pCurrent) 24492 24477 ................................................................................ 25064 25049 unsigned char bProcessLock; /* An exclusive process lock is held */ 25065 25050 int nRef; /* Number of pointers to this structure */ 25066 25051 unixShmNode *pShmNode; /* Shared memory associated with this inode */ 25067 25052 int nLock; /* Number of outstanding file locks */ 25068 25053 UnixUnusedFd *pUnused; /* Unused file descriptors to close */ 25069 25054 unixInodeInfo *pNext; /* List of all unixInodeInfo objects */ 25070 25055 unixInodeInfo *pPrev; /* .... doubly linked */ 25071 -#if SQLITE_ENABLE_LOCKING_STYLE 25056 +#if defined(SQLITE_ENABLE_LOCKING_STYLE) 25072 25057 unsigned long long sharedByte; /* for AFP simulated shared lock */ 25073 25058 #endif 25074 25059 #if OS_VXWORKS 25075 25060 sem_t *pSem; /* Named POSIX semaphore */ 25076 25061 char aSemName[MAX_PATHNAME+2]; /* Name of that semaphore */ 25077 25062 #endif 25078 25063 }; ................................................................................ 27221 27206 offset += wrote; 27222 27207 pBuf = &((char*)pBuf)[wrote]; 27223 27208 } 27224 27209 SimulateIOError(( wrote=(-1), amt=1 )); 27225 27210 SimulateDiskfullError(( wrote=0, amt=1 )); 27226 27211 27227 27212 if( amt>0 ){ 27228 - if( wrote<0 && pFile->lastErrno!=ENOSPC ){ 27213 + if( wrote<0 ){ 27229 27214 /* lastErrno set by seekAndWrite */ 27230 27215 return SQLITE_IOERR_WRITE; 27231 27216 }else{ 27232 27217 pFile->lastErrno = 0; /* not a system error */ 27233 27218 return SQLITE_FULL; 27234 27219 } 27235 27220 } ................................................................................ 28046 28031 while(pShmNode->nRegion<=iRegion){ 28047 28032 void *pMem; 28048 28033 if( pShmNode->h>=0 ){ 28049 28034 pMem = mmap(0, szRegion, PROT_READ|PROT_WRITE, 28050 28035 MAP_SHARED, pShmNode->h, pShmNode->nRegion*szRegion 28051 28036 ); 28052 28037 if( pMem==MAP_FAILED ){ 28053 - rc = unixLogError(SQLITE_IOERR_SHMMAP, "mmap", pShmNode->zFilename); 28038 + rc = SQLITE_IOERR; 28054 28039 goto shmpage_out; 28055 28040 } 28056 28041 }else{ 28057 28042 pMem = sqlite3_malloc(szRegion); 28058 28043 if( pMem==0 ){ 28059 28044 rc = SQLITE_NOMEM; 28060 28045 goto shmpage_out; ................................................................................ 31167 31152 HANDLE hMutex; /* Mutex used to control access to shared lock */ 31168 31153 HANDLE hShared; /* Shared memory segment used for locking */ 31169 31154 winceLock local; /* Locks obtained by this instance of winFile */ 31170 31155 winceLock *shared; /* Global shared lock memory for the file */ 31171 31156 #endif 31172 31157 }; 31173 31158 31174 - 31175 31159 /* 31176 31160 ** Forward prototypes. 31177 31161 */ 31178 31162 static int getSectorSize( 31179 31163 sqlite3_vfs *pVfs, 31180 31164 const char *zRelative /* UTF-8 file name */ 31181 31165 ); ................................................................................ 31335 31319 return zFilenameUtf8; 31336 31320 } 31337 31321 31338 31322 /* 31339 31323 ** Convert UTF-8 to multibyte character string. Space to hold the 31340 31324 ** returned string is obtained from malloc(). 31341 31325 */ 31342 -SQLITE_API char *sqlite3_win32_utf8_to_mbcs(const char *zFilename){ 31326 +static char *utf8ToMbcs(const char *zFilename){ 31343 31327 char *zFilenameMbcs; 31344 31328 WCHAR *zTmpWide; 31345 31329 31346 31330 zTmpWide = utf8ToUnicode(zFilename); 31347 31331 if( zTmpWide==0 ){ 31348 31332 return 0; 31349 31333 } 31350 31334 zFilenameMbcs = unicodeToMbcs(zTmpWide); 31351 31335 free(zTmpWide); 31352 31336 return zFilenameMbcs; 31353 31337 } 31354 31338 31355 - 31356 -/* 31357 -** The return value of getLastErrorMsg 31358 -** is zero if the error message fits in the buffer, or non-zero 31359 -** otherwise (if the message was truncated). 31360 -*/ 31361 -static int getLastErrorMsg(int nBuf, char *zBuf){ 31362 - /* FormatMessage returns 0 on failure. Otherwise it 31363 - ** returns the number of TCHARs written to the output 31364 - ** buffer, excluding the terminating null char. 31365 - */ 31366 - DWORD error = GetLastError(); 31367 - DWORD dwLen = 0; 31368 - char *zOut = 0; 31369 - 31370 - if( isNT() ){ 31371 - WCHAR *zTempWide = NULL; 31372 - dwLen = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 31373 - NULL, 31374 - error, 31375 - 0, 31376 - (LPWSTR) &zTempWide, 31377 - 0, 31378 - 0); 31379 - if( dwLen > 0 ){ 31380 - /* allocate a buffer and convert to UTF8 */ 31381 - zOut = unicodeToUtf8(zTempWide); 31382 - /* free the system buffer allocated by FormatMessage */ 31383 - LocalFree(zTempWide); 31384 - } 31385 -/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. 31386 -** Since the ASCII version of these Windows API do not exist for WINCE, 31387 -** it's important to not reference them for WINCE builds. 31388 -*/ 31389 -#if SQLITE_OS_WINCE==0 31390 - }else{ 31391 - char *zTemp = NULL; 31392 - dwLen = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 31393 - NULL, 31394 - error, 31395 - 0, 31396 - (LPSTR) &zTemp, 31397 - 0, 31398 - 0); 31399 - if( dwLen > 0 ){ 31400 - /* allocate a buffer and convert to UTF8 */ 31401 - zOut = sqlite3_win32_mbcs_to_utf8(zTemp); 31402 - /* free the system buffer allocated by FormatMessage */ 31403 - LocalFree(zTemp); 31404 - } 31405 -#endif 31406 - } 31407 - if( 0 == dwLen ){ 31408 - sqlite3_snprintf(nBuf, zBuf, "OsError 0x%x (%u)", error, error); 31409 - }else{ 31410 - /* copy a maximum of nBuf chars to output buffer */ 31411 - sqlite3_snprintf(nBuf, zBuf, "%s", zOut); 31412 - /* free the UTF8 buffer */ 31413 - free(zOut); 31414 - } 31415 - return 0; 31416 -} 31417 - 31418 -/* 31419 -** 31420 -** This function - winLogErrorAtLine() - is only ever called via the macro 31421 -** winLogError(). 31422 -** 31423 -** This routine is invoked after an error occurs in an OS function. 31424 -** It logs a message using sqlite3_log() containing the current value of 31425 -** error code and, if possible, the human-readable equivalent from 31426 -** FormatMessage. 31427 -** 31428 -** The first argument passed to the macro should be the error code that 31429 -** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN). 31430 -** The two subsequent arguments should be the name of the OS function that 31431 -** failed and the the associated file-system path, if any. 31432 -*/ 31433 -#define winLogError(a,b,c) winLogErrorAtLine(a,b,c,__LINE__) 31434 -static int winLogErrorAtLine( 31435 - int errcode, /* SQLite error code */ 31436 - const char *zFunc, /* Name of OS function that failed */ 31437 - const char *zPath, /* File path associated with error */ 31438 - int iLine /* Source line number where error occurred */ 31439 -){ 31440 - char zMsg[500]; /* Human readable error text */ 31441 - int i; /* Loop counter */ 31442 - DWORD iErrno = GetLastError(); /* Error code */ 31443 - 31444 - zMsg[0] = 0; 31445 - getLastErrorMsg(sizeof(zMsg), zMsg); 31446 - assert( errcode!=SQLITE_OK ); 31447 - if( zPath==0 ) zPath = ""; 31448 - for(i=0; zMsg[i] && zMsg[i]!='\r' && zMsg[i]!='\n'; i++){} 31449 - zMsg[i] = 0; 31450 - sqlite3_log(errcode, 31451 - "os_win.c:%d: (%d) %s(%s) - %s", 31452 - iLine, iErrno, zFunc, zPath, zMsg 31453 - ); 31454 - 31455 - return errcode; 31456 -} 31457 - 31458 31339 #if SQLITE_OS_WINCE 31459 31340 /************************************************************************* 31460 31341 ** This section contains code for WinCE only. 31461 31342 */ 31462 31343 /* 31463 31344 ** WindowsCE does not have a localtime() function. So create a 31464 31345 ** substitute. ................................................................................ 31527 31408 if (*zTok == '\\') *zTok = '_'; 31528 31409 } 31529 31410 31530 31411 /* Create/open the named mutex */ 31531 31412 pFile->hMutex = CreateMutexW(NULL, FALSE, zName); 31532 31413 if (!pFile->hMutex){ 31533 31414 pFile->lastErrno = GetLastError(); 31534 - winLogError(SQLITE_ERROR, "winceCreateLock1", zFilename); 31535 31415 free(zName); 31536 31416 return FALSE; 31537 31417 } 31538 31418 31539 31419 /* Acquire the mutex before continuing */ 31540 31420 winceMutexAcquire(pFile->hMutex); 31541 31421 ................................................................................ 31559 31439 /* If we succeeded in making the shared memory handle, map it. */ 31560 31440 if (pFile->hShared){ 31561 31441 pFile->shared = (winceLock*)MapViewOfFile(pFile->hShared, 31562 31442 FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, sizeof(winceLock)); 31563 31443 /* If mapping failed, close the shared memory handle and erase it */ 31564 31444 if (!pFile->shared){ 31565 31445 pFile->lastErrno = GetLastError(); 31566 - winLogError(SQLITE_ERROR, "winceCreateLock2", zFilename); 31567 31446 CloseHandle(pFile->hShared); 31568 31447 pFile->hShared = NULL; 31569 31448 } 31570 31449 } 31571 31450 31572 31451 /* If shared memory could not be created, then close the mutex and fail */ 31573 31452 if (pFile->hShared == NULL){ ................................................................................ 31805 31684 ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine 31806 31685 ** whether an error has actually occured, it is also necessary to call 31807 31686 ** GetLastError(). 31808 31687 */ 31809 31688 dwRet = SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN); 31810 31689 if( (dwRet==INVALID_SET_FILE_POINTER && GetLastError()!=NO_ERROR) ){ 31811 31690 pFile->lastErrno = GetLastError(); 31812 - winLogError(SQLITE_IOERR_SEEK, "seekWinFile", pFile->zPath); 31813 31691 return 1; 31814 31692 } 31815 31693 31816 31694 return 0; 31817 31695 } 31818 31696 31819 31697 /* ................................................................................ 31851 31729 Sleep(100); /* Wait a little before trying again */ 31852 31730 } 31853 31731 free(pFile->zDeleteOnClose); 31854 31732 } 31855 31733 #endif 31856 31734 OSTRACE(("CLOSE %d %s\n", pFile->h, rc ? "ok" : "failed")); 31857 31735 OpenCounter(-1); 31858 - return rc ? SQLITE_OK 31859 - : winLogError(SQLITE_IOERR_CLOSE, "winClose", pFile->zPath); 31736 + return rc ? SQLITE_OK : SQLITE_IOERR; 31860 31737 } 31861 31738 31862 31739 /* 31863 31740 ** Read data from a file into a buffer. Return SQLITE_OK if all 31864 31741 ** bytes were read successfully and SQLITE_IOERR if anything goes 31865 31742 ** wrong. 31866 31743 */ ................................................................................ 31878 31755 OSTRACE(("READ %d lock=%d\n", pFile->h, pFile->locktype)); 31879 31756 31880 31757 if( seekWinFile(pFile, offset) ){ 31881 31758 return SQLITE_FULL; 31882 31759 } 31883 31760 if( !ReadFile(pFile->h, pBuf, amt, &nRead, 0) ){ 31884 31761 pFile->lastErrno = GetLastError(); 31885 - return winLogError(SQLITE_IOERR_READ, "winRead", pFile->zPath); 31762 + return SQLITE_IOERR_READ; 31886 31763 } 31887 31764 if( nRead<(DWORD)amt ){ 31888 31765 /* Unread parts of the buffer must be zero-filled */ 31889 31766 memset(&((char*)pBuf)[nRead], 0, amt-nRead); 31890 31767 return SQLITE_IOERR_SHORT_READ; 31891 31768 } 31892 31769 ................................................................................ 31929 31806 } 31930 31807 } 31931 31808 31932 31809 if( rc ){ 31933 31810 if( pFile->lastErrno==ERROR_HANDLE_DISK_FULL ){ 31934 31811 return SQLITE_FULL; 31935 31812 } 31936 - return winLogError(SQLITE_IOERR_WRITE, "winWrite", pFile->zPath); 31813 + return SQLITE_IOERR_WRITE; 31937 31814 } 31938 31815 return SQLITE_OK; 31939 31816 } 31940 31817 31941 31818 /* 31942 31819 ** Truncate an open file to a specified size 31943 31820 */ ................................................................................ 31957 31834 */ 31958 31835 if( pFile->szChunk ){ 31959 31836 nByte = ((nByte + pFile->szChunk - 1)/pFile->szChunk) * pFile->szChunk; 31960 31837 } 31961 31838 31962 31839 /* SetEndOfFile() returns non-zero when successful, or zero when it fails. */ 31963 31840 if( seekWinFile(pFile, nByte) ){ 31964 - rc = winLogError(SQLITE_IOERR_TRUNCATE, "winTruncate1", pFile->zPath); 31841 + rc = SQLITE_IOERR_TRUNCATE; 31965 31842 }else if( 0==SetEndOfFile(pFile->h) ){ 31966 31843 pFile->lastErrno = GetLastError(); 31967 - rc = winLogError(SQLITE_IOERR_TRUNCATE, "winTruncate2", pFile->zPath); 31844 + rc = SQLITE_IOERR_TRUNCATE; 31968 31845 } 31969 31846 31970 31847 OSTRACE(("TRUNCATE %d %lld %s\n", pFile->h, nByte, rc ? "failed" : "ok")); 31971 31848 return rc; 31972 31849 } 31973 31850 31974 31851 #ifdef SQLITE_TEST ................................................................................ 31982 31859 31983 31860 /* 31984 31861 ** Make sure all writes to a particular file are committed to disk. 31985 31862 */ 31986 31863 static int winSync(sqlite3_file *id, int flags){ 31987 31864 #if !defined(NDEBUG) || !defined(SQLITE_NO_SYNC) || defined(SQLITE_DEBUG) 31988 31865 winFile *pFile = (winFile*)id; 31989 - BOOL rc; 31990 31866 #else 31991 31867 UNUSED_PARAMETER(id); 31992 31868 #endif 31993 31869 31994 31870 assert( pFile ); 31995 31871 /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */ 31996 31872 assert((flags&0x0F)==SQLITE_SYNC_NORMAL 31997 31873 || (flags&0x0F)==SQLITE_SYNC_FULL 31998 31874 ); 31999 31875 32000 31876 OSTRACE(("SYNC %d lock=%d\n", pFile->h, pFile->locktype)); 32001 31877 32002 - /* Unix cannot, but some systems may return SQLITE_FULL from here. This 32003 - ** line is to test that doing so does not cause any problems. 32004 - */ 32005 - SimulateDiskfullError( return SQLITE_FULL ); 32006 - 32007 31878 #ifndef SQLITE_TEST 32008 31879 UNUSED_PARAMETER(flags); 32009 31880 #else 32010 - if( (flags&0x0F)==SQLITE_SYNC_FULL ){ 31881 + if( flags & SQLITE_SYNC_FULL ){ 32011 31882 sqlite3_fullsync_count++; 32012 31883 } 32013 31884 sqlite3_sync_count++; 32014 31885 #endif 31886 + 31887 + /* Unix cannot, but some systems may return SQLITE_FULL from here. This 31888 + ** line is to test that doing so does not cause any problems. 31889 + */ 31890 + SimulateDiskfullError( return SQLITE_FULL ); 31891 + SimulateIOError( return SQLITE_IOERR; ); 32015 31892 32016 31893 /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a 32017 31894 ** no-op 32018 31895 */ 32019 31896 #ifdef SQLITE_NO_SYNC 32020 31897 return SQLITE_OK; 32021 31898 #else 32022 - rc = FlushFileBuffers(pFile->h); 32023 - SimulateIOError( rc=FALSE ); 32024 - if( rc ){ 31899 + if( FlushFileBuffers(pFile->h) ){ 32025 31900 return SQLITE_OK; 32026 31901 }else{ 32027 31902 pFile->lastErrno = GetLastError(); 32028 - return winLogError(SQLITE_IOERR_FSYNC, "winSync", pFile->zPath); 31903 + return SQLITE_IOERR; 32029 31904 } 32030 31905 #endif 32031 31906 } 32032 31907 32033 31908 /* 32034 31909 ** Determine the current size of a file in bytes 32035 31910 */ ................................................................................ 32042 31917 assert( id!=0 ); 32043 31918 SimulateIOError(return SQLITE_IOERR_FSTAT); 32044 31919 lowerBits = GetFileSize(pFile->h, &upperBits); 32045 31920 if( (lowerBits == INVALID_FILE_SIZE) 32046 31921 && ((error = GetLastError()) != NO_ERROR) ) 32047 31922 { 32048 31923 pFile->lastErrno = error; 32049 - return winLogError(SQLITE_IOERR_FSTAT, "winFileSize", pFile->zPath); 31924 + return SQLITE_IOERR_FSTAT; 32050 31925 } 32051 31926 *pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits; 32052 31927 return SQLITE_OK; 32053 31928 } 32054 31929 32055 31930 /* 32056 31931 ** LOCKFILE_FAIL_IMMEDIATELY is undefined on some Windows systems. ................................................................................ 32081 31956 sqlite3_randomness(sizeof(lk), &lk); 32082 31957 pFile->sharedLockByte = (short)((lk & 0x7fffffff)%(SHARED_SIZE - 1)); 32083 31958 res = LockFile(pFile->h, SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0); 32084 31959 #endif 32085 31960 } 32086 31961 if( res == 0 ){ 32087 31962 pFile->lastErrno = GetLastError(); 32088 - /* No need to log a failure to lock */ 32089 31963 } 32090 31964 return res; 32091 31965 } 32092 31966 32093 31967 /* 32094 31968 ** Undo a readlock 32095 31969 */ ................................................................................ 32102 31976 #if SQLITE_OS_WINCE==0 32103 31977 }else{ 32104 31978 res = UnlockFile(pFile->h, SHARED_FIRST + pFile->sharedLockByte, 0, 1, 0); 32105 31979 #endif 32106 31980 } 32107 31981 if( res == 0 ){ 32108 31982 pFile->lastErrno = GetLastError(); 32109 - winLogError(SQLITE_IOERR_UNLOCK, "unlockReadLock", pFile->zPath); 32110 31983 } 32111 31984 return res; 32112 31985 } 32113 31986 32114 31987 /* 32115 31988 ** Lock the file with the lock specified by parameter locktype - one 32116 31989 ** of the following: ................................................................................ 32303 32176 pFile->locktype, pFile->sharedLockByte)); 32304 32177 type = pFile->locktype; 32305 32178 if( type>=EXCLUSIVE_LOCK ){ 32306 32179 UnlockFile(pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0); 32307 32180 if( locktype==SHARED_LOCK && !getReadLock(pFile) ){ 32308 32181 /* This should never happen. We should always be able to 32309 32182 ** reacquire the read lock */ 32310 - rc = winLogError(SQLITE_IOERR_UNLOCK, "winUnlock", pFile->zPath); 32183 + rc = SQLITE_IOERR_UNLOCK; 32311 32184 } 32312 32185 } 32313 32186 if( type>=RESERVED_LOCK ){ 32314 32187 UnlockFile(pFile->h, RESERVED_BYTE, 0, 1, 0); 32315 32188 } 32316 32189 if( locktype==NO_LOCK && type>=SHARED_LOCK ){ 32317 32190 unlockReadLock(pFile); ................................................................................ 32660 32533 32661 32534 /* Check to see if another process is holding the dead-man switch. 32662 32535 ** If not, truncate the file to zero length. 32663 32536 */ 32664 32537 if( winShmSystemLock(pShmNode, _SHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){ 32665 32538 rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0); 32666 32539 if( rc!=SQLITE_OK ){ 32667 - rc = winLogError(SQLITE_IOERR_SHMOPEN, "winOpenShm", pDbFd->zPath); 32540 + rc = SQLITE_IOERR_SHMOPEN; 32668 32541 } 32669 32542 } 32670 32543 if( rc==SQLITE_OK ){ 32671 32544 winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1); 32672 32545 rc = winShmSystemLock(pShmNode, _SHM_RDLCK, WIN_SHM_DMS, 1); 32673 32546 } 32674 32547 if( rc ) goto shm_open_err; ................................................................................ 32919 32792 32920 32793 /* The requested region is not mapped into this processes address space. 32921 32794 ** Check to see if it has been allocated (i.e. if the wal-index file is 32922 32795 ** large enough to contain the requested region). 32923 32796 */ 32924 32797 rc = winFileSize((sqlite3_file *)&pShmNode->hFile, &sz); 32925 32798 if( rc!=SQLITE_OK ){ 32926 - rc = winLogError(SQLITE_IOERR_SHMSIZE, "winShmMap1", pDbFd->zPath); 32799 + rc = SQLITE_IOERR_SHMSIZE; 32927 32800 goto shmpage_out; 32928 32801 } 32929 32802 32930 32803 if( sz<nByte ){ 32931 32804 /* The requested memory region does not exist. If isWrite is set to 32932 32805 ** zero, exit early. *pp will be set to NULL and SQLITE_OK returned. 32933 32806 ** 32934 32807 ** Alternatively, if isWrite is non-zero, use ftruncate() to allocate 32935 32808 ** the requested memory region. 32936 32809 */ 32937 32810 if( !isWrite ) goto shmpage_out; 32938 32811 rc = winTruncate((sqlite3_file *)&pShmNode->hFile, nByte); 32939 32812 if( rc!=SQLITE_OK ){ 32940 - rc = winLogError(SQLITE_IOERR_SHMSIZE, "winShmMap2", pDbFd->zPath); 32813 + rc = SQLITE_IOERR_SHMSIZE; 32941 32814 goto shmpage_out; 32942 32815 } 32943 32816 } 32944 32817 32945 32818 /* Map the requested memory region into this processes address space. */ 32946 32819 apNew = (struct ShmRegion *)sqlite3_realloc( 32947 32820 pShmNode->aRegion, (iRegion+1)*sizeof(apNew[0]) ................................................................................ 32970 32843 ); 32971 32844 OSTRACE(("SHM-MAP pid-%d map region=%d offset=%d size=%d %s\n", 32972 32845 (int)GetCurrentProcessId(), pShmNode->nRegion, iOffset, szRegion, 32973 32846 pMap ? "ok" : "failed")); 32974 32847 } 32975 32848 if( !pMap ){ 32976 32849 pShmNode->lastErrno = GetLastError(); 32977 - rc = winLogError(SQLITE_IOERR_SHMMAP, "winShmMap3", pDbFd->zPath); 32850 + rc = SQLITE_IOERR; 32978 32851 if( hMap ) CloseHandle(hMap); 32979 32852 goto shmpage_out; 32980 32853 } 32981 32854 32982 32855 pShmNode->aRegion[pShmNode->nRegion].pMap = pMap; 32983 32856 pShmNode->aRegion[pShmNode->nRegion].hMap = hMap; 32984 32857 pShmNode->nRegion++; ................................................................................ 33052 32925 void *zConverted = 0; 33053 32926 if( isNT() ){ 33054 32927 zConverted = utf8ToUnicode(zFilename); 33055 32928 /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. 33056 32929 */ 33057 32930 #if SQLITE_OS_WINCE==0 33058 32931 }else{ 33059 - zConverted = sqlite3_win32_utf8_to_mbcs(zFilename); 32932 + zConverted = utf8ToMbcs(zFilename); 33060 32933 #endif 33061 32934 } 33062 32935 /* caller will handle out of memory */ 33063 32936 return zConverted; 33064 32937 } 33065 32938 33066 32939 /* ................................................................................ 33131 33004 zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; 33132 33005 } 33133 33006 zBuf[j] = 0; 33134 33007 33135 33008 OSTRACE(("TEMP FILENAME: %s\n", zBuf)); 33136 33009 return SQLITE_OK; 33137 33010 } 33011 + 33012 +/* 33013 +** The return value of getLastErrorMsg 33014 +** is zero if the error message fits in the buffer, or non-zero 33015 +** otherwise (if the message was truncated). 33016 +*/ 33017 +static int getLastErrorMsg(int nBuf, char *zBuf){ 33018 + /* FormatMessage returns 0 on failure. Otherwise it 33019 + ** returns the number of TCHARs written to the output 33020 + ** buffer, excluding the terminating null char. 33021 + */ 33022 + DWORD error = GetLastError(); 33023 + DWORD dwLen = 0; 33024 + char *zOut = 0; 33025 + 33026 + if( isNT() ){ 33027 + WCHAR *zTempWide = NULL; 33028 + dwLen = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 33029 + NULL, 33030 + error, 33031 + 0, 33032 + (LPWSTR) &zTempWide, 33033 + 0, 33034 + 0); 33035 + if( dwLen > 0 ){ 33036 + /* allocate a buffer and convert to UTF8 */ 33037 + zOut = unicodeToUtf8(zTempWide); 33038 + /* free the system buffer allocated by FormatMessage */ 33039 + LocalFree(zTempWide); 33040 + } 33041 +/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. 33042 +** Since the ASCII version of these Windows API do not exist for WINCE, 33043 +** it's important to not reference them for WINCE builds. 33044 +*/ 33045 +#if SQLITE_OS_WINCE==0 33046 + }else{ 33047 + char *zTemp = NULL; 33048 + dwLen = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 33049 + NULL, 33050 + error, 33051 + 0, 33052 + (LPSTR) &zTemp, 33053 + 0, 33054 + 0); 33055 + if( dwLen > 0 ){ 33056 + /* allocate a buffer and convert to UTF8 */ 33057 + zOut = sqlite3_win32_mbcs_to_utf8(zTemp); 33058 + /* free the system buffer allocated by FormatMessage */ 33059 + LocalFree(zTemp); 33060 + } 33061 +#endif 33062 + } 33063 + if( 0 == dwLen ){ 33064 + sqlite3_snprintf(nBuf, zBuf, "OsError 0x%x (%u)", error, error); 33065 + }else{ 33066 + /* copy a maximum of nBuf chars to output buffer */ 33067 + sqlite3_snprintf(nBuf, zBuf, "%s", zOut); 33068 + /* free the UTF8 buffer */ 33069 + free(zOut); 33070 + } 33071 + return 0; 33072 +} 33138 33073 33139 33074 /* 33140 33075 ** Open a file. 33141 33076 */ 33142 33077 static int winOpen( 33143 33078 sqlite3_vfs *pVfs, /* Not used */ 33144 33079 const char *zName, /* Name of the file (UTF-8) */ ................................................................................ 33303 33238 33304 33239 OSTRACE(("OPEN %d %s 0x%lx %s\n", 33305 33240 h, zName, dwDesiredAccess, 33306 33241 h==INVALID_HANDLE_VALUE ? "failed" : "ok")); 33307 33242 33308 33243 if( h==INVALID_HANDLE_VALUE ){ 33309 33244 pFile->lastErrno = GetLastError(); 33310 - winLogError(SQLITE_CANTOPEN, "winOpen", zUtf8Name); 33311 33245 free(zConverted); 33312 33246 if( isReadWrite ){ 33313 33247 return winOpen(pVfs, zName, id, 33314 33248 ((flags|SQLITE_OPEN_READONLY)&~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE)), pOutFlags); 33315 33249 }else{ 33316 33250 return SQLITE_CANTOPEN_BKPT; 33317 33251 } ................................................................................ 33407 33341 } 33408 33342 free(zConverted); 33409 33343 OSTRACE(("DELETE \"%s\" %s\n", zFilename, 33410 33344 ( (rc==INVALID_FILE_ATTRIBUTES) && (error==ERROR_FILE_NOT_FOUND)) ? 33411 33345 "ok" : "failed" )); 33412 33346 33413 33347 return ( (rc == INVALID_FILE_ATTRIBUTES) 33414 - && (error == ERROR_FILE_NOT_FOUND)) ? SQLITE_OK : 33415 - winLogError(SQLITE_IOERR_DELETE, "winDelete", zFilename); 33348 + && (error == ERROR_FILE_NOT_FOUND)) ? SQLITE_OK : SQLITE_IOERR_DELETE; 33416 33349 } 33417 33350 33418 33351 /* 33419 33352 ** Check the existance and status of a file. 33420 33353 */ 33421 33354 static int winAccess( 33422 33355 sqlite3_vfs *pVfs, /* Not used on win32 */ ................................................................................ 33448 33381 && sAttrData.nFileSizeLow==0 ){ 33449 33382 attr = INVALID_FILE_ATTRIBUTES; 33450 33383 }else{ 33451 33384 attr = sAttrData.dwFileAttributes; 33452 33385 } 33453 33386 }else{ 33454 33387 if( GetLastError()!=ERROR_FILE_NOT_FOUND ){ 33455 - winLogError(SQLITE_IOERR_ACCESS, "winAccess", zFilename); 33456 33388 free(zConverted); 33457 33389 return SQLITE_IOERR_ACCESS; 33458 33390 }else{ 33459 33391 attr = INVALID_FILE_ATTRIBUTES; 33460 33392 } 33461 33393 } 33462 33394 /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. ................................................................................ 42136 42068 ** function has already been called, it is mostly a no-op. However, any 42137 42069 ** backup in progress needs to be restarted. 42138 42070 */ 42139 42071 sqlite3BackupRestart(pPager->pBackup); 42140 42072 }else{ 42141 42073 if( pagerUseWal(pPager) ){ 42142 42074 PgHdr *pList = sqlite3PcacheDirtyList(pPager->pPCache); 42075 + PgHdr *pPageOne = 0; 42076 + if( pList==0 ){ 42077 + /* Must have at least one page for the WAL commit flag. 42078 + ** Ticket [2d1a5c67dfc2363e44f29d9bbd57f] 2011-05-18 */ 42079 + rc = sqlite3PagerGet(pPager, 1, &pPageOne); 42080 + pList = pPageOne; 42081 + pList->pDirty = 0; 42082 + } 42083 + assert( pList!=0 || rc!=SQLITE_OK ); 42143 42084 if( pList ){ 42144 42085 rc = pagerWalFrames(pPager, pList, pPager->dbSize, 1, 42145 42086 (pPager->fullSync ? pPager->syncFlags : 0) 42146 42087 ); 42147 42088 } 42089 + sqlite3PagerUnref(pPageOne); 42148 42090 if( rc==SQLITE_OK ){ 42149 42091 sqlite3PcacheCleanAll(pPager->pPCache); 42150 42092 } 42151 42093 }else{ 42152 42094 /* The following block updates the change-counter. Exactly how it 42153 42095 ** does this depends on whether or not the atomic-update optimization 42154 42096 ** was enabled at compile time, and if this transaction meets the ................................................................................ 59983 59925 mem1.enc = pKeyInfo->enc; 59984 59926 mem1.db = pKeyInfo->db; 59985 59927 /* mem1.flags = 0; // Will be initialized by sqlite3VdbeSerialGet() */ 59986 59928 VVA_ONLY( mem1.zMalloc = 0; ) /* Only needed by assert() statements */ 59987 59929 59988 59930 /* Compilers may complain that mem1.u.i is potentially uninitialized. 59989 59931 ** We could initialize it, as shown here, to silence those complaints. 59990 - ** But in fact, mem1.u.i will never actually be used uninitialized, and doing 59932 + ** But in fact, mem1.u.i will never actually be used initialized, and doing 59991 59933 ** the unnecessary initialization has a measurable negative performance 59992 59934 ** impact, since this routine is a very high runner. And so, we choose 59993 59935 ** to ignore the compiler warnings and leave this variable uninitialized. 59994 59936 */ 59995 59937 /* mem1.u.i = 0; // not needed, here to silence compiler warning */ 59996 59938 59997 59939 idx1 = getVarint32(aKey1, szHdr1); ................................................................................ 82402 82344 ){ 82403 82345 UNUSED_PARAMETER2(NotUsed, NotUsed2); 82404 82346 /* IMP: R-24470-31136 This function is an SQL wrapper around the 82405 82347 ** sqlite3_sourceid() C interface. */ 82406 82348 sqlite3_result_text(context, sqlite3_sourceid(), -1, SQLITE_STATIC); 82407 82349 } 82408 82350 82409 -/* 82410 -** Implementation of the sqlite_log() function. This is a wrapper around 82411 -** sqlite3_log(). The return value is NULL. The function exists purely for 82412 -** its side-effects. 82413 -*/ 82414 -static void errlogFunc( 82415 - sqlite3_context *context, 82416 - int argc, 82417 - sqlite3_value **argv 82418 -){ 82419 - UNUSED_PARAMETER(argc); 82420 - UNUSED_PARAMETER(context); 82421 - sqlite3_log(sqlite3_value_int(argv[0]), "%s", sqlite3_value_text(argv[1])); 82422 -} 82423 - 82424 82351 /* 82425 82352 ** Implementation of the sqlite_compileoption_used() function. 82426 82353 ** The result is an integer that identifies if the compiler option 82427 82354 ** was used to build SQLite. 82428 82355 */ 82429 82356 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS 82430 82357 static void compileoptionusedFunc( ................................................................................ 83184 83111 /* FUNCTION(ifnull, 2, 0, 0, ifnullFunc ), */ 83185 83112 {2,SQLITE_UTF8,SQLITE_FUNC_COALESCE,0,0,ifnullFunc,0,0,"ifnull",0,0}, 83186 83113 FUNCTION(random, 0, 0, 0, randomFunc ), 83187 83114 FUNCTION(randomblob, 1, 0, 0, randomBlob ), 83188 83115 FUNCTION(nullif, 2, 0, 1, nullifFunc ), 83189 83116 FUNCTION(sqlite_version, 0, 0, 0, versionFunc ), 83190 83117 FUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ), 83191 - FUNCTION(sqlite_log, 2, 0, 0, errlogFunc ), 83192 83118 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS 83193 83119 FUNCTION(sqlite_compileoption_used,1, 0, 0, compileoptionusedFunc ), 83194 83120 FUNCTION(sqlite_compileoption_get, 1, 0, 0, compileoptiongetFunc ), 83195 83121 #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ 83196 83122 FUNCTION(quote, 1, 0, 0, quoteFunc ), 83197 83123 FUNCTION(last_insert_rowid, 0, 0, 0, last_insert_rowid), 83198 83124 FUNCTION(changes, 0, 0, 0, changes ), ................................................................................ 86161 86087 return 0; /* pDestIdx has no corresponding index in pSrc */ 86162 86088 } 86163 86089 } 86164 86090 #ifndef SQLITE_OMIT_CHECK 86165 86091 if( pDest->pCheck && sqlite3ExprCompare(pSrc->pCheck, pDest->pCheck) ){ 86166 86092 return 0; /* Tables have different CHECK constraints. Ticket #2252 */ 86167 86093 } 86168 -#endif 86169 -#ifndef SQLITE_OMIT_FOREIGN_KEY 86170 - /* Disallow the transfer optimization if the destination table constains 86171 - ** any foreign key constraints. This is more restrictive than necessary. 86172 - ** But the main beneficiary of the transfer optimization is the VACUUM 86173 - ** command, and the VACUUM command disables foreign key constraints. So 86174 - ** the extra complication to make this rule less restrictive is probably 86175 - ** not worth the effort. Ticket [6284df89debdfa61db8073e062908af0c9b6118e] 86176 - */ 86177 - if( (pParse->db->flags & SQLITE_ForeignKeys)!=0 && pDest->pFKey!=0 ){ 86178 - return 0; 86179 - } 86180 86094 #endif 86181 86095 86182 86096 /* If we get this far, it means either: 86183 86097 ** 86184 86098 ** * We can always do the transfer if the table contains an 86185 86099 ** an integer primary key 86186 86100 ** ................................................................................ 94118 94032 ** there is such an index, and it has less columns than the table 94119 94033 ** does, then we can assume that it consumes less space on disk and 94120 94034 ** will therefore be cheaper to scan to determine the query result. 94121 94035 ** In this case set iRoot to the root page number of the index b-tree 94122 94036 ** and pKeyInfo to the KeyInfo structure required to navigate the 94123 94037 ** index. 94124 94038 ** 94125 - ** (2011-04-15) Do not do a full scan of an unordered index. 94126 - ** 94127 94039 ** In practice the KeyInfo structure will not be used. It is only 94128 94040 ** passed to keep OP_OpenRead happy. 94129 94041 */ 94130 94042 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ 94131 - if( pIdx->bUnordered==0 && (!pBest || pIdx->nColumn<pBest->nColumn) ){ 94043 + if( !pBest || pIdx->nColumn<pBest->nColumn ){ 94132 94044 pBest = pIdx; 94133 94045 } 94134 94046 } 94135 94047 if( pBest && pBest->nColumn<pTab->nCol ){ 94136 94048 iRoot = pBest->tnum; 94137 94049 pKeyInfo = sqlite3IndexKeyinfo(pParse, pBest); 94138 94050 } ................................................................................ 118244 118156 sqlite3_tokenizer_module const *pModule = pTokenizer->pModule; 118245 118157 sqlite3_tokenizer_cursor *pCsr; 118246 118158 int (*xNext)(sqlite3_tokenizer_cursor *pCursor, 118247 118159 const char**,int*,int*,int*,int*); 118248 118160 118249 118161 assert( pTokenizer && pModule ); 118250 118162 118251 - /* If the user has inserted a NULL value, this function may be called with 118252 - ** zText==0. In this case, add zero token entries to the hash table and 118253 - ** return early. */ 118254 - if( zText==0 ){ 118255 - *pnWord = 0; 118256 - return SQLITE_OK; 118257 - } 118258 - 118259 118163 rc = pModule->xOpen(pTokenizer, zText, -1, &pCsr); 118260 118164 if( rc!=SQLITE_OK ){ 118261 118165 return rc; 118262 118166 } 118263 118167 pCsr->pTokenizer = pTokenizer; 118264 118168 118265 118169 xNext = pModule->xNext; ................................................................................ 118342 118246 ** Argument apVal is the same as the similarly named argument passed to 118343 118247 ** fts3InsertData(). Parameter iDocid is the docid of the new row. 118344 118248 */ 118345 118249 static int fts3InsertTerms(Fts3Table *p, sqlite3_value **apVal, u32 *aSz){ 118346 118250 int i; /* Iterator variable */ 118347 118251 for(i=2; i<p->nColumn+2; i++){ 118348 118252 const char *zText = (const char *)sqlite3_value_text(apVal[i]); 118349 - int rc = fts3PendingTermsAdd(p, zText, i-2, &aSz[i-2]); 118350 - if( rc!=SQLITE_OK ){ 118351 - return rc; 118253 + if( zText ){ 118254 + int rc = fts3PendingTermsAdd(p, zText, i-2, &aSz[i-2]); 118255 + if( rc!=SQLITE_OK ){ 118256 + return rc; 118257 + } 118352 118258 } 118353 118259 aSz[p->nColumn] += sqlite3_value_bytes(apVal[i]); 118354 118260 } 118355 118261 return SQLITE_OK; 118356 118262 } 118357 118263 118358 118264 /*
Changes to SQLite.Interop/src/core/sqlite3.h.
103 103 ** string contains the date and time of the check-in (UTC) and an SHA1 104 104 ** hash of the entire source tree. 105 105 ** 106 106 ** See also: [sqlite3_libversion()], 107 107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()], 108 108 ** [sqlite_version()] and [sqlite_source_id()]. 109 109 */ 110 -#define SQLITE_VERSION "3.7.6.1" 110 +#define SQLITE_VERSION "3.7.6.3" 111 111 #define SQLITE_VERSION_NUMBER 3007006 112 -#define SQLITE_SOURCE_ID "2011-04-27 18:08:42 1bd1484cd7e09709d87aa84b82e87597d00a4162" 112 +#define SQLITE_SOURCE_ID "2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e" 113 113 114 114 /* 115 115 ** CAPI3REF: Run-Time Library Version Numbers 116 116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid 117 117 ** 118 118 ** These interfaces provide the same information as the [SQLITE_VERSION], 119 119 ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros ................................................................................ 448 448 #define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8)) 449 449 #define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8)) 450 450 #define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8)) 451 451 #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8)) 452 452 #define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8)) 453 453 #define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8)) 454 454 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8)) 455 -#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8)) 456 -#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8)) 457 455 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) 458 456 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) 459 457 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) 460 458 461 459 /* 462 460 ** CAPI3REF: Flags For File Open Operations 463 461 **