System.Data.SQLite
Check-in [8b068e1af8]
Not logged in

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

Overview
Comment:Update SQLite core library to the 3.22.0 release in preparation for the 1.0.108.0 release.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:8b068e1af83d6f933abd17f2fe9b3e1ecebdcb23
User & Date: mistachkin 2018-02-26 22:08:30
Context
2018-02-26
22:53
In the test suite infrastructure, retain version of SQLite core library for use by test constraint expressions. check-in: c588ddf749 user: mistachkin tags: trunk
22:08
Update SQLite core library to the 3.22.0 release in preparation for the 1.0.108.0 release. check-in: 8b068e1af8 user: mistachkin tags: trunk
21:31
Make the (new) SetConfigurationOption tests more robust and get them passing again. check-in: 550a609491 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Doc/Extra/Provider/version.html.

    41     41         </table>
    42     42       </div>
    43     43       <div id="mainSection">
    44     44       <div id="mainBody">
    45     45       <h1 class="heading">Version History</h1>
    46     46       <p><b>1.0.108.0 - March XX, 2018 <font color="red">(release scheduled)</font></b></p>
    47     47       <ul>
    48         -      <li>Updated to <a href="https://www.sqlite.org/src/timeline?r=trunk">SQLite 3.23.0</a>.</li>
    49     48         <li>Support extended result codes when messages are looked up without the SQLite core library.</li>
    50     49         <li>Override System.Object members for the SQLiteException class to improve its ToString return value. Pursuant to <a href="https://system.data.sqlite.org/index.html/info/53962f9eff">[53962f9eff]</a>.</li>
    51     50         <li>More database connection configuration options for the <a href="https://www.sqlite.org/c3ref/db_config.html">sqlite3_db_config()</a> interface.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    52     51         <li>Set HResult property of SQLiteException based on the SQLite core library error code.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    53     52       </ul>
    54     53       <p><b>1.0.107.0 - January 30, 2018</b></p>
    55     54       <ul>

Changes to SQLite.Interop/props/sqlite3.props.

     5      5    *
     6      6    * Written by Joe Mistachkin.
     7      7    * Released to the public domain, use at your own risk!
     8      8    *
     9      9   -->
    10     10   <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
    11     11     <PropertyGroup Label="UserMacros">
    12         -    <SQLITE_MANIFEST_VERSION>3.23.0.0</SQLITE_MANIFEST_VERSION>
    13         -    <SQLITE_RC_VERSION>3,23,0,0</SQLITE_RC_VERSION>
           12  +    <SQLITE_MANIFEST_VERSION>3.22.0.0</SQLITE_MANIFEST_VERSION>
           13  +    <SQLITE_RC_VERSION>3,22,0,0</SQLITE_RC_VERSION>
    14     14       <SQLITE_COMMON_DEFINES>_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;SQLITE_THREADSAFE=1;SQLITE_USE_URI=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_STAT4=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_LOAD_EXTENSION=1;SQLITE_ENABLE_RTREE=1;SQLITE_SOUNDEX=1;SQLITE_ENABLE_MEMORY_MANAGEMENT=1;SQLITE_ENABLE_API_ARMOR=1;SQLITE_ENABLE_DBSTAT_VTAB=1;SQLITE_ENABLE_STMTVTAB=1</SQLITE_COMMON_DEFINES>
    15     15       <SQLITE_EXTRA_DEFINES>SQLITE_PLACEHOLDER=1;SQLITE_HAS_CODEC=1</SQLITE_EXTRA_DEFINES>
    16     16       <SQLITE_WINCE_200X_DEFINES>SQLITE_OMIT_WAL=1</SQLITE_WINCE_200X_DEFINES>
    17     17       <SQLITE_WINCE_2013_DEFINES>HAVE_ERRNO_H=1;SQLITE_MSVC_LOCALTIME_API=1</SQLITE_WINCE_2013_DEFINES>
    18     18       <SQLITE_DEBUG_DEFINES>SQLITE_DEBUG=1;SQLITE_MEMDEBUG=1;SQLITE_ENABLE_EXPENSIVE_ASSERT=1</SQLITE_DEBUG_DEFINES>
    19     19       <SQLITE_RELEASE_DEFINES>SQLITE_WIN32_MALLOC=1</SQLITE_RELEASE_DEFINES>
    20     20       <SQLITE_DISABLE_WARNINGS>4055;4100;4127;4146;4210;4232;4244;4245;4267;4306;4389;4701;4703;4706</SQLITE_DISABLE_WARNINGS>

Changes to SQLite.Interop/props/sqlite3.vsprops.

    10     10   <VisualStudioPropertySheet
    11     11   	ProjectType="Visual C++"
    12     12   	Version="8.00"
    13     13   	Name="sqlite3"
    14     14   	>
    15     15   	<UserMacro
    16     16   		Name="SQLITE_MANIFEST_VERSION"
    17         -		Value="3.23.0.0"
           17  +		Value="3.22.0.0"
    18     18   		PerformEnvironmentSet="true"
    19     19   	/>
    20     20   	<UserMacro
    21     21   		Name="SQLITE_RC_VERSION"
    22         -		Value="3,23,0,0"
           22  +		Value="3,22,0,0"
    23     23   		PerformEnvironmentSet="true"
    24     24   	/>
    25     25   	<UserMacro
    26     26   		Name="SQLITE_COMMON_DEFINES"
    27     27   		Value="_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;SQLITE_THREADSAFE=1;SQLITE_USE_URI=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_STAT4=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_LOAD_EXTENSION=1;SQLITE_ENABLE_RTREE=1;SQLITE_SOUNDEX=1;SQLITE_ENABLE_MEMORY_MANAGEMENT=1;SQLITE_ENABLE_API_ARMOR=1;SQLITE_ENABLE_DBSTAT_VTAB=1;SQLITE_ENABLE_STMTVTAB=1"
    28     28   		PerformEnvironmentSet="true"
    29     29   	/>

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.23.0.  By combining all the individual C code files into this
            3  +** version 3.22.0.  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
................................................................................
  1143   1143   ** been edited in any way since it was last checked in, then the last
  1144   1144   ** four hexadecimal digits of the hash may be modified.
  1145   1145   **
  1146   1146   ** See also: [sqlite3_libversion()],
  1147   1147   ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
  1148   1148   ** [sqlite_version()] and [sqlite_source_id()].
  1149   1149   */
  1150         -#define SQLITE_VERSION        "3.23.0"
  1151         -#define SQLITE_VERSION_NUMBER 3023000
  1152         -#define SQLITE_SOURCE_ID      "2018-02-08 01:00:11 ad5d3bdc739a0997786f94fb5789b726b9f53ff883226093924338fe5000922b"
         1150  +#define SQLITE_VERSION        "3.22.0"
         1151  +#define SQLITE_VERSION_NUMBER 3022000
         1152  +#define SQLITE_SOURCE_ID      "2018-01-22 18:45:57 0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e86726f2171d"
  1153   1153   
  1154   1154   /*
  1155   1155   ** CAPI3REF: Run-Time Library Version Numbers
  1156   1156   ** KEYWORDS: sqlite3_version sqlite3_sourceid
  1157   1157   **
  1158   1158   ** These interfaces provide the same information as the [SQLITE_VERSION],
  1159   1159   ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
................................................................................
  4679   4679   ** a schema change, on the first  [sqlite3_step()] call following any change
  4680   4680   ** to the [sqlite3_bind_text | bindings] of that [parameter]. 
  4681   4681   ** ^The specific value of WHERE-clause [parameter] might influence the 
  4682   4682   ** choice of query plan if the parameter is the left-hand side of a [LIKE]
  4683   4683   ** or [GLOB] operator or if the parameter is compared to an indexed column
  4684   4684   ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
  4685   4685   ** </li>
  4686         -** </ol>
  4687   4686   **
  4688   4687   ** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having
  4689   4688   ** the extra prepFlags parameter, which is a bit array consisting of zero or
  4690   4689   ** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags.  ^The
  4691   4690   ** sqlite3_prepare_v2() interface works exactly the same as
  4692   4691   ** sqlite3_prepare_v3() with a zero prepFlags parameter.
         4692  +** </ol>
  4693   4693   */
  4694   4694   SQLITE_API int sqlite3_prepare(
  4695   4695     sqlite3 *db,            /* Database handle */
  4696   4696     const char *zSql,       /* SQL statement, UTF-8 encoded */
  4697   4697     int nByte,              /* Maximum length of zSql in bytes. */
  4698   4698     sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  4699   4699     const char **pzTail     /* OUT: Pointer to unused portion of zSql */
................................................................................
 15633  15633   };
 15634  15634   
 15635  15635   /* Allowed values for Column.colFlags:
 15636  15636   */
 15637  15637   #define COLFLAG_PRIMKEY  0x0001    /* Column is part of the primary key */
 15638  15638   #define COLFLAG_HIDDEN   0x0002    /* A hidden column in a virtual table */
 15639  15639   #define COLFLAG_HASTYPE  0x0004    /* Type name follows column name */
 15640         -#define COLFLAG_UNIQUE   0x0008    /* Column def contains "UNIQUE" or "PK" */
 15641  15640   
 15642  15641   /*
 15643  15642   ** A "Collating Sequence" is defined by an instance of the following
 15644  15643   ** structure. Conceptually, a collating sequence consists of a name and
 15645  15644   ** a comparison routine that defines the order of that sequence.
 15646  15645   **
 15647  15646   ** If CollSeq.xCmp is NULL, it means that the
................................................................................
 18854  18853   
 18855  18854   /* One or more of the following flags are set to indicate the validOK
 18856  18855   ** representations of the value stored in the Mem struct.
 18857  18856   **
 18858  18857   ** If the MEM_Null flag is set, then the value is an SQL NULL value.
 18859  18858   ** For a pointer type created using sqlite3_bind_pointer() or
 18860  18859   ** sqlite3_result_pointer() the MEM_Term and MEM_Subtype flags are also set.
        18860  +** If both MEM_Null and MEM_Zero are set, that means that the value is
        18861  +** an unchanging column value from VColumn.
 18861  18862   **
 18862  18863   ** If the MEM_Str flag is set then Mem.z points at a string representation.
 18863  18864   ** Usually this is encoded in the same unicode encoding as the main
 18864  18865   ** database (see below for exceptions). If the MEM_Term flag is also
 18865  18866   ** set, then the string is nul terminated. The MEM_Int and MEM_Real 
 18866  18867   ** flags may coexist with the MEM_Str flag.
 18867  18868   */
................................................................................
 18947  18948     Mem *pOut;              /* The return value is stored here */
 18948  18949     FuncDef *pFunc;         /* Pointer to function information */
 18949  18950     Mem *pMem;              /* Memory cell used to store aggregate context */
 18950  18951     Vdbe *pVdbe;            /* The VM that owns this context */
 18951  18952     int iOp;                /* Instruction number of OP_Function */
 18952  18953     int isError;            /* Error code returned by the function. */
 18953  18954     u8 skipFlag;            /* Skip accumulator loading if true */
        18955  +  u8 fErrorOrAux;         /* isError!=0 or pVdbe->pAuxData modified */
 18954  18956     u8 argc;                /* Number of arguments */
 18955  18957     sqlite3_value *argv[1]; /* Argument set */
 18956  18958   };
 18957  18959   
 18958  18960   /* A bitfield type for use inside of structures.  Always follow with :N where
 18959  18961   ** N is the number of bits.
 18960  18962   */
................................................................................
 29057  29059   /*
 29058  29060   ** Convert zNum to a 64-bit signed integer.  zNum must be decimal. This
 29059  29061   ** routine does *not* accept hexadecimal notation.
 29060  29062   **
 29061  29063   ** Returns:
 29062  29064   **
 29063  29065   **     0    Successful transformation.  Fits in a 64-bit signed integer.
 29064         -**     1    Excess non-space text after the integer value
        29066  +**     1    Excess text after the integer value
 29065  29067   **     2    Integer too large for a 64-bit signed integer or is malformed
 29066  29068   **     3    Special case of 9223372036854775808
 29067  29069   **
 29068  29070   ** length is the number of bytes in the string (bytes, not characters).
 29069  29071   ** The string is not necessarily zero-terminated.  The encoding is
 29070  29072   ** given by enc.
 29071  29073   */
