System.Data.SQLite
Check-in [d77d930e0d]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Update SQLite core library to the latest trunk code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | vs2013
Files: files | file ages | folders
SHA1: d77d930e0d87ea6ce113903a7d56d240af9c17b7
User & Date: mistachkin 2013-11-27 04:57:16
Context
2013-11-27
05:28
Updates to support the Visual Studio 2013 design-time components. check-in: 71dce9f1cf user: mistachkin tags: vs2013
04:57
Update SQLite core library to the latest trunk code. check-in: d77d930e0d user: mistachkin tags: vs2013
04:49
Update the Eagle script library in externals to the latest trunk, needed for its test suite infrastructure updates for Visual Studio 2013 and the .NET Framework 4.5.1. check-in: d0704d07a1 user: mistachkin tags: vs2013
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to SQLite.Interop/src/core/sqlite3.c.

   133    133   **
   134    134   ** See also: [sqlite3_libversion()],
   135    135   ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
   136    136   ** [sqlite_version()] and [sqlite_source_id()].
   137    137   */
   138    138   #define SQLITE_VERSION        "3.8.2"
   139    139   #define SQLITE_VERSION_NUMBER 3008002
   140         -#define SQLITE_SOURCE_ID      "2013-11-22 21:32:44 f336c18fb72ab90e93640b12ac540d41accc7658"
          140  +#define SQLITE_SOURCE_ID      "2013-11-27 04:22:27 83c0bb9913838d18ba355033afde6e38b4690842"
   141    141   
   142    142   /*
   143    143   ** CAPI3REF: Run-Time Library Version Numbers
   144    144   ** KEYWORDS: sqlite3_version, sqlite3_sourceid
   145    145   **
   146    146   ** These interfaces provide the same information as the [SQLITE_VERSION],
   147    147   ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
................................................................................
  1711   1711   ** either the [PRAGMA mmap_size] command, or by using the
  1712   1712   ** [SQLITE_FCNTL_MMAP_SIZE] file control.  ^(The maximum allowed mmap size
  1713   1713   ** cannot be changed at run-time.  Nor may the maximum allowed mmap size
  1714   1714   ** exceed the compile-time maximum mmap size set by the
  1715   1715   ** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
  1716   1716   ** ^If either argument to this option is negative, then that argument is
  1717   1717   ** changed to its compile-time default.
         1718  +**
         1719  +** [[SQLITE_CONFIG_WIN32_HEAPSIZE]]
         1720  +** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
         1721  +** <dd>^This option is only available if SQLite is compiled for Windows
         1722  +** with the [SQLITE_WIN32_MALLOC] pre-processor macro defined.
         1723  +** SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
         1724  +** that specifies the maximum size of the created heap.
  1718   1725   ** </dl>
  1719   1726   */
  1720   1727   #define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */
  1721   1728   #define SQLITE_CONFIG_MULTITHREAD   2  /* nil */
  1722   1729   #define SQLITE_CONFIG_SERIALIZED    3  /* nil */
  1723   1730   #define SQLITE_CONFIG_MALLOC        4  /* sqlite3_mem_methods* */
  1724   1731   #define SQLITE_CONFIG_GETMALLOC     5  /* sqlite3_mem_methods* */
................................................................................
  1735   1742   #define SQLITE_CONFIG_LOG          16  /* xFunc, void* */
  1736   1743   #define SQLITE_CONFIG_URI          17  /* int */
  1737   1744   #define SQLITE_CONFIG_PCACHE2      18  /* sqlite3_pcache_methods2* */
  1738   1745   #define SQLITE_CONFIG_GETPCACHE2   19  /* sqlite3_pcache_methods2* */
  1739   1746   #define SQLITE_CONFIG_COVERING_INDEX_SCAN 20  /* int */
  1740   1747   #define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */
  1741   1748   #define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */
         1749  +#define SQLITE_CONFIG_WIN32_HEAPSIZE      23  /* int nByte */
  1742   1750   
  1743   1751   /*
  1744   1752   ** CAPI3REF: Database Connection Configuration Options
  1745   1753   **
  1746   1754   ** These constants are the available integer configuration options that
  1747   1755   ** can be passed as the second argument to the [sqlite3_db_config()] interface.
  1748   1756   **
................................................................................
 17495  17503       int i = ((u8 *)p-mem5.zPool)/mem5.szAtom;
 17496  17504       assert( i>=0 && i<mem5.nBlock );
 17497  17505       iSize = mem5.szAtom * (1 << (mem5.aCtrl[i]&CTRL_LOGSIZE));
 17498  17506     }
 17499  17507     return iSize;
 17500  17508   }
 17501  17509   
 17502         -/*
 17503         -** Find the first entry on the freelist iLogsize.  Unlink that
 17504         -** entry and return its index. 
 17505         -*/
 17506         -static int memsys5UnlinkFirst(int iLogsize){
 17507         -  int i;
 17508         -  int iFirst;
 17509         -
 17510         -  assert( iLogsize>=0 && iLogsize<=LOGMAX );
 17511         -  i = iFirst = mem5.aiFreelist[iLogsize];
 17512         -  assert( iFirst>=0 );
 17513         -  while( i>0 ){
 17514         -    if( i<iFirst ) iFirst = i;
 17515         -    i = MEM5LINK(i)->next;
 17516         -  }
 17517         -  memsys5Unlink(iFirst, iLogsize);
 17518         -  return iFirst;
 17519         -}
 17520         -
 17521  17510   /*
 17522  17511   ** Return a block of memory of at least nBytes in size.
 17523  17512   ** Return NULL if unable.  Return NULL if nBytes==0.
 17524  17513   **
 17525  17514   ** The caller guarantees that nByte is positive.
 17526  17515   **
 17527  17516   ** The caller has obtained a mutex prior to invoking this
................................................................................
 17559  17548     */
 17560  17549     for(iBin=iLogsize; mem5.aiFreelist[iBin]<0 && iBin<=LOGMAX; iBin++){}
 17561  17550     if( iBin>LOGMAX ){
 17562  17551       testcase( sqlite3GlobalConfig.xLog!=0 );
 17563  17552       sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes", nByte);
 17564  17553       return 0;
 17565  17554     }
 17566         -  i = memsys5UnlinkFirst(iBin);
        17555  +  i = mem5.aiFreelist[iBin];
        17556  +  memsys5Unlink(i, iBin);
 17567  17557     while( iBin>iLogsize ){
 17568  17558       int newSize;
 17569  17559   
 17570  17560       iBin--;
 17571  17561       newSize = 1 << iBin;
 17572  17562       mem5.aCtrl[i+newSize] = CTRL_FREE | iBin;
 17573  17563       memsys5Link(i+newSize, iBin);
................................................................................
 21848  21838     }
 21849  21839     zStart = zNum;
 21850  21840     while( zNum<zEnd && zNum[0]=='0' ){ zNum+=incr; } /* Skip leading zeros. */
 21851  21841     for(i=0; &zNum[i]<zEnd && (c=zNum[i])>='0' && c<='9'; i+=incr){
 21852  21842       u = u*10 + c - '0';
 21853  21843     }
 21854  21844     if( u>LARGEST_INT64 ){
 21855         -    *pNum = SMALLEST_INT64;
        21845  +    *pNum = neg ? SMALLEST_INT64 : LARGEST_INT64;
 21856  21846     }else if( neg ){
 21857  21847       *pNum = -(i64)u;
 21858  21848     }else{
 21859  21849       *pNum = (i64)u;
 21860  21850     }
 21861  21851     testcase( i==18 );
 21862  21852     testcase( i==19 );