................................................................................
 29100  29102       }
 29101  29103     }
 29102  29104     zStart = zNum;
 29103  29105     while( zNum<zEnd && zNum[0]=='0' ){ zNum+=incr; } /* Skip leading zeros. */
 29104  29106     for(i=0; &zNum[i]<zEnd && (c=zNum[i])>='0' && c<='9'; i+=incr){
 29105  29107       u = u*10 + c - '0';
 29106  29108     }
 29107         -  testcase( i==18*incr );
 29108         -  testcase( i==19*incr );
 29109         -  testcase( i==20*incr );
 29110  29109     if( u>LARGEST_INT64 ){
 29111         -    /* This test and assignment is needed only to suppress UB warnings
 29112         -    ** from clang and -fsanitize=undefined.  This test and assignment make
 29113         -    ** the code a little larger and slower, and no harm comes from omitting
 29114         -    ** them, but we must appaise the undefined-behavior pharisees. */
 29115  29110       *pNum = neg ? SMALLEST_INT64 : LARGEST_INT64;
 29116  29111     }else if( neg ){
 29117  29112       *pNum = -(i64)u;
 29118  29113     }else{
 29119  29114       *pNum = (i64)u;
 29120  29115     }
 29121         -  rc = 0;
 29122         -  if( (i==0 && zStart==zNum)     /* No digits */
        29116  +  testcase( i==18 );
        29117  +  testcase( i==19 );
        29118  +  testcase( i==20 );
        29119  +  if( &zNum[i]<zEnd              /* Extra bytes at the end */
        29120  +   || (i==0 && zStart==zNum)     /* No digits */
 29123  29121      || nonNum                     /* UTF16 with high-order bytes non-zero */
 29124  29122     ){
 29125  29123       rc = 1;
 29126         -  }else if( &zNum[i]<zEnd ){     /* Extra bytes at the end */
 29127         -    int jj = i;
 29128         -    do{
 29129         -      if( !sqlite3Isspace(zNum[jj]) ){
 29130         -        rc = 1;          /* Extra non-space text after the integer */
 29131         -        break;
 29132         -      }
 29133         -      jj += incr;
 29134         -    }while( &zNum[jj]<zEnd );
        29124  +  }else{
        29125  +    rc = 0;
 29135  29126     }
 29136         -  if( i<19*incr ){
        29127  +  if( i>19*incr ){                /* Too many digits */
        29128  +    /* zNum is empty or contains non-numeric text or is longer
        29129  +    ** than 19 digits (thus guaranteeing that it is too large) */
        29130  +    return 2;
        29131  +  }else if( i<19*incr ){
 29137  29132       /* Less than 19 digits, so we know that it fits in 64 bits */
 29138  29133       assert( u<=LARGEST_INT64 );
 29139  29134       return rc;
 29140  29135     }else{
 29141  29136       /* zNum is a 19-digit numbers.  Compare it against 9223372036854775808. */
 29142         -    c = i>19*incr ? 1 : compare2pow63(zNum, incr);
        29137  +    c = compare2pow63(zNum, incr);
 29143  29138       if( c<0 ){
 29144  29139         /* zNum is less than 9223372036854775808 so it fits */
 29145  29140         assert( u<=LARGEST_INT64 );
 29146  29141         return rc;
        29142  +    }else if( c>0 ){
        29143  +      /* zNum is greater than 9223372036854775808 so it overflows */
        29144  +      return 2;
 29147  29145       }else{
 29148         -      *pNum = neg ? SMALLEST_INT64 : LARGEST_INT64;
 29149         -      if( c>0 ){
 29150         -        /* zNum is greater than 9223372036854775808 so it overflows */
 29151         -        return 2;
 29152         -      }else{
 29153         -        /* zNum is exactly 9223372036854775808.  Fits if negative.  The
 29154         -        ** special case 2 overflow if positive */
 29155         -        assert( u-1==LARGEST_INT64 );
 29156         -        return neg ? rc : 3;
 29157         -      }
        29146  +      /* zNum is exactly 9223372036854775808.  Fits if negative.  The
        29147  +      ** special case 2 overflow if positive */
        29148  +      assert( u-1==LARGEST_INT64 );
        29149  +      return neg ? rc : 3;
 29158  29150       }
 29159  29151     }
 29160  29152   }
 29161  29153   
 29162  29154   /*
 29163  29155   ** Transform a UTF-8 integer literal, in either decimal or hexadecimal,
 29164  29156   ** into a 64-bit signed integer.  This routine accepts hexadecimal literals,
................................................................................
 31444  31436   ** is held when required. This function is only used as part of assert() 
 31445  31437   ** statements. e.g.
 31446  31438   **
 31447  31439   **   unixEnterMutex()
 31448  31440   **     assert( unixMutexHeld() );
 31449  31441   **   unixEnterLeave()
 31450  31442   */
 31451         -static sqlite3_mutex *unixBigLock = 0;
 31452  31443   static void unixEnterMutex(void){
 31453         -  sqlite3_mutex_enter(unixBigLock);
        31444  +  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));
 31454  31445   }
 31455  31446   static void unixLeaveMutex(void){
 31456         -  sqlite3_mutex_leave(unixBigLock);
        31447  +  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));
 31457  31448   }
 31458  31449   #ifdef SQLITE_DEBUG
 31459  31450   static int unixMutexHeld(void) {
 31460         -  return sqlite3_mutex_held(unixBigLock);
        31451  +  return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));
 31461  31452   }
 31462  31453   #endif
 31463  31454   
 31464  31455   
 31465  31456   #ifdef SQLITE_HAVE_OS_TRACE
 31466  31457   /*
 31467  31458   ** Helper function for printing out trace information from debugging
................................................................................
 36595  36586     ** the same instant might all reset the PRNG.  But multiple resets
 36596  36587     ** are harmless.
 36597  36588     */
 36598  36589     if( randomnessPid!=osGetpid(0) ){
 36599  36590       randomnessPid = osGetpid(0);
 36600  36591       sqlite3_randomness(0,0);
 36601  36592     }
        36593  +
 36602  36594     memset(p, 0, sizeof(unixFile));
 36603  36595   
 36604  36596     if( eType==SQLITE_OPEN_MAIN_DB ){
 36605  36597       UnixUnusedFd *pUnused;
 36606  36598       pUnused = findReusableFd(zName, flags);
 36607  36599       if( pUnused ){
 36608  36600         fd = pUnused->fd;
................................................................................
 38469  38461     ** correctly.  See ticket [bb3a86e890c8e96ab] */
 38470  38462     assert( ArraySize(aSyscall)==29 );
 38471  38463   
 38472  38464     /* Register all VFSes defined in the aVfs[] array */
 38473  38465     for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){
 38474  38466       sqlite3_vfs_register(&aVfs[i], i==0);
 38475  38467     }
 38476         -  unixBigLock = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1);
 38477  38468     return SQLITE_OK; 
 38478  38469   }
 38479  38470   
 38480  38471   /*
 38481  38472   ** Shutdown the operating system interface.
 38482  38473   **
 38483  38474   ** Some operating systems might need to do some cleanup in this routine,
 38484  38475   ** to release dynamically allocated objects.  But not on unix.
 38485  38476   ** This routine is a no-op for unix.
 38486  38477   */
 38487  38478   SQLITE_API int sqlite3_os_end(void){ 
 38488         -  unixBigLock = 0;
 38489  38479     return SQLITE_OK; 
 38490  38480   }
 38491  38481    
 38492  38482   #endif /* SQLITE_OS_UNIX */
 38493  38483   
 38494  38484   /************** End of os_unix.c *********************************************/
 38495  38485   /************** Begin file os_win.c ******************************************/
................................................................................
 42320  42310   ** is held when required. This function is only used as part of assert()
 42321  42311   ** statements. e.g.
 42322  42312   **
 42323  42313   **   winShmEnterMutex()
 42324  42314   **     assert( winShmMutexHeld() );
 42325  42315   **   winShmLeaveMutex()
 42326  42316   */
 42327         -static sqlite3_mutex *winBigLock = 0;
 42328  42317   static void winShmEnterMutex(void){
 42329         -  sqlite3_mutex_enter(winBigLock);
        42318  +  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));
 42330  42319   }
 42331  42320   static void winShmLeaveMutex(void){
 42332         -  sqlite3_mutex_leave(winBigLock);
        42321  +  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));
 42333  42322   }
 42334  42323   #ifndef NDEBUG
 42335  42324   static int winShmMutexHeld(void) {
 42336         -  return sqlite3_mutex_held(winBigLock);
        42325  +  return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));
 42337  42326   }
 42338  42327   #endif
 42339  42328   
 42340  42329   /*
 42341  42330   ** Object used to represent a single file opened and mmapped to provide
 42342  42331   ** shared memory.  When multiple threads all reference the same
 42343  42332   ** log-summary, each thread has its own winFile object, but they all
................................................................................
 44752  44741   
 44753  44742     sqlite3_vfs_register(&winNolockVfs, 0);
 44754  44743   
 44755  44744   #if defined(SQLITE_WIN32_HAS_WIDE)
 44756  44745     sqlite3_vfs_register(&winLongPathNolockVfs, 0);
 44757  44746   #endif
 44758  44747   
 44759         -#ifndef SQLITE_OMIT_WAL
 44760         -  winBigLock = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1);
 44761         -#endif
 44762         -
 44763  44748     return SQLITE_OK;
 44764  44749   }
 44765  44750   
 44766  44751   SQLITE_API int sqlite3_os_end(void){
 44767  44752   #if SQLITE_OS_WINRT
 44768  44753     if( sleepObj!=NULL ){
 44769  44754       osCloseHandle(sleepObj);
 44770  44755       sleepObj = NULL;
 44771  44756     }
 44772  44757   #endif
 44773         -
 44774         -#ifndef SQLITE_OMIT_WAL
 44775         -  winBigLock = 0;
 44776         -#endif
 44777         -
 44778  44758     return SQLITE_OK;
 44779  44759   }
 44780  44760   
 44781  44761   #endif /* SQLITE_OS_WIN */
 44782  44762   
 44783  44763   /************** End of os_win.c **********************************************/
 44784  44764   /************** Begin file bitvec.c ******************************************/
................................................................................
 49195  49175     assert( isOpen(pPager->fd) );
 49196  49176     dc = sqlite3OsDeviceCharacteristics(pPager->fd);
 49197  49177   #else
 49198  49178     UNUSED_PARAMETER(pPager);
 49199  49179   #endif
 49200  49180   
 49201  49181   #ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE
 49202         -  if( pPager->dbSize>0 && (dc&SQLITE_IOCAP_BATCH_ATOMIC) ){
        49182  +  if( dc&SQLITE_IOCAP_BATCH_ATOMIC ){
 49203  49183       return -1;
 49204  49184     }
 49205  49185   #endif
 49206  49186   
 49207  49187   #ifdef SQLITE_ENABLE_ATOMIC_WRITE
 49208  49188     {
 49209  49189       int nSector = pPager->sectorSize;
................................................................................
 52084  52064     PgHdr *pNext;
 52085  52065     for(p=pPager->pMmapFreelist; p; p=pNext){
 52086  52066       pNext = p->pDirty;
 52087  52067       sqlite3_free(p);
 52088  52068     }
 52089  52069   }
 52090  52070   
 52091         -/* Verify that the database file has not be deleted or renamed out from
 52092         -** under the pager.  Return SQLITE_OK if the database is still where it ought
 52093         -** to be on disk.  Return non-zero (SQLITE_READONLY_DBMOVED or some other error
 52094         -** code from sqlite3OsAccess()) if the database has gone missing.
 52095         -*/
 52096         -static int databaseIsUnmoved(Pager *pPager){
 52097         -  int bHasMoved = 0;
 52098         -  int rc;
 52099         -
 52100         -  if( pPager->tempFile ) return SQLITE_OK;
 52101         -  if( pPager->dbSize==0 ) return SQLITE_OK;
 52102         -  assert( pPager->zFilename && pPager->zFilename[0] );
 52103         -  rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_HAS_MOVED, &bHasMoved);
 52104         -  if( rc==SQLITE_NOTFOUND ){
 52105         -    /* If the HAS_MOVED file-control is unimplemented, assume that the file
 52106         -    ** has not been moved.  That is the historical behavior of SQLite: prior to
 52107         -    ** version 3.8.3, it never checked */
 52108         -    rc = SQLITE_OK;
 52109         -  }else if( rc==SQLITE_OK && bHasMoved ){
 52110         -    rc = SQLITE_READONLY_DBMOVED;
 52111         -  }
 52112         -  return rc;
 52113         -}
 52114         -
 52115  52071   
 52116  52072   /*
 52117  52073   ** Shutdown the page cache.  Free all memory and close all files.
 52118  52074   **
 52119  52075   ** If a transaction was in progress when this routine is called, that
 52120  52076   ** transaction is rolled back.  All outstanding pages are invalidated
 52121  52077   ** and their memory is freed.  Any attempt to use a page associated
................................................................................
 52124  52080   **
 52125  52081   ** This function always succeeds. If a transaction is active an attempt
 52126  52082   ** is made to roll it back. If an error occurs during the rollback 
 52127  52083   ** a hot journal may be left in the filesystem but no error is returned
 52128  52084   ** to the caller.
 52129  52085   */
 52130  52086   SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager, sqlite3 *db){
 52131         -  u8 *pTmp = (u8*)pPager->pTmpSpace;
        52087  +  u8 *pTmp = (u8 *)pPager->pTmpSpace;
        52088  +
 52132  52089     assert( db || pagerUseWal(pPager)==0 );
 52133  52090     assert( assert_pager_state(pPager) );
 52134  52091     disable_simulated_io_errors();
 52135  52092     sqlite3BeginBenignMalloc();
 52136  52093     pagerFreeMapHdrs(pPager);
 52137  52094     /* pPager->errCode = 0; */
 52138  52095     pPager->exclusiveMode = 0;
 52139  52096   #ifndef SQLITE_OMIT_WAL
 52140         -  {
 52141         -    u8 *a = 0;
 52142         -    assert( db || pPager->pWal==0 );
 52143         -    if( db && 0==(db->flags & SQLITE_NoCkptOnClose) 
 52144         -     && SQLITE_OK==databaseIsUnmoved(pPager)
 52145         -    ){
 52146         -      a = pTmp;
 52147         -    }
 52148         -    sqlite3WalClose(pPager->pWal, db, pPager->walSyncFlags, pPager->pageSize,a);
 52149         -    pPager->pWal = 0;
 52150         -  }
        52097  +  assert( db || pPager->pWal==0 );
        52098  +  sqlite3WalClose(pPager->pWal, db, pPager->walSyncFlags, pPager->pageSize,
        52099  +      (db && (db->flags & SQLITE_NoCkptOnClose) ? 0 : pTmp)
        52100  +  );
        52101  +  pPager->pWal = 0;
 52151  52102   #endif
 52152  52103     pager_reset(pPager);
 52153  52104     if( MEMDB ){
 52154  52105       pager_unlock(pPager);
 52155  52106     }else{
 52156  52107       /* If it is open, sync the journal file before calling UnlockAndRollback.
 52157  52108       ** If this is not done, then an unsynced portion of the open journal 
................................................................................
 52977  52928     /* memset(pPager->aHash, 0, sizeof(pPager->aHash)); */
 52978  52929     /* pPager->szMmap = SQLITE_DEFAULT_MMAP_SIZE // will be set by btree.c */
 52979  52930   
 52980  52931     *ppPager = pPager;
 52981  52932     return SQLITE_OK;
 52982  52933   }
 52983  52934   
        52935  +
        52936  +/* Verify that the database file has not be deleted or renamed out from
        52937  +** under the pager.  Return SQLITE_OK if the database is still were it ought
        52938  +** to be on disk.  Return non-zero (SQLITE_READONLY_DBMOVED or some other error
        52939  +** code from sqlite3OsAccess()) if the database has gone missing.
        52940  +*/
        52941  +static int databaseIsUnmoved(Pager *pPager){
        52942  +  int bHasMoved = 0;
        52943  +  int rc;
        52944  +
        52945  +  if( pPager->tempFile ) return SQLITE_OK;
        52946  +  if( pPager->dbSize==0 ) return SQLITE_OK;
        52947  +  assert( pPager->zFilename && pPager->zFilename[0] );
        52948  +  rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_HAS_MOVED, &bHasMoved);
        52949  +  if( rc==SQLITE_NOTFOUND ){
        52950  +    /* If the HAS_MOVED file-control is unimplemented, assume that the file
        52951  +    ** has not been moved.  That is the historical behavior of SQLite: prior to
        52952  +    ** version 3.8.3, it never checked */
        52953  +    rc = SQLITE_OK;
        52954  +  }else if( rc==SQLITE_OK && bHasMoved ){
        52955  +    rc = SQLITE_READONLY_DBMOVED;
        52956  +  }
        52957  +  return rc;
        52958  +}
 52984  52959   
 52985  52960   
 52986  52961   /*
 52987  52962   ** This function is called after transitioning from PAGER_UNLOCK to
 52988  52963   ** PAGER_SHARED state. It tests if there is a hot journal present in
 52989  52964   ** the file-system for the given pager. A hot journal is one that 
 52990  52965   ** needs to be played back. According to this function, a hot-journal
................................................................................
 54486  54461           rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_BEGIN_ATOMIC_WRITE, 0);
 54487  54462           if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
 54488  54463         }
 54489  54464         rc = pager_write_pagelist(pPager,sqlite3PcacheDirtyList(pPager->pPCache));
 54490  54465         if( bBatch ){
 54491  54466           if( rc==SQLITE_OK ){
 54492  54467             rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE, 0);
 54493         -        }
 54494         -        if( rc!=SQLITE_OK ){
 54495         -          sqlite3OsFileControlHint(fd, SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE, 0);
        54468  +        }else{
        54469  +          sqlite3OsFileControl(fd, SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE, 0);
 54496  54470           }
 54497  54471         }
 54498  54472   
 54499  54473         if( rc!=SQLITE_OK ){
 54500  54474           assert( rc!=SQLITE_IOERR_BLOCKED );
 54501  54475           goto commit_phase_one_exit;
 54502  54476         }
................................................................................
 59928  59902   **    eState==FAULT:                   Cursor fault with skipNext as error code.
 59929  59903   */
 59930  59904   struct BtCursor {
 59931  59905     u8 eState;                /* One of the CURSOR_XXX constants (see below) */
 59932  59906     u8 curFlags;              /* zero or more BTCF_* flags defined below */
 59933  59907     u8 curPagerFlags;         /* Flags to send to sqlite3PagerGet() */
 59934  59908     u8 hints;                 /* As configured by CursorSetHints() */
        59909  +  int nOvflAlloc;           /* Allocated size of aOverflow[] array */
        59910  +  Btree *pBtree;            /* The Btree to which this cursor belongs */
        59911  +  BtShared *pBt;            /* The BtShared this cursor points to */
        59912  +  BtCursor *pNext;          /* Forms a linked list of all cursors */
        59913  +  Pgno *aOverflow;          /* Cache of overflow page locations */
        59914  +  CellInfo info;            /* A parse of the cell we are pointing at */
        59915  +  i64 nKey;                 /* Size of pKey, or last integer key */
        59916  +  void *pKey;               /* Saved key that was cursor last known position */
        59917  +  Pgno pgnoRoot;            /* The root page of this tree */
 59935  59918     int skipNext;    /* Prev() is noop if negative. Next() is noop if positive.
 59936  59919                      ** Error code if eState==CURSOR_FAULT */
 59937         -  Btree *pBtree;            /* The Btree to which this cursor belongs */
 59938         -  Pgno *aOverflow;          /* Cache of overflow page locations */
 59939         -  void *pKey;               /* Saved key that was cursor last known position */
 59940  59920     /* All fields above are zeroed when the cursor is allocated.  See
 59941  59921     ** sqlite3BtreeCursorZero().  Fields that follow must be manually
 59942  59922     ** initialized. */
 59943         -#define BTCURSOR_FIRST_UNINIT pBt   /* Name of first uninitialized field */
 59944         -  BtShared *pBt;            /* The BtShared this cursor points to */
 59945         -  BtCursor *pNext;          /* Forms a linked list of all cursors */
 59946         -  CellInfo info;            /* A parse of the cell we are pointing at */
 59947         -  i64 nKey;                 /* Size of pKey, or last integer key */
 59948         -  Pgno pgnoRoot;            /* The root page of this tree */
 59949  59923     i8 iPage;                 /* Index of current page in apPage */
 59950  59924     u8 curIntKey;             /* Value of apPage[0]->intKey */
 59951  59925     u16 ix;                   /* Current index for apPage[iPage] */
 59952  59926     u16 aiIdx[BTCURSOR_MAX_DEPTH-1];     /* Current index in apPage[i] */
 59953  59927     struct KeyInfo *pKeyInfo;            /* Arg passed to comparison function */
 59954  59928     MemPage *pPage;                        /* Current page */
 59955  59929     MemPage *apPage[BTCURSOR_MAX_DEPTH-1]; /* Stack of parents of current page */
................................................................................
 59991  59965   ** CURSOR_FAULT:
 59992  59966   **   An unrecoverable error (an I/O error or a malloc failure) has occurred
 59993  59967   **   on a different connection that shares the BtShared cache with this
 59994  59968   **   cursor.  The error has left the cache in an inconsistent state.
 59995  59969   **   Do nothing else with this cursor.  Any attempt to use the cursor
 59996  59970   **   should return the error code stored in BtCursor.skipNext
 59997  59971   */
 59998         -#define CURSOR_VALID             0
 59999         -#define CURSOR_INVALID           1
        59972  +#define CURSOR_INVALID           0
        59973  +#define CURSOR_VALID             1
 60000  59974   #define CURSOR_SKIPNEXT          2
 60001  59975   #define CURSOR_REQUIRESEEK       3
 60002  59976   #define CURSOR_FAULT             4
 60003  59977   
 60004  59978   /* 
 60005  59979   ** The database page the PENDING_BYTE occupies. This page is never used.
 60006  59980   */
................................................................................
 64770  64744   **
 64771  64745   ** The simple approach here would be to memset() the entire object
 64772  64746   ** to zero.  But it turns out that the apPage[] and aiIdx[] arrays
 64773  64747   ** do not need to be zeroed and they are large, so we can save a lot
 64774  64748   ** of run-time by skipping the initialization of those elements.
 64775  64749   */
 64776  64750   SQLITE_PRIVATE void sqlite3BtreeCursorZero(BtCursor *p){
 64777         -  memset(p, 0, offsetof(BtCursor, BTCURSOR_FIRST_UNINIT));
        64751  +  memset(p, 0, offsetof(BtCursor, iPage));
 64778  64752   }
 64779  64753   
 64780  64754   /*
 64781  64755   ** Close a cursor.  The read lock on the database file is released
 64782  64756   ** when the last cursor is closed.
 64783  64757   */
 64784  64758   SQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor *pCur){
................................................................................
 65093  65067       ** The aOverflow[] array is sized at one entry for each overflow page
 65094  65068       ** in the overflow chain. The page number of the first overflow page is
 65095  65069       ** stored in aOverflow[0], etc. A value of 0 in the aOverflow[] array
 65096  65070       ** means "not yet known" (the cache is lazily populated).
 65097  65071       */
 65098  65072       if( (pCur->curFlags & BTCF_ValidOvfl)==0 ){
 65099  65073         int nOvfl = (pCur->info.nPayload-pCur->info.nLocal+ovflSize-1)/ovflSize;
 65100         -      if( pCur->aOverflow==0
 65101         -       || nOvfl*(int)sizeof(Pgno) > sqlite3MallocSize(pCur->aOverflow)
 65102         -      ){
        65074  +      if( nOvfl>pCur->nOvflAlloc ){
 65103  65075           Pgno *aNew = (Pgno*)sqlite3Realloc(
 65104  65076               pCur->aOverflow, nOvfl*2*sizeof(Pgno)
 65105  65077           );
 65106  65078           if( aNew==0 ){
 65107  65079             return SQLITE_NOMEM_BKPT;
 65108  65080           }else{
        65081  +          pCur->nOvflAlloc = nOvfl*2;
 65109  65082             pCur->aOverflow = aNew;
 65110  65083           }
 65111  65084         }
 65112  65085         memset(pCur->aOverflow, 0, nOvfl*sizeof(Pgno));
 65113  65086         pCur->curFlags |= BTCF_ValidOvfl;
 65114  65087       }else{
 65115  65088         /* If the overflow page-list cache has been allocated and the
................................................................................
 66615  66588   static void freePage(MemPage *pPage, int *pRC){
 66616  66589     if( (*pRC)==SQLITE_OK ){
 66617  66590       *pRC = freePage2(pPage->pBt, pPage, pPage->pgno);
 66618  66591     }
 66619  66592   }
 66620  66593   
 66621  66594   /*
 66622         -** Free any overflow pages associated with the given Cell.  Store
 66623         -** size information about the cell in pInfo.
        66595  +** Free any overflow pages associated with the given Cell.  Write the
        66596  +** local Cell size (the number of bytes on the original page, omitting
        66597  +** overflow) into *pnSize.
 66624  66598   */
 66625  66599   static int clearCell(
 66626  66600     MemPage *pPage,          /* The page that contains the Cell */
 66627  66601     unsigned char *pCell,    /* First byte of the Cell */
 66628  66602     CellInfo *pInfo          /* Size information about the cell */
 66629  66603   ){
 66630  66604     BtShared *pBt;
................................................................................
 67820  67794       */
 67821  67795       if( pOld->aData[0]!=apOld[0]->aData[0] ){
 67822  67796         rc = SQLITE_CORRUPT_BKPT;
 67823  67797         goto balance_cleanup;
 67824  67798       }
 67825  67799   
 67826  67800       /* Load b.apCell[] with pointers to all cells in pOld.  If pOld
 67827         -    ** contains overflow cells, include them in the b.apCell[] array
        67801  +    ** constains overflow cells, include them in the b.apCell[] array
 67828  67802       ** in the correct spot.
 67829  67803       **
 67830  67804       ** Note that when there are multiple overflow cells, it is always the
 67831  67805       ** case that they are sequential and adjacent.  This invariant arises
 67832  67806       ** because multiple overflows can only occurs when inserting divider
 67833  67807       ** cells into a parent on a prior balance, and divider cells are always
 67834  67808       ** adjacent and are inserted in order.  There is an assert() tagged
................................................................................
 71305  71279         ((p->flags&MEM_Static)!=0 ? 1 : 0) == 1
 71306  71280       );
 71307  71281     }
 71308  71282     return 1;
 71309  71283   }
 71310  71284   #endif
 71311  71285   
 71312         -#ifdef SQLITE_DEBUG
 71313         -/*
 71314         -** Check that string value of pMem agrees with its integer or real value.
 71315         -**
 71316         -** A single int or real value always converts to the same strings.  But
 71317         -** many different strings can be converted into the same int or real.
 71318         -** If a table contains a numeric value and an index is based on the
 71319         -** corresponding string value, then it is important that the string be
 71320         -** derived from the numeric value, not the other way around, to ensure
 71321         -** that the index and table are consistent.  See ticket
 71322         -** https://www.sqlite.org/src/info/343634942dd54ab (2018-01-31) for
 71323         -** an example.
 71324         -**
 71325         -** This routine looks at pMem to verify that if it has both a numeric
 71326         -** representation and a string representation then the string rep has
 71327         -** been derived from the numeric and not the other way around.  It returns
 71328         -** true if everything is ok and false if there is a problem.
 71329         -**
 71330         -** This routine is for use inside of assert() statements only.
 71331         -*/
 71332         -SQLITE_PRIVATE int sqlite3VdbeMemConsistentDualRep(Mem *p){
 71333         -  char zBuf[100];
 71334         -  char *z;
 71335         -  int i, j, incr;
 71336         -  if( (p->flags & MEM_Str)==0 ) return 1;
 71337         -  if( (p->flags & (MEM_Int|MEM_Real))==0 ) return 1;
 71338         -  if( p->flags & MEM_Int ){
 71339         -    sqlite3_snprintf(sizeof(zBuf),zBuf,"%lld",p->u.i);
 71340         -  }else{
 71341         -    sqlite3_snprintf(sizeof(zBuf),zBuf,"%!.15g",p->u.r);
 71342         -  }
 71343         -  z = p->z;
 71344         -  i = j = 0;
 71345         -  incr = 1;
 71346         -  if( p->enc!=SQLITE_UTF8 ){
 71347         -    incr = 2;
 71348         -    if( p->enc==SQLITE_UTF16BE ) z++;
 71349         -  }
 71350         -  while( zBuf[j] ){
 71351         -    if( zBuf[j++]!=z[i] ) return 0;
 71352         -    i += incr;
 71353         -  }
 71354         -  return 1;
 71355         -}
 71356         -#endif /* SQLITE_DEBUG */
 71357  71286   
 71358  71287   /*
 71359  71288   ** If pMem is an object with a valid string representation, this routine
 71360  71289   ** ensures the internal encoding for the string representation is
 71361  71290   ** 'desiredEnc', one of SQLITE_UTF8, SQLITE_UTF16LE or SQLITE_UTF16BE.
 71362  71291   **
 71363  71292   ** If pMem is not a string object, or the encoding of the string
................................................................................
 71839  71768     assert( EIGHT_BYTE_ALIGNMENT(pMem) );
 71840  71769   
 71841  71770     pMem->u.r = sqlite3VdbeRealValue(pMem);
 71842  71771     MemSetTypeFlag(pMem, MEM_Real);
 71843  71772     return SQLITE_OK;
 71844  71773   }
 71845  71774   
 71846         -/* Compare a floating point value to an integer.  Return true if the two
 71847         -** values are the same within the precision of the floating point value.
 71848         -**
 71849         -** For some versions of GCC on 32-bit machines, if you do the more obvious
 71850         -** comparison of "r1==(double)i" you sometimes get an answer of false even
 71851         -** though the r1 and (double)i values are bit-for-bit the same.
 71852         -*/
 71853         -static int sqlite3RealSameAsInt(double r1, sqlite3_int64 i){
 71854         -  double r2 = (double)i;
 71855         -  return memcmp(&r1, &r2, sizeof(r1))==0;
 71856         -}
 71857         -
 71858  71775   /*
 71859  71776   ** Convert pMem so that it has types MEM_Real or MEM_Int or both.
 71860  71777   ** Invalidate any prior representations.
 71861  71778   **
 71862  71779   ** Every effort is made to force the conversion, even if the input
 71863  71780   ** is a string that does not look completely like a number.  Convert
 71864  71781   ** as much of the string as we can and ignore the rest.
................................................................................
 71870  71787       assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
 71871  71788       rc = sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc);
 71872  71789       if( rc==0 ){
 71873  71790         MemSetTypeFlag(pMem, MEM_Int);
 71874  71791       }else{
 71875  71792         i64 i = pMem->u.i;
 71876  71793         sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc);
 71877         -      if( rc==1 && sqlite3RealSameAsInt(pMem->u.r, i) ){
        71794  +      if( rc==1 && pMem->u.r==(double)i ){
 71878  71795           pMem->u.i = i;
 71879  71796           MemSetTypeFlag(pMem, MEM_Int);
 71880  71797         }else{
 71881  71798           MemSetTypeFlag(pMem, MEM_Real);
 71882  71799         }
 71883  71800       }
 71884  71801     }
................................................................................
 72353  72270     }else{
 72354  72271       sqlite3VdbeMemStringify(pVal, enc, 0);
 72355  72272       assert( 0==(1&SQLITE_PTR_TO_INT(pVal->z)) );
 72356  72273     }
 72357  72274     assert(pVal->enc==(enc & ~SQLITE_UTF16_ALIGNED) || pVal->db==0
 72358  72275                 || pVal->db->mallocFailed );
 72359  72276     if( pVal->enc==(enc & ~SQLITE_UTF16_ALIGNED) ){
 72360         -    assert( sqlite3VdbeMemConsistentDualRep(pVal) );
 72361  72277       return pVal->z;
 72362  72278     }else{
 72363  72279       return 0;
 72364  72280     }
 72365  72281   }
 72366  72282   
 72367  72283   /* This function is only available internally, it is not part of the
................................................................................
 72376  72292   */
 72377  72293   SQLITE_PRIVATE const void *sqlite3ValueText(sqlite3_value* pVal, u8 enc){
 72378  72294     if( !pVal ) return 0;
 72379  72295     assert( pVal->db==0 || sqlite3_mutex_held(pVal->db->mutex) );
 72380  72296     assert( (enc&3)==(enc&~SQLITE_UTF16_ALIGNED) );
 72381  72297     assert( (pVal->flags & MEM_RowSet)==0 );
 72382  72298     if( (pVal->flags&(MEM_Str|MEM_Term))==(MEM_Str|MEM_Term) && pVal->enc==enc ){
 72383         -    assert( sqlite3VdbeMemConsistentDualRep(pVal) );
 72384  72299       return pVal->z;
 72385  72300     }
 72386  72301     if( pVal->flags&MEM_Null ){
 72387  72302       return 0;
 72388  72303     }
 72389  72304     return valueToText(pVal, enc);
 72390  72305   }
................................................................................
 78158  78073   SQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){
 78159  78074     assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
 78160  78075     sqlite3VdbeMemSetDouble(pCtx->pOut, rVal);
 78161  78076   }
 78162  78077   SQLITE_API void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){
 78163  78078     assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
 78164  78079     pCtx->isError = SQLITE_ERROR;
        78080  +  pCtx->fErrorOrAux = 1;
 78165  78081     sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT);
 78166  78082   }
 78167  78083   #ifndef SQLITE_OMIT_UTF16
 78168  78084   SQLITE_API void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){
 78169  78085     assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
 78170  78086     pCtx->isError = SQLITE_ERROR;
        78087  +  pCtx->fErrorOrAux = 1;
 78171  78088     sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT);
 78172  78089   }
 78173  78090   #endif
 78174  78091   SQLITE_API void sqlite3_result_int(sqlite3_context *pCtx, int iVal){
 78175  78092     assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
 78176  78093     sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal);
 78177  78094   }