................................................................................
 21879  21869       }else if( c>0 ){
 21880  21870         /* zNum is greater than 9223372036854775808 so it overflows */
 21881  21871         return 1;
 21882  21872       }else{
 21883  21873         /* zNum is exactly 9223372036854775808.  Fits if negative.  The
 21884  21874         ** special case 2 overflow if positive */
 21885  21875         assert( u-1==LARGEST_INT64 );
 21886         -      assert( (*pNum)==SMALLEST_INT64 );
 21887  21876         return neg ? 0 : 2;
 21888  21877       }
 21889  21878     }
 21890  21879   }
 21891  21880   
 21892  21881   /*
 21893  21882   ** If zNum represents an integer that will fit in 32-bits, then set
................................................................................
 31002  30991   ** Make sure at least one set of Win32 APIs is available.
 31003  30992   */
 31004  30993   #if !defined(SQLITE_WIN32_HAS_ANSI) && !defined(SQLITE_WIN32_HAS_WIDE)
 31005  30994   #  error "At least one of SQLITE_WIN32_HAS_ANSI and SQLITE_WIN32_HAS_WIDE\
 31006  30995    must be defined."
 31007  30996   #endif
 31008  30997   
        30998  +/*
        30999  +** Define the required Windows SDK version constants if they are not
        31000  +** already available.
        31001  +*/
        31002  +#ifndef NTDDI_WIN8
        31003  +#  define NTDDI_WIN8                        0x06020000
        31004  +#endif
        31005  +
        31006  +#ifndef NTDDI_WINBLUE
        31007  +#  define NTDDI_WINBLUE                     0x06030000
        31008  +#endif
        31009  +
        31010  +/*
        31011  +** Check if the GetVersionEx[AW] functions should be considered deprecated
        31012  +** and avoid using them in that case.  It should be noted here that if the
        31013  +** value of the SQLITE_WIN32_GETVERSIONEX pre-processor macro is zero
        31014  +** (whether via this block or via being manually specified), that implies
        31015  +** the underlying operating system will always be based on the Windows NT
        31016  +** Kernel.
        31017  +*/
        31018  +#ifndef SQLITE_WIN32_GETVERSIONEX
        31019  +#  if defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WINBLUE
        31020  +#    define SQLITE_WIN32_GETVERSIONEX   0
        31021  +#  else
        31022  +#    define SQLITE_WIN32_GETVERSIONEX   1
        31023  +#  endif
        31024  +#endif
        31025  +
 31009  31026   /*
 31010  31027   ** This constant should already be defined (in the "WinDef.h" SDK file).
 31011  31028   */
 31012  31029   #ifndef MAX_PATH
 31013  31030   #  define MAX_PATH                      (260)
 31014  31031   #endif
 31015  31032   
................................................................................
 31637  31654     { "GetTickCount",            (SYSCALL)GetTickCount,            0 },
 31638  31655   #else
 31639  31656     { "GetTickCount",            (SYSCALL)0,                       0 },
 31640  31657   #endif
 31641  31658   
 31642  31659   #define osGetTickCount ((DWORD(WINAPI*)(VOID))aSyscall[33].pCurrent)
 31643  31660   
 31644         -#if defined(SQLITE_WIN32_HAS_ANSI)
        31661  +#if defined(SQLITE_WIN32_HAS_ANSI) && defined(SQLITE_WIN32_GETVERSIONEX) && \
        31662  +        SQLITE_WIN32_GETVERSIONEX
 31645  31663     { "GetVersionExA",           (SYSCALL)GetVersionExA,           0 },
 31646  31664   #else
 31647  31665     { "GetVersionExA",           (SYSCALL)0,                       0 },
 31648  31666   #endif
 31649  31667   
 31650  31668   #define osGetVersionExA ((BOOL(WINAPI*)( \
 31651  31669           LPOSVERSIONINFOA))aSyscall[34].pCurrent)
 31652  31670   
 31653         -#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)
        31671  +#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \
        31672  +        defined(SQLITE_WIN32_GETVERSIONEX) && SQLITE_WIN32_GETVERSIONEX
 31654  31673     { "GetVersionExW",           (SYSCALL)GetVersionExW,           0 },
 31655  31674   #else
 31656  31675     { "GetVersionExW",           (SYSCALL)0,                       0 },
 31657  31676   #endif
 31658  31677   
 31659  31678   #define osGetVersionExW ((BOOL(WINAPI*)( \
 31660  31679           LPOSVERSIONINFOW))aSyscall[35].pCurrent)
................................................................................
 32203  32222   ** Here is an interesting observation:  Win95, Win98, and WinME lack
 32204  32223   ** the LockFileEx() API.  But we can still statically link against that
 32205  32224   ** API as long as we don't call it when running Win95/98/ME.  A call to
 32206  32225   ** this routine is used to determine if the host is Win95/98/ME or
 32207  32226   ** WinNT/2K/XP so that we will know whether or not we can safely call
 32208  32227   ** the LockFileEx() API.
 32209  32228   */
 32210         -#ifndef NTDDI_WIN8
 32211         -#  define NTDDI_WIN8                        0x06020000
 32212         -#endif
 32213  32229   
 32214         -#if SQLITE_OS_WINCE || SQLITE_OS_WINRT || !defined(SQLITE_WIN32_HAS_ANSI)
        32230  +#if !defined(SQLITE_WIN32_GETVERSIONEX) || !SQLITE_WIN32_GETVERSIONEX
        32231  +# define osIsNT()  (1)
        32232  +#elif SQLITE_OS_WINCE || SQLITE_OS_WINRT || !defined(SQLITE_WIN32_HAS_ANSI)
 32215  32233   # define osIsNT()  (1)
 32216  32234   #elif !defined(SQLITE_WIN32_HAS_WIDE)
 32217  32235   # define osIsNT()  (0)
 32218  32236   #else
 32219  32237     static int osIsNT(void){
 32220  32238       if( sqlite3_os_type==0 ){
 32221  32239   #if defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WIN8
................................................................................
 32344  32362   
 32345  32363     if( !pWinMemData ) return SQLITE_ERROR;
 32346  32364     assert( pWinMemData->magic1==WINMEM_MAGIC1 );
 32347  32365     assert( pWinMemData->magic2==WINMEM_MAGIC2 );
 32348  32366   
 32349  32367   #if !SQLITE_OS_WINRT && SQLITE_WIN32_HEAP_CREATE
 32350  32368     if( !pWinMemData->hHeap ){
        32369  +    DWORD dwInitialSize = SQLITE_WIN32_HEAP_INIT_SIZE;
        32370  +    DWORD dwMaximumSize = (DWORD)sqlite3GlobalConfig.nHeap;
        32371  +    if( dwMaximumSize==0 ){
        32372  +      dwMaximumSize = SQLITE_WIN32_HEAP_MAX_SIZE;
        32373  +    }else if( dwInitialSize>dwMaximumSize ){
        32374  +      dwInitialSize = dwMaximumSize;
        32375  +    }
 32351  32376       pWinMemData->hHeap = osHeapCreate(SQLITE_WIN32_HEAP_FLAGS,
 32352         -                                      SQLITE_WIN32_HEAP_INIT_SIZE,
 32353         -                                      SQLITE_WIN32_HEAP_MAX_SIZE);
        32377  +                                      dwInitialSize, dwMaximumSize);
 32354  32378       if( !pWinMemData->hHeap ){
 32355  32379         sqlite3_log(SQLITE_NOMEM,
 32356         -          "failed to HeapCreate (%lu), flags=%u, initSize=%u, maxSize=%u",
 32357         -          osGetLastError(), SQLITE_WIN32_HEAP_FLAGS,
 32358         -          SQLITE_WIN32_HEAP_INIT_SIZE, SQLITE_WIN32_HEAP_MAX_SIZE);
        32380  +          "failed to HeapCreate (%lu), flags=%u, initSize=%lu, maxSize=%lu",
        32381  +          osGetLastError(), SQLITE_WIN32_HEAP_FLAGS, dwInitialSize,
        32382  +          dwMaximumSize);
 32359  32383         return SQLITE_NOMEM;
 32360  32384       }
 32361  32385       pWinMemData->bOwned = TRUE;
 32362  32386       assert( pWinMemData->bOwned );
 32363  32387     }
 32364  32388   #else
 32365  32389     pWinMemData->hHeap = osGetProcessHeap();
................................................................................
 35011  35035   /****************************************************************************
 35012  35036   **************************** sqlite3_vfs methods ****************************
 35013  35037   **
 35014  35038   ** This division contains the implementation of methods on the
 35015  35039   ** sqlite3_vfs object.
 35016  35040   */
 35017  35041   
 35018         -#if 0
        35042  +#if defined(__CYGWIN__)
 35019  35043   /*
 35020  35044   ** Convert a filename from whatever the underlying operating system
 35021  35045   ** supports for filenames into UTF-8.  Space to hold the result is
 35022  35046   ** obtained from malloc and must be freed by the calling function.
 35023  35047   */
 35024  35048   static char *winConvertToUtf8Filename(const void *zFilename){
 35025  35049     char *zConverted = 0;
................................................................................
 35187  35211                                "winGetTempname2", zDir);
 35188  35212           }
 35189  35213           if( winIsDir(zConverted) ){
 35190  35214             /* At this point, we know the candidate directory exists and should
 35191  35215             ** be used.  However, we may need to convert the string containing
 35192  35216             ** its name into UTF-8 (i.e. if it is UTF-16 right now).
 35193  35217             */
 35194         -          if( osIsNT() ){
 35195         -            char *zUtf8 = winUnicodeToUtf8(zConverted);
 35196         -            if( !zUtf8 ){
 35197         -              sqlite3_free(zConverted);
 35198         -              sqlite3_free(zBuf);
 35199         -              OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
 35200         -              return SQLITE_IOERR_NOMEM;
 35201         -            }
 35202         -            sqlite3_snprintf(nMax, zBuf, "%s", zUtf8);
 35203         -            sqlite3_free(zUtf8);
        35218  +          char *zUtf8 = winConvertToUtf8Filename(zConverted);
        35219  +          if( !zUtf8 ){
 35204  35220               sqlite3_free(zConverted);
 35205         -            break;
 35206         -          }else{
 35207         -            sqlite3_snprintf(nMax, zBuf, "%s", zConverted);
 35208         -            sqlite3_free(zConverted);
 35209         -            break;
        35221  +            sqlite3_free(zBuf);
        35222  +            OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
        35223  +            return SQLITE_IOERR_NOMEM;
 35210  35224             }
        35225  +          sqlite3_snprintf(nMax, zBuf, "%s", zUtf8);
        35226  +          sqlite3_free(zUtf8);
        35227  +          sqlite3_free(zConverted);
        35228  +          break;
 35211  35229           }
 35212  35230           sqlite3_free(zConverted);
 35213  35231         }
 35214  35232       }
 35215  35233     }
 35216  35234   #elif !SQLITE_OS_WINRT && !defined(__CYGWIN__)
 35217  35235     else if( osIsNT() ){
................................................................................
 35888  35906       **       for converting the relative path name to an absolute
 35889  35907       **       one by prepending the data directory and a slash.
 35890  35908       */
 35891  35909       char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 );
 35892  35910       if( !zOut ){
 35893  35911         return SQLITE_IOERR_NOMEM;
 35894  35912       }
 35895         -    if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
 35896         -                         pVfs->mxPathname+1)<0 ){
        35913  +    if( cygwin_conv_path(
        35914  +            (osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A) |
        35915  +            CCP_RELATIVE, zRelative, zOut, pVfs->mxPathname+1)<0 ){
 35897  35916         sqlite3_free(zOut);
 35898  35917         return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno,
 35899  35918                            "winFullPathname1", zRelative);
        35919  +    }else{
        35920  +      char *zUtf8 = winConvertToUtf8Filename(zOut);
        35921  +      if( !zUtf8 ){
        35922  +        sqlite3_free(zOut);
        35923  +        return SQLITE_IOERR_NOMEM;
        35924  +      }
        35925  +      sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s",
        35926  +                       sqlite3_data_directory, winGetDirSep(), zUtf8);
        35927  +      sqlite3_free(zUtf8);
        35928  +      sqlite3_free(zOut);
 35900  35929       }
 35901         -    sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s",
 35902         -                     sqlite3_data_directory, winGetDirSep(), zOut);
 35903         -    sqlite3_free(zOut);
 35904  35930     }else{
 35905         -    if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){
        35931  +    char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 );
        35932  +    if( !zOut ){
        35933  +      return SQLITE_IOERR_NOMEM;
        35934  +    }
        35935  +    if( cygwin_conv_path(
        35936  +            (osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A),
        35937  +            zRelative, zOut, pVfs->mxPathname+1)<0 ){
        35938  +      sqlite3_free(zOut);
 35906  35939         return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno,
 35907  35940                            "winFullPathname2", zRelative);
        35941  +    }else{
        35942  +      char *zUtf8 = winConvertToUtf8Filename(zOut);
        35943  +      if( !zUtf8 ){
        35944  +        sqlite3_free(zOut);
        35945  +        return SQLITE_IOERR_NOMEM;
        35946  +      }
        35947  +      sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zUtf8);
        35948  +      sqlite3_free(zUtf8);
        35949  +      sqlite3_free(zOut);
 35908  35950       }
 35909  35951     }
 35910  35952     return SQLITE_OK;
 35911  35953   #endif
 35912  35954   
 35913  35955   #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
 35914  35956     SimulateIOError( return SQLITE_ERROR );