................................................................................
 78269  78186     if( n>(u64)pOut->db->aLimit[SQLITE_LIMIT_LENGTH] ){
 78270  78187       return SQLITE_TOOBIG;
 78271  78188     }
 78272  78189     sqlite3VdbeMemSetZeroBlob(pCtx->pOut, (int)n);
 78273  78190     return SQLITE_OK;
 78274  78191   }
 78275  78192   SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){
 78276         -  pCtx->isError = errCode ? errCode : -1;
        78193  +  pCtx->isError = errCode;
        78194  +  pCtx->fErrorOrAux = 1;
 78277  78195   #ifdef SQLITE_DEBUG
 78278  78196     if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode;
 78279  78197   #endif
 78280  78198     if( pCtx->pOut->flags & MEM_Null ){
 78281  78199       sqlite3VdbeMemSetStr(pCtx->pOut, sqlite3ErrStr(errCode), -1, 
 78282  78200                            SQLITE_UTF8, SQLITE_STATIC);
 78283  78201     }
 78284  78202   }
 78285  78203   
 78286  78204   /* Force an SQLITE_TOOBIG error. */
 78287  78205   SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){
 78288  78206     assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
 78289  78207     pCtx->isError = SQLITE_TOOBIG;
        78208  +  pCtx->fErrorOrAux = 1;
 78290  78209     sqlite3VdbeMemSetStr(pCtx->pOut, "string or blob too big", -1, 
 78291  78210                          SQLITE_UTF8, SQLITE_STATIC);
 78292  78211   }
 78293  78212   
 78294  78213   /* An SQLITE_NOMEM error. */
 78295  78214   SQLITE_API void sqlite3_result_error_nomem(sqlite3_context *pCtx){
 78296  78215     assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
 78297  78216     sqlite3VdbeMemSetNull(pCtx->pOut);
 78298  78217     pCtx->isError = SQLITE_NOMEM_BKPT;
        78218  +  pCtx->fErrorOrAux = 1;
 78299  78219     sqlite3OomFault(pCtx->pOut->db);
 78300  78220   }
 78301  78221   
 78302  78222   /*
 78303  78223   ** This function is called after a transaction has been committed. It 
 78304  78224   ** invokes callbacks registered with sqlite3_wal_hook() as required.
 78305  78225   */
................................................................................
 78698  78618     if( pAuxData==0 ){
 78699  78619       pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData));
 78700  78620       if( !pAuxData ) goto failed;
 78701  78621       pAuxData->iAuxOp = pCtx->iOp;
 78702  78622       pAuxData->iAuxArg = iArg;
 78703  78623       pAuxData->pNextAux = pVdbe->pAuxData;
 78704  78624       pVdbe->pAuxData = pAuxData;
 78705         -    if( pCtx->isError==0 ) pCtx->isError = -1;
        78625  +    if( pCtx->fErrorOrAux==0 ){
        78626  +      pCtx->isError = 0;
        78627  +      pCtx->fErrorOrAux = 1;
        78628  +    }
 78706  78629     }else if( pAuxData->xDeleteAux ){
 78707  78630       pAuxData->xDeleteAux(pAuxData->pAux);
 78708  78631     }
 78709  78632   
 78710  78633     pAuxData->pAux = pAux;
 78711  78634     pAuxData->xDeleteAux = xDelete;
 78712  78635     return;