................................................................................
 54494  54536     u32 nLocal;
 54495  54537   
 54496  54538     assert( pCur!=0 && pCur->iPage>=0 && pCur->apPage[pCur->iPage]);
 54497  54539     assert( pCur->eState==CURSOR_VALID );
 54498  54540     assert( cursorHoldsMutex(pCur) );
 54499  54541     pPage = pCur->apPage[pCur->iPage];
 54500  54542     assert( pCur->aiIdx[pCur->iPage]<pPage->nCell );
 54501         -  if( NEVER(pCur->info.nSize==0) ){
        54543  +  if( pCur->info.nSize==0 ){
 54502  54544       btreeParseCell(pCur->apPage[pCur->iPage], pCur->aiIdx[pCur->iPage],
 54503  54545                      &pCur->info);
 54504  54546     }
 54505  54547     aPayload = pCur->info.pCell;
 54506  54548     aPayload += pCur->info.nHeader;
 54507  54549     if( pPage->intKey ){
 54508  54550       nKey = 0;
................................................................................
 54922  54964     if( pCur->eState==CURSOR_INVALID ){
 54923  54965       *pRes = -1;
 54924  54966       assert( pCur->pgnoRoot==0 || pCur->apPage[pCur->iPage]->nCell==0 );
 54925  54967       return SQLITE_OK;
 54926  54968     }
 54927  54969     assert( pCur->apPage[0]->intKey || pIdxKey );
 54928  54970     for(;;){
 54929         -    int lwr, upr, idx;
        54971  +    int lwr, upr, idx, c;
 54930  54972       Pgno chldPg;
 54931  54973       MemPage *pPage = pCur->apPage[pCur->iPage];
 54932         -    int c;
        54974  +    u8 *pCell;                          /* Pointer to current cell in pPage */
 54933  54975   
 54934  54976       /* pPage->nCell must be greater than zero. If this is the root-page
 54935  54977       ** the cursor would have been INVALID above and this for(;;) loop
 54936  54978       ** not run. If this is not the root-page, then the moveToChild() routine
 54937  54979       ** would have already detected db corruption. Similarly, pPage must
 54938  54980       ** be the right kind (index or table) of b-tree page. Otherwise
 54939  54981       ** a moveToChild() or moveToRoot() call would have detected corruption.  */
 54940  54982       assert( pPage->nCell>0 );
 54941  54983       assert( pPage->intKey==(pIdxKey==0) );
 54942  54984       lwr = 0;
 54943  54985       upr = pPage->nCell-1;
 54944         -    if( biasRight ){
 54945         -      pCur->aiIdx[pCur->iPage] = (u16)(idx = upr);
 54946         -    }else{
 54947         -      pCur->aiIdx[pCur->iPage] = (u16)(idx = (upr+lwr)/2);
 54948         -    }
 54949         -    for(;;){
 54950         -      u8 *pCell;                          /* Pointer to current cell in pPage */
 54951         -
 54952         -      assert( idx==pCur->aiIdx[pCur->iPage] );
 54953         -      pCur->info.nSize = 0;
 54954         -      pCell = findCell(pPage, idx) + pPage->childPtrSize;
 54955         -      if( pPage->intKey ){
        54986  +    assert( biasRight==0 || biasRight==1 );
        54987  +    idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */
        54988  +    pCur->aiIdx[pCur->iPage] = (u16)idx;
        54989  +    if( pPage->intKey ){
        54990  +      for(;;){
 54956  54991           i64 nCellKey;
        54992  +        pCell = findCell(pPage, idx) + pPage->childPtrSize;
 54957  54993           if( pPage->hasData ){
 54958         -          u32 dummy;
 54959         -          pCell += getVarint32(pCell, dummy);
        54994  +          while( 0x80 <= *(pCell++) ){
        54995  +            if( pCell>=pPage->aDataEnd ) return SQLITE_CORRUPT_BKPT;
        54996  +          }
 54960  54997           }
 54961  54998           getVarint(pCell, (u64*)&nCellKey);
 54962         -        if( nCellKey==intKey ){
 54963         -          c = 0;
 54964         -        }else if( nCellKey<intKey ){
 54965         -          c = -1;
        54999  +        if( nCellKey<intKey ){
        55000  +          lwr = idx+1;
        55001  +          if( lwr>upr ){ c = -1; break; }
        55002  +        }else if( nCellKey>intKey ){
        55003  +          upr = idx-1;
        55004  +          if( lwr>upr ){ c = +1; break; }
 54966  55005           }else{
 54967         -          assert( nCellKey>intKey );
 54968         -          c = +1;
        55006  +          assert( nCellKey==intKey );
        55007  +          pCur->validNKey = 1;
        55008  +          pCur->info.nKey = nCellKey;
        55009  +          pCur->aiIdx[pCur->iPage] = (u16)idx;
        55010  +          if( !pPage->leaf ){
        55011  +            lwr = idx;
        55012  +            goto moveto_next_layer;
        55013  +          }else{
        55014  +            *pRes = 0;
        55015  +            rc = SQLITE_OK;
        55016  +            goto moveto_finish;
        55017  +          }
 54969  55018           }
 54970         -        pCur->validNKey = 1;
 54971         -        pCur->info.nKey = nCellKey;
 54972         -      }else{
        55019  +        assert( lwr+upr>=0 );
        55020  +        idx = (lwr+upr)>>1;  /* idx = (lwr+upr)/2; */
        55021  +      }
        55022  +    }else{
        55023  +      for(;;){
        55024  +        int nCell;
        55025  +        pCell = findCell(pPage, idx) + pPage->childPtrSize;
        55026  +
 54973  55027           /* The maximum supported page-size is 65536 bytes. This means that
 54974  55028           ** the maximum number of record bytes stored on an index B-Tree
 54975  55029           ** page is less than 16384 bytes and may be stored as a 2-byte
 54976  55030           ** varint. This information is used to attempt to avoid parsing 
 54977  55031           ** the entire cell by checking for the cases where the record is 
 54978  55032           ** stored entirely within the b-tree page by inspecting the first 
 54979  55033           ** 2 bytes of the cell.
 54980  55034           */
 54981         -        int nCell = pCell[0];
        55035  +        nCell = pCell[0];
 54982  55036           if( nCell<=pPage->max1bytePayload
 54983  55037            /* && (pCell+nCell)<pPage->aDataEnd */
 54984  55038           ){
 54985  55039             /* This branch runs if the record-size field of the cell is a
 54986  55040             ** single byte varint and the record fits entirely on the main
 54987  55041             ** b-tree page.  */
 54988  55042             testcase( pCell+nCell+1==pPage->aDataEnd );
................................................................................
 55005  55059             btreeParseCellPtr(pPage, pCellBody, &pCur->info);
 55006  55060             nCell = (int)pCur->info.nKey;
 55007  55061             pCellKey = sqlite3Malloc( nCell );
 55008  55062             if( pCellKey==0 ){
 55009  55063               rc = SQLITE_NOMEM;
 55010  55064               goto moveto_finish;
 55011  55065             }
        55066  +          pCur->aiIdx[pCur->iPage] = (u16)idx;
 55012  55067             rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0);
 55013  55068             if( rc ){
 55014  55069               sqlite3_free(pCellKey);
 55015  55070               goto moveto_finish;
 55016  55071             }
 55017  55072             c = sqlite3VdbeRecordCompare(nCell, pCellKey, pIdxKey);
 55018  55073             sqlite3_free(pCellKey);
 55019  55074           }
 55020         -      }
 55021         -      if( c==0 ){
 55022         -        if( pPage->intKey && !pPage->leaf ){
 55023         -          lwr = idx;
 55024         -          break;
        55075  +        if( c<0 ){
        55076  +          lwr = idx+1;
        55077  +        }else if( c>0 ){
        55078  +          upr = idx-1;
 55025  55079           }else{
        55080  +          assert( c==0 );
 55026  55081             *pRes = 0;
 55027  55082             rc = SQLITE_OK;
        55083  +          pCur->aiIdx[pCur->iPage] = (u16)idx;
 55028  55084             goto moveto_finish;
 55029  55085           }
        55086  +        if( lwr>upr ) break;
        55087  +        assert( lwr+upr>=0 );
        55088  +        idx = (lwr+upr)>>1;  /* idx = (lwr+upr)/2 */
 55030  55089         }
 55031         -      if( c<0 ){
 55032         -        lwr = idx+1;
 55033         -      }else{
 55034         -        upr = idx-1;
 55035         -      }
 55036         -      if( lwr>upr ){
 55037         -        break;
 55038         -      }
 55039         -      pCur->aiIdx[pCur->iPage] = (u16)(idx = (lwr+upr)/2);
 55040  55090       }
 55041  55091       assert( lwr==upr+1 || (pPage->intKey && !pPage->leaf) );
 55042  55092       assert( pPage->isInit );
 55043  55093       if( pPage->leaf ){
 55044         -      chldPg = 0;
 55045         -    }else if( lwr>=pPage->nCell ){
 55046         -      chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]);
 55047         -    }else{
 55048         -      chldPg = get4byte(findCell(pPage, lwr));
 55049         -    }
 55050         -    if( chldPg==0 ){
 55051  55094         assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
        55095  +      pCur->aiIdx[pCur->iPage] = (u16)idx;
 55052  55096         *pRes = c;
 55053  55097         rc = SQLITE_OK;
 55054  55098         goto moveto_finish;
 55055  55099       }
        55100  +moveto_next_layer:
        55101  +    if( lwr>=pPage->nCell ){
        55102  +      chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]);
        55103  +    }else{
        55104  +      chldPg = get4byte(findCell(pPage, lwr));
        55105  +    }
 55056  55106       pCur->aiIdx[pCur->iPage] = (u16)lwr;
 55057         -    pCur->info.nSize = 0;
 55058         -    pCur->validNKey = 0;
 55059  55107       rc = moveToChild(pCur, chldPg);
 55060         -    if( rc ) goto moveto_finish;
        55108  +    if( rc ) break;
 55061  55109     }
 55062  55110   moveto_finish:
        55111  +  pCur->info.nSize = 0;
        55112  +  pCur->validNKey = 0;
 55063  55113     return rc;
 55064  55114   }
 55065  55115   
 55066  55116   
 55067  55117   /*
 55068  55118   ** Return TRUE if the cursor is not pointing at an entry of the table.
 55069  55119   **
................................................................................
 59850  59900     p->z = 0;
 59851  59901     p->zMalloc = 0;
 59852  59902     p->xDel = 0;
 59853  59903   }
 59854  59904   
 59855  59905   /*
 59856  59906   ** Convert a 64-bit IEEE double into a 64-bit signed integer.
 59857         -** If the double is too large, return 0x8000000000000000.
 59858         -**
 59859         -** Most systems appear to do this simply by assigning
 59860         -** variables and without the extra range tests.  But
 59861         -** there are reports that windows throws an expection
 59862         -** if the floating point value is out of range. (See ticket #2880.)
 59863         -** Because we do not completely understand the problem, we will
 59864         -** take the conservative approach and always do range tests
 59865         -** before attempting the conversion.
        59907  +** If the double is out of range of a 64-bit signed integer then
        59908  +** return the closest available 64-bit signed integer.
 59866  59909   */
 59867  59910   static i64 doubleToInt64(double r){
 59868  59911   #ifdef SQLITE_OMIT_FLOATING_POINT
 59869  59912     /* When floating-point is omitted, double and int64 are the same thing */
 59870  59913     return r;
 59871  59914   #else
 59872  59915     /*
................................................................................
 59875  59918     ** inconsistently.  And many do not understand the "LL" notation.
 59876  59919     ** So we define our own static constants here using nothing
 59877  59920     ** larger than a 32-bit integer constant.
 59878  59921     */
 59879  59922     static const i64 maxInt = LARGEST_INT64;
 59880  59923     static const i64 minInt = SMALLEST_INT64;
 59881  59924   
 59882         -  if( r<(double)minInt ){
        59925  +  if( r<=(double)minInt ){
 59883  59926       return minInt;
 59884         -  }else if( r>(double)maxInt ){
 59885         -    /* minInt is correct here - not maxInt.  It turns out that assigning
 59886         -    ** a very large positive number to an integer results in a very large
 59887         -    ** negative integer.  This makes no sense, but it is what x86 hardware
 59888         -    ** does so for compatibility we will do the same in software. */
 59889         -    return minInt;
        59927  +  }else if( r>=(double)maxInt ){
        59928  +    return maxInt;
 59890  59929     }else{
 59891  59930       return (i64)r;
 59892  59931     }
 59893  59932   #endif
 59894  59933   }
 59895  59934   
 59896  59935   /*
................................................................................
 59964  60003     **
 59965  60004     **    (1) the round-trip conversion real->int->real is a no-op, and
 59966  60005     **    (2) The integer is neither the largest nor the smallest
 59967  60006     **        possible integer (ticket #3922)
 59968  60007     **
 59969  60008     ** The second and third terms in the following conditional enforces
 59970  60009     ** the second condition under the assumption that addition overflow causes
 59971         -  ** values to wrap around.  On x86 hardware, the third term is always
 59972         -  ** true and could be omitted.  But we leave it in because other
 59973         -  ** architectures might behave differently.
        60010  +  ** values to wrap around.
 59974  60011     */
 59975  60012     if( pMem->r==(double)pMem->u.i
 59976  60013      && pMem->u.i>SMALLEST_INT64
 59977         -#if defined(__i486__) || defined(__x86_64__)
 59978         -   && ALWAYS(pMem->u.i<LARGEST_INT64)
 59979         -#else
 59980  60014      && pMem->u.i<LARGEST_INT64
 59981         -#endif
 59982  60015     ){
 59983  60016       pMem->flags |= MEM_Int;
 59984  60017     }
 59985  60018   }
 59986  60019   
 59987  60020   /*
 59988  60021   ** Convert pMem to type integer.  Invalidate any prior representations.
................................................................................
 64075  64108     */
 64076  64109     /*  mem1.u.i = 0;  // not needed, here to silence compiler warning */
 64077  64110     
 64078  64111     idx1 = getVarint32(aKey1, szHdr1);
 64079  64112     d1 = szHdr1;
 64080  64113     assert( pKeyInfo->nField+pKeyInfo->nXField>=pPKey2->nField );
 64081  64114     assert( pKeyInfo->aSortOrder!=0 );
 64082         -  while( idx1<szHdr1 && i<pPKey2->nField ){
        64115  +  assert( idx1<szHdr1 && i<pPKey2->nField );
        64116  +  do{
 64083  64117       u32 serial_type1;
 64084  64118   
 64085  64119       /* Read the serial types for the next element in each key. */
 64086  64120       idx1 += getVarint32( aKey1+idx1, serial_type1 );
 64087  64121   
 64088  64122       /* Verify that there is enough key space remaining to avoid
 64089  64123       ** a buffer overread.  The "d1+serial_type1+2" subexpression will
................................................................................
 64108  64142         assert( mem1.zMalloc==0 );  /* See comment below */
 64109  64143         if( pKeyInfo->aSortOrder[i] ){
 64110  64144           rc = -rc;  /* Invert the result for DESC sort order. */
 64111  64145         }
 64112  64146         return rc;
 64113  64147       }
 64114  64148       i++;
 64115         -  }
        64149  +  }while( idx1<szHdr1 && i<pPKey2->nField );
 64116  64150   
 64117  64151     /* No memory allocation is ever used on mem1.  Prove this using
 64118  64152     ** the following assert().  If the assert() fails, it indicates a
 64119  64153     ** memory leak and a need to call sqlite3VdbeMemRelease(&mem1).
 64120  64154     */
 64121  64155     assert( mem1.zMalloc==0 );
 64122  64156   