................................................................................
 80228  80151       pRec->u.i = iValue;
 80229  80152       pRec->flags |= MEM_Int;
 80230  80153     }else{
 80231  80154       pRec->u.r = rValue;
 80232  80155       pRec->flags |= MEM_Real;
 80233  80156       if( bTryForInt ) sqlite3VdbeIntegerAffinity(pRec);
 80234  80157     }
 80235         -  /* TEXT->NUMERIC is many->one.  Hence, it is important to invalidate the
 80236         -  ** string representation after computing a numeric equivalent, because the
 80237         -  ** string representation might not be the canonical representation for the
 80238         -  ** numeric value.  Ticket [343634942dd54ab57b7024] 2018-01-31. */
 80239         -  pRec->flags &= ~MEM_Str;
 80240  80158   }
 80241  80159   
 80242  80160   /*
 80243  80161   ** Processing is determine by the affinity parameter:
 80244  80162   **
 80245  80163   ** SQLITE_AFF_INTEGER:
 80246  80164   ** SQLITE_AFF_REAL:
................................................................................
 82347  82265   case OP_If:                 /* jump, in1 */
 82348  82266   case OP_IfNot: {            /* jump, in1 */
 82349  82267     int c;
 82350  82268     pIn1 = &aMem[pOp->p1];
 82351  82269     if( pIn1->flags & MEM_Null ){
 82352  82270       c = pOp->p3;
 82353  82271     }else{
 82354         -    if( pIn1->flags & MEM_Int ){
 82355         -      c = pIn1->u.i!=0;
 82356         -    }else{
 82357         -      c = sqlite3VdbeRealValue(pIn1)!=0.0;
 82358         -    }
        82272  +#ifdef SQLITE_OMIT_FLOATING_POINT
        82273  +    c = sqlite3VdbeIntValue(pIn1)!=0;
        82274  +#else
        82275  +    c = sqlite3VdbeRealValue(pIn1)!=0.0;
        82276  +#endif
 82359  82277       if( pOp->opcode==OP_IfNot ) c = !c;
 82360  82278     }
 82361  82279     VdbeBranchTaken(c!=0, 2);
 82362  82280     if( c ){
 82363  82281       goto jump_to_p2;
 82364  82282     }
 82365  82283     break;
................................................................................
 86262  86180     sqlite3_context *pCtx;
 86263  86181   
 86264  86182     assert( pOp->p4type==P4_FUNCDEF );
 86265  86183     n = pOp->p5;
 86266  86184     assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
 86267  86185     assert( n==0 || (pOp->p2>0 && pOp->p2+n<=(p->nMem+1 - p->nCursor)+1) );
 86268  86186     assert( pOp->p3<pOp->p2 || pOp->p3>=pOp->p2+n );
 86269         -  pCtx = sqlite3DbMallocRawNN(db, n*sizeof(sqlite3_value*) +
 86270         -               (sizeof(pCtx[0]) + sizeof(Mem) - sizeof(sqlite3_value*)));
        86187  +  pCtx = sqlite3DbMallocRawNN(db, sizeof(*pCtx) + (n-1)*sizeof(sqlite3_value*));
 86271  86188     if( pCtx==0 ) goto no_mem;
 86272  86189     pCtx->pMem = 0;
 86273         -  pCtx->pOut = (Mem*)&(pCtx->argv[n]);
 86274         -  sqlite3VdbeMemInit(pCtx->pOut, db, MEM_Null);
 86275  86190     pCtx->pFunc = pOp->p4.pFunc;
 86276  86191     pCtx->iOp = (int)(pOp - aOp);
 86277  86192     pCtx->pVdbe = p;
 86278         -  pCtx->skipFlag = 0;
 86279         -  pCtx->isError = 0;
 86280  86193     pCtx->argc = n;
 86281  86194     pOp->p4type = P4_FUNCCTX;
 86282  86195     pOp->p4.pCtx = pCtx;
 86283  86196     pOp->opcode = OP_AggStep;
 86284  86197     /* Fall through into OP_AggStep */
 86285  86198   }
 86286  86199   case OP_AggStep: {
 86287  86200     int i;
 86288  86201     sqlite3_context *pCtx;
 86289  86202     Mem *pMem;
        86203  +  Mem t;
 86290  86204   
 86291  86205     assert( pOp->p4type==P4_FUNCCTX );
 86292  86206     pCtx = pOp->p4.pCtx;
 86293  86207     pMem = &aMem[pOp->p3];
 86294  86208   
 86295  86209     /* If this function is inside of a trigger, the register array in aMem[]
 86296  86210     ** might change from one evaluation to the next.  The next block of code
................................................................................
 86305  86219     for(i=0; i<pCtx->argc; i++){
 86306  86220       assert( memIsValid(pCtx->argv[i]) );
 86307  86221       REGISTER_TRACE(pOp->p2+i, pCtx->argv[i]);
 86308  86222     }
 86309  86223   #endif
 86310  86224   
 86311  86225     pMem->n++;
 86312         -  assert( pCtx->pOut->flags==MEM_Null );
 86313         -  assert( pCtx->isError==0 );
 86314         -  assert( pCtx->skipFlag==0 );
        86226  +  sqlite3VdbeMemInit(&t, db, MEM_Null);
        86227  +  pCtx->pOut = &t;
        86228  +  pCtx->fErrorOrAux = 0;
        86229  +  pCtx->skipFlag = 0;
 86315  86230     (pCtx->pFunc->xSFunc)(pCtx,pCtx->argc,pCtx->argv); /* IMP: R-24505-23230 */
 86316         -  if( pCtx->isError ){
 86317         -    if( pCtx->isError>0 ){
 86318         -      sqlite3VdbeError(p, "%s", sqlite3_value_text(pCtx->pOut));
        86231  +  if( pCtx->fErrorOrAux ){
        86232  +    if( pCtx->isError ){
        86233  +      sqlite3VdbeError(p, "%s", sqlite3_value_text(&t));
 86319  86234         rc = pCtx->isError;
 86320  86235       }
 86321         -    if( pCtx->skipFlag ){
 86322         -      assert( pOp[-1].opcode==OP_CollSeq );
 86323         -      i = pOp[-1].p1;
 86324         -      if( i ) sqlite3VdbeMemSetInt64(&aMem[i], 1);
 86325         -      pCtx->skipFlag = 0;
 86326         -    }
 86327         -    sqlite3VdbeMemRelease(pCtx->pOut);
 86328         -    pCtx->pOut->flags = MEM_Null;
 86329         -    pCtx->isError = 0;
        86236  +    sqlite3VdbeMemRelease(&t);
 86330  86237       if( rc ) goto abort_due_to_error;
        86238  +  }else{
        86239  +    assert( t.flags==MEM_Null );
 86331  86240     }
 86332         -  assert( pCtx->pOut->flags==MEM_Null );
 86333         -  assert( pCtx->skipFlag==0 );
        86241  +  if( pCtx->skipFlag ){
        86242  +    assert( pOp[-1].opcode==OP_CollSeq );
        86243  +    i = pOp[-1].p1;
        86244  +    if( i ) sqlite3VdbeMemSetInt64(&aMem[i], 1);
        86245  +  }
 86334  86246     break;
 86335  86247   }
 86336  86248   
 86337  86249   /* Opcode: AggFinal P1 P2 * P4 *
 86338  86250   ** Synopsis: accum=r[P1] N=P2
 86339  86251   **
 86340  86252   ** Execute the finalizer function for an aggregate.  P1 is
................................................................................
 86813  86725       pDest->flags = MEM_Null|MEM_Zero;
 86814  86726       pDest->u.nZero = 0;
 86815  86727     }else{
 86816  86728       MemSetTypeFlag(pDest, MEM_Null);
 86817  86729     }
 86818  86730     rc = pModule->xColumn(pCur->uc.pVCur, &sContext, pOp->p2);
 86819  86731     sqlite3VtabImportErrmsg(p, pVtab);
 86820         -  if( sContext.isError>0 ){
 86821         -    sqlite3VdbeError(p, "%s", sqlite3_value_text(pDest));
        86732  +  if( sContext.isError ){
 86822  86733       rc = sContext.isError;
 86823  86734     }
 86824  86735     sqlite3VdbeChangeEncoding(pDest, encoding);
 86825  86736     REGISTER_TRACE(pOp->p3, pDest);
 86826  86737     UPDATE_MAX_BLOBSIZE(pDest);
 86827  86738   
 86828  86739     if( sqlite3VdbeMemTooBig(pDest) ){
................................................................................
 87079  86990     assert( pOp->p3<pOp->p2 || pOp->p3>=pOp->p2+n );
 87080  86991     pCtx = sqlite3DbMallocRawNN(db, sizeof(*pCtx) + (n-1)*sizeof(sqlite3_value*));
 87081  86992     if( pCtx==0 ) goto no_mem;
 87082  86993     pCtx->pOut = 0;
 87083  86994     pCtx->pFunc = pOp->p4.pFunc;
 87084  86995     pCtx->iOp = (int)(pOp - aOp);
 87085  86996     pCtx->pVdbe = p;
 87086         -  pCtx->isError = 0;
 87087  86997     pCtx->argc = n;
 87088  86998     pOp->p4type = P4_FUNCCTX;
 87089  86999     pOp->p4.pCtx = pCtx;
 87090  87000     assert( OP_PureFunc == OP_PureFunc0+2 );
 87091  87001     assert( OP_Function == OP_Function0+2 );
 87092  87002     pOp->opcode += 2;
 87093  87003     /* Fall through into OP_Function */
................................................................................
 87114  87024   #ifdef SQLITE_DEBUG
 87115  87025     for(i=0; i<pCtx->argc; i++){
 87116  87026       assert( memIsValid(pCtx->argv[i]) );
 87117  87027       REGISTER_TRACE(pOp->p2+i, pCtx->argv[i]);
 87118  87028     }
 87119  87029   #endif
 87120  87030     MemSetTypeFlag(pOut, MEM_Null);
 87121         -  assert( pCtx->isError==0 );
        87031  +  pCtx->fErrorOrAux = 0;
 87122  87032     (*pCtx->pFunc->xSFunc)(pCtx, pCtx->argc, pCtx->argv);/* IMP: R-24505-23230 */
 87123  87033   
 87124  87034     /* If the function returned an error, throw an exception */
 87125         -  if( pCtx->isError ){
 87126         -    if( pCtx->isError>0 ){
        87035  +  if( pCtx->fErrorOrAux ){
        87036  +    if( pCtx->isError ){
 87127  87037         sqlite3VdbeError(p, "%s", sqlite3_value_text(pOut));
 87128  87038         rc = pCtx->isError;
 87129  87039       }
 87130  87040       sqlite3VdbeDeleteAuxData(db, &p->pAuxData, pCtx->iOp, pOp->p1);
 87131         -    pCtx->isError = 0;
 87132  87041       if( rc ) goto abort_due_to_error;
 87133  87042     }
 87134  87043   
 87135  87044     /* Copy the result of the function into register P3 */
 87136  87045     if( pOut->flags & (MEM_Str|MEM_Blob) ){
 87137  87046       sqlite3VdbeChangeEncoding(pOut, encoding);
 87138  87047       if( sqlite3VdbeMemTooBig(pOut) ) goto too_big;
................................................................................
 87166  87075   ** first time they are evaluated for this run.
 87167  87076   **
 87168  87077   ** If P3 is not zero, then it is an address to jump to if an SQLITE_CORRUPT
 87169  87078   ** error is encountered.
 87170  87079   */
 87171  87080   case OP_Trace:
 87172  87081   case OP_Init: {          /* jump */
 87173         -  int i;
 87174         -#ifndef SQLITE_OMIT_TRACE
 87175  87082     char *zTrace;
 87176         -#endif
        87083  +  int i;
 87177  87084   
 87178  87085     /* If the P4 argument is not NULL, then it must be an SQL comment string.
 87179  87086     ** The "--" string is broken up to prevent false-positives with srcck1.c.
 87180  87087     **
 87181  87088     ** This assert() provides evidence for:
 87182  87089     ** EVIDENCE-OF: R-50676-09860 The callback can compute the same text that
 87183  87090     ** would have been returned by the legacy sqlite3_trace() interface by
................................................................................
102825 102732   ** This routine is called by the parser while in the middle of
102826 102733   ** parsing a CREATE TABLE statement.  A "NOT NULL" constraint has
102827 102734   ** been seen on a column.  This routine sets the notNull flag on
102828 102735   ** the column currently under construction.
102829 102736   */
102830 102737   SQLITE_PRIVATE void sqlite3AddNotNull(Parse *pParse, int onError){
102831 102738     Table *p;
102832         -  Column *pCol;
102833 102739     p = pParse->pNewTable;
102834 102740     if( p==0 || NEVER(p->nCol<1) ) return;
102835         -  pCol = &p->aCol[p->nCol-1];
102836         -  pCol->notNull = (u8)onError;
       102741  +  p->aCol[p->nCol-1].notNull = (u8)onError;
102837 102742     p->tabFlags |= TF_HasNotNull;
102838         -
102839         -  /* Set the uniqNotNull flag on any UNIQUE or PK indexes already created
102840         -  ** on this column.  */
102841         -  if( pCol->colFlags & COLFLAG_UNIQUE ){
102842         -    Index *pIdx;
102843         -    for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){
102844         -      assert( pIdx->nKeyCol==1 && pIdx->onError!=OE_None );
102845         -      if( pIdx->aiColumn[0]==p->nCol-1 ){
102846         -        pIdx->uniqNotNull = 1;
102847         -      }
102848         -    }
102849         -  }
102850 102743   }
102851 102744   
102852 102745   /*
102853 102746   ** Scan the column type name zType (length nType) and return the
102854 102747   ** associated affinity type.
102855 102748   **
102856 102749   ** This routine does a case-independent search of zType for the 
................................................................................
104806 104699   
104807 104700     /* If pList==0, it means this routine was called to make a primary
104808 104701     ** key out of the last column added to the table under construction.
104809 104702     ** So create a fake list to simulate this.
104810 104703     */
104811 104704     if( pList==0 ){
104812 104705       Token prevCol;
104813         -    Column *pCol = &pTab->aCol[pTab->nCol-1];
104814         -    pCol->colFlags |= COLFLAG_UNIQUE;
104815         -    sqlite3TokenInit(&prevCol, pCol->zName);
       104706  +    sqlite3TokenInit(&prevCol, pTab->aCol[pTab->nCol-1].zName);
104816 104707       pList = sqlite3ExprListAppend(pParse, 0,
104817 104708                 sqlite3ExprAlloc(db, TK_ID, &prevCol, 0));
104818 104709       if( pList==0 ) goto exit_create_index;
104819 104710       assert( pList->nExpr==1 );
104820 104711       sqlite3ExprListSetSortOrder(pList, sortOrder);
104821 104712     }else{
104822 104713       sqlite3ExprListCheckLength(pParse, pList, "index");
................................................................................
107653 107544   }
107654 107545   
107655 107546   /*
107656 107547   ** Indicate that the accumulator load should be skipped on this
107657 107548   ** iteration of the aggregate loop.
107658 107549   */
107659 107550   static void sqlite3SkipAccumulatorLoad(sqlite3_context *context){
107660         -  assert( context->isError<=0 );
107661         -  context->isError = -1;
107662 107551     context->skipFlag = 1;
107663 107552   }
107664 107553   
107665 107554   /*
107666 107555   ** Implementation of the non-aggregate min() and max() functions
107667 107556   */
107668 107557   static void minmaxFunc(
................................................................................
107721 107610   ** Implementation of the length() function
107722 107611   */
107723 107612   static void lengthFunc(
107724 107613     sqlite3_context *context,
107725 107614     int argc,
107726 107615     sqlite3_value **argv
107727 107616   ){
       107617  +  int len;
       107618  +
107728 107619     assert( argc==1 );
107729 107620     UNUSED_PARAMETER(argc);
107730 107621     switch( sqlite3_value_type(argv[0]) ){
107731 107622       case SQLITE_BLOB:
107732 107623       case SQLITE_INTEGER:
107733 107624       case SQLITE_FLOAT: {
107734 107625         sqlite3_result_int(context, sqlite3_value_bytes(argv[0]));
107735 107626         break;
107736 107627       }
107737 107628       case SQLITE_TEXT: {
107738 107629         const unsigned char *z = sqlite3_value_text(argv[0]);
107739         -      const unsigned char *z0;
107740         -      unsigned char c;
107741 107630         if( z==0 ) return;
107742         -      z0 = z;
107743         -      while( (c = *z)!=0 ){
107744         -        z++;
107745         -        if( c>=0xc0 ){
107746         -          while( (*z & 0xc0)==0x80 ){ z++; z0++; }
107747         -        }
       107631  +      len = 0;
       107632  +      while( *z ){
       107633  +        len++;
       107634  +        SQLITE_SKIP_UTF8(z);
107748 107635         }
107749         -      sqlite3_result_int(context, (int)(z-z0));
       107636  +      sqlite3_result_int(context, len);
107750 107637         break;
107751 107638       }
107752 107639       default: {
107753 107640         sqlite3_result_null(context);
107754 107641         break;
107755 107642       }
107756 107643     }
................................................................................
113937 113824   #define sqlite3_prepare_v3             sqlite3_api->prepare_v3
113938 113825   #define sqlite3_prepare16_v3           sqlite3_api->prepare16_v3
113939 113826   #define sqlite3_bind_pointer           sqlite3_api->bind_pointer
113940 113827   #define sqlite3_result_pointer         sqlite3_api->result_pointer
113941 113828   #define sqlite3_value_pointer          sqlite3_api->value_pointer
113942 113829   /* Version 3.22.0 and later */
113943 113830   #define sqlite3_vtab_nochange          sqlite3_api->vtab_nochange
113944         -#define sqlite3_value_nochange         sqlite3_api->value_nochange
113945         -#define sqlite3_vtab_collation         sqlite3_api->vtab_collation
       113831  +#define sqlite3_value_nochange         sqltie3_api->value_nochange
       113832  +#define sqlite3_vtab_collation         sqltie3_api->vtab_collation
113946 113833   #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
113947 113834   
113948 113835   #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
113949 113836     /* This case when the file really is being compiled as a loadable 
113950 113837     ** extension */
113951 113838   # define SQLITE_EXTENSION_INIT1     const sqlite3_api_routines *sqlite3_api=0;
113952 113839   # define SQLITE_EXTENSION_INIT2(v)  sqlite3_api=v;
................................................................................
120061 119948       bSeq = 0;
120062 119949     }else{
120063 119950       addr = 1 + sqlite3VdbeAddOp2(v, OP_Sort, iTab, addrBreak); VdbeCoverage(v);
120064 119951       codeOffset(v, p->iOffset, addrContinue);
120065 119952       iSortTab = iTab;
120066 119953       bSeq = 1;
120067 119954     }
120068         -  for(i=0, iCol=nKey+bSeq-1; i<nSortData; i++){
120069         -    if( aOutEx[i].u.x.iOrderByCol==0 ) iCol++;
120070         -  }
120071         -  for(i=nSortData-1; i>=0; i--){
       119955  +  for(i=0, iCol=nKey+bSeq; i<nSortData; i++){
120072 119956       int iRead;
120073 119957       if( aOutEx[i].u.x.iOrderByCol ){
120074 119958         iRead = aOutEx[i].u.x.iOrderByCol-1;
120075 119959       }else{
120076         -      iRead = iCol--;
       119960  +      iRead = iCol++;
120077 119961       }
120078 119962       sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iRead, regRow+i);
120079 119963       VdbeComment((v, "%s", aOutEx[i].zName ? aOutEx[i].zName : aOutEx[i].zSpan));
120080 119964     }
120081 119965     switch( eDest ){
120082 119966       case SRT_Table:
120083 119967       case SRT_EphemTab: {
................................................................................
131450 131334       pE = pTerm->pExpr;
131451 131335       assert( !ExprHasProperty(pE, EP_FromJoin) );
131452 131336       assert( (pTerm->prereqRight & pLevel->notReady)!=0 );
131453 131337       pAlt = sqlite3WhereFindTerm(pWC, iCur, pTerm->u.leftColumn, notReady,
131454 131338                       WO_EQ|WO_IN|WO_IS, 0);
131455 131339       if( pAlt==0 ) continue;
131456 131340       if( pAlt->wtFlags & (TERM_CODED) ) continue;
131457         -    if( (pAlt->eOperator & WO_IN) 
131458         -     && (pAlt->pExpr->flags & EP_xIsSelect)
131459         -     && (pAlt->pExpr->x.pSelect->pEList->nExpr>1)
131460         -    ){
131461         -      continue;
131462         -    }
131463 131341       testcase( pAlt->eOperator & WO_EQ );
131464 131342       testcase( pAlt->eOperator & WO_IS );
131465 131343       testcase( pAlt->eOperator & WO_IN );
131466 131344       VdbeModuleComment((v, "begin transitive constraint"));
131467 131345       sEAlt = *pAlt->pExpr;
131468 131346       sEAlt.pLeft = pE->pLeft;
131469 131347       sqlite3ExprIfFalse(pParse, &sEAlt, addrCont, SQLITE_JUMPIFNULL);
................................................................................
132370 132248       mask |= sqlite3WhereExprUsage(pMaskSet, pS->pWhere);
132371 132249       mask |= sqlite3WhereExprUsage(pMaskSet, pS->pHaving);
132372 132250       if( ALWAYS(pSrc!=0) ){
132373 132251         int i;
132374 132252         for(i=0; i<pSrc->nSrc; i++){
132375 132253           mask |= exprSelectUsage(pMaskSet, pSrc->a[i].pSelect);
132376 132254           mask |= sqlite3WhereExprUsage(pMaskSet, pSrc->a[i].pOn);
132377         -        if( pSrc->a[i].fg.isTabFunc ){
132378         -          mask |= sqlite3WhereExprListUsage(pMaskSet, pSrc->a[i].u1.pFuncArg);
132379         -        }
132380 132255         }
132381 132256       }
132382 132257       pS = pS->pPrior;
132383 132258     }
132384 132259     return mask;
132385 132260   }
132386 132261   
................................................................................
135510 135385       }else if( eOp & (WO_EQ|WO_IS) ){
135511 135386         int iCol = pProbe->aiColumn[saved_nEq];
135512 135387         pNew->wsFlags |= WHERE_COLUMN_EQ;
135513 135388         assert( saved_nEq==pNew->u.btree.nEq );
135514 135389         if( iCol==XN_ROWID 
135515 135390          || (iCol>=0 && nInMul==0 && saved_nEq==pProbe->nKeyCol-1)
135516 135391         ){
135517         -        if( iCol==XN_ROWID || pProbe->uniqNotNull 
135518         -         || (pProbe->nKeyCol==1 && pProbe->onError && eOp==WO_EQ) 
135519         -        ){
135520         -          pNew->wsFlags |= WHERE_ONEROW;
135521         -        }else{
       135392  +        if( iCol>=0 && pProbe->uniqNotNull==0 ){
135522 135393             pNew->wsFlags |= WHERE_UNQ_WANTED;
       135394  +        }else{
       135395  +          pNew->wsFlags |= WHERE_ONEROW;
135523 135396           }
135524 135397         }
135525 135398       }else if( eOp & WO_ISNULL ){
135526 135399         pNew->wsFlags |= WHERE_COLUMN_NULL;
135527 135400       }else if( eOp & (WO_GT|WO_GE) ){
135528 135401         testcase( eOp & WO_GT );
135529 135402         testcase( eOp & WO_GE );
................................................................................
137662 137535     ** preserves SQLite's legacy behaviour in the following two cases:
137663 137536     **
137664 137537     **   FROM ... WHERE random()>0;           -- eval random() once per row
137665 137538     **   FROM ... WHERE (SELECT random())>0;  -- eval random() once overall
137666 137539     */
137667 137540     for(ii=0; ii<sWLB.pWC->nTerm; ii++){
137668 137541       WhereTerm *pT = &sWLB.pWC->a[ii];
137669         -    if( pT->wtFlags & TERM_VIRTUAL ) continue;
137670 137542       if( pT->prereqAll==0 && (nTabList==0 || exprIsDeterministic(pT->pExpr)) ){
137671 137543         sqlite3ExprIfFalse(pParse, pT->pExpr, pWInfo->iBreak, SQLITE_JUMPIFNULL);
137672 137544         pT->wtFlags |= TERM_CODED;
137673 137545       }
137674 137546     }
137675 137547   
137676 137548     if( wctrlFlags & WHERE_WANT_DISTINCT ){
................................................................................
144927 144799   #else
144928 144800       /* SQLITE_NOLFS       */ 0,
144929 144801   #endif
144930 144802       /* SQLITE_AUTH        */ "authorization denied",
144931 144803       /* SQLITE_FORMAT      */ 0,
144932 144804       /* SQLITE_RANGE       */ "column index out of range",
144933 144805       /* SQLITE_NOTADB      */ "file is not a database",
144934         -    /* SQLITE_NOTICE      */ "notification message",
144935         -    /* SQLITE_WARNING     */ "warning message",
144936 144806     };
144937 144807     const char *zErr = "unknown error";
144938 144808     switch( rc ){
144939 144809       case SQLITE_ABORT_ROLLBACK: {
144940 144810         zErr = "abort due to ROLLBACK";
144941 144811         break;
144942 144812       }
144943         -    case SQLITE_ROW: {
144944         -      zErr = "another row available";
144945         -      break;
144946         -    }
144947         -    case SQLITE_DONE: {
144948         -      zErr = "no more rows available";
144949         -      break;
144950         -    }
144951 144813       default: {
144952 144814         rc &= 0xff;
144953 144815         if( ALWAYS(rc>=0) && rc<ArraySize(aMsg) && aMsg[rc]!=0 ){
144954 144816           zErr = aMsg[rc];
144955 144817         }
144956 144818         break;
144957 144819       }
................................................................................
160930 160792     sqlite3_stmt *pStmt;
160931 160793     int rc = fts3SqlStmt(p, SQL_INSERT_SEGMENTS, &pStmt, 0);
160932 160794     if( rc==SQLITE_OK ){
160933 160795       sqlite3_bind_int64(pStmt, 1, iBlock);
160934 160796       sqlite3_bind_blob(pStmt, 2, z, n, SQLITE_STATIC);
160935 160797       sqlite3_step(pStmt);
160936 160798       rc = sqlite3_reset(pStmt);
160937         -    sqlite3_bind_null(pStmt, 2);
160938 160799     }
160939 160800     return rc;
160940 160801   }
160941 160802   
160942 160803   /*
160943 160804   ** Find the largest relative level number in the table. If successful, set
160944 160805   ** *pnMax to this value and return SQLITE_OK. Otherwise, if an error occurs,
................................................................................
160987 160848         char *zEnd = sqlite3_mprintf("%lld %lld", iEndBlock, nLeafData);
160988 160849         if( !zEnd ) return SQLITE_NOMEM;
160989 160850         sqlite3_bind_text(pStmt, 5, zEnd, -1, sqlite3_free);
160990 160851       }
160991 160852       sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC);
160992 160853       sqlite3_step(pStmt);
160993 160854       rc = sqlite3_reset(pStmt);
160994         -    sqlite3_bind_null(pStmt, 6);
160995 160855     }
160996 160856     return rc;
160997 160857   }
160998 160858   
160999 160859   /*
161000 160860   ** Return the size of the common prefix (if any) shared by zPrev and
161001 160861   ** zNext, in bytes. For example, 
................................................................................
162467 162327       *pRC = rc;
162468 162328       return;
162469 162329     }
162470 162330     sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);
162471 162331     sqlite3_bind_blob(pStmt, 2, pBlob, nBlob, SQLITE_STATIC);
162472 162332     sqlite3_step(pStmt);
162473 162333     *pRC = sqlite3_reset(pStmt);
162474         -  sqlite3_bind_null(pStmt, 2);
162475 162334     sqlite3_free(a);
162476 162335   }
162477 162336   
162478 162337   /*
162479 162338   ** Merge the entire database so that there is one segment for each 
162480 162339   ** iIndex/iLangid combination.
162481 162340   */
................................................................................
163656 163515       if( rc==SQLITE_OK ){
163657 163516         sqlite3_bind_int64(pChomp, 1, iNewStart);
163658 163517         sqlite3_bind_blob(pChomp, 2, root.a, root.n, SQLITE_STATIC);
163659 163518         sqlite3_bind_int64(pChomp, 3, iAbsLevel);
163660 163519         sqlite3_bind_int(pChomp, 4, iIdx);
163661 163520         sqlite3_step(pChomp);
163662 163521         rc = sqlite3_reset(pChomp);
163663         -      sqlite3_bind_null(pChomp, 2);
163664 163522       }
163665 163523     }
163666 163524   
163667 163525     sqlite3_free(root.a);
163668 163526     sqlite3_free(block.a);
163669 163527     return rc;
163670 163528   }
................................................................................
163736 163594   
163737 163595     rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pReplace, 0);
163738 163596     if( rc==SQLITE_OK ){
163739 163597       sqlite3_bind_int(pReplace, 1, FTS_STAT_INCRMERGEHINT);
163740 163598       sqlite3_bind_blob(pReplace, 2, pHint->a, pHint->n, SQLITE_STATIC);
163741 163599       sqlite3_step(pReplace);
163742 163600       rc = sqlite3_reset(pReplace);
163743         -    sqlite3_bind_null(pReplace, 2);
163744 163601     }
163745 163602   
163746 163603     return rc;
163747 163604   }
163748 163605   
163749 163606   /*
163750 163607   ** Load an incr-merge hint from the database. The incr-merge hint, if one 
................................................................................
167969 167826       }else{
167970 167827         sqlite3_bind_null(p, 1);
167971 167828       }
167972 167829       sqlite3_bind_blob(p, 2, pNode->zData, pRtree->iNodeSize, SQLITE_STATIC);
167973 167830       sqlite3_step(p);
167974 167831       pNode->isDirty = 0;
167975 167832       rc = sqlite3_reset(p);
167976         -    sqlite3_bind_null(p, 2);
167977 167833       if( pNode->iNode==0 && rc==SQLITE_OK ){
167978 167834         pNode->iNode = sqlite3_last_insert_rowid(pRtree->db);
167979 167835         nodeHashInsert(pRtree, pNode);
167980 167836       }
167981 167837     }
167982 167838     return rc;
167983 167839   }
................................................................................
179965 179821     int op,                         /* One of SQLITE_UPDATE, INSERT, DELETE */
179966 179822     sqlite3_session *pSession,      /* Session object pTab is attached to */
179967 179823     SessionTable *pTab              /* Table that change applies to */
179968 179824   ){
179969 179825     int iHash; 
179970 179826     int bNull = 0; 
179971 179827     int rc = SQLITE_OK;
179972         -  SessionStat1Ctx stat1 = {0};
       179828  +  SessionStat1Ctx stat1;
179973 179829   
179974 179830     if( pSession->rc ) return;
179975 179831   
179976 179832     /* Load table details if required */
179977 179833     if( sessionInitTable(pSession, pTab) ) return;
179978 179834   
179979 179835     /* Check the number of columns in this xPreUpdate call matches the 
................................................................................
195100 194956       if( p->rc ) return;
195101 194957     }
195102 194958   
195103 194959     sqlite3_bind_int64(p->pWriter, 1, iRowid);
195104 194960     sqlite3_bind_blob(p->pWriter, 2, pData, nData, SQLITE_STATIC);
195105 194961     sqlite3_step(p->pWriter);
195106 194962     p->rc = sqlite3_reset(p->pWriter);
195107         -  sqlite3_bind_null(p->pWriter, 2);
195108 194963   }
195109 194964   
195110 194965   /*
195111 194966   ** Execute the following SQL:
195112 194967   **
195113 194968   **     DELETE FROM %_data WHERE id BETWEEN $iFirst AND $iLast
195114 194969   */
................................................................................
196729 196584     sqlite3_bind_blob(pIdxSelect, 2, pTerm, nTerm, SQLITE_STATIC);
196730 196585     if( SQLITE_ROW==sqlite3_step(pIdxSelect) ){
196731 196586       i64 val = sqlite3_column_int(pIdxSelect, 0);
196732 196587       iPg = (int)(val>>1);
196733 196588       bDlidx = (val & 0x0001);
196734 196589     }
196735 196590     p->rc = sqlite3_reset(pIdxSelect);
196736         -  sqlite3_bind_null(pIdxSelect, 2);
196737 196591   
196738 196592     if( iPg<pSeg->pgnoFirst ){
196739 196593       iPg = pSeg->pgnoFirst;
196740 196594       bDlidx = 0;
196741 196595     }
196742 196596   
196743 196597     pIter->iLeafPgno = iPg - 1;
................................................................................
197942 197796           sqlite3_stmt *pIdxSelect = fts5IdxSelectStmt(p);
197943 197797           if( p->rc==SQLITE_OK ){
197944 197798             u8 aBlob[2] = {0xff, 0xff};
197945 197799             sqlite3_bind_int(pIdxSelect, 1, iSegid);
197946 197800             sqlite3_bind_blob(pIdxSelect, 2, aBlob, 2, SQLITE_STATIC);
197947 197801             assert( sqlite3_step(pIdxSelect)!=SQLITE_ROW );
197948 197802             p->rc = sqlite3_reset(pIdxSelect);
197949         -          sqlite3_bind_null(pIdxSelect, 2);
197950 197803           }
197951 197804         }
197952 197805   #endif
197953 197806       }
197954 197807     }
197955 197808   
197956 197809     return iSegid;
................................................................................
198069 197922       const char *z = (pWriter->btterm.n>0?(const char*)pWriter->btterm.p:"");
198070 197923       /* The following was already done in fts5WriteInit(): */
198071 197924       /* sqlite3_bind_int(p->pIdxWriter, 1, pWriter->iSegid); */
198072 197925       sqlite3_bind_blob(p->pIdxWriter, 2, z, pWriter->btterm.n, SQLITE_STATIC);
198073 197926       sqlite3_bind_int64(p->pIdxWriter, 3, bFlag + ((i64)pWriter->iBtPage<<1));
198074 197927       sqlite3_step(p->pIdxWriter);
198075 197928       p->rc = sqlite3_reset(p->pIdxWriter);
198076         -    sqlite3_bind_null(p->pIdxWriter, 2);
198077 197929     }
198078 197930     pWriter->iBtPage = 0;
198079 197931   }
198080 197932   
198081 197933   /*
198082 197934   ** This is called once for each leaf page except the first that contains
198083 197935   ** at least one term. Argument (nTerm/pTerm) is the split-key - a term that
................................................................................
203477 203329   static void fts5SourceIdFunc(
203478 203330     sqlite3_context *pCtx,          /* Function call context */
203479 203331     int nArg,                       /* Number of args */
203480 203332     sqlite3_value **apUnused        /* Function arguments */
203481 203333   ){
203482 203334     assert( nArg==0 );
203483 203335     UNUSED_PARAM2(nArg, apUnused);
203484         -  sqlite3_result_text(pCtx, "fts5: 2018-02-08 01:00:11 ad5d3bdc739a0997786f94fb5789b726b9f53ff883226093924338fe5000922b", -1, SQLITE_TRANSIENT);
       203336  +  sqlite3_result_text(pCtx, "fts5: 2018-01-22 18:45:57 0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e86726f2171d", -1, SQLITE_TRANSIENT);
203485 203337   }
203486 203338   
203487 203339   static int fts5Init(sqlite3 *db){
203488 203340     static const sqlite3_module fts5Mod = {
203489 203341       /* iVersion      */ 2,
203490 203342       /* xCreate       */ fts5CreateMethod,
203491 203343       /* xConnect      */ fts5ConnectMethod,
................................................................................
204053 203905       sqlite3_stmt *pReplace = 0;
204054 203906       rc = fts5StorageGetStmt(p, FTS5_STMT_REPLACE_DOCSIZE, &pReplace, 0);
204055 203907       if( rc==SQLITE_OK ){
204056 203908         sqlite3_bind_int64(pReplace, 1, iRowid);
204057 203909         sqlite3_bind_blob(pReplace, 2, pBuf->p, pBuf->n, SQLITE_STATIC);
204058 203910         sqlite3_step(pReplace);
204059 203911         rc = sqlite3_reset(pReplace);
204060         -      sqlite3_bind_null(pReplace, 2);
204061 203912       }
204062 203913     }
204063 203914     return rc;
204064 203915   }
204065 203916   
204066 203917   /*
204067 203918   ** Load the contents of the "averages" record from disk into the 
................................................................................
204714 204565       if( pVal ){
204715 204566         sqlite3_bind_value(pReplace, 2, pVal);
204716 204567       }else{
204717 204568         sqlite3_bind_int(pReplace, 2, iVal);
204718 204569       }
204719 204570       sqlite3_step(pReplace);
204720 204571       rc = sqlite3_reset(pReplace);
204721         -    sqlite3_bind_null(pReplace, 1);
204722 204572     }
204723 204573     if( rc==SQLITE_OK && pVal ){
204724 204574       int iNew = p->pConfig->iCookie + 1;
204725 204575       rc = sqlite3Fts5IndexSetCookie(p->pIndex, iNew);
204726 204576       if( rc==SQLITE_OK ){
204727 204577         p->pConfig->iCookie = iNew;
204728 204578       }
................................................................................
207747 207597   #endif
207748 207598     return rc;
207749 207599   }
207750 207600   #endif /* SQLITE_CORE */
207751 207601   #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
207752 207602   
207753 207603   /************** End of stmt.c ************************************************/
207754         -#if __LINE__!=207754
       207604  +#if __LINE__!=207604
207755 207605   #undef SQLITE_SOURCE_ID
207756         -#define SQLITE_SOURCE_ID      "2018-02-08 01:00:11 ad5d3bdc739a0997786f94fb5789b726b9f53ff883226093924338fe5000alt2"
       207606  +#define SQLITE_SOURCE_ID      "2018-01-22 18:45:57 0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e86726f2alt2"
207757 207607   #endif
207758 207608   /* Return the source-id for this library */
207759 207609   SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
207760 207610   /************************** End of sqlite3.c ******************************/

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

   119    119   ** been edited in any way since it was last checked in, then the last
   120    120   ** four hexadecimal digits of the hash may be modified.
   121    121   **
   122    122   ** See also: [sqlite3_libversion()],
   123    123   ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
   124    124   ** [sqlite_version()] and [sqlite_source_id()].
   125    125   */
   126         -#define SQLITE_VERSION        "3.23.0"
   127         -#define SQLITE_VERSION_NUMBER 3023000
   128         -#define SQLITE_SOURCE_ID      "2018-02-08 01:00:11 ad5d3bdc739a0997786f94fb5789b726b9f53ff883226093924338fe5000922b"
          126  +#define SQLITE_VERSION        "3.22.0"
          127  +#define SQLITE_VERSION_NUMBER 3022000
          128  +#define SQLITE_SOURCE_ID      "2018-01-22 18:45:57 0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e86726f2171d"
   129    129   
   130    130   /*
   131    131   ** CAPI3REF: Run-Time Library Version Numbers
   132    132   ** KEYWORDS: sqlite3_version sqlite3_sourceid
   133    133   **
   134    134   ** These interfaces provide the same information as the [SQLITE_VERSION],
   135    135   ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
................................................................................
  3655   3655   ** a schema change, on the first  [sqlite3_step()] call following any change
  3656   3656   ** to the [sqlite3_bind_text | bindings] of that [parameter]. 
  3657   3657   ** ^The specific value of WHERE-clause [parameter] might influence the 
  3658   3658   ** choice of query plan if the parameter is the left-hand side of a [LIKE]
  3659   3659   ** or [GLOB] operator or if the parameter is compared to an indexed column
  3660   3660   ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
  3661   3661   ** </li>
  3662         -** </ol>
  3663   3662   **
  3664   3663   ** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having
  3665   3664   ** the extra prepFlags parameter, which is a bit array consisting of zero or
  3666   3665   ** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags.  ^The
  3667   3666   ** sqlite3_prepare_v2() interface works exactly the same as
  3668   3667   ** sqlite3_prepare_v3() with a zero prepFlags parameter.
         3668  +** </ol>
  3669   3669   */
  3670   3670   SQLITE_API int sqlite3_prepare(
  3671   3671     sqlite3 *db,            /* Database handle */
  3672   3672     const char *zSql,       /* SQL statement, UTF-8 encoded */
  3673   3673     int nByte,              /* Maximum length of zSql in bytes. */
  3674   3674     sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  3675   3675     const char **pzTail     /* OUT: Pointer to unused portion of zSql */

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

   559    559   #define sqlite3_prepare_v3             sqlite3_api->prepare_v3
   560    560   #define sqlite3_prepare16_v3           sqlite3_api->prepare16_v3
   561    561   #define sqlite3_bind_pointer           sqlite3_api->bind_pointer
   562    562   #define sqlite3_result_pointer         sqlite3_api->result_pointer
   563    563   #define sqlite3_value_pointer          sqlite3_api->value_pointer
   564    564   /* Version 3.22.0 and later */
   565    565   #define sqlite3_vtab_nochange          sqlite3_api->vtab_nochange
   566         -#define sqlite3_value_nochange         sqlite3_api->value_nochange
   567         -#define sqlite3_vtab_collation         sqlite3_api->vtab_collation
          566  +#define sqlite3_value_nochange         sqltie3_api->value_nochange
          567  +#define sqlite3_vtab_collation         sqltie3_api->vtab_collation
   568    568   #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
   569    569   
   570    570   #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
   571    571     /* This case when the file really is being compiled as a loadable 
   572    572     ** extension */
   573    573   # define SQLITE_EXTENSION_INIT1     const sqlite3_api_routines *sqlite3_api=0;
   574    574   # define SQLITE_EXTENSION_INIT2(v)  sqlite3_api=v;

Changes to SQLite.Interop/src/ext/fts5.c.

  9080   9080       if( p->rc ) return;
  9081   9081     }
  9082   9082   
  9083   9083     sqlite3_bind_int64(p->pWriter, 1, iRowid);
  9084   9084     sqlite3_bind_blob(p->pWriter, 2, pData, nData, SQLITE_STATIC);
  9085   9085     sqlite3_step(p->pWriter);
  9086   9086     p->rc = sqlite3_reset(p->pWriter);
  9087         -  sqlite3_bind_null(p->pWriter, 2);
  9088   9087   }
  9089   9088   
  9090   9089   /*
  9091   9090   ** Execute the following SQL:
  9092   9091   **
  9093   9092   **     DELETE FROM %_data WHERE id BETWEEN $iFirst AND $iLast
  9094   9093   */