................................................................................
 70048  70082       if( (pIn3->flags & MEM_Int)==0 ){
 70049  70083         if( (pIn3->flags & MEM_Real)==0 ){
 70050  70084           /* If the P3 value cannot be converted into any kind of a number,
 70051  70085           ** then the seek is not possible, so jump to P2 */
 70052  70086           pc = pOp->p2 - 1;
 70053  70087           break;
 70054  70088         }
 70055         -      /* If we reach this point, then the P3 value must be a floating
 70056         -      ** point number. */
 70057         -      assert( (pIn3->flags & MEM_Real)!=0 );
 70058         -
 70059         -      if( u.bd.iKey==SMALLEST_INT64 && (pIn3->r<(double)u.bd.iKey || pIn3->r>0) ){
 70060         -        /* The P3 value is too large in magnitude to be expressed as an
 70061         -        ** integer. */
 70062         -        u.bd.res = 1;
 70063         -        if( pIn3->r<0 ){
 70064         -          if( u.bd.oc>=OP_SeekGe ){  assert( u.bd.oc==OP_SeekGe || u.bd.oc==OP_SeekGt );
 70065         -            rc = sqlite3BtreeFirst(u.bd.pC->pCursor, &u.bd.res);
 70066         -            if( rc!=SQLITE_OK ) goto abort_due_to_error;
 70067         -          }
 70068         -        }else{
 70069         -          if( u.bd.oc<=OP_SeekLe ){  assert( u.bd.oc==OP_SeekLt || u.bd.oc==OP_SeekLe );
 70070         -            rc = sqlite3BtreeLast(u.bd.pC->pCursor, &u.bd.res);
 70071         -            if( rc!=SQLITE_OK ) goto abort_due_to_error;
 70072         -          }
 70073         -        }
 70074         -        if( u.bd.res ){
 70075         -          pc = pOp->p2 - 1;
 70076         -        }
 70077         -        break;
 70078         -      }else if( u.bd.oc==OP_SeekLt || u.bd.oc==OP_SeekGe ){
 70079         -        /* Use the ceiling() function to convert real->int */
 70080         -        if( pIn3->r > (double)u.bd.iKey ) u.bd.iKey++;
 70081         -      }else{
 70082         -        /* Use the floor() function to convert real->int */
 70083         -        assert( u.bd.oc==OP_SeekLe || u.bd.oc==OP_SeekGt );
 70084         -        if( pIn3->r < (double)u.bd.iKey ) u.bd.iKey--;
        70089  +
        70090  +      /* If the approximation u.bd.iKey is larger than the actual real search
        70091  +      ** term, substitute >= for > and < for <=. e.g. if the search term
        70092  +      ** is 4.9 and the integer approximation 5:
        70093  +      **
        70094  +      **        (x >  4.9)    ->     (x >= 5)
        70095  +      **        (x <= 4.9)    ->     (x <  5)
        70096  +      */
        70097  +      if( pIn3->r<(double)u.bd.iKey ){
        70098  +        assert( OP_SeekGe==(OP_SeekGt-1) );
        70099  +        assert( OP_SeekLt==(OP_SeekLe-1) );
        70100  +        assert( (OP_SeekLe & 0x0001)==(OP_SeekGt & 0x0001) );
        70101  +        if( (u.bd.oc & 0x0001)==(OP_SeekGt & 0x0001) ) u.bd.oc--;
        70102  +      }
        70103  +
        70104  +      /* If the approximation u.bd.iKey is smaller than the actual real search
        70105  +      ** term, substitute <= for < and > for >=.  */
        70106  +      else if( pIn3->r>(double)u.bd.iKey ){
        70107  +        assert( OP_SeekLe==(OP_SeekLt+1) );
        70108  +        assert( OP_SeekGt==(OP_SeekGe+1) );
        70109  +        assert( (OP_SeekLt & 0x0001)==(OP_SeekGe & 0x0001) );
        70110  +        if( (u.bd.oc & 0x0001)==(OP_SeekLt & 0x0001) ) u.bd.oc++;
 70085  70111         }
 70086  70112       }
 70087  70113       rc = sqlite3BtreeMovetoUnpacked(u.bd.pC->pCursor, 0, (u64)u.bd.iKey, 0, &u.bd.res);
 70088  70114       if( rc!=SQLITE_OK ){
 70089  70115         goto abort_due_to_error;
 70090  70116       }
 70091  70117       if( u.bd.res==0 ){
................................................................................
 70623  70649       u.bi.nZero = u.bi.pData->u.nZero;
 70624  70650     }else{
 70625  70651       u.bi.nZero = 0;
 70626  70652     }
 70627  70653     sqlite3BtreeSetCachedRowid(u.bi.pC->pCursor, 0);
 70628  70654     rc = sqlite3BtreeInsert(u.bi.pC->pCursor, 0, u.bi.iKey,
 70629  70655                             u.bi.pData->z, u.bi.pData->n, u.bi.nZero,
 70630         -                          pOp->p5 & OPFLAG_APPEND, u.bi.seekResult
        70656  +                          (pOp->p5 & OPFLAG_APPEND)!=0, u.bi.seekResult
 70631  70657     );
 70632  70658     u.bi.pC->rowidIsValid = 0;
 70633  70659     u.bi.pC->deferredMoveto = 0;
 70634  70660     u.bi.pC->cacheStatus = CACHE_STALE;
 70635  70661   
 70636  70662     /* Invoke the update-hook if required. */
 70637  70663     if( rc==SQLITE_OK && db->xUpdateCallback && pOp->p4.z ){
................................................................................
 70667  70693   */
 70668  70694   case OP_Delete: {
 70669  70695   #if 0  /* local variables moved into u.bj */
 70670  70696     i64 iKey;
 70671  70697     VdbeCursor *pC;
 70672  70698   #endif /* local variables moved into u.bj */
 70673  70699   
 70674         -  u.bj.iKey = 0;
 70675  70700     assert( pOp->p1>=0 && pOp->p1<p->nCursor );
 70676  70701     u.bj.pC = p->apCsr[pOp->p1];
 70677  70702     assert( u.bj.pC!=0 );
 70678  70703     assert( u.bj.pC->pCursor!=0 );  /* Only valid for real tables, no pseudotables */
 70679         -
 70680         -  /* If the update-hook will be invoked, set u.bj.iKey to the rowid of the
 70681         -  ** row being deleted.
 70682         -  */
 70683         -  if( db->xUpdateCallback && pOp->p4.z ){
 70684         -    assert( u.bj.pC->isTable );
 70685         -    assert( u.bj.pC->rowidIsValid );  /* lastRowid set by previous OP_NotFound */
 70686         -    u.bj.iKey = u.bj.pC->lastRowid;
 70687         -  }
        70704  +  u.bj.iKey = u.bj.pC->lastRowid;      /* Only used for the update hook */
 70688  70705   
 70689  70706     /* The OP_Delete opcode always follows an OP_NotExists or OP_Last or
 70690  70707     ** OP_Column on the same table without any intervening operations that
 70691  70708     ** might move or invalidate the cursor.  Hence cursor u.bj.pC is always pointing
 70692  70709     ** to the row to be deleted and the sqlite3VdbeCursorMoveto() operation
 70693  70710     ** below is always a no-op and cannot fail.  We will run it anyhow, though,
 70694  70711     ** to guard against future changes to the code generator.
................................................................................
 70698  70715     if( NEVER(rc!=SQLITE_OK) ) goto abort_due_to_error;
 70699  70716   
 70700  70717     sqlite3BtreeSetCachedRowid(u.bj.pC->pCursor, 0);
 70701  70718     rc = sqlite3BtreeDelete(u.bj.pC->pCursor);
 70702  70719     u.bj.pC->cacheStatus = CACHE_STALE;
 70703  70720   
 70704  70721     /* Invoke the update-hook if required. */
 70705         -  if( rc==SQLITE_OK && db->xUpdateCallback && pOp->p4.z ){
        70722  +  if( rc==SQLITE_OK && db->xUpdateCallback && pOp->p4.z && u.bj.pC->isTable ){
 70706  70723       const char *zDb = db->aDb[u.bj.pC->iDb].zName;
 70707  70724       const char *zTbl = pOp->p4.z;
 70708  70725       db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE, zDb, zTbl, u.bj.iKey);
 70709  70726       assert( u.bj.pC->iDb>=0 );
 70710  70727     }
 70711  70728     if( pOp->p2 & OPFLAG_NCHANGE ) p->nChange++;
 70712  70729     break;
................................................................................
 75472  75489               if( iCol==pTab->iPKey ){
 75473  75490                 iCol = -1;
 75474  75491               }
 75475  75492               break;
 75476  75493             }
 75477  75494           }
 75478  75495           if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) && HasRowid(pTab) ){
 75479         -          iCol = -1;        /* IMP: R-44911-55124 */
        75496  +          /* IMP: R-24309-18625 */
        75497  +          /* IMP: R-44911-55124 */
        75498  +          iCol = -1;
 75480  75499           }
 75481  75500           if( iCol<pTab->nCol ){
 75482  75501             cnt++;
 75483  75502             if( iCol<0 ){
 75484  75503               pExpr->affinity = SQLITE_AFF_INTEGER;
 75485  75504             }else if( pExpr->iTable==0 ){
 75486  75505               testcase( iCol==31 );
................................................................................
112298 112317     saved_prereq = pNew->prereq;
112299 112318     saved_nOut = pNew->nOut;
112300 112319     pNew->rSetup = 0;
112301 112320     rLogSize = estLog(sqlite3LogEst(pProbe->aiRowEst[0]));
112302 112321   
112303 112322     /* Consider using a skip-scan if there are no WHERE clause constraints
112304 112323     ** available for the left-most terms of the index, and if the average
112305         -  ** number of repeats in the left-most terms is at least 50.
       112324  +  ** number of repeats in the left-most terms is at least 18.  The magic
       112325  +  ** number 18 was found by experimentation to be the payoff point where
       112326  +  ** skip-scan become faster than a full-scan.
112306 112327     */
112307 112328     if( pTerm==0
112308 112329      && saved_nEq==saved_nSkip
112309 112330      && saved_nEq+1<pProbe->nKeyCol
112310         -   && pProbe->aiRowEst[saved_nEq+1]>50  /* TUNING: Minimum for skip-scan */
       112331  +   && pProbe->aiRowEst[saved_nEq+1]>=18  /* TUNING: Minimum for skip-scan */
112311 112332     ){
112312 112333       LogEst nIter;
112313 112334       pNew->u.btree.nEq++;
112314 112335       pNew->u.btree.nSkip++;
112315 112336       pNew->aLTerm[pNew->nLTerm++] = 0;
112316 112337       pNew->wsFlags |= WHERE_SKIPSCAN;
112317 112338       nIter = sqlite3LogEst(pProbe->aiRowEst[0]/pProbe->aiRowEst[saved_nEq+1]);
................................................................................
119474 119495         }
119475 119496         sqlite3GlobalConfig.mxMmap = mxMmap;
119476 119497         if( szMmap<0 ) szMmap = SQLITE_DEFAULT_MMAP_SIZE;
119477 119498         if( szMmap>mxMmap) szMmap = mxMmap;
119478 119499         sqlite3GlobalConfig.szMmap = szMmap;
119479 119500         break;
119480 119501       }
       119502  +
       119503  +#if SQLITE_OS_WIN && defined(SQLITE_WIN32_MALLOC)
       119504  +    case SQLITE_CONFIG_WIN32_HEAPSIZE: {
       119505  +      sqlite3GlobalConfig.nHeap = va_arg(ap, int);
       119506  +      break;
       119507  +    }
       119508  +#endif
119481 119509   
119482 119510       default: {
119483 119511         rc = SQLITE_ERROR;
119484 119512         break;
119485 119513       }
119486 119514     }
119487 119515     va_end(ap);