................................................................................
 10709  10708     sqlite3_bind_blob(pIdxSelect, 2, pTerm, nTerm, SQLITE_STATIC);
 10710  10709     if( SQLITE_ROW==sqlite3_step(pIdxSelect) ){
 10711  10710       i64 val = sqlite3_column_int(pIdxSelect, 0);
 10712  10711       iPg = (int)(val>>1);
 10713  10712       bDlidx = (val & 0x0001);
 10714  10713     }
 10715  10714     p->rc = sqlite3_reset(pIdxSelect);
 10716         -  sqlite3_bind_null(pIdxSelect, 2);
 10717  10715   
 10718  10716     if( iPg<pSeg->pgnoFirst ){
 10719  10717       iPg = pSeg->pgnoFirst;
 10720  10718       bDlidx = 0;
 10721  10719     }
 10722  10720   
 10723  10721     pIter->iLeafPgno = iPg - 1;
................................................................................
 11922  11920           sqlite3_stmt *pIdxSelect = fts5IdxSelectStmt(p);
 11923  11921           if( p->rc==SQLITE_OK ){
 11924  11922             u8 aBlob[2] = {0xff, 0xff};
 11925  11923             sqlite3_bind_int(pIdxSelect, 1, iSegid);
 11926  11924             sqlite3_bind_blob(pIdxSelect, 2, aBlob, 2, SQLITE_STATIC);
 11927  11925             assert( sqlite3_step(pIdxSelect)!=SQLITE_ROW );
 11928  11926             p->rc = sqlite3_reset(pIdxSelect);
 11929         -          sqlite3_bind_null(pIdxSelect, 2);
 11930  11927           }
 11931  11928         }
 11932  11929   #endif
 11933  11930       }
 11934  11931     }
 11935  11932   
 11936  11933     return iSegid;
................................................................................
 12049  12046       const char *z = (pWriter->btterm.n>0?(const char*)pWriter->btterm.p:"");
 12050  12047       /* The following was already done in fts5WriteInit(): */
 12051  12048       /* sqlite3_bind_int(p->pIdxWriter, 1, pWriter->iSegid); */
 12052  12049       sqlite3_bind_blob(p->pIdxWriter, 2, z, pWriter->btterm.n, SQLITE_STATIC);
 12053  12050       sqlite3_bind_int64(p->pIdxWriter, 3, bFlag + ((i64)pWriter->iBtPage<<1));
 12054  12051       sqlite3_step(p->pIdxWriter);
 12055  12052       p->rc = sqlite3_reset(p->pIdxWriter);
 12056         -    sqlite3_bind_null(p->pIdxWriter, 2);
 12057  12053     }
 12058  12054     pWriter->iBtPage = 0;
 12059  12055   }
 12060  12056   
 12061  12057   /*
 12062  12058   ** This is called once for each leaf page except the first that contains
 12063  12059   ** at least one term. Argument (nTerm/pTerm) is the split-key - a term that
................................................................................
 17458  17454   static void fts5SourceIdFunc(
 17459  17455     sqlite3_context *pCtx,          /* Function call context */
 17460  17456     int nArg,                       /* Number of args */
 17461  17457     sqlite3_value **apUnused        /* Function arguments */
 17462  17458   ){
 17463  17459     assert( nArg==0 );
 17464  17460     UNUSED_PARAM2(nArg, apUnused);
 17465         -  sqlite3_result_text(pCtx, "fts5: 2018-02-08 01:00:11 ad5d3bdc739a0997786f94fb5789b726b9f53ff883226093924338fe5000922b", -1, SQLITE_TRANSIENT);
        17461  +  sqlite3_result_text(pCtx, "fts5: 2018-01-22 18:45:57 0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e86726f2171d", -1, SQLITE_TRANSIENT);
 17466  17462   }
 17467  17463   
 17468  17464   static int fts5Init(sqlite3 *db){
 17469  17465     static const sqlite3_module fts5Mod = {
 17470  17466       /* iVersion      */ 2,
 17471  17467       /* xCreate       */ fts5CreateMethod,
 17472  17468       /* xConnect      */ fts5ConnectMethod,
................................................................................
 18035  18031       sqlite3_stmt *pReplace = 0;
 18036  18032       rc = fts5StorageGetStmt(p, FTS5_STMT_REPLACE_DOCSIZE, &pReplace, 0);
 18037  18033       if( rc==SQLITE_OK ){
 18038  18034         sqlite3_bind_int64(pReplace, 1, iRowid);
 18039  18035         sqlite3_bind_blob(pReplace, 2, pBuf->p, pBuf->n, SQLITE_STATIC);
 18040  18036         sqlite3_step(pReplace);
 18041  18037         rc = sqlite3_reset(pReplace);
 18042         -      sqlite3_bind_null(pReplace, 2);
 18043  18038       }
 18044  18039     }
 18045  18040     return rc;
 18046  18041   }
 18047  18042   
 18048  18043   /*
 18049  18044   ** Load the contents of the "averages" record from disk into the 
................................................................................
 18696  18691       if( pVal ){
 18697  18692         sqlite3_bind_value(pReplace, 2, pVal);
 18698  18693       }else{
 18699  18694         sqlite3_bind_int(pReplace, 2, iVal);
 18700  18695       }
 18701  18696       sqlite3_step(pReplace);
 18702  18697       rc = sqlite3_reset(pReplace);
 18703         -    sqlite3_bind_null(pReplace, 1);
 18704  18698     }
 18705  18699     if( rc==SQLITE_OK && pVal ){
 18706  18700       int iNew = p->pConfig->iCookie + 1;
 18707  18701       rc = sqlite3Fts5IndexSetCookie(p->pIndex, iNew);
 18708  18702       if( rc==SQLITE_OK ){
 18709  18703         p->pConfig->iCookie = iNew;
 18710  18704       }

Changes to readme.htm.

     2      2   <html>
     3      3   <head>
     4      4   <title></title>
     5      5   </head>
     6      6   <body>
     7      7   ADO.NET SQLite Data Provider<br />
     8      8   Version 1.0.108.0 - March XX, 2018 <font color="red">(release scheduled)</font><br />
     9         -Using <a href="https://www.sqlite.org/src/timeline?r=trunk">SQLite 3.23.0</a><br />Originally written by Robert Simpson<br />
            9  +Using <a href="https://www.sqlite.org/releaselog/3_22_0.html">SQLite 3.22.0</a><br />Originally written by Robert Simpson<br />
    10     10   Released to the public domain, use at your own risk!<br />
    11     11   Official provider website:&nbsp;<a href="https://system.data.sqlite.org/">https://system.data.sqlite.org/</a><br />
    12     12   Legacy versions:&nbsp;<a href="https://sourceforge.net/projects/sqlite-dotnet2/">https://sourceforge.net/projects/sqlite-dotnet2/</a><br />
    13     13   <br />
    14     14   The current development version can be downloaded from <a href="https://system.data.sqlite.org/index.html/timeline?y=ci">
    15     15   https://system.data.sqlite.org/index.html/timeline?y=ci</a>
    16     16   <br />
................................................................................
   207    207   
   208    208   <h2><b>Version History</b></h2>
   209    209   
   210    210   <p>
   211    211       <b>1.0.108.0 - March XX, 2018</b>
   212    212   </p>
   213    213   <ul>
   214         -    <li>Updated to <a href="https://www.sqlite.org/src/timeline?r=trunk">SQLite 3.23.0</a>.</li>
   215    214       <li>Support extended result codes when messages are looked up without the SQLite core library.</li>
   216    215       <li>Override System.Object members for the SQLiteException class to improve its ToString return value. Pursuant to [53962f9eff].</li>
   217    216       <li>More database connection configuration options for the <a href="https://www.sqlite.org/c3ref/db_config.html">sqlite3_db_config()</a> interface.&nbsp;<b>** Potentially Incompatible Change **</b></li>
   218    217       <li>Set HResult property of SQLiteException based on the SQLite core library error code.&nbsp;<b>** Potentially Incompatible Change **</b></li>
   219    218   </ul>
   220    219   <p>
   221    220       <b>1.0.107.0 - January 30, 2018</b>

Changes to www/news.wiki.

    44     44   
    45     45   <div align="center"><h2><b>Version History</b></h2></div>
    46     46   
    47     47   <p>
    48     48       <b>1.0.108.0 - March XX, 2018 <font color="red">(release scheduled)</font></b>
    49     49   </p>
    50     50   <ul>
    51         -    <li>Updated to [https://www.sqlite.org/src/timeline?r=trunk|SQLite 3.23.0].</li>
    52     51       <li>Support extended result codes when messages are looked up without the SQLite core library.</li>
    53     52       <li>Override System.Object members for the SQLiteException class to improve its ToString return value. Pursuant to [53962f9eff].</li>
    54     53       <li>More database connection configuration options for the [https://www.sqlite.org/c3ref/db_config.html|sqlite3_db_config()] interface.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    55     54       <li>Set HResult property of SQLiteException based on the SQLite core library error code.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    56     55   </ul>
    57     56   <p>
    58     57       <b>1.0.107.0 - January 30, 2018</b>