Changes to SQLite.Interop/src/core/sqlite3.h.

   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    110   #define SQLITE_VERSION        "3.8.2"
   111    111   #define SQLITE_VERSION_NUMBER 3008002
   112         -#define SQLITE_SOURCE_ID      "2013-11-22 21:32:44 f336c18fb72ab90e93640b12ac540d41accc7658"
          112  +#define SQLITE_SOURCE_ID      "2013-11-27 04:22:27 83c0bb9913838d18ba355033afde6e38b4690842"
   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
................................................................................
  1683   1683   ** either the [PRAGMA mmap_size] command, or by using the
  1684   1684   ** [SQLITE_FCNTL_MMAP_SIZE] file control.  ^(The maximum allowed mmap size
  1685   1685   ** cannot be changed at run-time.  Nor may the maximum allowed mmap size
  1686   1686   ** exceed the compile-time maximum mmap size set by the
  1687   1687   ** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
  1688   1688   ** ^If either argument to this option is negative, then that argument is
  1689   1689   ** changed to its compile-time default.
         1690  +**
         1691  +** [[SQLITE_CONFIG_WIN32_HEAPSIZE]]
         1692  +** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
         1693  +** <dd>^This option is only available if SQLite is compiled for Windows
         1694  +** with the [SQLITE_WIN32_MALLOC] pre-processor macro defined.
         1695  +** SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
         1696  +** that specifies the maximum size of the created heap.
  1690   1697   ** </dl>
  1691   1698   */
  1692   1699   #define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */
  1693   1700   #define SQLITE_CONFIG_MULTITHREAD   2  /* nil */
  1694   1701   #define SQLITE_CONFIG_SERIALIZED    3  /* nil */
  1695   1702   #define SQLITE_CONFIG_MALLOC        4  /* sqlite3_mem_methods* */
  1696   1703   #define SQLITE_CONFIG_GETMALLOC     5  /* sqlite3_mem_methods* */
................................................................................
  1707   1714   #define SQLITE_CONFIG_LOG          16  /* xFunc, void* */
  1708   1715   #define SQLITE_CONFIG_URI          17  /* int */
  1709   1716   #define SQLITE_CONFIG_PCACHE2      18  /* sqlite3_pcache_methods2* */
  1710   1717   #define SQLITE_CONFIG_GETPCACHE2   19  /* sqlite3_pcache_methods2* */
  1711   1718   #define SQLITE_CONFIG_COVERING_INDEX_SCAN 20  /* int */
  1712   1719   #define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */
  1713   1720   #define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */
         1721  +#define SQLITE_CONFIG_WIN32_HEAPSIZE      23  /* int nByte */
  1714   1722   
  1715   1723   /*
  1716   1724   ** CAPI3REF: Database Connection Configuration Options
  1717   1725   **
  1718   1726   ** These constants are the available integer configuration options that
  1719   1727   ** can be passed as the second argument to the [sqlite3_db_config()] interface.
  1720   1728   **

Changes to SQLite.Interop/src/win/interop.h.

     6      6    */
     7      7   
     8      8   #ifndef INTEROP_VERSION
     9      9   #define INTEROP_VERSION          "1.0.90.0"
    10     10   #endif
    11     11   
    12     12   #ifndef INTEROP_SOURCE_ID
    13         -#define INTEROP_SOURCE_ID        "07ecc4ebfa97eddd155df718c73523746b853a0d"
           13  +#define INTEROP_SOURCE_ID        "0000000000000000000000000000000000000000"
    14     14   #endif
    15     15   
    16     16   #ifndef INTEROP_SOURCE_TIMESTAMP
    17         -#define INTEROP_SOURCE_TIMESTAMP "2013-11-27 02:15:17 UTC"
           17  +#define INTEROP_SOURCE_TIMESTAMP "0000-00-00 00:00:00 UTC"
    18     18   #endif

Changes to System.Data.SQLite/SQLitePatchLevel.cs.

     5      5    * Released to the public domain, use at your own risk!
     6      6    ********************************************************/
     7      7   
     8      8   using System.Data.SQLite;
     9      9   
    10     10   ///////////////////////////////////////////////////////////////////////////////
    11     11   
    12         -[assembly: AssemblySourceId("07ecc4ebfa97eddd155df718c73523746b853a0d")]
           12  +[assembly: AssemblySourceId("0000000000000000000000000000000000000000")]
    13     13   
    14     14   ///////////////////////////////////////////////////////////////////////////////
    15     15   
    16         -[assembly: AssemblySourceTimeStamp("2013-11-27 02:15:17 UTC")]
           16  +[assembly: AssemblySourceTimeStamp("0000-00-00 00:00:00 UTC")]