src/sqlite3.c
changeset 491 d32c60ada438
parent 130 507895068f83
child 716 498156bf9993
     1.1 --- a/src/sqlite3.c	Thu Mar 03 11:14:07 2016 +0100
     1.2 +++ b/src/sqlite3.c	Thu Mar 03 13:09:12 2016 +0100
     1.3 @@ -1,6 +1,6 @@
     1.4  /******************************************************************************
     1.5  ** This file is an amalgamation of many separate C source files from SQLite
     1.6 -** version 3.8.6.  By combining all the individual C code files into this 
     1.7 +** version 3.11.0.  By combining all the individual C code files into this 
     1.8  ** single large file, the entire code can be compiled as a single translation
     1.9  ** unit.  This allows many compilers to do optimizations that would not be
    1.10  ** possible if the files were compiled separately.  Performance improvements
    1.11 @@ -22,9 +22,6 @@
    1.12  #ifndef SQLITE_PRIVATE
    1.13  # define SQLITE_PRIVATE static
    1.14  #endif
    1.15 -#ifndef SQLITE_API
    1.16 -# define SQLITE_API
    1.17 -#endif
    1.18  /************** Begin file sqliteInt.h ***************************************/
    1.19  /*
    1.20  ** 2001 September 15
    1.21 @@ -44,6 +41,95 @@
    1.22  #define _SQLITEINT_H_
    1.23  
    1.24  /*
    1.25 +** Include the header file used to customize the compiler options for MSVC.
    1.26 +** This should be done first so that it can successfully prevent spurious
    1.27 +** compiler warnings due to subsequent content in this file and other files
    1.28 +** that are included by this file.
    1.29 +*/
    1.30 +/************** Include msvc.h in the middle of sqliteInt.h ******************/
    1.31 +/************** Begin file msvc.h ********************************************/
    1.32 +/*
    1.33 +** 2015 January 12
    1.34 +**
    1.35 +** The author disclaims copyright to this source code.  In place of
    1.36 +** a legal notice, here is a blessing:
    1.37 +**
    1.38 +**    May you do good and not evil.
    1.39 +**    May you find forgiveness for yourself and forgive others.
    1.40 +**    May you share freely, never taking more than you give.
    1.41 +**
    1.42 +******************************************************************************
    1.43 +**
    1.44 +** This file contains code that is specific to MSVC.
    1.45 +*/
    1.46 +#ifndef _MSVC_H_
    1.47 +#define _MSVC_H_
    1.48 +
    1.49 +#if defined(_MSC_VER)
    1.50 +#pragma warning(disable : 4054)
    1.51 +#pragma warning(disable : 4055)
    1.52 +#pragma warning(disable : 4100)
    1.53 +#pragma warning(disable : 4127)
    1.54 +#pragma warning(disable : 4130)
    1.55 +#pragma warning(disable : 4152)
    1.56 +#pragma warning(disable : 4189)
    1.57 +#pragma warning(disable : 4206)
    1.58 +#pragma warning(disable : 4210)
    1.59 +#pragma warning(disable : 4232)
    1.60 +#pragma warning(disable : 4244)
    1.61 +#pragma warning(disable : 4305)
    1.62 +#pragma warning(disable : 4306)
    1.63 +#pragma warning(disable : 4702)
    1.64 +#pragma warning(disable : 4706)
    1.65 +#endif /* defined(_MSC_VER) */
    1.66 +
    1.67 +#endif /* _MSVC_H_ */
    1.68 +
    1.69 +/************** End of msvc.h ************************************************/
    1.70 +/************** Continuing where we left off in sqliteInt.h ******************/
    1.71 +
    1.72 +/*
    1.73 +** Special setup for VxWorks
    1.74 +*/
    1.75 +/************** Include vxworks.h in the middle of sqliteInt.h ***************/
    1.76 +/************** Begin file vxworks.h *****************************************/
    1.77 +/*
    1.78 +** 2015-03-02
    1.79 +**
    1.80 +** The author disclaims copyright to this source code.  In place of
    1.81 +** a legal notice, here is a blessing:
    1.82 +**
    1.83 +**    May you do good and not evil.
    1.84 +**    May you find forgiveness for yourself and forgive others.
    1.85 +**    May you share freely, never taking more than you give.
    1.86 +**
    1.87 +******************************************************************************
    1.88 +**
    1.89 +** This file contains code that is specific to Wind River's VxWorks
    1.90 +*/
    1.91 +#if defined(__RTP__) || defined(_WRS_KERNEL)
    1.92 +/* This is VxWorks.  Set up things specially for that OS
    1.93 +*/
    1.94 +#include <vxWorks.h>
    1.95 +#include <pthread.h>  /* amalgamator: dontcache */
    1.96 +#define OS_VXWORKS 1
    1.97 +#define SQLITE_OS_OTHER 0
    1.98 +#define SQLITE_HOMEGROWN_RECURSIVE_MUTEX 1
    1.99 +#define SQLITE_OMIT_LOAD_EXTENSION 1
   1.100 +#define SQLITE_ENABLE_LOCKING_STYLE 0
   1.101 +#define HAVE_UTIME 1
   1.102 +#else
   1.103 +/* This is not VxWorks. */
   1.104 +#define OS_VXWORKS 0
   1.105 +#define HAVE_FCHOWN 1
   1.106 +#define HAVE_READLINK 1
   1.107 +#define HAVE_LSTAT 1
   1.108 +#endif /* defined(_WRS_KERNEL) */
   1.109 +
   1.110 +/************** End of vxworks.h *********************************************/
   1.111 +/************** Continuing where we left off in sqliteInt.h ******************/
   1.112 +
   1.113 +/*
   1.114  ** These #defines should enable >2GB file support on POSIX if the
   1.115  ** underlying operating system supports it.  If the OS lacks
   1.116  ** large file support, or if the OS is windows, these should be no-ops.
   1.117 @@ -75,6 +161,22 @@
   1.118  # define _LARGEFILE_SOURCE 1
   1.119  #endif
   1.120  
   1.121 +/* What version of GCC is being used.  0 means GCC is not being used */
   1.122 +#ifdef __GNUC__
   1.123 +# define GCC_VERSION (__GNUC__*1000000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__)
   1.124 +#else
   1.125 +# define GCC_VERSION 0
   1.126 +#endif
   1.127 +
   1.128 +/* Needed for various definitions... */
   1.129 +#if defined(__GNUC__) && !defined(_GNU_SOURCE)
   1.130 +# define _GNU_SOURCE
   1.131 +#endif
   1.132 +
   1.133 +#if defined(__OpenBSD__) && !defined(_BSD_SOURCE)
   1.134 +# define _BSD_SOURCE
   1.135 +#endif
   1.136 +
   1.137  /*
   1.138  ** For MinGW, check to see if we can include the header file containing its
   1.139  ** version information, among other things.  Normally, this internal MinGW
   1.140 @@ -138,7 +240,7 @@
   1.141  **
   1.142  ** The official C-language API documentation for SQLite is derived
   1.143  ** from comments in this file.  This file is the authoritative source
   1.144 -** on how SQLite interfaces are suppose to operate.
   1.145 +** on how SQLite interfaces are supposed to operate.
   1.146  **
   1.147  ** The name of this file under configuration management is "sqlite.h.in".
   1.148  ** The makefile makes some minor changes to this file (such as inserting
   1.149 @@ -158,21 +260,25 @@
   1.150  
   1.151  
   1.152  /*
   1.153 -** Add the ability to override 'extern'
   1.154 +** Provide the ability to override linkage features of the interface.
   1.155  */
   1.156  #ifndef SQLITE_EXTERN
   1.157  # define SQLITE_EXTERN extern
   1.158  #endif
   1.159 -
   1.160  #ifndef SQLITE_API
   1.161  # define SQLITE_API
   1.162  #endif
   1.163 -
   1.164 +#ifndef SQLITE_CDECL
   1.165 +# define SQLITE_CDECL
   1.166 +#endif
   1.167 +#ifndef SQLITE_STDCALL
   1.168 +# define SQLITE_STDCALL
   1.169 +#endif
   1.170  
   1.171  /*
   1.172  ** These no-op macros are used in front of interfaces to mark those
   1.173  ** interfaces as either deprecated or experimental.  New applications
   1.174 -** should not use deprecated interfaces - they are support for backwards
   1.175 +** should not use deprecated interfaces - they are supported for backwards
   1.176  ** compatibility only.  Application writers should be aware that
   1.177  ** experimental interfaces are subject to change in point releases.
   1.178  **
   1.179 @@ -222,9 +328,9 @@
   1.180  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
   1.181  ** [sqlite_version()] and [sqlite_source_id()].
   1.182  */
   1.183 -#define SQLITE_VERSION        "3.8.6"
   1.184 -#define SQLITE_VERSION_NUMBER 3008006
   1.185 -#define SQLITE_SOURCE_ID      "2014-08-15 11:46:33 9491ba7d738528f168657adb43a198238abde19e"
   1.186 +#define SQLITE_VERSION        "3.11.0"
   1.187 +#define SQLITE_VERSION_NUMBER 3011000
   1.188 +#define SQLITE_SOURCE_ID      "2016-02-15 17:29:24 3d862f207e3adc00f78066799ac5a8c282430a5f"
   1.189  
   1.190  /*
   1.191  ** CAPI3REF: Run-Time Library Version Numbers
   1.192 @@ -235,7 +341,7 @@
   1.193  ** but are associated with the library instead of the header file.  ^(Cautious
   1.194  ** programmers might include assert() statements in their application to
   1.195  ** verify that values returned by these interfaces match the macros in
   1.196 -** the header, and thus insure that the application is
   1.197 +** the header, and thus ensure that the application is
   1.198  ** compiled with matching library and header files.
   1.199  **
   1.200  ** <blockquote><pre>
   1.201 @@ -257,9 +363,9 @@
   1.202  ** See also: [sqlite_version()] and [sqlite_source_id()].
   1.203  */
   1.204  SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
   1.205 -SQLITE_API const char *sqlite3_libversion(void);
   1.206 -SQLITE_API const char *sqlite3_sourceid(void);
   1.207 -SQLITE_API int sqlite3_libversion_number(void);
   1.208 +SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void);
   1.209 +SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void);
   1.210 +SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void);
   1.211  
   1.212  /*
   1.213  ** CAPI3REF: Run-Time Library Compilation Options Diagnostics
   1.214 @@ -284,8 +390,8 @@
   1.215  ** [sqlite_compileoption_get()] and the [compile_options pragma].
   1.216  */
   1.217  #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
   1.218 -SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
   1.219 -SQLITE_API const char *sqlite3_compileoption_get(int N);
   1.220 +SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName);
   1.221 +SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N);
   1.222  #endif
   1.223  
   1.224  /*
   1.225 @@ -316,7 +422,7 @@
   1.226  ** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
   1.227  ** can be fully or partially disabled using a call to [sqlite3_config()]
   1.228  ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
   1.229 -** or [SQLITE_CONFIG_MUTEX].  ^(The return value of the
   1.230 +** or [SQLITE_CONFIG_SERIALIZED].  ^(The return value of the
   1.231  ** sqlite3_threadsafe() function shows only the compile-time setting of
   1.232  ** thread safety, not any run-time changes to that setting made by
   1.233  ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
   1.234 @@ -324,7 +430,7 @@
   1.235  **
   1.236  ** See the [threading mode] documentation for additional information.
   1.237  */
   1.238 -SQLITE_API int sqlite3_threadsafe(void);
   1.239 +SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void);
   1.240  
   1.241  /*
   1.242  ** CAPI3REF: Database Connection Handle
   1.243 @@ -381,6 +487,7 @@
   1.244  
   1.245  /*
   1.246  ** CAPI3REF: Closing A Database Connection
   1.247 +** DESTRUCTOR: sqlite3
   1.248  **
   1.249  ** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors
   1.250  ** for the [sqlite3] object.
   1.251 @@ -420,8 +527,8 @@
   1.252  ** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
   1.253  ** argument is a harmless no-op.
   1.254  */
   1.255 -SQLITE_API int sqlite3_close(sqlite3*);
   1.256 -SQLITE_API int sqlite3_close_v2(sqlite3*);
   1.257 +SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3*);
   1.258 +SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3*);
   1.259  
   1.260  /*
   1.261  ** The type for a callback function.
   1.262 @@ -432,6 +539,7 @@
   1.263  
   1.264  /*
   1.265  ** CAPI3REF: One-Step Query Execution Interface
   1.266 +** METHOD: sqlite3
   1.267  **
   1.268  ** The sqlite3_exec() interface is a convenience wrapper around
   1.269  ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
   1.270 @@ -456,7 +564,7 @@
   1.271  ** from [sqlite3_malloc()] and passed back through the 5th parameter.
   1.272  ** To avoid memory leaks, the application should invoke [sqlite3_free()]
   1.273  ** on error message strings returned through the 5th parameter of
   1.274 -** of sqlite3_exec() after the error message string is no longer needed.
   1.275 +** sqlite3_exec() after the error message string is no longer needed.
   1.276  ** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors
   1.277  ** occur, then sqlite3_exec() sets the pointer in its 5th parameter to
   1.278  ** NULL before returning.
   1.279 @@ -483,7 +591,7 @@
   1.280  ** Restrictions:
   1.281  **
   1.282  ** <ul>
   1.283 -** <li> The application must insure that the 1st parameter to sqlite3_exec()
   1.284 +** <li> The application must ensure that the 1st parameter to sqlite3_exec()
   1.285  **      is a valid and open [database connection].
   1.286  ** <li> The application must not close the [database connection] specified by
   1.287  **      the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
   1.288 @@ -491,7 +599,7 @@
   1.289  **      the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
   1.290  ** </ul>
   1.291  */
   1.292 -SQLITE_API int sqlite3_exec(
   1.293 +SQLITE_API int SQLITE_STDCALL sqlite3_exec(
   1.294    sqlite3*,                                  /* An open database */
   1.295    const char *sql,                           /* SQL to be evaluated */
   1.296    int (*callback)(void*,int,char**,char**),  /* Callback function */
   1.297 @@ -586,6 +694,8 @@
   1.298  #define SQLITE_IOERR_MMAP              (SQLITE_IOERR | (24<<8))
   1.299  #define SQLITE_IOERR_GETTEMPPATH       (SQLITE_IOERR | (25<<8))
   1.300  #define SQLITE_IOERR_CONVPATH          (SQLITE_IOERR | (26<<8))
   1.301 +#define SQLITE_IOERR_VNODE             (SQLITE_IOERR | (27<<8))
   1.302 +#define SQLITE_IOERR_AUTH              (SQLITE_IOERR | (28<<8))
   1.303  #define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))
   1.304  #define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))
   1.305  #define SQLITE_BUSY_SNAPSHOT           (SQLITE_BUSY   |  (2<<8))
   1.306 @@ -612,6 +722,7 @@
   1.307  #define SQLITE_NOTICE_RECOVER_WAL      (SQLITE_NOTICE | (1<<8))
   1.308  #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
   1.309  #define SQLITE_WARNING_AUTOINDEX       (SQLITE_WARNING | (1<<8))
   1.310 +#define SQLITE_AUTH_USER               (SQLITE_AUTH | (1<<8))
   1.311  
   1.312  /*
   1.313  ** CAPI3REF: Flags For File Open Operations
   1.314 @@ -870,14 +981,16 @@
   1.315  ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
   1.316  ** interface.
   1.317  **
   1.318 +** <ul>
   1.319 +** <li>[[SQLITE_FCNTL_LOCKSTATE]]
   1.320  ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging.  This
   1.321  ** opcode causes the xFileControl method to write the current state of
   1.322  ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
   1.323  ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
   1.324  ** into an integer that the pArg argument points to. This capability
   1.325 -** is used during testing and only needs to be supported when SQLITE_TEST
   1.326 -** is defined.
   1.327 -** <ul>
   1.328 +** is used during testing and is only available when the SQLITE_TEST
   1.329 +** compile-time option is used.
   1.330 +**
   1.331  ** <li>[[SQLITE_FCNTL_SIZE_HINT]]
   1.332  ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
   1.333  ** layer a hint of how large the database file will grow to be during the
   1.334 @@ -898,8 +1011,13 @@
   1.335  ** <li>[[SQLITE_FCNTL_FILE_POINTER]]
   1.336  ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer
   1.337  ** to the [sqlite3_file] object associated with a particular database
   1.338 -** connection.  See the [sqlite3_file_control()] documentation for
   1.339 -** additional information.
   1.340 +** connection.  See also [SQLITE_FCNTL_JOURNAL_POINTER].
   1.341 +**
   1.342 +** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]]
   1.343 +** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer
   1.344 +** to the [sqlite3_file] object associated with the journal file (either
   1.345 +** the [rollback journal] or the [write-ahead log]) for a particular database
   1.346 +** connection.  See also [SQLITE_FCNTL_FILE_POINTER].
   1.347  **
   1.348  ** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]
   1.349  ** No longer in use.
   1.350 @@ -986,6 +1104,15 @@
   1.351  ** pointer in case this file-control is not implemented.  This file-control
   1.352  ** is intended for diagnostic use only.
   1.353  **
   1.354 +** <li>[[SQLITE_FCNTL_VFS_POINTER]]
   1.355 +** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level
   1.356 +** [VFSes] currently in use.  ^(The argument X in
   1.357 +** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be
   1.358 +** of type "[sqlite3_vfs] **".  This opcodes will set *X
   1.359 +** to a pointer to the top-level VFS.)^
   1.360 +** ^When there are multiple VFS shims in the stack, this opcode finds the
   1.361 +** upper-most shim only.
   1.362 +**
   1.363  ** <li>[[SQLITE_FCNTL_PRAGMA]]
   1.364  ** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] 
   1.365  ** file control is sent to the open [sqlite3_file] object corresponding
   1.366 @@ -1002,7 +1129,9 @@
   1.367  ** [PRAGMA] processing continues.  ^If the [SQLITE_FCNTL_PRAGMA]
   1.368  ** file control returns [SQLITE_OK], then the parser assumes that the
   1.369  ** VFS has handled the PRAGMA itself and the parser generates a no-op
   1.370 -** prepared statement.  ^If the [SQLITE_FCNTL_PRAGMA] file control returns
   1.371 +** prepared statement if result string is NULL, or that returns a copy
   1.372 +** of the result string if the string is non-NULL.
   1.373 +** ^If the [SQLITE_FCNTL_PRAGMA] file control returns
   1.374  ** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
   1.375  ** that the VFS encountered an error while handling the [PRAGMA] and the
   1.376  ** compilation of the PRAGMA fails with an error.  ^The [SQLITE_FCNTL_PRAGMA]
   1.377 @@ -1060,12 +1189,27 @@
   1.378  ** pointed to by the pArg argument.  This capability is used during testing
   1.379  ** and only needs to be supported when SQLITE_TEST is defined.
   1.380  **
   1.381 +** <li>[[SQLITE_FCNTL_WAL_BLOCK]]
   1.382 +** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might
   1.383 +** be advantageous to block on the next WAL lock if the lock is not immediately
   1.384 +** available.  The WAL subsystem issues this signal during rare
   1.385 +** circumstances in order to fix a problem with priority inversion.
   1.386 +** Applications should <em>not</em> use this file-control.
   1.387 +**
   1.388 +** <li>[[SQLITE_FCNTL_ZIPVFS]]
   1.389 +** The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other
   1.390 +** VFS should return SQLITE_NOTFOUND for this opcode.
   1.391 +**
   1.392 +** <li>[[SQLITE_FCNTL_RBU]]
   1.393 +** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by
   1.394 +** the RBU extension only.  All other VFS should return SQLITE_NOTFOUND for
   1.395 +** this opcode.  
   1.396  ** </ul>
   1.397  */
   1.398  #define SQLITE_FCNTL_LOCKSTATE               1
   1.399 -#define SQLITE_GET_LOCKPROXYFILE             2
   1.400 -#define SQLITE_SET_LOCKPROXYFILE             3
   1.401 -#define SQLITE_LAST_ERRNO                    4
   1.402 +#define SQLITE_FCNTL_GET_LOCKPROXYFILE       2
   1.403 +#define SQLITE_FCNTL_SET_LOCKPROXYFILE       3
   1.404 +#define SQLITE_FCNTL_LAST_ERRNO              4
   1.405  #define SQLITE_FCNTL_SIZE_HINT               5
   1.406  #define SQLITE_FCNTL_CHUNK_SIZE              6
   1.407  #define SQLITE_FCNTL_FILE_POINTER            7
   1.408 @@ -1084,6 +1228,17 @@
   1.409  #define SQLITE_FCNTL_SYNC                   21
   1.410  #define SQLITE_FCNTL_COMMIT_PHASETWO        22
   1.411  #define SQLITE_FCNTL_WIN32_SET_HANDLE       23
   1.412 +#define SQLITE_FCNTL_WAL_BLOCK              24
   1.413 +#define SQLITE_FCNTL_ZIPVFS                 25
   1.414 +#define SQLITE_FCNTL_RBU                    26
   1.415 +#define SQLITE_FCNTL_VFS_POINTER            27
   1.416 +#define SQLITE_FCNTL_JOURNAL_POINTER        28
   1.417 +
   1.418 +/* deprecated names */
   1.419 +#define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE
   1.420 +#define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE
   1.421 +#define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO
   1.422 +
   1.423  
   1.424  /*
   1.425  ** CAPI3REF: Mutex Handle
   1.426 @@ -1335,7 +1490,7 @@
   1.427  ** </ul>
   1.428  **
   1.429  ** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as
   1.430 -** was given no the corresponding lock.  
   1.431 +** was given on the corresponding lock.  
   1.432  **
   1.433  ** The xShmLock method can transition between unlocked and SHARED or
   1.434  ** between unlocked and EXCLUSIVE.  It cannot transition between SHARED
   1.435 @@ -1432,10 +1587,10 @@
   1.436  ** must return [SQLITE_OK] on success and some other [error code] upon
   1.437  ** failure.
   1.438  */
   1.439 -SQLITE_API int sqlite3_initialize(void);
   1.440 -SQLITE_API int sqlite3_shutdown(void);
   1.441 -SQLITE_API int sqlite3_os_init(void);
   1.442 -SQLITE_API int sqlite3_os_end(void);
   1.443 +SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void);
   1.444 +SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void);
   1.445 +SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void);
   1.446 +SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void);
   1.447  
   1.448  /*
   1.449  ** CAPI3REF: Configuring The SQLite Library
   1.450 @@ -1446,9 +1601,11 @@
   1.451  ** applications and so this routine is usually not necessary.  It is
   1.452  ** provided to support rare applications with unusual needs.
   1.453  **
   1.454 -** The sqlite3_config() interface is not threadsafe.  The application
   1.455 -** must insure that no other SQLite interfaces are invoked by other
   1.456 -** threads while sqlite3_config() is running.  Furthermore, sqlite3_config()
   1.457 +** <b>The sqlite3_config() interface is not threadsafe. The application
   1.458 +** must ensure that no other SQLite interfaces are invoked by other
   1.459 +** threads while sqlite3_config() is running.</b>
   1.460 +**
   1.461 +** The sqlite3_config() interface
   1.462  ** may only be invoked prior to library initialization using
   1.463  ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
   1.464  ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
   1.465 @@ -1466,10 +1623,11 @@
   1.466  ** ^If the option is unknown or SQLite is unable to set the option
   1.467  ** then this routine returns a non-zero [error code].
   1.468  */
   1.469 -SQLITE_API int sqlite3_config(int, ...);
   1.470 +SQLITE_API int SQLITE_CDECL sqlite3_config(int, ...);
   1.471  
   1.472  /*
   1.473  ** CAPI3REF: Configure database connections
   1.474 +** METHOD: sqlite3
   1.475  **
   1.476  ** The sqlite3_db_config() interface is used to make configuration
   1.477  ** changes to a [database connection].  The interface is similar to
   1.478 @@ -1484,7 +1642,7 @@
   1.479  ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
   1.480  ** the call is considered successful.
   1.481  */
   1.482 -SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
   1.483 +SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3*, int op, ...);
   1.484  
   1.485  /*
   1.486  ** CAPI3REF: Memory Allocation Routines
   1.487 @@ -1618,31 +1776,33 @@
   1.488  ** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
   1.489  **
   1.490  ** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>
   1.491 -** <dd> ^(This option takes a single argument which is a pointer to an
   1.492 -** instance of the [sqlite3_mem_methods] structure.  The argument specifies
   1.493 +** <dd> ^(The SQLITE_CONFIG_MALLOC option takes a single argument which is 
   1.494 +** a pointer to an instance of the [sqlite3_mem_methods] structure.
   1.495 +** The argument specifies
   1.496  ** alternative low-level memory allocation routines to be used in place of
   1.497  ** the memory allocation routines built into SQLite.)^ ^SQLite makes
   1.498  ** its own private copy of the content of the [sqlite3_mem_methods] structure
   1.499  ** before the [sqlite3_config()] call returns.</dd>
   1.500  **
   1.501  ** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>
   1.502 -** <dd> ^(This option takes a single argument which is a pointer to an
   1.503 -** instance of the [sqlite3_mem_methods] structure.  The [sqlite3_mem_methods]
   1.504 +** <dd> ^(The SQLITE_CONFIG_GETMALLOC option takes a single argument which
   1.505 +** is a pointer to an instance of the [sqlite3_mem_methods] structure.
   1.506 +** The [sqlite3_mem_methods]
   1.507  ** structure is filled with the currently defined memory allocation routines.)^
   1.508  ** This option can be used to overload the default memory allocation
   1.509  ** routines with a wrapper that simulations memory allocation failure or
   1.510  ** tracks memory usage, for example. </dd>
   1.511  **
   1.512  ** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>
   1.513 -** <dd> ^This option takes single argument of type int, interpreted as a 
   1.514 -** boolean, which enables or disables the collection of memory allocation 
   1.515 -** statistics. ^(When memory allocation statistics are disabled, the 
   1.516 -** following SQLite interfaces become non-operational:
   1.517 +** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,
   1.518 +** interpreted as a boolean, which enables or disables the collection of
   1.519 +** memory allocation statistics. ^(When memory allocation statistics are
   1.520 +** disabled, the following SQLite interfaces become non-operational:
   1.521  **   <ul>
   1.522  **   <li> [sqlite3_memory_used()]
   1.523  **   <li> [sqlite3_memory_highwater()]
   1.524  **   <li> [sqlite3_soft_heap_limit64()]
   1.525 -**   <li> [sqlite3_status()]
   1.526 +**   <li> [sqlite3_status64()]
   1.527  **   </ul>)^
   1.528  ** ^Memory allocation statistics are enabled by default unless SQLite is
   1.529  ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
   1.530 @@ -1650,53 +1810,72 @@
   1.531  ** </dd>
   1.532  **
   1.533  ** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt>
   1.534 -** <dd> ^This option specifies a static memory buffer that SQLite can use for
   1.535 -** scratch memory.  There are three arguments:  A pointer an 8-byte
   1.536 +** <dd> ^The SQLITE_CONFIG_SCRATCH option specifies a static memory buffer
   1.537 +** that SQLite can use for scratch memory.  ^(There are three arguments
   1.538 +** to SQLITE_CONFIG_SCRATCH:  A pointer an 8-byte
   1.539  ** aligned memory buffer from which the scratch allocations will be
   1.540  ** drawn, the size of each scratch allocation (sz),
   1.541 -** and the maximum number of scratch allocations (N).  The sz
   1.542 -** argument must be a multiple of 16.
   1.543 +** and the maximum number of scratch allocations (N).)^
   1.544  ** The first argument must be a pointer to an 8-byte aligned buffer
   1.545  ** of at least sz*N bytes of memory.
   1.546 -** ^SQLite will use no more than two scratch buffers per thread.  So
   1.547 -** N should be set to twice the expected maximum number of threads.
   1.548 -** ^SQLite will never require a scratch buffer that is more than 6
   1.549 -** times the database page size. ^If SQLite needs needs additional
   1.550 +** ^SQLite will not use more than one scratch buffers per thread.
   1.551 +** ^SQLite will never request a scratch buffer that is more than 6
   1.552 +** times the database page size.
   1.553 +** ^If SQLite needs needs additional
   1.554  ** scratch memory beyond what is provided by this configuration option, then 
   1.555 -** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
   1.556 +** [sqlite3_malloc()] will be used to obtain the memory needed.<p>
   1.557 +** ^When the application provides any amount of scratch memory using
   1.558 +** SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary large
   1.559 +** [sqlite3_malloc|heap allocations].
   1.560 +** This can help [Robson proof|prevent memory allocation failures] due to heap
   1.561 +** fragmentation in low-memory embedded systems.
   1.562 +** </dd>
   1.563  **
   1.564  ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
   1.565 -** <dd> ^This option specifies a static memory buffer that SQLite can use for
   1.566 -** the database page cache with the default page cache implementation.  
   1.567 -** This configuration should not be used if an application-define page
   1.568 -** cache implementation is loaded using the SQLITE_CONFIG_PCACHE2 option.
   1.569 -** There are three arguments to this option: A pointer to 8-byte aligned
   1.570 -** memory, the size of each page buffer (sz), and the number of pages (N).
   1.571 +** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool
   1.572 +** that SQLite can use for the database page cache with the default page
   1.573 +** cache implementation.  
   1.574 +** This configuration option is a no-op if an application-define page
   1.575 +** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2].
   1.576 +** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to
   1.577 +** 8-byte aligned memory (pMem), the size of each page cache line (sz),
   1.578 +** and the number of cache lines (N).
   1.579  ** The sz argument should be the size of the largest database page
   1.580 -** (a power of two between 512 and 32768) plus a little extra for each
   1.581 -** page header.  ^The page header size is 20 to 40 bytes depending on
   1.582 -** the host architecture.  ^It is harmless, apart from the wasted memory,
   1.583 -** to make sz a little too large.  The first
   1.584 -** argument should point to an allocation of at least sz*N bytes of memory.
   1.585 -** ^SQLite will use the memory provided by the first argument to satisfy its
   1.586 -** memory needs for the first N pages that it adds to cache.  ^If additional
   1.587 -** page cache memory is needed beyond what is provided by this option, then
   1.588 -** SQLite goes to [sqlite3_malloc()] for the additional storage space.
   1.589 -** The pointer in the first argument must
   1.590 -** be aligned to an 8-byte boundary or subsequent behavior of SQLite
   1.591 -** will be undefined.</dd>
   1.592 +** (a power of two between 512 and 65536) plus some extra bytes for each
   1.593 +** page header.  ^The number of extra bytes needed by the page header
   1.594 +** can be determined using [SQLITE_CONFIG_PCACHE_HDRSZ].
   1.595 +** ^It is harmless, apart from the wasted memory,
   1.596 +** for the sz parameter to be larger than necessary.  The pMem
   1.597 +** argument must be either a NULL pointer or a pointer to an 8-byte
   1.598 +** aligned block of memory of at least sz*N bytes, otherwise
   1.599 +** subsequent behavior is undefined.
   1.600 +** ^When pMem is not NULL, SQLite will strive to use the memory provided
   1.601 +** to satisfy page cache needs, falling back to [sqlite3_malloc()] if
   1.602 +** a page cache line is larger than sz bytes or if all of the pMem buffer
   1.603 +** is exhausted.
   1.604 +** ^If pMem is NULL and N is non-zero, then each database connection
   1.605 +** does an initial bulk allocation for page cache memory
   1.606 +** from [sqlite3_malloc()] sufficient for N cache lines if N is positive or
   1.607 +** of -1024*N bytes if N is negative, . ^If additional
   1.608 +** page cache memory is needed beyond what is provided by the initial
   1.609 +** allocation, then SQLite goes to [sqlite3_malloc()] separately for each
   1.610 +** additional cache line. </dd>
   1.611  **
   1.612  ** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>
   1.613 -** <dd> ^This option specifies a static memory buffer that SQLite will use
   1.614 -** for all of its dynamic memory allocation needs beyond those provided
   1.615 -** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
   1.616 -** There are three arguments: An 8-byte aligned pointer to the memory,
   1.617 +** <dd> ^The SQLITE_CONFIG_HEAP option specifies a static memory buffer 
   1.618 +** that SQLite will use for all of its dynamic memory allocation needs
   1.619 +** beyond those provided for by [SQLITE_CONFIG_SCRATCH] and
   1.620 +** [SQLITE_CONFIG_PAGECACHE].
   1.621 +** ^The SQLITE_CONFIG_HEAP option is only available if SQLite is compiled
   1.622 +** with either [SQLITE_ENABLE_MEMSYS3] or [SQLITE_ENABLE_MEMSYS5] and returns
   1.623 +** [SQLITE_ERROR] if invoked otherwise.
   1.624 +** ^There are three arguments to SQLITE_CONFIG_HEAP:
   1.625 +** An 8-byte aligned pointer to the memory,
   1.626  ** the number of bytes in the memory buffer, and the minimum allocation size.
   1.627  ** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts
   1.628  ** to using its default memory allocator (the system malloc() implementation),
   1.629  ** undoing any prior invocation of [SQLITE_CONFIG_MALLOC].  ^If the
   1.630 -** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or
   1.631 -** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
   1.632 +** memory pointer is not NULL then the alternative memory
   1.633  ** allocator is engaged to handle all of SQLites memory allocation needs.
   1.634  ** The first pointer (the memory pointer) must be aligned to an 8-byte
   1.635  ** boundary or subsequent behavior of SQLite will be undefined.
   1.636 @@ -1704,11 +1883,11 @@
   1.637  ** for the minimum allocation size are 2**5 through 2**8.</dd>
   1.638  **
   1.639  ** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>
   1.640 -** <dd> ^(This option takes a single argument which is a pointer to an
   1.641 -** instance of the [sqlite3_mutex_methods] structure.  The argument specifies
   1.642 -** alternative low-level mutex routines to be used in place
   1.643 -** the mutex routines built into SQLite.)^  ^SQLite makes a copy of the
   1.644 -** content of the [sqlite3_mutex_methods] structure before the call to
   1.645 +** <dd> ^(The SQLITE_CONFIG_MUTEX option takes a single argument which is a
   1.646 +** pointer to an instance of the [sqlite3_mutex_methods] structure.
   1.647 +** The argument specifies alternative low-level mutex routines to be used
   1.648 +** in place the mutex routines built into SQLite.)^  ^SQLite makes a copy of
   1.649 +** the content of the [sqlite3_mutex_methods] structure before the call to
   1.650  ** [sqlite3_config()] returns. ^If SQLite is compiled with
   1.651  ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
   1.652  ** the entire mutexing subsystem is omitted from the build and hence calls to
   1.653 @@ -1716,8 +1895,8 @@
   1.654  ** return [SQLITE_ERROR].</dd>
   1.655  **
   1.656  ** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt>
   1.657 -** <dd> ^(This option takes a single argument which is a pointer to an
   1.658 -** instance of the [sqlite3_mutex_methods] structure.  The
   1.659 +** <dd> ^(The SQLITE_CONFIG_GETMUTEX option takes a single argument which
   1.660 +** is a pointer to an instance of the [sqlite3_mutex_methods] structure.  The
   1.661  ** [sqlite3_mutex_methods]
   1.662  ** structure is filled with the currently defined mutex routines.)^
   1.663  ** This option can be used to overload the default mutex allocation
   1.664 @@ -1729,25 +1908,25 @@
   1.665  ** return [SQLITE_ERROR].</dd>
   1.666  **
   1.667  ** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>
   1.668 -** <dd> ^(This option takes two arguments that determine the default
   1.669 -** memory allocation for the lookaside memory allocator on each
   1.670 -** [database connection].  The first argument is the
   1.671 +** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine
   1.672 +** the default size of lookaside memory on each [database connection].
   1.673 +** The first argument is the
   1.674  ** size of each lookaside buffer slot and the second is the number of
   1.675 -** slots allocated to each database connection.)^  ^(This option sets the
   1.676 -** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
   1.677 -** verb to [sqlite3_db_config()] can be used to change the lookaside
   1.678 +** slots allocated to each database connection.)^  ^(SQLITE_CONFIG_LOOKASIDE
   1.679 +** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
   1.680 +** option to [sqlite3_db_config()] can be used to change the lookaside
   1.681  ** configuration on individual connections.)^ </dd>
   1.682  **
   1.683  ** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>
   1.684 -** <dd> ^(This option takes a single argument which is a pointer to
   1.685 -** an [sqlite3_pcache_methods2] object.  This object specifies the interface
   1.686 -** to a custom page cache implementation.)^  ^SQLite makes a copy of the
   1.687 -** object and uses it for page cache memory allocations.</dd>
   1.688 +** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is 
   1.689 +** a pointer to an [sqlite3_pcache_methods2] object.  This object specifies
   1.690 +** the interface to a custom page cache implementation.)^
   1.691 +** ^SQLite makes a copy of the [sqlite3_pcache_methods2] object.</dd>
   1.692  **
   1.693  ** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>
   1.694 -** <dd> ^(This option takes a single argument which is a pointer to an
   1.695 -** [sqlite3_pcache_methods2] object.  SQLite copies of the current
   1.696 -** page cache implementation into that object.)^ </dd>
   1.697 +** <dd> ^(The SQLITE_CONFIG_GETPCACHE2 option takes a single argument which
   1.698 +** is a pointer to an [sqlite3_pcache_methods2] object.  SQLite copies of
   1.699 +** the current page cache implementation into that object.)^ </dd>
   1.700  **
   1.701  ** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>
   1.702  ** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite
   1.703 @@ -1770,10 +1949,11 @@
   1.704  ** function must be threadsafe. </dd>
   1.705  **
   1.706  ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
   1.707 -** <dd>^(This option takes a single argument of type int. If non-zero, then
   1.708 -** URI handling is globally enabled. If the parameter is zero, then URI handling
   1.709 -** is globally disabled.)^ ^If URI handling is globally enabled, all filenames
   1.710 -** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
   1.711 +** <dd>^(The SQLITE_CONFIG_URI option takes a single argument of type int.
   1.712 +** If non-zero, then URI handling is globally enabled. If the parameter is zero,
   1.713 +** then URI handling is globally disabled.)^ ^If URI handling is globally
   1.714 +** enabled, all filenames passed to [sqlite3_open()], [sqlite3_open_v2()],
   1.715 +** [sqlite3_open16()] or
   1.716  ** specified as part of [ATTACH] commands are interpreted as URIs, regardless
   1.717  ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
   1.718  ** connection is opened. ^If it is globally disabled, filenames are
   1.719 @@ -1783,9 +1963,10 @@
   1.720  ** [SQLITE_USE_URI] symbol defined.)^
   1.721  **
   1.722  ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
   1.723 -** <dd>^This option takes a single integer argument which is interpreted as
   1.724 -** a boolean in order to enable or disable the use of covering indices for
   1.725 -** full table scans in the query optimizer.  ^The default setting is determined
   1.726 +** <dd>^The SQLITE_CONFIG_COVERING_INDEX_SCAN option takes a single integer
   1.727 +** argument which is interpreted as a boolean in order to enable or disable
   1.728 +** the use of covering indices for full table scans in the query optimizer.
   1.729 +** ^The default setting is determined
   1.730  ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
   1.731  ** if that compile-time option is omitted.
   1.732  ** The ability to disable the use of covering indices for full table scans
   1.733 @@ -1825,18 +2006,37 @@
   1.734  ** ^The default setting can be overridden by each database connection using
   1.735  ** either the [PRAGMA mmap_size] command, or by using the
   1.736  ** [SQLITE_FCNTL_MMAP_SIZE] file control.  ^(The maximum allowed mmap size
   1.737 -** cannot be changed at run-time.  Nor may the maximum allowed mmap size
   1.738 -** exceed the compile-time maximum mmap size set by the
   1.739 +** will be silently truncated if necessary so that it does not exceed the
   1.740 +** compile-time maximum mmap size set by the
   1.741  ** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
   1.742  ** ^If either argument to this option is negative, then that argument is
   1.743  ** changed to its compile-time default.
   1.744  **
   1.745  ** [[SQLITE_CONFIG_WIN32_HEAPSIZE]]
   1.746  ** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
   1.747 -** <dd>^This option is only available if SQLite is compiled for Windows
   1.748 -** with the [SQLITE_WIN32_MALLOC] pre-processor macro defined.
   1.749 -** SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
   1.750 +** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is
   1.751 +** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro
   1.752 +** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
   1.753  ** that specifies the maximum size of the created heap.
   1.754 +**
   1.755 +** [[SQLITE_CONFIG_PCACHE_HDRSZ]]
   1.756 +** <dt>SQLITE_CONFIG_PCACHE_HDRSZ
   1.757 +** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which
   1.758 +** is a pointer to an integer and writes into that integer the number of extra
   1.759 +** bytes per page required for each page in [SQLITE_CONFIG_PAGECACHE].
   1.760 +** The amount of extra space required can change depending on the compiler,
   1.761 +** target platform, and SQLite version.
   1.762 +**
   1.763 +** [[SQLITE_CONFIG_PMASZ]]
   1.764 +** <dt>SQLITE_CONFIG_PMASZ
   1.765 +** <dd>^The SQLITE_CONFIG_PMASZ option takes a single parameter which
   1.766 +** is an unsigned integer and sets the "Minimum PMA Size" for the multithreaded
   1.767 +** sorter to that integer.  The default minimum PMA Size is set by the
   1.768 +** [SQLITE_SORTER_PMASZ] compile-time option.  New threads are launched
   1.769 +** to help with sort operations when multithreaded sorting
   1.770 +** is enabled (using the [PRAGMA threads] command) and the amount of content
   1.771 +** to be sorted exceeds the page size times the minimum of the
   1.772 +** [PRAGMA cache_size] setting and this value.
   1.773  ** </dl>
   1.774  */
   1.775  #define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */
   1.776 @@ -1862,6 +2062,8 @@
   1.777  #define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */
   1.778  #define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */
   1.779  #define SQLITE_CONFIG_WIN32_HEAPSIZE      23  /* int nByte */
   1.780 +#define SQLITE_CONFIG_PCACHE_HDRSZ        24  /* int *psz */
   1.781 +#define SQLITE_CONFIG_PMASZ               25  /* unsigned int szPma */
   1.782  
   1.783  /*
   1.784  ** CAPI3REF: Database Connection Configuration Options
   1.785 @@ -1928,15 +2130,17 @@
   1.786  
   1.787  /*
   1.788  ** CAPI3REF: Enable Or Disable Extended Result Codes
   1.789 +** METHOD: sqlite3
   1.790  **
   1.791  ** ^The sqlite3_extended_result_codes() routine enables or disables the
   1.792  ** [extended result codes] feature of SQLite. ^The extended result
   1.793  ** codes are disabled by default for historical compatibility.
   1.794  */
   1.795 -SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
   1.796 +SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3*, int onoff);
   1.797  
   1.798  /*
   1.799  ** CAPI3REF: Last Insert Rowid
   1.800 +** METHOD: sqlite3
   1.801  **
   1.802  ** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
   1.803  ** has a unique 64-bit signed
   1.804 @@ -1984,52 +2188,51 @@
   1.805  ** unpredictable and might not equal either the old or the new
   1.806  ** last insert [rowid].
   1.807  */
   1.808 -SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
   1.809 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3*);
   1.810  
   1.811  /*
   1.812  ** CAPI3REF: Count The Number Of Rows Modified
   1.813 -**
   1.814 -** ^This function returns the number of database rows that were changed
   1.815 -** or inserted or deleted by the most recently completed SQL statement
   1.816 -** on the [database connection] specified by the first parameter.
   1.817 -** ^(Only changes that are directly specified by the [INSERT], [UPDATE],
   1.818 -** or [DELETE] statement are counted.  Auxiliary changes caused by
   1.819 -** triggers or [foreign key actions] are not counted.)^ Use the
   1.820 -** [sqlite3_total_changes()] function to find the total number of changes
   1.821 -** including changes caused by triggers and foreign key actions.
   1.822 -**
   1.823 -** ^Changes to a view that are simulated by an [INSTEAD OF trigger]
   1.824 -** are not counted.  Only real table changes are counted.
   1.825 -**
   1.826 -** ^(A "row change" is a change to a single row of a single table
   1.827 -** caused by an INSERT, DELETE, or UPDATE statement.  Rows that
   1.828 -** are changed as side effects of [REPLACE] constraint resolution,
   1.829 -** rollback, ABORT processing, [DROP TABLE], or by any other
   1.830 -** mechanisms do not count as direct row changes.)^
   1.831 -**
   1.832 -** A "trigger context" is a scope of execution that begins and
   1.833 -** ends with the script of a [CREATE TRIGGER | trigger]. 
   1.834 -** Most SQL statements are
   1.835 -** evaluated outside of any trigger.  This is the "top level"
   1.836 -** trigger context.  If a trigger fires from the top level, a
   1.837 -** new trigger context is entered for the duration of that one
   1.838 -** trigger.  Subtriggers create subcontexts for their duration.
   1.839 -**
   1.840 -** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
   1.841 -** not create a new trigger context.
   1.842 -**
   1.843 -** ^This function returns the number of direct row changes in the
   1.844 -** most recent INSERT, UPDATE, or DELETE statement within the same
   1.845 -** trigger context.
   1.846 -**
   1.847 -** ^Thus, when called from the top level, this function returns the
   1.848 -** number of changes in the most recent INSERT, UPDATE, or DELETE
   1.849 -** that also occurred at the top level.  ^(Within the body of a trigger,
   1.850 -** the sqlite3_changes() interface can be called to find the number of
   1.851 -** changes in the most recently completed INSERT, UPDATE, or DELETE
   1.852 -** statement within the body of the same trigger.
   1.853 -** However, the number returned does not include changes
   1.854 -** caused by subtriggers since those have their own context.)^
   1.855 +** METHOD: sqlite3
   1.856 +**
   1.857 +** ^This function returns the number of rows modified, inserted or
   1.858 +** deleted by the most recently completed INSERT, UPDATE or DELETE
   1.859 +** statement on the database connection specified by the only parameter.
   1.860 +** ^Executing any other type of SQL statement does not modify the value
   1.861 +** returned by this function.
   1.862 +**
   1.863 +** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are
   1.864 +** considered - auxiliary changes caused by [CREATE TRIGGER | triggers], 
   1.865 +** [foreign key actions] or [REPLACE] constraint resolution are not counted.
   1.866 +** 
   1.867 +** Changes to a view that are intercepted by 
   1.868 +** [INSTEAD OF trigger | INSTEAD OF triggers] are not counted. ^The value 
   1.869 +** returned by sqlite3_changes() immediately after an INSERT, UPDATE or 
   1.870 +** DELETE statement run on a view is always zero. Only changes made to real 
   1.871 +** tables are counted.
   1.872 +**
   1.873 +** Things are more complicated if the sqlite3_changes() function is
   1.874 +** executed while a trigger program is running. This may happen if the
   1.875 +** program uses the [changes() SQL function], or if some other callback
   1.876 +** function invokes sqlite3_changes() directly. Essentially:
   1.877 +** 
   1.878 +** <ul>
   1.879 +**   <li> ^(Before entering a trigger program the value returned by
   1.880 +**        sqlite3_changes() function is saved. After the trigger program 
   1.881 +**        has finished, the original value is restored.)^
   1.882 +** 
   1.883 +**   <li> ^(Within a trigger program each INSERT, UPDATE and DELETE 
   1.884 +**        statement sets the value returned by sqlite3_changes() 
   1.885 +**        upon completion as normal. Of course, this value will not include 
   1.886 +**        any changes performed by sub-triggers, as the sqlite3_changes() 
   1.887 +**        value will be saved and restored after each sub-trigger has run.)^
   1.888 +** </ul>
   1.889 +** 
   1.890 +** ^This means that if the changes() SQL function (or similar) is used
   1.891 +** by the first INSERT, UPDATE or DELETE statement within a trigger, it 
   1.892 +** returns the value as set when the calling statement began executing.
   1.893 +** ^If it is used by the second or subsequent such statement within a trigger 
   1.894 +** program, the value returned reflects the number of rows modified by the 
   1.895 +** previous INSERT, UPDATE or DELETE statement within the same trigger.
   1.896  **
   1.897  ** See also the [sqlite3_total_changes()] interface, the
   1.898  ** [count_changes pragma], and the [changes() SQL function].
   1.899 @@ -2038,25 +2241,23 @@
   1.900  ** while [sqlite3_changes()] is running then the value returned
   1.901  ** is unpredictable and not meaningful.
   1.902  */
   1.903 -SQLITE_API int sqlite3_changes(sqlite3*);
   1.904 +SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3*);
   1.905  
   1.906  /*
   1.907  ** CAPI3REF: Total Number Of Rows Modified
   1.908 -**
   1.909 -** ^This function returns the number of row changes caused by [INSERT],
   1.910 -** [UPDATE] or [DELETE] statements since the [database connection] was opened.
   1.911 -** ^(The count returned by sqlite3_total_changes() includes all changes
   1.912 -** from all [CREATE TRIGGER | trigger] contexts and changes made by
   1.913 -** [foreign key actions]. However,
   1.914 -** the count does not include changes used to implement [REPLACE] constraints,
   1.915 -** do rollbacks or ABORT processing, or [DROP TABLE] processing.  The
   1.916 -** count does not include rows of views that fire an [INSTEAD OF trigger],
   1.917 -** though if the INSTEAD OF trigger makes changes of its own, those changes 
   1.918 -** are counted.)^
   1.919 -** ^The sqlite3_total_changes() function counts the changes as soon as
   1.920 -** the statement that makes them is completed (when the statement handle
   1.921 -** is passed to [sqlite3_reset()] or [sqlite3_finalize()]).
   1.922 -**
   1.923 +** METHOD: sqlite3
   1.924 +**
   1.925 +** ^This function returns the total number of rows inserted, modified or
   1.926 +** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
   1.927 +** since the database connection was opened, including those executed as
   1.928 +** part of trigger programs. ^Executing any other type of SQL statement
   1.929 +** does not affect the value returned by sqlite3_total_changes().
   1.930 +** 
   1.931 +** ^Changes made as part of [foreign key actions] are included in the
   1.932 +** count, but those made as part of REPLACE constraint resolution are
   1.933 +** not. ^Changes to a view that are intercepted by INSTEAD OF triggers 
   1.934 +** are not counted.
   1.935 +** 
   1.936  ** See also the [sqlite3_changes()] interface, the
   1.937  ** [count_changes pragma], and the [total_changes() SQL function].
   1.938  **
   1.939 @@ -2064,10 +2265,11 @@
   1.940  ** while [sqlite3_total_changes()] is running then the value
   1.941  ** returned is unpredictable and not meaningful.
   1.942  */
   1.943 -SQLITE_API int sqlite3_total_changes(sqlite3*);
   1.944 +SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3*);
   1.945  
   1.946  /*
   1.947  ** CAPI3REF: Interrupt A Long-Running Query
   1.948 +** METHOD: sqlite3
   1.949  **
   1.950  ** ^This function causes any pending database operation to abort and
   1.951  ** return at its earliest opportunity. This routine is typically
   1.952 @@ -2103,7 +2305,7 @@
   1.953  ** If the database connection closes while [sqlite3_interrupt()]
   1.954  ** is running then bad things will likely happen.
   1.955  */
   1.956 -SQLITE_API void sqlite3_interrupt(sqlite3*);
   1.957 +SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3*);
   1.958  
   1.959  /*
   1.960  ** CAPI3REF: Determine If An SQL Statement Is Complete
   1.961 @@ -2138,11 +2340,13 @@
   1.962  ** The input to [sqlite3_complete16()] must be a zero-terminated
   1.963  ** UTF-16 string in native byte order.
   1.964  */
   1.965 -SQLITE_API int sqlite3_complete(const char *sql);
   1.966 -SQLITE_API int sqlite3_complete16(const void *sql);
   1.967 +SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *sql);
   1.968 +SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *sql);
   1.969  
   1.970  /*
   1.971  ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
   1.972 +** KEYWORDS: {busy-handler callback} {busy handler}
   1.973 +** METHOD: sqlite3
   1.974  **
   1.975  ** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X
   1.976  ** that might be invoked with argument P whenever
   1.977 @@ -2159,7 +2363,7 @@
   1.978  ** ^The first argument to the busy handler is a copy of the void* pointer which
   1.979  ** is the third argument to sqlite3_busy_handler().  ^The second argument to
   1.980  ** the busy handler callback is the number of times that the busy handler has
   1.981 -** been invoked for the same locking event.  ^If the
   1.982 +** been invoked previously for the same locking event.  ^If the
   1.983  ** busy callback returns 0, then no additional attempts are made to
   1.984  ** access the database and [SQLITE_BUSY] is returned
   1.985  ** to the application.
   1.986 @@ -2198,10 +2402,11 @@
   1.987  ** A busy handler must not close the database connection
   1.988  ** or [prepared statement] that invoked the busy handler.
   1.989  */
   1.990 -SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
   1.991 +SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
   1.992  
   1.993  /*
   1.994  ** CAPI3REF: Set A Busy Timeout
   1.995 +** METHOD: sqlite3
   1.996  **
   1.997  ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
   1.998  ** for a specified amount of time when a table is locked.  ^The handler
   1.999 @@ -2214,16 +2419,17 @@
  1.1000  ** turns off all busy handlers.
  1.1001  **
  1.1002  ** ^(There can only be a single busy handler for a particular
  1.1003 -** [database connection] any any given moment.  If another busy handler
  1.1004 +** [database connection] at any given moment.  If another busy handler
  1.1005  ** was defined  (using [sqlite3_busy_handler()]) prior to calling
  1.1006  ** this routine, that other busy handler is cleared.)^
  1.1007  **
  1.1008  ** See also:  [PRAGMA busy_timeout]
  1.1009  */
  1.1010 -SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
  1.1011 +SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3*, int ms);
  1.1012  
  1.1013  /*
  1.1014  ** CAPI3REF: Convenience Routines For Running Queries
  1.1015 +** METHOD: sqlite3
  1.1016  **
  1.1017  ** This is a legacy interface that is preserved for backwards compatibility.
  1.1018  ** Use of this interface is not recommended.
  1.1019 @@ -2294,7 +2500,7 @@
  1.1020  ** reflected in subsequent calls to [sqlite3_errcode()] or
  1.1021  ** [sqlite3_errmsg()].
  1.1022  */
  1.1023 -SQLITE_API int sqlite3_get_table(
  1.1024 +SQLITE_API int SQLITE_STDCALL sqlite3_get_table(
  1.1025    sqlite3 *db,          /* An open database */
  1.1026    const char *zSql,     /* SQL to be evaluated */
  1.1027    char ***pazResult,    /* Results of the query */
  1.1028 @@ -2302,13 +2508,17 @@
  1.1029    int *pnColumn,        /* Number of result columns written here */
  1.1030    char **pzErrmsg       /* Error msg written here */
  1.1031  );
  1.1032 -SQLITE_API void sqlite3_free_table(char **result);
  1.1033 +SQLITE_API void SQLITE_STDCALL sqlite3_free_table(char **result);
  1.1034  
  1.1035  /*
  1.1036  ** CAPI3REF: Formatted String Printing Functions
  1.1037  **
  1.1038  ** These routines are work-alikes of the "printf()" family of functions
  1.1039  ** from the standard C library.
  1.1040 +** These routines understand most of the common K&R formatting options,
  1.1041 +** plus some additional non-standard formats, detailed below.
  1.1042 +** Note that some of the more obscure formatting options from recent
  1.1043 +** C-library standards are omitted from this implementation.
  1.1044  **
  1.1045  ** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
  1.1046  ** results into memory obtained from [sqlite3_malloc()].
  1.1047 @@ -2341,7 +2551,7 @@
  1.1048  ** These routines all implement some additional formatting
  1.1049  ** options that are useful for constructing SQL statements.
  1.1050  ** All of the usual printf() formatting options apply.  In addition, there
  1.1051 -** is are "%q", "%Q", and "%z" options.
  1.1052 +** is are "%q", "%Q", "%w" and "%z" options.
  1.1053  **
  1.1054  ** ^(The %q option works like %s in that it substitutes a nul-terminated
  1.1055  ** string from the argument list.  But %q also doubles every '\'' character.
  1.1056 @@ -2394,14 +2604,20 @@
  1.1057  ** The code above will render a correct SQL statement in the zSQL
  1.1058  ** variable even if the zText variable is a NULL pointer.
  1.1059  **
  1.1060 +** ^(The "%w" formatting option is like "%q" except that it expects to
  1.1061 +** be contained within double-quotes instead of single quotes, and it
  1.1062 +** escapes the double-quote character instead of the single-quote
  1.1063 +** character.)^  The "%w" formatting option is intended for safely inserting
  1.1064 +** table and column names into a constructed SQL statement.
  1.1065 +**
  1.1066  ** ^(The "%z" formatting option works like "%s" but with the
  1.1067  ** addition that after the string has been read and copied into
  1.1068  ** the result, [sqlite3_free()] is called on the input string.)^
  1.1069  */
  1.1070 -SQLITE_API char *sqlite3_mprintf(const char*,...);
  1.1071 -SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
  1.1072 -SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
  1.1073 -SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
  1.1074 +SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char*,...);
  1.1075 +SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char*, va_list);
  1.1076 +SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int,char*,const char*, ...);
  1.1077 +SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int,char*,const char*, va_list);
  1.1078  
  1.1079  /*
  1.1080  ** CAPI3REF: Memory Allocation Subsystem
  1.1081 @@ -2418,6 +2634,10 @@
  1.1082  ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns
  1.1083  ** a NULL pointer.
  1.1084  **
  1.1085 +** ^The sqlite3_malloc64(N) routine works just like
  1.1086 +** sqlite3_malloc(N) except that N is an unsigned 64-bit integer instead
  1.1087 +** of a signed 32-bit integer.
  1.1088 +**
  1.1089  ** ^Calling sqlite3_free() with a pointer previously returned
  1.1090  ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so
  1.1091  ** that it might be reused.  ^The sqlite3_free() routine is
  1.1092 @@ -2429,24 +2649,38 @@
  1.1093  ** might result if sqlite3_free() is called with a non-NULL pointer that
  1.1094  ** was not obtained from sqlite3_malloc() or sqlite3_realloc().
  1.1095  **
  1.1096 -** ^(The sqlite3_realloc() interface attempts to resize a
  1.1097 -** prior memory allocation to be at least N bytes, where N is the
  1.1098 -** second parameter.  The memory allocation to be resized is the first
  1.1099 -** parameter.)^ ^ If the first parameter to sqlite3_realloc()
  1.1100 +** ^The sqlite3_realloc(X,N) interface attempts to resize a
  1.1101 +** prior memory allocation X to be at least N bytes.
  1.1102 +** ^If the X parameter to sqlite3_realloc(X,N)
  1.1103  ** is a NULL pointer then its behavior is identical to calling
  1.1104 -** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc().
  1.1105 -** ^If the second parameter to sqlite3_realloc() is zero or
  1.1106 +** sqlite3_malloc(N).
  1.1107 +** ^If the N parameter to sqlite3_realloc(X,N) is zero or
  1.1108  ** negative then the behavior is exactly the same as calling
  1.1109 -** sqlite3_free(P) where P is the first parameter to sqlite3_realloc().
  1.1110 -** ^sqlite3_realloc() returns a pointer to a memory allocation
  1.1111 -** of at least N bytes in size or NULL if sufficient memory is unavailable.
  1.1112 +** sqlite3_free(X).
  1.1113 +** ^sqlite3_realloc(X,N) returns a pointer to a memory allocation
  1.1114 +** of at least N bytes in size or NULL if insufficient memory is available.
  1.1115  ** ^If M is the size of the prior allocation, then min(N,M) bytes
  1.1116  ** of the prior allocation are copied into the beginning of buffer returned
  1.1117 -** by sqlite3_realloc() and the prior allocation is freed.
  1.1118 -** ^If sqlite3_realloc() returns NULL, then the prior allocation
  1.1119 -** is not freed.
  1.1120 -**
  1.1121 -** ^The memory returned by sqlite3_malloc() and sqlite3_realloc()
  1.1122 +** by sqlite3_realloc(X,N) and the prior allocation is freed.
  1.1123 +** ^If sqlite3_realloc(X,N) returns NULL and N is positive, then the
  1.1124 +** prior allocation is not freed.
  1.1125 +**
  1.1126 +** ^The sqlite3_realloc64(X,N) interfaces works the same as
  1.1127 +** sqlite3_realloc(X,N) except that N is a 64-bit unsigned integer instead
  1.1128 +** of a 32-bit signed integer.
  1.1129 +**
  1.1130 +** ^If X is a memory allocation previously obtained from sqlite3_malloc(),
  1.1131 +** sqlite3_malloc64(), sqlite3_realloc(), or sqlite3_realloc64(), then
  1.1132 +** sqlite3_msize(X) returns the size of that memory allocation in bytes.
  1.1133 +** ^The value returned by sqlite3_msize(X) might be larger than the number
  1.1134 +** of bytes requested when X was allocated.  ^If X is a NULL pointer then
  1.1135 +** sqlite3_msize(X) returns zero.  If X points to something that is not
  1.1136 +** the beginning of memory allocation, or if it points to a formerly
  1.1137 +** valid memory allocation that has now been freed, then the behavior
  1.1138 +** of sqlite3_msize(X) is undefined and possibly harmful.
  1.1139 +**
  1.1140 +** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(),
  1.1141 +** sqlite3_malloc64(), and sqlite3_realloc64()
  1.1142  ** is always aligned to at least an 8 byte boundary, or to a
  1.1143  ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time
  1.1144  ** option is used.
  1.1145 @@ -2473,9 +2707,12 @@
  1.1146  ** a block of memory after it has been released using
  1.1147  ** [sqlite3_free()] or [sqlite3_realloc()].
  1.1148  */
  1.1149 -SQLITE_API void *sqlite3_malloc(int);
  1.1150 -SQLITE_API void *sqlite3_realloc(void*, int);
  1.1151 -SQLITE_API void sqlite3_free(void*);
  1.1152 +SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int);
  1.1153 +SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64);
  1.1154 +SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void*, int);
  1.1155 +SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void*, sqlite3_uint64);
  1.1156 +SQLITE_API void SQLITE_STDCALL sqlite3_free(void*);
  1.1157 +SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void*);
  1.1158  
  1.1159  /*
  1.1160  ** CAPI3REF: Memory Allocator Statistics
  1.1161 @@ -2500,8 +2737,8 @@
  1.1162  ** by [sqlite3_memory_highwater(1)] is the high-water mark
  1.1163  ** prior to the reset.
  1.1164  */
  1.1165 -SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
  1.1166 -SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
  1.1167 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void);
  1.1168 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag);
  1.1169  
  1.1170  /*
  1.1171  ** CAPI3REF: Pseudo-Random Number Generator
  1.1172 @@ -2513,20 +2750,22 @@
  1.1173  ** applications to access the same PRNG for other purposes.
  1.1174  **
  1.1175  ** ^A call to this routine stores N bytes of randomness into buffer P.
  1.1176 -** ^If N is less than one, then P can be a NULL pointer.
  1.1177 +** ^The P parameter can be a NULL pointer.
  1.1178  **
  1.1179  ** ^If this routine has not been previously called or if the previous
  1.1180 -** call had N less than one, then the PRNG is seeded using randomness
  1.1181 -** obtained from the xRandomness method of the default [sqlite3_vfs] object.
  1.1182 -** ^If the previous call to this routine had an N of 1 or more then
  1.1183 -** the pseudo-randomness is generated
  1.1184 +** call had N less than one or a NULL pointer for P, then the PRNG is
  1.1185 +** seeded using randomness obtained from the xRandomness method of
  1.1186 +** the default [sqlite3_vfs] object.
  1.1187 +** ^If the previous call to this routine had an N of 1 or more and a
  1.1188 +** non-NULL P then the pseudo-randomness is generated
  1.1189  ** internally and without recourse to the [sqlite3_vfs] xRandomness
  1.1190  ** method.
  1.1191  */
  1.1192 -SQLITE_API void sqlite3_randomness(int N, void *P);
  1.1193 +SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *P);
  1.1194  
  1.1195  /*
  1.1196  ** CAPI3REF: Compile-Time Authorization Callbacks
  1.1197 +** METHOD: sqlite3
  1.1198  **
  1.1199  ** ^This routine registers an authorizer callback with a particular
  1.1200  ** [database connection], supplied in the first argument.
  1.1201 @@ -2605,7 +2844,7 @@
  1.1202  ** as stated in the previous paragraph, sqlite3_step() invokes
  1.1203  ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
  1.1204  */
  1.1205 -SQLITE_API int sqlite3_set_authorizer(
  1.1206 +SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
  1.1207    sqlite3*,
  1.1208    int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
  1.1209    void *pUserData
  1.1210 @@ -2683,6 +2922,7 @@
  1.1211  
  1.1212  /*
  1.1213  ** CAPI3REF: Tracing And Profiling Functions
  1.1214 +** METHOD: sqlite3
  1.1215  **
  1.1216  ** These routines register callback functions that can be used for
  1.1217  ** tracing and profiling the execution of SQL statements.
  1.1218 @@ -2709,12 +2949,13 @@
  1.1219  ** sqlite3_profile() function is considered experimental and is
  1.1220  ** subject to change in future versions of SQLite.
  1.1221  */
  1.1222 -SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
  1.1223 -SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
  1.1224 +SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
  1.1225 +SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
  1.1226     void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
  1.1227  
  1.1228  /*
  1.1229  ** CAPI3REF: Query Progress Callbacks
  1.1230 +** METHOD: sqlite3
  1.1231  **
  1.1232  ** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback
  1.1233  ** function X to be invoked periodically during long running calls to
  1.1234 @@ -2744,10 +2985,11 @@
  1.1235  ** database connections for the meaning of "modify" in this paragraph.
  1.1236  **
  1.1237  */
  1.1238 -SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
  1.1239 +SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
  1.1240  
  1.1241  /*
  1.1242  ** CAPI3REF: Opening A New Database Connection
  1.1243 +** CONSTRUCTOR: sqlite3
  1.1244  **
  1.1245  ** ^These routines open an SQLite database file as specified by the 
  1.1246  ** filename argument. ^The filename argument is interpreted as UTF-8 for
  1.1247 @@ -2762,9 +3004,9 @@
  1.1248  ** an English language description of the error following a failure of any
  1.1249  ** of the sqlite3_open() routines.
  1.1250  **
  1.1251 -** ^The default encoding for the database will be UTF-8 if
  1.1252 -** sqlite3_open() or sqlite3_open_v2() is called and
  1.1253 -** UTF-16 in the native byte order if sqlite3_open16() is used.
  1.1254 +** ^The default encoding will be UTF-8 for databases created using
  1.1255 +** sqlite3_open() or sqlite3_open_v2().  ^The default encoding for databases
  1.1256 +** created using sqlite3_open16() will be UTF-16 in the native byte order.
  1.1257  **
  1.1258  ** Whether or not an error occurs when it is opened, resources
  1.1259  ** associated with the [database connection] handle should be released by
  1.1260 @@ -2852,13 +3094,14 @@
  1.1261  ** then it is interpreted as an absolute path. ^If the path does not begin 
  1.1262  ** with a '/' (meaning that the authority section is omitted from the URI)
  1.1263  ** then the path is interpreted as a relative path. 
  1.1264 -** ^On windows, the first component of an absolute path 
  1.1265 -** is a drive specification (e.g. "C:").
  1.1266 +** ^(On windows, the first component of an absolute path 
  1.1267 +** is a drive specification (e.g. "C:").)^
  1.1268  **
  1.1269  ** [[core URI query parameters]]
  1.1270  ** The query component of a URI may contain parameters that are interpreted
  1.1271  ** either by SQLite itself, or by a [VFS | custom VFS implementation].
  1.1272 -** SQLite interprets the following three query parameters:
  1.1273 +** SQLite and its built-in [VFSes] interpret the
  1.1274 +** following query parameters:
  1.1275  **
  1.1276  ** <ul>
  1.1277  **   <li> <b>vfs</b>: ^The "vfs" parameter may be used to specify the name of
  1.1278 @@ -2893,11 +3136,9 @@
  1.1279  **     a URI filename, its value overrides any behavior requested by setting
  1.1280  **     SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag.
  1.1281  **
  1.1282 -**  <li> <b>psow</b>: ^The psow parameter may be "true" (or "on" or "yes" or
  1.1283 -**     "1") or "false" (or "off" or "no" or "0") to indicate that the
  1.1284 +**  <li> <b>psow</b>: ^The psow parameter indicates whether or not the
  1.1285  **     [powersafe overwrite] property does or does not apply to the
  1.1286 -**     storage media on which the database file resides.  ^The psow query
  1.1287 -**     parameter only works for the built-in unix and Windows VFSes.
  1.1288 +**     storage media on which the database file resides.
  1.1289  **
  1.1290  **  <li> <b>nolock</b>: ^The nolock parameter is a boolean query parameter
  1.1291  **     which if set disables file locking in rollback journal modes.  This
  1.1292 @@ -2973,15 +3214,15 @@
  1.1293  **
  1.1294  ** See also: [sqlite3_temp_directory]
  1.1295  */
  1.1296 -SQLITE_API int sqlite3_open(
  1.1297 +SQLITE_API int SQLITE_STDCALL sqlite3_open(
  1.1298    const char *filename,   /* Database filename (UTF-8) */
  1.1299    sqlite3 **ppDb          /* OUT: SQLite db handle */
  1.1300  );
  1.1301 -SQLITE_API int sqlite3_open16(
  1.1302 +SQLITE_API int SQLITE_STDCALL sqlite3_open16(
  1.1303    const void *filename,   /* Database filename (UTF-16) */
  1.1304    sqlite3 **ppDb          /* OUT: SQLite db handle */
  1.1305  );
  1.1306 -SQLITE_API int sqlite3_open_v2(
  1.1307 +SQLITE_API int SQLITE_STDCALL sqlite3_open_v2(
  1.1308    const char *filename,   /* Database filename (UTF-8) */
  1.1309    sqlite3 **ppDb,         /* OUT: SQLite db handle */
  1.1310    int flags,              /* Flags */
  1.1311 @@ -3027,19 +3268,22 @@
  1.1312  ** VFS method, then the behavior of this routine is undefined and probably
  1.1313  ** undesirable.
  1.1314  */
  1.1315 -SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
  1.1316 -SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
  1.1317 -SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
  1.1318 +SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam);
  1.1319 +SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
  1.1320 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
  1.1321  
  1.1322  
  1.1323  /*
  1.1324  ** CAPI3REF: Error Codes And Messages
  1.1325 -**
  1.1326 -** ^The sqlite3_errcode() interface returns the numeric [result code] or
  1.1327 -** [extended result code] for the most recent failed sqlite3_* API call
  1.1328 -** associated with a [database connection]. If a prior API call failed
  1.1329 -** but the most recent API call succeeded, the return value from
  1.1330 -** sqlite3_errcode() is undefined.  ^The sqlite3_extended_errcode()
  1.1331 +** METHOD: sqlite3
  1.1332 +**
  1.1333 +** ^If the most recent sqlite3_* API call associated with 
  1.1334 +** [database connection] D failed, then the sqlite3_errcode(D) interface
  1.1335 +** returns the numeric [result code] or [extended result code] for that
  1.1336 +** API call.
  1.1337 +** If the most recent API call was successful,
  1.1338 +** then the return value from sqlite3_errcode() is undefined.
  1.1339 +** ^The sqlite3_extended_errcode()
  1.1340  ** interface is the same except that it always returns the 
  1.1341  ** [extended result code] even when extended result codes are
  1.1342  ** disabled.
  1.1343 @@ -3070,40 +3314,41 @@
  1.1344  ** was invoked incorrectly by the application.  In that case, the
  1.1345  ** error code and message may or may not be set.
  1.1346  */
  1.1347 -SQLITE_API int sqlite3_errcode(sqlite3 *db);
  1.1348 -SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
  1.1349 -SQLITE_API const char *sqlite3_errmsg(sqlite3*);
  1.1350 -SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
  1.1351 -SQLITE_API const char *sqlite3_errstr(int);
  1.1352 -
  1.1353 -/*
  1.1354 -** CAPI3REF: SQL Statement Object
  1.1355 +SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db);
  1.1356 +SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db);
  1.1357 +SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3*);
  1.1358 +SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3*);
  1.1359 +SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int);
  1.1360 +
  1.1361 +/*
  1.1362 +** CAPI3REF: Prepared Statement Object
  1.1363  ** KEYWORDS: {prepared statement} {prepared statements}
  1.1364  **
  1.1365 -** An instance of this object represents a single SQL statement.
  1.1366 -** This object is variously known as a "prepared statement" or a
  1.1367 -** "compiled SQL statement" or simply as a "statement".
  1.1368 -**
  1.1369 -** The life of a statement object goes something like this:
  1.1370 +** An instance of this object represents a single SQL statement that
  1.1371 +** has been compiled into binary form and is ready to be evaluated.
  1.1372 +**
  1.1373 +** Think of each SQL statement as a separate computer program.  The
  1.1374 +** original SQL text is source code.  A prepared statement object 
  1.1375 +** is the compiled object code.  All SQL must be converted into a
  1.1376 +** prepared statement before it can be run.
  1.1377 +**
  1.1378 +** The life-cycle of a prepared statement object usually goes like this:
  1.1379  **
  1.1380  ** <ol>
  1.1381 -** <li> Create the object using [sqlite3_prepare_v2()] or a related
  1.1382 -**      function.
  1.1383 -** <li> Bind values to [host parameters] using the sqlite3_bind_*()
  1.1384 +** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
  1.1385 +** <li> Bind values to [parameters] using the sqlite3_bind_*()
  1.1386  **      interfaces.
  1.1387  ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
  1.1388 -** <li> Reset the statement using [sqlite3_reset()] then go back
  1.1389 +** <li> Reset the prepared statement using [sqlite3_reset()] then go back
  1.1390  **      to step 2.  Do this zero or more times.
  1.1391  ** <li> Destroy the object using [sqlite3_finalize()].
  1.1392  ** </ol>
  1.1393 -**
  1.1394 -** Refer to documentation on individual methods above for additional
  1.1395 -** information.
  1.1396  */
  1.1397  typedef struct sqlite3_stmt sqlite3_stmt;
  1.1398  
  1.1399  /*
  1.1400  ** CAPI3REF: Run-time Limits
  1.1401 +** METHOD: sqlite3
  1.1402  **
  1.1403  ** ^(This interface allows the size of various constructs to be limited
  1.1404  ** on a connection by connection basis.  The first parameter is the
  1.1405 @@ -3141,7 +3386,7 @@
  1.1406  **
  1.1407  ** New run-time limit categories may be added in future releases.
  1.1408  */
  1.1409 -SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
  1.1410 +SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3*, int id, int newVal);
  1.1411  
  1.1412  /*
  1.1413  ** CAPI3REF: Run-Time Limit Categories
  1.1414 @@ -3193,6 +3438,10 @@
  1.1415  **
  1.1416  ** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
  1.1417  ** <dd>The maximum depth of recursion for triggers.</dd>)^
  1.1418 +**
  1.1419 +** [[SQLITE_LIMIT_WORKER_THREADS]] ^(<dt>SQLITE_LIMIT_WORKER_THREADS</dt>
  1.1420 +** <dd>The maximum number of auxiliary worker threads that a single
  1.1421 +** [prepared statement] may start.</dd>)^
  1.1422  ** </dl>
  1.1423  */
  1.1424  #define SQLITE_LIMIT_LENGTH                    0
  1.1425 @@ -3206,10 +3455,13 @@
  1.1426  #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH       8
  1.1427  #define SQLITE_LIMIT_VARIABLE_NUMBER           9
  1.1428  #define SQLITE_LIMIT_TRIGGER_DEPTH            10
  1.1429 +#define SQLITE_LIMIT_WORKER_THREADS           11
  1.1430  
  1.1431  /*
  1.1432  ** CAPI3REF: Compiling An SQL Statement
  1.1433  ** KEYWORDS: {SQL statement compiler}
  1.1434 +** METHOD: sqlite3
  1.1435 +** CONSTRUCTOR: sqlite3_stmt
  1.1436  **
  1.1437  ** To execute an SQL query, it must first be compiled into a byte-code
  1.1438  ** program using one of these routines.
  1.1439 @@ -3223,16 +3475,14 @@
  1.1440  ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
  1.1441  ** use UTF-16.
  1.1442  **
  1.1443 -** ^If the nByte argument is less than zero, then zSql is read up to the
  1.1444 -** first zero terminator. ^If nByte is non-negative, then it is the maximum
  1.1445 -** number of  bytes read from zSql.  ^When nByte is non-negative, the
  1.1446 -** zSql string ends at either the first '\000' or '\u0000' character or
  1.1447 -** the nByte-th byte, whichever comes first. If the caller knows
  1.1448 -** that the supplied string is nul-terminated, then there is a small
  1.1449 -** performance advantage to be gained by passing an nByte parameter that
  1.1450 -** is equal to the number of bytes in the input string <i>including</i>
  1.1451 -** the nul-terminator bytes as this saves SQLite from having to
  1.1452 -** make a copy of the input string.
  1.1453 +** ^If the nByte argument is negative, then zSql is read up to the
  1.1454 +** first zero terminator. ^If nByte is positive, then it is the
  1.1455 +** number of bytes read from zSql.  ^If nByte is zero, then no prepared
  1.1456 +** statement is generated.
  1.1457 +** If the caller knows that the supplied string is nul-terminated, then
  1.1458 +** there is a small performance advantage to passing an nByte parameter that
  1.1459 +** is the number of bytes in the input string <i>including</i>
  1.1460 +** the nul-terminator.
  1.1461  **
  1.1462  ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
  1.1463  ** past the end of the first SQL statement in zSql.  These routines only
  1.1464 @@ -3288,28 +3538,28 @@
  1.1465  ** </li>
  1.1466  ** </ol>
  1.1467  */
  1.1468 -SQLITE_API int sqlite3_prepare(
  1.1469 +SQLITE_API int SQLITE_STDCALL sqlite3_prepare(
  1.1470    sqlite3 *db,            /* Database handle */
  1.1471    const char *zSql,       /* SQL statement, UTF-8 encoded */
  1.1472    int nByte,              /* Maximum length of zSql in bytes. */
  1.1473    sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  1.1474    const char **pzTail     /* OUT: Pointer to unused portion of zSql */
  1.1475  );
  1.1476 -SQLITE_API int sqlite3_prepare_v2(
  1.1477 +SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2(
  1.1478    sqlite3 *db,            /* Database handle */
  1.1479    const char *zSql,       /* SQL statement, UTF-8 encoded */
  1.1480    int nByte,              /* Maximum length of zSql in bytes. */
  1.1481    sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  1.1482    const char **pzTail     /* OUT: Pointer to unused portion of zSql */
  1.1483  );
  1.1484 -SQLITE_API int sqlite3_prepare16(
  1.1485 +SQLITE_API int SQLITE_STDCALL sqlite3_prepare16(
  1.1486    sqlite3 *db,            /* Database handle */
  1.1487    const void *zSql,       /* SQL statement, UTF-16 encoded */
  1.1488    int nByte,              /* Maximum length of zSql in bytes. */
  1.1489    sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  1.1490    const void **pzTail     /* OUT: Pointer to unused portion of zSql */
  1.1491  );
  1.1492 -SQLITE_API int sqlite3_prepare16_v2(
  1.1493 +SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
  1.1494    sqlite3 *db,            /* Database handle */
  1.1495    const void *zSql,       /* SQL statement, UTF-16 encoded */
  1.1496    int nByte,              /* Maximum length of zSql in bytes. */
  1.1497 @@ -3319,15 +3569,17 @@
  1.1498  
  1.1499  /*
  1.1500  ** CAPI3REF: Retrieving Statement SQL
  1.1501 +** METHOD: sqlite3_stmt
  1.1502  **
  1.1503  ** ^This interface can be used to retrieve a saved copy of the original
  1.1504  ** SQL text used to create a [prepared statement] if that statement was
  1.1505  ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
  1.1506  */
  1.1507 -SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
  1.1508 +SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
  1.1509  
  1.1510  /*
  1.1511  ** CAPI3REF: Determine If An SQL Statement Writes The Database
  1.1512 +** METHOD: sqlite3_stmt
  1.1513  **
  1.1514  ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
  1.1515  ** and only if the [prepared statement] X makes no direct changes to
  1.1516 @@ -3355,14 +3607,16 @@
  1.1517  ** change the configuration of a database connection, they do not make 
  1.1518  ** changes to the content of the database files on disk.
  1.1519  */
  1.1520 -SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
  1.1521 +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
  1.1522  
  1.1523  /*
  1.1524  ** CAPI3REF: Determine If A Prepared Statement Has Been Reset
  1.1525 +** METHOD: sqlite3_stmt
  1.1526  **
  1.1527  ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
  1.1528  ** [prepared statement] S has been stepped at least once using 
  1.1529 -** [sqlite3_step(S)] but has not run to completion and/or has not 
  1.1530 +** [sqlite3_step(S)] but has neither run to completion (returned
  1.1531 +** [SQLITE_DONE] from [sqlite3_step(S)]) nor
  1.1532  ** been reset using [sqlite3_reset(S)].  ^The sqlite3_stmt_busy(S)
  1.1533  ** interface returns false if S is a NULL pointer.  If S is not a 
  1.1534  ** NULL pointer and is not a pointer to a valid [prepared statement]
  1.1535 @@ -3374,7 +3628,7 @@
  1.1536  ** for example, in diagnostic routines to search for prepared 
  1.1537  ** statements that are holding a transaction open.
  1.1538  */
  1.1539 -SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
  1.1540 +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt*);
  1.1541  
  1.1542  /*
  1.1543  ** CAPI3REF: Dynamically Typed Value Object
  1.1544 @@ -3389,7 +3643,9 @@
  1.1545  ** Some interfaces require a protected sqlite3_value.  Other interfaces
  1.1546  ** will accept either a protected or an unprotected sqlite3_value.
  1.1547  ** Every interface that accepts sqlite3_value arguments specifies
  1.1548 -** whether or not it requires a protected sqlite3_value.
  1.1549 +** whether or not it requires a protected sqlite3_value.  The
  1.1550 +** [sqlite3_value_dup()] interface can be used to construct a new 
  1.1551 +** protected sqlite3_value from an unprotected sqlite3_value.
  1.1552  **
  1.1553  ** The terms "protected" and "unprotected" refer to whether or not
  1.1554  ** a mutex is held.  An internal mutex is held for a protected
  1.1555 @@ -3433,6 +3689,7 @@
  1.1556  ** CAPI3REF: Binding Values To Prepared Statements
  1.1557  ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
  1.1558  ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
  1.1559 +** METHOD: sqlite3_stmt
  1.1560  **
  1.1561  ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
  1.1562  ** literals may be replaced by a [parameter] that matches one of following
  1.1563 @@ -3479,18 +3736,18 @@
  1.1564  ** If the fourth parameter to sqlite3_bind_blob() is negative, then
  1.1565  ** the behavior is undefined.
  1.1566  ** If a non-negative fourth parameter is provided to sqlite3_bind_text()
  1.1567 -** or sqlite3_bind_text16() then that parameter must be the byte offset
  1.1568 +** or sqlite3_bind_text16() or sqlite3_bind_text64() then
  1.1569 +** that parameter must be the byte offset
  1.1570  ** where the NUL terminator would occur assuming the string were NUL
  1.1571  ** terminated.  If any NUL characters occur at byte offsets less than 
  1.1572  ** the value of the fourth parameter then the resulting string value will
  1.1573  ** contain embedded NULs.  The result of expressions involving strings
  1.1574  ** with embedded NULs is undefined.
  1.1575  **
  1.1576 -** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
  1.1577 -** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
  1.1578 +** ^The fifth argument to the BLOB and string binding interfaces
  1.1579 +** is a destructor used to dispose of the BLOB or
  1.1580  ** string after SQLite has finished with it.  ^The destructor is called
  1.1581 -** to dispose of the BLOB or string even if the call to sqlite3_bind_blob(),
  1.1582 -** sqlite3_bind_text(), or sqlite3_bind_text16() fails.  
  1.1583 +** to dispose of the BLOB or string even if the call to bind API fails.
  1.1584  ** ^If the fifth argument is
  1.1585  ** the special value [SQLITE_STATIC], then SQLite assumes that the
  1.1586  ** information is in static, unmanaged space and does not need to be freed.
  1.1587 @@ -3498,6 +3755,14 @@
  1.1588  ** SQLite makes its own private copy of the data immediately, before
  1.1589  ** the sqlite3_bind_*() routine returns.
  1.1590  **
  1.1591 +** ^The sixth argument to sqlite3_bind_text64() must be one of
  1.1592 +** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]
  1.1593 +** to specify the encoding of the text in the third parameter.  If
  1.1594 +** the sixth argument to sqlite3_bind_text64() is not one of the
  1.1595 +** allowed values shown above, or if the text encoding is different
  1.1596 +** from the encoding specified by the sixth parameter, then the behavior
  1.1597 +** is undefined.
  1.1598 +**
  1.1599  ** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
  1.1600  ** is filled with zeroes.  ^A zeroblob uses a fixed amount of memory
  1.1601  ** (just an integer to hold its size) while it is being processed.
  1.1602 @@ -3518,24 +3783,33 @@
  1.1603  **
  1.1604  ** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an
  1.1605  ** [error code] if anything goes wrong.
  1.1606 +** ^[SQLITE_TOOBIG] might be returned if the size of a string or BLOB
  1.1607 +** exceeds limits imposed by [sqlite3_limit]([SQLITE_LIMIT_LENGTH]) or
  1.1608 +** [SQLITE_MAX_LENGTH].
  1.1609  ** ^[SQLITE_RANGE] is returned if the parameter
  1.1610  ** index is out of range.  ^[SQLITE_NOMEM] is returned if malloc() fails.
  1.1611  **
  1.1612  ** See also: [sqlite3_bind_parameter_count()],
  1.1613  ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
  1.1614  */
  1.1615 -SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
  1.1616 -SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
  1.1617 -SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
  1.1618 -SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
  1.1619 -SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
  1.1620 -SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));
  1.1621 -SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
  1.1622 -SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
  1.1623 -SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
  1.1624 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
  1.1625 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
  1.1626 +                        void(*)(void*));
  1.1627 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt*, int, double);
  1.1628 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt*, int, int);
  1.1629 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
  1.1630 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt*, int);
  1.1631 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
  1.1632 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
  1.1633 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
  1.1634 +                         void(*)(void*), unsigned char encoding);
  1.1635 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
  1.1636 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
  1.1637 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
  1.1638  
  1.1639  /*
  1.1640  ** CAPI3REF: Number Of SQL Parameters
  1.1641 +** METHOD: sqlite3_stmt
  1.1642  **
  1.1643  ** ^This routine can be used to find the number of [SQL parameters]
  1.1644  ** in a [prepared statement].  SQL parameters are tokens of the
  1.1645 @@ -3552,10 +3826,11 @@
  1.1646  ** [sqlite3_bind_parameter_name()], and
  1.1647  ** [sqlite3_bind_parameter_index()].
  1.1648  */
  1.1649 -SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
  1.1650 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt*);
  1.1651  
  1.1652  /*
  1.1653  ** CAPI3REF: Name Of A Host Parameter
  1.1654 +** METHOD: sqlite3_stmt
  1.1655  **
  1.1656  ** ^The sqlite3_bind_parameter_name(P,N) interface returns
  1.1657  ** the name of the N-th [SQL parameter] in the [prepared statement] P.
  1.1658 @@ -3579,10 +3854,11 @@
  1.1659  ** [sqlite3_bind_parameter_count()], and
  1.1660  ** [sqlite3_bind_parameter_index()].
  1.1661  */
  1.1662 -SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
  1.1663 +SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt*, int);
  1.1664  
  1.1665  /*
  1.1666  ** CAPI3REF: Index Of A Parameter With A Given Name
  1.1667 +** METHOD: sqlite3_stmt
  1.1668  **
  1.1669  ** ^Return the index of an SQL parameter given its name.  ^The
  1.1670  ** index value returned is suitable for use as the second
  1.1671 @@ -3593,21 +3869,23 @@
  1.1672  **
  1.1673  ** See also: [sqlite3_bind_blob|sqlite3_bind()],
  1.1674  ** [sqlite3_bind_parameter_count()], and
  1.1675 -** [sqlite3_bind_parameter_index()].
  1.1676 -*/
  1.1677 -SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
  1.1678 +** [sqlite3_bind_parameter_name()].
  1.1679 +*/
  1.1680 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
  1.1681  
  1.1682  /*
  1.1683  ** CAPI3REF: Reset All Bindings On A Prepared Statement
  1.1684 +** METHOD: sqlite3_stmt
  1.1685  **
  1.1686  ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
  1.1687  ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
  1.1688  ** ^Use this routine to reset all host parameters to NULL.
  1.1689  */
  1.1690 -SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
  1.1691 +SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt*);
  1.1692  
  1.1693  /*
  1.1694  ** CAPI3REF: Number Of Columns In A Result Set
  1.1695 +** METHOD: sqlite3_stmt
  1.1696  **
  1.1697  ** ^Return the number of columns in the result set returned by the
  1.1698  ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
  1.1699 @@ -3615,10 +3893,11 @@
  1.1700  **
  1.1701  ** See also: [sqlite3_data_count()]
  1.1702  */
  1.1703 -SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
  1.1704 +SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt);
  1.1705  
  1.1706  /*
  1.1707  ** CAPI3REF: Column Names In A Result Set
  1.1708 +** METHOD: sqlite3_stmt
  1.1709  **
  1.1710  ** ^These routines return the name assigned to a particular column
  1.1711  ** in the result set of a [SELECT] statement.  ^The sqlite3_column_name()
  1.1712 @@ -3643,11 +3922,12 @@
  1.1713  ** then the name of the column is unspecified and may change from
  1.1714  ** one release of SQLite to the next.
  1.1715  */
  1.1716 -SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
  1.1717 -SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
  1.1718 +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt*, int N);
  1.1719 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt*, int N);
  1.1720  
  1.1721  /*
  1.1722  ** CAPI3REF: Source Of Data In A Query Result
  1.1723 +** METHOD: sqlite3_stmt
  1.1724  **
  1.1725  ** ^These routines provide a means to determine the database, table, and
  1.1726  ** table column that is the origin of a particular result column in
  1.1727 @@ -3691,15 +3971,16 @@
  1.1728  ** for the same [prepared statement] and result column
  1.1729  ** at the same time then the results are undefined.
  1.1730  */
  1.1731 -SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);
  1.1732 -SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
  1.1733 -SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);
  1.1734 -SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
  1.1735 -SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
  1.1736 -SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
  1.1737 +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt*,int);
  1.1738 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt*,int);
  1.1739 +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt*,int);
  1.1740 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt*,int);
  1.1741 +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt*,int);
  1.1742 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt*,int);
  1.1743  
  1.1744  /*
  1.1745  ** CAPI3REF: Declared Datatype Of A Query Result
  1.1746 +** METHOD: sqlite3_stmt
  1.1747  **
  1.1748  ** ^(The first parameter is a [prepared statement].
  1.1749  ** If this statement is a [SELECT] statement and the Nth column of the
  1.1750 @@ -3727,11 +4008,12 @@
  1.1751  ** is associated with individual values, not with the containers
  1.1752  ** used to hold those values.
  1.1753  */
  1.1754 -SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
  1.1755 -SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
  1.1756 +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt*,int);
  1.1757 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt*,int);
  1.1758  
  1.1759  /*
  1.1760  ** CAPI3REF: Evaluate An SQL Statement
  1.1761 +** METHOD: sqlite3_stmt
  1.1762  **
  1.1763  ** After a [prepared statement] has been prepared using either
  1.1764  ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
  1.1765 @@ -3807,10 +4089,11 @@
  1.1766  ** then the more specific [error codes] are returned directly
  1.1767  ** by sqlite3_step().  The use of the "v2" interface is recommended.
  1.1768  */
  1.1769 -SQLITE_API int sqlite3_step(sqlite3_stmt*);
  1.1770 +SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt*);
  1.1771  
  1.1772  /*
  1.1773  ** CAPI3REF: Number of columns in a result set
  1.1774 +** METHOD: sqlite3_stmt
  1.1775  **
  1.1776  ** ^The sqlite3_data_count(P) interface returns the number of columns in the
  1.1777  ** current row of the result set of [prepared statement] P.
  1.1778 @@ -3827,7 +4110,7 @@
  1.1779  **
  1.1780  ** See also: [sqlite3_column_count()]
  1.1781  */
  1.1782 -SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
  1.1783 +SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt);
  1.1784  
  1.1785  /*
  1.1786  ** CAPI3REF: Fundamental Datatypes
  1.1787 @@ -3864,8 +4147,7 @@
  1.1788  /*
  1.1789  ** CAPI3REF: Result Values From A Query
  1.1790  ** KEYWORDS: {column access functions}
  1.1791 -**
  1.1792 -** These routines form the "result set" interface.
  1.1793 +** METHOD: sqlite3_stmt
  1.1794  **
  1.1795  ** ^These routines return information about a single column of the current
  1.1796  ** result row of a query.  ^In every case the first argument is a pointer
  1.1797 @@ -3926,13 +4208,14 @@
  1.1798  ** even empty strings, are always zero-terminated.  ^The return
  1.1799  ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
  1.1800  **
  1.1801 -** ^The object returned by [sqlite3_column_value()] is an
  1.1802 -** [unprotected sqlite3_value] object.  An unprotected sqlite3_value object
  1.1803 -** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
  1.1804 +** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
  1.1805 +** [unprotected sqlite3_value] object.  In a multithreaded environment,
  1.1806 +** an unprotected sqlite3_value object may only be used safely with
  1.1807 +** [sqlite3_bind_value()] and [sqlite3_result_value()].
  1.1808  ** If the [unprotected sqlite3_value] object returned by
  1.1809  ** [sqlite3_column_value()] is used in any other way, including calls
  1.1810  ** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
  1.1811 -** or [sqlite3_value_bytes()], then the behavior is undefined.
  1.1812 +** or [sqlite3_value_bytes()], the behavior is not threadsafe.
  1.1813  **
  1.1814  ** These routines attempt to convert the value where appropriate.  ^For
  1.1815  ** example, if the internal representation is FLOAT and a text result
  1.1816 @@ -3963,12 +4246,6 @@
  1.1817  ** </table>
  1.1818  ** </blockquote>)^
  1.1819  **
  1.1820 -** The table above makes reference to standard C library functions atoi()
  1.1821 -** and atof().  SQLite does not really use these functions.  It has its
  1.1822 -** own equivalent internal routines.  The atoi() and atof() names are
  1.1823 -** used in the table for brevity and because they are familiar to most
  1.1824 -** C programmers.
  1.1825 -**
  1.1826  ** Note that when type conversions occur, pointers returned by prior
  1.1827  ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
  1.1828  ** sqlite3_column_text16() may be invalidated.
  1.1829 @@ -3993,7 +4270,7 @@
  1.1830  ** of conversion are done in place when it is possible, but sometimes they
  1.1831  ** are not possible and in those cases prior pointers are invalidated.
  1.1832  **
  1.1833 -** The safest and easiest to remember policy is to invoke these routines
  1.1834 +** The safest policy is to invoke these routines
  1.1835  ** in one of the following ways:
  1.1836  **
  1.1837  ** <ul>
  1.1838 @@ -4013,7 +4290,7 @@
  1.1839  ** ^The pointers returned are valid until a type conversion occurs as
  1.1840  ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
  1.1841  ** [sqlite3_finalize()] is called.  ^The memory space used to hold strings
  1.1842 -** and BLOBs is freed automatically.  Do <b>not</b> pass the pointers returned
  1.1843 +** and BLOBs is freed automatically.  Do <em>not</em> pass the pointers returned
  1.1844  ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
  1.1845  ** [sqlite3_free()].
  1.1846  **
  1.1847 @@ -4023,19 +4300,20 @@
  1.1848  ** pointer.  Subsequent calls to [sqlite3_errcode()] will return
  1.1849  ** [SQLITE_NOMEM].)^
  1.1850  */
  1.1851 -SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
  1.1852 -SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
  1.1853 -SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
  1.1854 -SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
  1.1855 -SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
  1.1856 -SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
  1.1857 -SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
  1.1858 -SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
  1.1859 -SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
  1.1860 -SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
  1.1861 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt*, int iCol);
  1.1862 +SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt*, int iCol);
  1.1863 +SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
  1.1864 +SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt*, int iCol);
  1.1865 +SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt*, int iCol);
  1.1866 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt*, int iCol);
  1.1867 +SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt*, int iCol);
  1.1868 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt*, int iCol);
  1.1869 +SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt*, int iCol);
  1.1870 +SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt*, int iCol);
  1.1871  
  1.1872  /*
  1.1873  ** CAPI3REF: Destroy A Prepared Statement Object
  1.1874 +** DESTRUCTOR: sqlite3_stmt
  1.1875  **
  1.1876  ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
  1.1877  ** ^If the most recent evaluation of the statement encountered no errors
  1.1878 @@ -4059,10 +4337,11 @@
  1.1879  ** statement after it has been finalized can result in undefined and
  1.1880  ** undesirable behavior such as segfaults and heap corruption.
  1.1881  */
  1.1882 -SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
  1.1883 +SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt);
  1.1884  
  1.1885  /*
  1.1886  ** CAPI3REF: Reset A Prepared Statement Object
  1.1887 +** METHOD: sqlite3_stmt
  1.1888  **
  1.1889  ** The sqlite3_reset() function is called to reset a [prepared statement]
  1.1890  ** object back to its initial state, ready to be re-executed.
  1.1891 @@ -4085,13 +4364,14 @@
  1.1892  ** ^The [sqlite3_reset(S)] interface does not change the values
  1.1893  ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
  1.1894  */
  1.1895 -SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
  1.1896 +SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt);
  1.1897  
  1.1898  /*
  1.1899  ** CAPI3REF: Create Or Redefine SQL Functions
  1.1900  ** KEYWORDS: {function creation routines}
  1.1901  ** KEYWORDS: {application-defined SQL function}
  1.1902  ** KEYWORDS: {application-defined SQL functions}
  1.1903 +** METHOD: sqlite3
  1.1904  **
  1.1905  ** ^These functions (collectively known as "function creation routines")
  1.1906  ** are used to add SQL functions or aggregates or to redefine the behavior
  1.1907 @@ -4184,7 +4464,7 @@
  1.1908  ** close the database connection nor finalize or reset the prepared
  1.1909  ** statement in which the function is running.
  1.1910  */
  1.1911 -SQLITE_API int sqlite3_create_function(
  1.1912 +SQLITE_API int SQLITE_STDCALL sqlite3_create_function(
  1.1913    sqlite3 *db,
  1.1914    const char *zFunctionName,
  1.1915    int nArg,
  1.1916 @@ -4194,7 +4474,7 @@
  1.1917    void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  1.1918    void (*xFinal)(sqlite3_context*)
  1.1919  );
  1.1920 -SQLITE_API int sqlite3_create_function16(
  1.1921 +SQLITE_API int SQLITE_STDCALL sqlite3_create_function16(
  1.1922    sqlite3 *db,
  1.1923    const void *zFunctionName,
  1.1924    int nArg,
  1.1925 @@ -4204,7 +4484,7 @@
  1.1926    void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  1.1927    void (*xFinal)(sqlite3_context*)
  1.1928  );
  1.1929 -SQLITE_API int sqlite3_create_function_v2(
  1.1930 +SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2(
  1.1931    sqlite3 *db,
  1.1932    const char *zFunctionName,
  1.1933    int nArg,
  1.1934 @@ -4222,9 +4502,9 @@
  1.1935  ** These constant define integer codes that represent the various
  1.1936  ** text encodings supported by SQLite.
  1.1937  */
  1.1938 -#define SQLITE_UTF8           1
  1.1939 -#define SQLITE_UTF16LE        2
  1.1940 -#define SQLITE_UTF16BE        3
  1.1941 +#define SQLITE_UTF8           1    /* IMP: R-37514-35566 */
  1.1942 +#define SQLITE_UTF16LE        2    /* IMP: R-03371-37637 */
  1.1943 +#define SQLITE_UTF16BE        3    /* IMP: R-51971-34154 */
  1.1944  #define SQLITE_UTF16          4    /* Use native byte order */
  1.1945  #define SQLITE_ANY            5    /* Deprecated */
  1.1946  #define SQLITE_UTF16_ALIGNED  8    /* sqlite3_create_collation only */
  1.1947 @@ -4246,25 +4526,26 @@
  1.1948  ** These functions are [deprecated].  In order to maintain
  1.1949  ** backwards compatibility with older code, these functions continue 
  1.1950  ** to be supported.  However, new applications should avoid
  1.1951 -** the use of these functions.  To help encourage people to avoid
  1.1952 -** using these functions, we are not going to tell you what they do.
  1.1953 +** the use of these functions.  To encourage programmers to avoid
  1.1954 +** these functions, we will not explain what they do.
  1.1955  */
  1.1956  #ifndef SQLITE_OMIT_DEPRECATED
  1.1957 -SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
  1.1958 -SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
  1.1959 -SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
  1.1960 -SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
  1.1961 -SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
  1.1962 -SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
  1.1963 +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context*);
  1.1964 +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt*);
  1.1965 +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
  1.1966 +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_global_recover(void);
  1.1967 +SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_thread_cleanup(void);
  1.1968 +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
  1.1969                        void*,sqlite3_int64);
  1.1970  #endif
  1.1971  
  1.1972  /*
  1.1973 -** CAPI3REF: Obtaining SQL Function Parameter Values
  1.1974 +** CAPI3REF: Obtaining SQL Values
  1.1975 +** METHOD: sqlite3_value
  1.1976  **
  1.1977  ** The C-language implementation of SQL functions and aggregates uses
  1.1978  ** this set of interface routines to access the parameter values on
  1.1979 -** the function or aggregate.
  1.1980 +** the function or aggregate.  
  1.1981  **
  1.1982  ** The xFunc (for scalar functions) or xStep (for aggregates) parameters
  1.1983  ** to [sqlite3_create_function()] and [sqlite3_create_function16()]
  1.1984 @@ -4279,7 +4560,7 @@
  1.1985  ** object results in undefined behavior.
  1.1986  **
  1.1987  ** ^These routines work just like the corresponding [column access functions]
  1.1988 -** except that  these routines take a single [protected sqlite3_value] object
  1.1989 +** except that these routines take a single [protected sqlite3_value] object
  1.1990  ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
  1.1991  **
  1.1992  ** ^The sqlite3_value_text16() interface extracts a UTF-16 string
  1.1993 @@ -4304,21 +4585,55 @@
  1.1994  ** These routines must be called from the same thread as
  1.1995  ** the SQL function that supplied the [sqlite3_value*] parameters.
  1.1996  */
  1.1997 -SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
  1.1998 -SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
  1.1999 -SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
  1.2000 -SQLITE_API double sqlite3_value_double(sqlite3_value*);
  1.2001 -SQLITE_API int sqlite3_value_int(sqlite3_value*);
  1.2002 -SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
  1.2003 -SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
  1.2004 -SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
  1.2005 -SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
  1.2006 -SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
  1.2007 -SQLITE_API int sqlite3_value_type(sqlite3_value*);
  1.2008 -SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
  1.2009 +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value*);
  1.2010 +SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value*);
  1.2011 +SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value*);
  1.2012 +SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value*);
  1.2013 +SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value*);
  1.2014 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value*);
  1.2015 +SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value*);
  1.2016 +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value*);
  1.2017 +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value*);
  1.2018 +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value*);
  1.2019 +SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value*);
  1.2020 +SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value*);
  1.2021 +
  1.2022 +/*
  1.2023 +** CAPI3REF: Finding The Subtype Of SQL Values
  1.2024 +** METHOD: sqlite3_value
  1.2025 +**
  1.2026 +** The sqlite3_value_subtype(V) function returns the subtype for
  1.2027 +** an [application-defined SQL function] argument V.  The subtype
  1.2028 +** information can be used to pass a limited amount of context from
  1.2029 +** one SQL function to another.  Use the [sqlite3_result_subtype()]
  1.2030 +** routine to set the subtype for the return value of an SQL function.
  1.2031 +**
  1.2032 +** SQLite makes no use of subtype itself.  It merely passes the subtype
  1.2033 +** from the result of one [application-defined SQL function] into the
  1.2034 +** input of another.
  1.2035 +*/
  1.2036 +SQLITE_API unsigned int SQLITE_STDCALL sqlite3_value_subtype(sqlite3_value*);
  1.2037 +
  1.2038 +/*
  1.2039 +** CAPI3REF: Copy And Free SQL Values
  1.2040 +** METHOD: sqlite3_value
  1.2041 +**
  1.2042 +** ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value]
  1.2043 +** object D and returns a pointer to that copy.  ^The [sqlite3_value] returned
  1.2044 +** is a [protected sqlite3_value] object even if the input is not.
  1.2045 +** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a
  1.2046 +** memory allocation fails.
  1.2047 +**
  1.2048 +** ^The sqlite3_value_free(V) interface frees an [sqlite3_value] object
  1.2049 +** previously obtained from [sqlite3_value_dup()].  ^If V is a NULL pointer
  1.2050 +** then sqlite3_value_free(V) is a harmless no-op.
  1.2051 +*/
  1.2052 +SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_value_dup(const sqlite3_value*);
  1.2053 +SQLITE_API void SQLITE_STDCALL sqlite3_value_free(sqlite3_value*);
  1.2054  
  1.2055  /*
  1.2056  ** CAPI3REF: Obtain Aggregate Function Context
  1.2057 +** METHOD: sqlite3_context
  1.2058  **
  1.2059  ** Implementations of aggregate SQL functions use this
  1.2060  ** routine to allocate memory for storing their state.
  1.2061 @@ -4359,10 +4674,11 @@
  1.2062  ** This routine must be called from the same thread in which
  1.2063  ** the aggregate SQL function is running.
  1.2064  */
  1.2065 -SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
  1.2066 +SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context*, int nBytes);
  1.2067  
  1.2068  /*
  1.2069  ** CAPI3REF: User Data For Functions
  1.2070 +** METHOD: sqlite3_context
  1.2071  **
  1.2072  ** ^The sqlite3_user_data() interface returns a copy of
  1.2073  ** the pointer that was the pUserData parameter (the 5th parameter)
  1.2074 @@ -4373,10 +4689,11 @@
  1.2075  ** This routine must be called from the same thread in which
  1.2076  ** the application-defined function is running.
  1.2077  */
  1.2078 -SQLITE_API void *sqlite3_user_data(sqlite3_context*);
  1.2079 +SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context*);
  1.2080  
  1.2081  /*
  1.2082  ** CAPI3REF: Database Connection For Functions
  1.2083 +** METHOD: sqlite3_context
  1.2084  **
  1.2085  ** ^The sqlite3_context_db_handle() interface returns a copy of
  1.2086  ** the pointer to the [database connection] (the 1st parameter)
  1.2087 @@ -4384,10 +4701,11 @@
  1.2088  ** and [sqlite3_create_function16()] routines that originally
  1.2089  ** registered the application defined function.
  1.2090  */
  1.2091 -SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
  1.2092 +SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context*);
  1.2093  
  1.2094  /*
  1.2095  ** CAPI3REF: Function Auxiliary Data
  1.2096 +** METHOD: sqlite3_context
  1.2097  **
  1.2098  ** These functions may be used by (non-aggregate) SQL functions to
  1.2099  ** associate metadata with argument values. If the same value is passed to
  1.2100 @@ -4436,8 +4754,8 @@
  1.2101  ** These routines must be called from the same thread in which
  1.2102  ** the SQL function is running.
  1.2103  */
  1.2104 -SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
  1.2105 -SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
  1.2106 +SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context*, int N);
  1.2107 +SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
  1.2108  
  1.2109  
  1.2110  /*
  1.2111 @@ -4460,6 +4778,7 @@
  1.2112  
  1.2113  /*
  1.2114  ** CAPI3REF: Setting The Result Of An SQL Function
  1.2115 +** METHOD: sqlite3_context
  1.2116  **
  1.2117  ** These routines are used by the xFunc or xFinal callbacks that
  1.2118  ** implement SQL functions and aggregates.  See
  1.2119 @@ -4475,9 +4794,9 @@
  1.2120  ** to by the second parameter and which is N bytes long where N is the
  1.2121  ** third parameter.
  1.2122  **
  1.2123 -** ^The sqlite3_result_zeroblob() interfaces set the result of
  1.2124 -** the application-defined function to be a BLOB containing all zero
  1.2125 -** bytes and N bytes in size, where N is the value of the 2nd parameter.
  1.2126 +** ^The sqlite3_result_zeroblob(C,N) and sqlite3_result_zeroblob64(C,N)
  1.2127 +** interfaces set the result of the application-defined function to be
  1.2128 +** a BLOB containing all zero bytes and N bytes in size.
  1.2129  **
  1.2130  ** ^The sqlite3_result_double() interface sets the result from
  1.2131  ** an application-defined function to be a floating point value specified
  1.2132 @@ -4526,6 +4845,10 @@
  1.2133  ** set the return value of the application-defined function to be
  1.2134  ** a text string which is represented as UTF-8, UTF-16 native byte order,
  1.2135  ** UTF-16 little endian, or UTF-16 big endian, respectively.
  1.2136 +** ^The sqlite3_result_text64() interface sets the return value of an
  1.2137 +** application-defined function to be a text string in an encoding
  1.2138 +** specified by the fifth (and last) parameter, which must be one
  1.2139 +** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].
  1.2140  ** ^SQLite takes the text result from the application from
  1.2141  ** the 2nd parameter of the sqlite3_result_text* interfaces.
  1.2142  ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
  1.2143 @@ -4555,7 +4878,7 @@
  1.2144  ** from [sqlite3_malloc()] before it returns.
  1.2145  **
  1.2146  ** ^The sqlite3_result_value() interface sets the result of
  1.2147 -** the application-defined function to be a copy the
  1.2148 +** the application-defined function to be a copy of the
  1.2149  ** [unprotected sqlite3_value] object specified by the 2nd parameter.  ^The
  1.2150  ** sqlite3_result_value() interface makes a copy of the [sqlite3_value]
  1.2151  ** so that the [sqlite3_value] specified in the parameter may change or
  1.2152 @@ -4568,25 +4891,46 @@
  1.2153  ** than the one containing the application-defined function that received
  1.2154  ** the [sqlite3_context] pointer, the results are undefined.
  1.2155  */
  1.2156 -SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
  1.2157 -SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
  1.2158 -SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
  1.2159 -SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
  1.2160 -SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);
  1.2161 -SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);
  1.2162 -SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);
  1.2163 -SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
  1.2164 -SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
  1.2165 -SQLITE_API void sqlite3_result_null(sqlite3_context*);
  1.2166 -SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
  1.2167 -SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
  1.2168 -SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
  1.2169 -SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
  1.2170 -SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
  1.2171 -SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
  1.2172 +SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
  1.2173 +SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(sqlite3_context*,const void*,
  1.2174 +                           sqlite3_uint64,void(*)(void*));
  1.2175 +SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context*, double);
  1.2176 +SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context*, const char*, int);
  1.2177 +SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context*, const void*, int);
  1.2178 +SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context*);
  1.2179 +SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context*);
  1.2180 +SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context*, int);
  1.2181 +SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context*, int);
  1.2182 +SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
  1.2183 +SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context*);
  1.2184 +SQLITE_API void SQLITE_STDCALL sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
  1.2185 +SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
  1.2186 +                           void(*)(void*), unsigned char encoding);
  1.2187 +SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
  1.2188 +SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
  1.2189 +SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
  1.2190 +SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context*, sqlite3_value*);
  1.2191 +SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context*, int n);
  1.2192 +SQLITE_API int SQLITE_STDCALL sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
  1.2193 +
  1.2194 +
  1.2195 +/*
  1.2196 +** CAPI3REF: Setting The Subtype Of An SQL Function
  1.2197 +** METHOD: sqlite3_context
  1.2198 +**
  1.2199 +** The sqlite3_result_subtype(C,T) function causes the subtype of
  1.2200 +** the result from the [application-defined SQL function] with 
  1.2201 +** [sqlite3_context] C to be the value T.  Only the lower 8 bits 
  1.2202 +** of the subtype T are preserved in current versions of SQLite;
  1.2203 +** higher order bits are discarded.
  1.2204 +** The number of subtype bytes preserved by SQLite might increase
  1.2205 +** in future releases of SQLite.
  1.2206 +*/
  1.2207 +SQLITE_API void SQLITE_STDCALL sqlite3_result_subtype(sqlite3_context*,unsigned int);
  1.2208  
  1.2209  /*
  1.2210  ** CAPI3REF: Define New Collating Sequences
  1.2211 +** METHOD: sqlite3
  1.2212  **
  1.2213  ** ^These functions add, remove, or modify a [collation] associated
  1.2214  ** with the [database connection] specified as the first argument.
  1.2215 @@ -4664,14 +5008,14 @@
  1.2216  **
  1.2217  ** See also:  [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
  1.2218  */
  1.2219 -SQLITE_API int sqlite3_create_collation(
  1.2220 +SQLITE_API int SQLITE_STDCALL sqlite3_create_collation(
  1.2221    sqlite3*, 
  1.2222    const char *zName, 
  1.2223    int eTextRep, 
  1.2224    void *pArg,
  1.2225    int(*xCompare)(void*,int,const void*,int,const void*)
  1.2226  );
  1.2227 -SQLITE_API int sqlite3_create_collation_v2(
  1.2228 +SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2(
  1.2229    sqlite3*, 
  1.2230    const char *zName, 
  1.2231    int eTextRep, 
  1.2232 @@ -4679,7 +5023,7 @@
  1.2233    int(*xCompare)(void*,int,const void*,int,const void*),
  1.2234    void(*xDestroy)(void*)
  1.2235  );
  1.2236 -SQLITE_API int sqlite3_create_collation16(
  1.2237 +SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16(
  1.2238    sqlite3*, 
  1.2239    const void *zName,
  1.2240    int eTextRep, 
  1.2241 @@ -4689,6 +5033,7 @@
  1.2242  
  1.2243  /*
  1.2244  ** CAPI3REF: Collation Needed Callbacks
  1.2245 +** METHOD: sqlite3
  1.2246  **
  1.2247  ** ^To avoid having to register all collation sequences before a database
  1.2248  ** can be used, a single callback function may be registered with the
  1.2249 @@ -4713,12 +5058,12 @@
  1.2250  ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
  1.2251  ** [sqlite3_create_collation_v2()].
  1.2252  */
  1.2253 -SQLITE_API int sqlite3_collation_needed(
  1.2254 +SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed(
  1.2255    sqlite3*, 
  1.2256    void*, 
  1.2257    void(*)(void*,sqlite3*,int eTextRep,const char*)
  1.2258  );
  1.2259 -SQLITE_API int sqlite3_collation_needed16(
  1.2260 +SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16(
  1.2261    sqlite3*, 
  1.2262    void*,
  1.2263    void(*)(void*,sqlite3*,int eTextRep,const void*)
  1.2264 @@ -4732,11 +5077,11 @@
  1.2265  ** The code to implement this API is not available in the public release
  1.2266  ** of SQLite.
  1.2267  */
  1.2268 -SQLITE_API int sqlite3_key(
  1.2269 +SQLITE_API int SQLITE_STDCALL sqlite3_key(
  1.2270    sqlite3 *db,                   /* Database to be rekeyed */
  1.2271    const void *pKey, int nKey     /* The key */
  1.2272  );
  1.2273 -SQLITE_API int sqlite3_key_v2(
  1.2274 +SQLITE_API int SQLITE_STDCALL sqlite3_key_v2(
  1.2275    sqlite3 *db,                   /* Database to be rekeyed */
  1.2276    const char *zDbName,           /* Name of the database */
  1.2277    const void *pKey, int nKey     /* The key */
  1.2278 @@ -4750,11 +5095,11 @@
  1.2279  ** The code to implement this API is not available in the public release
  1.2280  ** of SQLite.
  1.2281  */
  1.2282 -SQLITE_API int sqlite3_rekey(
  1.2283 +SQLITE_API int SQLITE_STDCALL sqlite3_rekey(
  1.2284    sqlite3 *db,                   /* Database to be rekeyed */
  1.2285    const void *pKey, int nKey     /* The new key */
  1.2286  );
  1.2287 -SQLITE_API int sqlite3_rekey_v2(
  1.2288 +SQLITE_API int SQLITE_STDCALL sqlite3_rekey_v2(
  1.2289    sqlite3 *db,                   /* Database to be rekeyed */
  1.2290    const char *zDbName,           /* Name of the database */
  1.2291    const void *pKey, int nKey     /* The new key */
  1.2292 @@ -4764,7 +5109,7 @@
  1.2293  ** Specify the activation key for a SEE database.  Unless 
  1.2294  ** activated, none of the SEE routines will work.
  1.2295  */
  1.2296 -SQLITE_API void sqlite3_activate_see(
  1.2297 +SQLITE_API void SQLITE_STDCALL sqlite3_activate_see(
  1.2298    const char *zPassPhrase        /* Activation phrase */
  1.2299  );
  1.2300  #endif
  1.2301 @@ -4774,7 +5119,7 @@
  1.2302  ** Specify the activation key for a CEROD database.  Unless 
  1.2303  ** activated, none of the CEROD routines will work.
  1.2304  */
  1.2305 -SQLITE_API void sqlite3_activate_cerod(
  1.2306 +SQLITE_API void SQLITE_STDCALL sqlite3_activate_cerod(
  1.2307    const char *zPassPhrase        /* Activation phrase */
  1.2308  );
  1.2309  #endif
  1.2310 @@ -4796,7 +5141,7 @@
  1.2311  ** all, then the behavior of sqlite3_sleep() may deviate from the description
  1.2312  ** in the previous paragraphs.
  1.2313  */
  1.2314 -SQLITE_API int sqlite3_sleep(int);
  1.2315 +SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int);
  1.2316  
  1.2317  /*
  1.2318  ** CAPI3REF: Name Of The Folder Holding Temporary Files
  1.2319 @@ -4896,6 +5241,7 @@
  1.2320  /*
  1.2321  ** CAPI3REF: Test For Auto-Commit Mode
  1.2322  ** KEYWORDS: {autocommit mode}
  1.2323 +** METHOD: sqlite3
  1.2324  **
  1.2325  ** ^The sqlite3_get_autocommit() interface returns non-zero or
  1.2326  ** zero if the given database connection is or is not in autocommit mode,
  1.2327 @@ -4914,10 +5260,11 @@
  1.2328  ** connection while this routine is running, then the return value
  1.2329  ** is undefined.
  1.2330  */
  1.2331 -SQLITE_API int sqlite3_get_autocommit(sqlite3*);
  1.2332 +SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3*);
  1.2333  
  1.2334  /*
  1.2335  ** CAPI3REF: Find The Database Handle Of A Prepared Statement
  1.2336 +** METHOD: sqlite3_stmt
  1.2337  **
  1.2338  ** ^The sqlite3_db_handle interface returns the [database connection] handle
  1.2339  ** to which a [prepared statement] belongs.  ^The [database connection]
  1.2340 @@ -4926,10 +5273,11 @@
  1.2341  ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
  1.2342  ** create the statement in the first place.
  1.2343  */
  1.2344 -SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
  1.2345 +SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt*);
  1.2346  
  1.2347  /*
  1.2348  ** CAPI3REF: Return The Filename For A Database Connection
  1.2349 +** METHOD: sqlite3
  1.2350  **
  1.2351  ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
  1.2352  ** associated with database N of connection D.  ^The main database file
  1.2353 @@ -4942,19 +5290,21 @@
  1.2354  ** will be an absolute pathname, even if the filename used
  1.2355  ** to open the database originally was a URI or relative pathname.
  1.2356  */
  1.2357 -SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
  1.2358 +SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName);
  1.2359  
  1.2360  /*
  1.2361  ** CAPI3REF: Determine if a database is read-only
  1.2362 +** METHOD: sqlite3
  1.2363  **
  1.2364  ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
  1.2365  ** of connection D is read-only, 0 if it is read/write, or -1 if N is not
  1.2366  ** the name of a database on connection D.
  1.2367  */
  1.2368 -SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
  1.2369 +SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
  1.2370  
  1.2371  /*
  1.2372  ** CAPI3REF: Find the next prepared statement
  1.2373 +** METHOD: sqlite3
  1.2374  **
  1.2375  ** ^This interface returns a pointer to the next [prepared statement] after
  1.2376  ** pStmt associated with the [database connection] pDb.  ^If pStmt is NULL
  1.2377 @@ -4966,10 +5316,11 @@
  1.2378  ** [sqlite3_next_stmt(D,S)] must refer to an open database
  1.2379  ** connection and in particular must not be a NULL pointer.
  1.2380  */
  1.2381 -SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
  1.2382 +SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
  1.2383  
  1.2384  /*
  1.2385  ** CAPI3REF: Commit And Rollback Notification Callbacks
  1.2386 +** METHOD: sqlite3
  1.2387  **
  1.2388  ** ^The sqlite3_commit_hook() interface registers a callback
  1.2389  ** function to be invoked whenever a transaction is [COMMIT | committed].
  1.2390 @@ -5014,11 +5365,12 @@
  1.2391  **
  1.2392  ** See also the [sqlite3_update_hook()] interface.
  1.2393  */
  1.2394 -SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
  1.2395 -SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
  1.2396 +SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
  1.2397 +SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
  1.2398  
  1.2399  /*
  1.2400  ** CAPI3REF: Data Change Notification Callbacks
  1.2401 +** METHOD: sqlite3
  1.2402  **
  1.2403  ** ^The sqlite3_update_hook() interface registers a callback function
  1.2404  ** with the [database connection] identified by the first argument
  1.2405 @@ -5065,7 +5417,7 @@
  1.2406  ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
  1.2407  ** interfaces.
  1.2408  */
  1.2409 -SQLITE_API void *sqlite3_update_hook(
  1.2410 +SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
  1.2411    sqlite3*, 
  1.2412    void(*)(void *,int ,char const *,char const *,sqlite3_int64),
  1.2413    void*
  1.2414 @@ -5095,12 +5447,17 @@
  1.2415  ** future releases of SQLite.  Applications that care about shared
  1.2416  ** cache setting should set it explicitly.
  1.2417  **
  1.2418 +** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0
  1.2419 +** and will always return SQLITE_MISUSE. On those systems, 
  1.2420 +** shared cache mode should be enabled per-database connection via 
  1.2421 +** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE].
  1.2422 +**
  1.2423  ** This interface is threadsafe on processors where writing a
  1.2424  ** 32-bit integer is atomic.
  1.2425  **
  1.2426  ** See Also:  [SQLite Shared-Cache Mode]
  1.2427  */
  1.2428 -SQLITE_API int sqlite3_enable_shared_cache(int);
  1.2429 +SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int);
  1.2430  
  1.2431  /*
  1.2432  ** CAPI3REF: Attempt To Free Heap Memory
  1.2433 @@ -5116,10 +5473,11 @@
  1.2434  **
  1.2435  ** See also: [sqlite3_db_release_memory()]
  1.2436  */
  1.2437 -SQLITE_API int sqlite3_release_memory(int);
  1.2438 +SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int);
  1.2439  
  1.2440  /*
  1.2441  ** CAPI3REF: Free Memory Used By A Database Connection
  1.2442 +** METHOD: sqlite3
  1.2443  **
  1.2444  ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
  1.2445  ** memory as possible from database connection D. Unlike the
  1.2446 @@ -5129,7 +5487,7 @@
  1.2447  **
  1.2448  ** See also: [sqlite3_release_memory()]
  1.2449  */
  1.2450 -SQLITE_API int sqlite3_db_release_memory(sqlite3*);
  1.2451 +SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3*);
  1.2452  
  1.2453  /*
  1.2454  ** CAPI3REF: Impose A Limit On Heap Size
  1.2455 @@ -5181,7 +5539,7 @@
  1.2456  ** The circumstances under which SQLite will enforce the soft heap limit may
  1.2457  ** changes in future releases of SQLite.
  1.2458  */
  1.2459 -SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
  1.2460 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 N);
  1.2461  
  1.2462  /*
  1.2463  ** CAPI3REF: Deprecated Soft Heap Limit Interface
  1.2464 @@ -5192,26 +5550,34 @@
  1.2465  ** only.  All new applications should use the
  1.2466  ** [sqlite3_soft_heap_limit64()] interface rather than this one.
  1.2467  */
  1.2468 -SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
  1.2469 +SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_soft_heap_limit(int N);
  1.2470  
  1.2471  
  1.2472  /*
  1.2473  ** CAPI3REF: Extract Metadata About A Column Of A Table
  1.2474 -**
  1.2475 -** ^This routine returns metadata about a specific column of a specific
  1.2476 -** database table accessible using the [database connection] handle
  1.2477 -** passed as the first function argument.
  1.2478 +** METHOD: sqlite3
  1.2479 +**
  1.2480 +** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
  1.2481 +** information about column C of table T in database D
  1.2482 +** on [database connection] X.)^  ^The sqlite3_table_column_metadata()
  1.2483 +** interface returns SQLITE_OK and fills in the non-NULL pointers in
  1.2484 +** the final five arguments with appropriate values if the specified
  1.2485 +** column exists.  ^The sqlite3_table_column_metadata() interface returns
  1.2486 +** SQLITE_ERROR and if the specified column does not exist.
  1.2487 +** ^If the column-name parameter to sqlite3_table_column_metadata() is a
  1.2488 +** NULL pointer, then this routine simply checks for the existance of the
  1.2489 +** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
  1.2490 +** does not.
  1.2491  **
  1.2492  ** ^The column is identified by the second, third and fourth parameters to
  1.2493 -** this function. ^The second parameter is either the name of the database
  1.2494 +** this function. ^(The second parameter is either the name of the database
  1.2495  ** (i.e. "main", "temp", or an attached database) containing the specified
  1.2496 -** table or NULL. ^If it is NULL, then all attached databases are searched
  1.2497 +** table or NULL.)^ ^If it is NULL, then all attached databases are searched
  1.2498  ** for the table using the same algorithm used by the database engine to
  1.2499  ** resolve unqualified table references.
  1.2500  **
  1.2501  ** ^The third and fourth parameters to this function are the table and column
  1.2502 -** name of the desired column, respectively. Neither of these parameters
  1.2503 -** may be NULL.
  1.2504 +** name of the desired column, respectively.
  1.2505  **
  1.2506  ** ^Metadata is returned by writing to the memory locations passed as the 5th
  1.2507  ** and subsequent parameters to this function. ^Any of these arguments may be
  1.2508 @@ -5230,16 +5596,17 @@
  1.2509  ** </blockquote>)^
  1.2510  **
  1.2511  ** ^The memory pointed to by the character pointers returned for the
  1.2512 -** declaration type and collation sequence is valid only until the next
  1.2513 +** declaration type and collation sequence is valid until the next
  1.2514  ** call to any SQLite API function.
  1.2515  **
  1.2516  ** ^If the specified table is actually a view, an [error code] is returned.
  1.2517  **
  1.2518 -** ^If the specified column is "rowid", "oid" or "_rowid_" and an
  1.2519 +** ^If the specified column is "rowid", "oid" or "_rowid_" and the table 
  1.2520 +** is not a [WITHOUT ROWID] table and an
  1.2521  ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
  1.2522  ** parameters are set for the explicitly declared column. ^(If there is no
  1.2523 -** explicitly declared [INTEGER PRIMARY KEY] column, then the output
  1.2524 -** parameters are set as follows:
  1.2525 +** [INTEGER PRIMARY KEY] column, then the outputs
  1.2526 +** for the [rowid] are set as follows:
  1.2527  **
  1.2528  ** <pre>
  1.2529  **     data type: "INTEGER"
  1.2530 @@ -5249,15 +5616,11 @@
  1.2531  **     auto increment: 0
  1.2532  ** </pre>)^
  1.2533  **
  1.2534 -** ^(This function may load one or more schemas from database files. If an
  1.2535 -** error occurs during this process, or if the requested table or column
  1.2536 -** cannot be found, an [error code] is returned and an error message left
  1.2537 -** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
  1.2538 -**
  1.2539 -** ^This API is only available if the library was compiled with the
  1.2540 -** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
  1.2541 -*/
  1.2542 -SQLITE_API int sqlite3_table_column_metadata(
  1.2543 +** ^This function causes all database schemas to be read from disk and
  1.2544 +** parsed, if that has not already been done, and returns an error if
  1.2545 +** any errors are encountered while loading the schema.
  1.2546 +*/
  1.2547 +SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
  1.2548    sqlite3 *db,                /* Connection handle */
  1.2549    const char *zDbName,        /* Database name or NULL */
  1.2550    const char *zTableName,     /* Table name */
  1.2551 @@ -5271,6 +5634,7 @@
  1.2552  
  1.2553  /*
  1.2554  ** CAPI3REF: Load An Extension
  1.2555 +** METHOD: sqlite3
  1.2556  **
  1.2557  ** ^This interface loads an SQLite extension library from the named file.
  1.2558  **
  1.2559 @@ -5303,7 +5667,7 @@
  1.2560  **
  1.2561  ** See also the [load_extension() SQL function].
  1.2562  */
  1.2563 -SQLITE_API int sqlite3_load_extension(
  1.2564 +SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
  1.2565    sqlite3 *db,          /* Load the extension into this database connection */
  1.2566    const char *zFile,    /* Name of the shared library containing extension */
  1.2567    const char *zProc,    /* Entry point.  Derived from zFile if 0 */
  1.2568 @@ -5312,6 +5676,7 @@
  1.2569  
  1.2570  /*
  1.2571  ** CAPI3REF: Enable Or Disable Extension Loading
  1.2572 +** METHOD: sqlite3
  1.2573  **
  1.2574  ** ^So as not to open security holes in older applications that are
  1.2575  ** unprepared to deal with [extension loading], and as a means of disabling
  1.2576 @@ -5323,7 +5688,7 @@
  1.2577  ** to turn extension loading on and call it with onoff==0 to turn
  1.2578  ** it back off again.
  1.2579  */
  1.2580 -SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
  1.2581 +SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff);
  1.2582  
  1.2583  /*
  1.2584  ** CAPI3REF: Automatically Load Statically Linked Extensions
  1.2585 @@ -5361,7 +5726,7 @@
  1.2586  ** See also: [sqlite3_reset_auto_extension()]
  1.2587  ** and [sqlite3_cancel_auto_extension()]
  1.2588  */
  1.2589 -SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
  1.2590 +SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
  1.2591  
  1.2592  /*
  1.2593  ** CAPI3REF: Cancel Automatic Extension Loading
  1.2594 @@ -5373,7 +5738,7 @@
  1.2595  ** unregistered and it returns 0 if X was not on the list of initialization
  1.2596  ** routines.
  1.2597  */
  1.2598 -SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
  1.2599 +SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
  1.2600  
  1.2601  /*
  1.2602  ** CAPI3REF: Reset Automatic Extension Loading
  1.2603 @@ -5381,7 +5746,7 @@
  1.2604  ** ^This interface disables all automatic extensions previously
  1.2605  ** registered using [sqlite3_auto_extension()].
  1.2606  */
  1.2607 -SQLITE_API void sqlite3_reset_auto_extension(void);
  1.2608 +SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void);
  1.2609  
  1.2610  /*
  1.2611  ** The interface to the virtual-table mechanism is currently considered
  1.2612 @@ -5483,6 +5848,17 @@
  1.2613  ** ^Information about the ORDER BY clause is stored in aOrderBy[].
  1.2614  ** ^Each term of aOrderBy records a column of the ORDER BY clause.
  1.2615  **
  1.2616 +** The colUsed field indicates which columns of the virtual table may be
  1.2617 +** required by the current scan. Virtual table columns are numbered from
  1.2618 +** zero in the order in which they appear within the CREATE TABLE statement
  1.2619 +** passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62),
  1.2620 +** the corresponding bit is set within the colUsed mask if the column may be
  1.2621 +** required by SQLite. If the table has at least 64 columns and any column
  1.2622 +** to the right of the first 63 is required, then bit 63 of colUsed is also
  1.2623 +** set. In other words, column iCol may be required if the expression
  1.2624 +** (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to 
  1.2625 +** non-zero.
  1.2626 +**
  1.2627  ** The [xBestIndex] method must fill aConstraintUsage[] with information
  1.2628  ** about what parameters to pass to xFilter.  ^If argvIndex>0 then
  1.2629  ** the right-hand side of the corresponding aConstraint[] is evaluated
  1.2630 @@ -5508,19 +5884,37 @@
  1.2631  ** ^The estimatedRows value is an estimate of the number of rows that
  1.2632  ** will be returned by the strategy.
  1.2633  **
  1.2634 +** The xBestIndex method may optionally populate the idxFlags field with a 
  1.2635 +** mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag -
  1.2636 +** SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite
  1.2637 +** assumes that the strategy may visit at most one row. 
  1.2638 +**
  1.2639 +** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then
  1.2640 +** SQLite also assumes that if a call to the xUpdate() method is made as
  1.2641 +** part of the same statement to delete or update a virtual table row and the
  1.2642 +** implementation returns SQLITE_CONSTRAINT, then there is no need to rollback
  1.2643 +** any database changes. In other words, if the xUpdate() returns
  1.2644 +** SQLITE_CONSTRAINT, the database contents must be exactly as they were
  1.2645 +** before xUpdate was called. By contrast, if SQLITE_INDEX_SCAN_UNIQUE is not
  1.2646 +** set and xUpdate returns SQLITE_CONSTRAINT, any database changes made by
  1.2647 +** the xUpdate method are automatically rolled back by SQLite.
  1.2648 +**
  1.2649  ** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info
  1.2650  ** structure for SQLite version 3.8.2. If a virtual table extension is
  1.2651  ** used with an SQLite version earlier than 3.8.2, the results of attempting 
  1.2652  ** to read or write the estimatedRows field are undefined (but are likely 
  1.2653  ** to included crashing the application). The estimatedRows field should
  1.2654  ** therefore only be used if [sqlite3_libversion_number()] returns a
  1.2655 -** value greater than or equal to 3008002.
  1.2656 +** value greater than or equal to 3008002. Similarly, the idxFlags field
  1.2657 +** was added for version 3.9.0. It may therefore only be used if
  1.2658 +** sqlite3_libversion_number() returns a value greater than or equal to
  1.2659 +** 3009000.
  1.2660  */
  1.2661  struct sqlite3_index_info {
  1.2662    /* Inputs */
  1.2663    int nConstraint;           /* Number of entries in aConstraint */
  1.2664    struct sqlite3_index_constraint {
  1.2665 -     int iColumn;              /* Column on left-hand side of constraint */
  1.2666 +     int iColumn;              /* Column constrained.  -1 for ROWID */
  1.2667       unsigned char op;         /* Constraint operator */
  1.2668       unsigned char usable;     /* True if this constraint is usable */
  1.2669       int iTermOffset;          /* Used internally - xBestIndex should ignore */
  1.2670 @@ -5542,7 +5936,16 @@
  1.2671    double estimatedCost;           /* Estimated cost of using this index */
  1.2672    /* Fields below are only available in SQLite 3.8.2 and later */
  1.2673    sqlite3_int64 estimatedRows;    /* Estimated number of rows returned */
  1.2674 -};
  1.2675 +  /* Fields below are only available in SQLite 3.9.0 and later */
  1.2676 +  int idxFlags;              /* Mask of SQLITE_INDEX_SCAN_* flags */
  1.2677 +  /* Fields below are only available in SQLite 3.10.0 and later */
  1.2678 +  sqlite3_uint64 colUsed;    /* Input: Mask of columns used by statement */
  1.2679 +};
  1.2680 +
  1.2681 +/*
  1.2682 +** CAPI3REF: Virtual Table Scan Flags
  1.2683 +*/
  1.2684 +#define SQLITE_INDEX_SCAN_UNIQUE      1     /* Scan visits at most 1 row */
  1.2685  
  1.2686  /*
  1.2687  ** CAPI3REF: Virtual Table Constraint Operator Codes
  1.2688 @@ -5552,15 +5955,19 @@
  1.2689  ** an operator that is part of a constraint term in the wHERE clause of
  1.2690  ** a query that uses a [virtual table].
  1.2691  */
  1.2692 -#define SQLITE_INDEX_CONSTRAINT_EQ    2
  1.2693 -#define SQLITE_INDEX_CONSTRAINT_GT    4
  1.2694 -#define SQLITE_INDEX_CONSTRAINT_LE    8
  1.2695 -#define SQLITE_INDEX_CONSTRAINT_LT    16
  1.2696 -#define SQLITE_INDEX_CONSTRAINT_GE    32
  1.2697 -#define SQLITE_INDEX_CONSTRAINT_MATCH 64
  1.2698 +#define SQLITE_INDEX_CONSTRAINT_EQ      2
  1.2699 +#define SQLITE_INDEX_CONSTRAINT_GT      4
  1.2700 +#define SQLITE_INDEX_CONSTRAINT_LE      8
  1.2701 +#define SQLITE_INDEX_CONSTRAINT_LT     16
  1.2702 +#define SQLITE_INDEX_CONSTRAINT_GE     32
  1.2703 +#define SQLITE_INDEX_CONSTRAINT_MATCH  64
  1.2704 +#define SQLITE_INDEX_CONSTRAINT_LIKE   65
  1.2705 +#define SQLITE_INDEX_CONSTRAINT_GLOB   66
  1.2706 +#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
  1.2707  
  1.2708  /*
  1.2709  ** CAPI3REF: Register A Virtual Table Implementation
  1.2710 +** METHOD: sqlite3
  1.2711  **
  1.2712  ** ^These routines are used to register a new [virtual table module] name.
  1.2713  ** ^Module names must be registered before
  1.2714 @@ -5584,13 +5991,13 @@
  1.2715  ** interface is equivalent to sqlite3_create_module_v2() with a NULL
  1.2716  ** destructor.
  1.2717  */
  1.2718 -SQLITE_API int sqlite3_create_module(
  1.2719 +SQLITE_API int SQLITE_STDCALL sqlite3_create_module(
  1.2720    sqlite3 *db,               /* SQLite connection to register module with */
  1.2721    const char *zName,         /* Name of the module */
  1.2722    const sqlite3_module *p,   /* Methods for the module */
  1.2723    void *pClientData          /* Client data for xCreate/xConnect */
  1.2724  );
  1.2725 -SQLITE_API int sqlite3_create_module_v2(
  1.2726 +SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2(
  1.2727    sqlite3 *db,               /* SQLite connection to register module with */
  1.2728    const char *zName,         /* Name of the module */
  1.2729    const sqlite3_module *p,   /* Methods for the module */
  1.2730 @@ -5618,7 +6025,7 @@
  1.2731  */
  1.2732  struct sqlite3_vtab {
  1.2733    const sqlite3_module *pModule;  /* The module for this virtual table */
  1.2734 -  int nRef;                       /* NO LONGER USED */
  1.2735 +  int nRef;                       /* Number of open cursors */
  1.2736    char *zErrMsg;                  /* Error message from sqlite3_mprintf() */
  1.2737    /* Virtual table implementations will typically add additional fields */
  1.2738  };
  1.2739 @@ -5653,10 +6060,11 @@
  1.2740  ** to declare the format (the names and datatypes of the columns) of
  1.2741  ** the virtual tables they implement.
  1.2742  */
  1.2743 -SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
  1.2744 +SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3*, const char *zSQL);
  1.2745  
  1.2746  /*
  1.2747  ** CAPI3REF: Overload A Function For A Virtual Table
  1.2748 +** METHOD: sqlite3
  1.2749  **
  1.2750  ** ^(Virtual tables can provide alternative implementations of functions
  1.2751  ** using the [xFindFunction] method of the [virtual table module].  
  1.2752 @@ -5671,7 +6079,7 @@
  1.2753  ** purpose is to be a placeholder function that can be overloaded
  1.2754  ** by a [virtual table].
  1.2755  */
  1.2756 -SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
  1.2757 +SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
  1.2758  
  1.2759  /*
  1.2760  ** The interface to the virtual-table mechanism defined above (back up
  1.2761 @@ -5699,6 +6107,8 @@
  1.2762  
  1.2763  /*
  1.2764  ** CAPI3REF: Open A BLOB For Incremental I/O
  1.2765 +** METHOD: sqlite3
  1.2766 +** CONSTRUCTOR: sqlite3_blob
  1.2767  **
  1.2768  ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located
  1.2769  ** in row iRow, column zColumn, table zTable in database zDb;
  1.2770 @@ -5708,26 +6118,42 @@
  1.2771  **     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
  1.2772  ** </pre>)^
  1.2773  **
  1.2774 +** ^(Parameter zDb is not the filename that contains the database, but 
  1.2775 +** rather the symbolic name of the database. For attached databases, this is
  1.2776 +** the name that appears after the AS keyword in the [ATTACH] statement.
  1.2777 +** For the main database file, the database name is "main". For TEMP
  1.2778 +** tables, the database name is "temp".)^
  1.2779 +**
  1.2780  ** ^If the flags parameter is non-zero, then the BLOB is opened for read
  1.2781 -** and write access. ^If it is zero, the BLOB is opened for read access.
  1.2782 -** ^It is not possible to open a column that is part of an index or primary 
  1.2783 -** key for writing. ^If [foreign key constraints] are enabled, it is 
  1.2784 -** not possible to open a column that is part of a [child key] for writing.
  1.2785 -**
  1.2786 -** ^Note that the database name is not the filename that contains
  1.2787 -** the database but rather the symbolic name of the database that
  1.2788 -** appears after the AS keyword when the database is connected using [ATTACH].
  1.2789 -** ^For the main database file, the database name is "main".
  1.2790 -** ^For TEMP tables, the database name is "temp".
  1.2791 -**
  1.2792 -** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written
  1.2793 -** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set
  1.2794 -** to be a null pointer.)^
  1.2795 -** ^This function sets the [database connection] error code and message
  1.2796 -** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related
  1.2797 -** functions. ^Note that the *ppBlob variable is always initialized in a
  1.2798 -** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob
  1.2799 -** regardless of the success or failure of this routine.
  1.2800 +** and write access. ^If the flags parameter is zero, the BLOB is opened for
  1.2801 +** read-only access.
  1.2802 +**
  1.2803 +** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is stored
  1.2804 +** in *ppBlob. Otherwise an [error code] is returned and, unless the error
  1.2805 +** code is SQLITE_MISUSE, *ppBlob is set to NULL.)^ ^This means that, provided
  1.2806 +** the API is not misused, it is always safe to call [sqlite3_blob_close()] 
  1.2807 +** on *ppBlob after this function it returns.
  1.2808 +**
  1.2809 +** This function fails with SQLITE_ERROR if any of the following are true:
  1.2810 +** <ul>
  1.2811 +**   <li> ^(Database zDb does not exist)^, 
  1.2812 +**   <li> ^(Table zTable does not exist within database zDb)^, 
  1.2813 +**   <li> ^(Table zTable is a WITHOUT ROWID table)^, 
  1.2814 +**   <li> ^(Column zColumn does not exist)^,
  1.2815 +**   <li> ^(Row iRow is not present in the table)^,
  1.2816 +**   <li> ^(The specified column of row iRow contains a value that is not
  1.2817 +**         a TEXT or BLOB value)^,
  1.2818 +**   <li> ^(Column zColumn is part of an index, PRIMARY KEY or UNIQUE 
  1.2819 +**         constraint and the blob is being opened for read/write access)^,
  1.2820 +**   <li> ^([foreign key constraints | Foreign key constraints] are enabled, 
  1.2821 +**         column zColumn is part of a [child key] definition and the blob is
  1.2822 +**         being opened for read/write access)^.
  1.2823 +** </ul>
  1.2824 +**
  1.2825 +** ^Unless it returns SQLITE_MISUSE, this function sets the 
  1.2826 +** [database connection] error code and message accessible via 
  1.2827 +** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. 
  1.2828 +**
  1.2829  **
  1.2830  ** ^(If the row that a BLOB handle points to is modified by an
  1.2831  ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects
  1.2832 @@ -5745,18 +6171,14 @@
  1.2833  ** interface.  Use the [UPDATE] SQL command to change the size of a
  1.2834  ** blob.
  1.2835  **
  1.2836 -** ^The [sqlite3_blob_open()] interface will fail for a [WITHOUT ROWID]
  1.2837 -** table.  Incremental BLOB I/O is not possible on [WITHOUT ROWID] tables.
  1.2838 -**
  1.2839  ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
  1.2840 -** and the built-in [zeroblob] SQL function can be used, if desired,
  1.2841 -** to create an empty, zero-filled blob in which to read or write using
  1.2842 -** this interface.
  1.2843 +** and the built-in [zeroblob] SQL function may be used to create a 
  1.2844 +** zero-filled blob to read or write using the incremental-blob interface.
  1.2845  **
  1.2846  ** To avoid a resource leak, every open [BLOB handle] should eventually
  1.2847  ** be released by a call to [sqlite3_blob_close()].
  1.2848  */
  1.2849 -SQLITE_API int sqlite3_blob_open(
  1.2850 +SQLITE_API int SQLITE_STDCALL sqlite3_blob_open(
  1.2851    sqlite3*,
  1.2852    const char *zDb,
  1.2853    const char *zTable,
  1.2854 @@ -5768,6 +6190,7 @@
  1.2855  
  1.2856  /*
  1.2857  ** CAPI3REF: Move a BLOB Handle to a New Row
  1.2858 +** METHOD: sqlite3_blob
  1.2859  **
  1.2860  ** ^This function is used to move an existing blob handle so that it points
  1.2861  ** to a different row of the same database table. ^The new row is identified
  1.2862 @@ -5788,34 +6211,34 @@
  1.2863  **
  1.2864  ** ^This function sets the database handle error code and message.
  1.2865  */
  1.2866 -SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
  1.2867 +SQLITE_API int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
  1.2868  
  1.2869  /*
  1.2870  ** CAPI3REF: Close A BLOB Handle
  1.2871 -**
  1.2872 -** ^Closes an open [BLOB handle].
  1.2873 -**
  1.2874 -** ^Closing a BLOB shall cause the current transaction to commit
  1.2875 -** if there are no other BLOBs, no pending prepared statements, and the
  1.2876 -** database connection is in [autocommit mode].
  1.2877 -** ^If any writes were made to the BLOB, they might be held in cache
  1.2878 -** until the close operation if they will fit.
  1.2879 -**
  1.2880 -** ^(Closing the BLOB often forces the changes
  1.2881 -** out to disk and so if any I/O errors occur, they will likely occur
  1.2882 -** at the time when the BLOB is closed.  Any errors that occur during
  1.2883 -** closing are reported as a non-zero return value.)^
  1.2884 -**
  1.2885 -** ^(The BLOB is closed unconditionally.  Even if this routine returns
  1.2886 -** an error code, the BLOB is still closed.)^
  1.2887 -**
  1.2888 -** ^Calling this routine with a null pointer (such as would be returned
  1.2889 -** by a failed call to [sqlite3_blob_open()]) is a harmless no-op.
  1.2890 -*/
  1.2891 -SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
  1.2892 +** DESTRUCTOR: sqlite3_blob
  1.2893 +**
  1.2894 +** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed
  1.2895 +** unconditionally.  Even if this routine returns an error code, the 
  1.2896 +** handle is still closed.)^
  1.2897 +**
  1.2898 +** ^If the blob handle being closed was opened for read-write access, and if
  1.2899 +** the database is in auto-commit mode and there are no other open read-write
  1.2900 +** blob handles or active write statements, the current transaction is
  1.2901 +** committed. ^If an error occurs while committing the transaction, an error
  1.2902 +** code is returned and the transaction rolled back.
  1.2903 +**
  1.2904 +** Calling this function with an argument that is not a NULL pointer or an
  1.2905 +** open blob handle results in undefined behaviour. ^Calling this routine 
  1.2906 +** with a null pointer (such as would be returned by a failed call to 
  1.2907 +** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
  1.2908 +** is passed a valid open blob handle, the values returned by the 
  1.2909 +** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
  1.2910 +*/
  1.2911 +SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *);
  1.2912  
  1.2913  /*
  1.2914  ** CAPI3REF: Return The Size Of An Open BLOB
  1.2915 +** METHOD: sqlite3_blob
  1.2916  **
  1.2917  ** ^Returns the size in bytes of the BLOB accessible via the 
  1.2918  ** successfully opened [BLOB handle] in its only argument.  ^The
  1.2919 @@ -5827,10 +6250,11 @@
  1.2920  ** been closed by [sqlite3_blob_close()].  Passing any other pointer in
  1.2921  ** to this routine results in undefined and probably undesirable behavior.
  1.2922  */
  1.2923 -SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
  1.2924 +SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *);
  1.2925  
  1.2926  /*
  1.2927  ** CAPI3REF: Read Data From A BLOB Incrementally
  1.2928 +** METHOD: sqlite3_blob
  1.2929  **
  1.2930  ** ^(This function is used to read data from an open [BLOB handle] into a
  1.2931  ** caller-supplied buffer. N bytes of data are copied into buffer Z
  1.2932 @@ -5855,26 +6279,33 @@
  1.2933  **
  1.2934  ** See also: [sqlite3_blob_write()].
  1.2935  */
  1.2936 -SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
  1.2937 +SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
  1.2938  
  1.2939  /*
  1.2940  ** CAPI3REF: Write Data Into A BLOB Incrementally
  1.2941 -**
  1.2942 -** ^This function is used to write data into an open [BLOB handle] from a
  1.2943 -** caller-supplied buffer. ^N bytes of data are copied from the buffer Z
  1.2944 -** into the open BLOB, starting at offset iOffset.
  1.2945 +** METHOD: sqlite3_blob
  1.2946 +**
  1.2947 +** ^(This function is used to write data into an open [BLOB handle] from a
  1.2948 +** caller-supplied buffer. N bytes of data are copied from the buffer Z
  1.2949 +** into the open BLOB, starting at offset iOffset.)^
  1.2950 +**
  1.2951 +** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
  1.2952 +** Otherwise, an  [error code] or an [extended error code] is returned.)^
  1.2953 +** ^Unless SQLITE_MISUSE is returned, this function sets the 
  1.2954 +** [database connection] error code and message accessible via 
  1.2955 +** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. 
  1.2956  **
  1.2957  ** ^If the [BLOB handle] passed as the first argument was not opened for
  1.2958  ** writing (the flags parameter to [sqlite3_blob_open()] was zero),
  1.2959  ** this function returns [SQLITE_READONLY].
  1.2960  **
  1.2961 -** ^This function may only modify the contents of the BLOB; it is
  1.2962 +** This function may only modify the contents of the BLOB; it is
  1.2963  ** not possible to increase the size of a BLOB using this API.
  1.2964  ** ^If offset iOffset is less than N bytes from the end of the BLOB,
  1.2965 -** [SQLITE_ERROR] is returned and no data is written.  ^If N is
  1.2966 -** less than zero [SQLITE_ERROR] is returned and no data is written.
  1.2967 -** The size of the BLOB (and hence the maximum value of N+iOffset)
  1.2968 -** can be determined using the [sqlite3_blob_bytes()] interface.
  1.2969 +** [SQLITE_ERROR] is returned and no data is written. The size of the 
  1.2970 +** BLOB (and hence the maximum value of N+iOffset) can be determined 
  1.2971 +** using the [sqlite3_blob_bytes()] interface. ^If N or iOffset are less 
  1.2972 +** than zero [SQLITE_ERROR] is returned and no data is written.
  1.2973  **
  1.2974  ** ^An attempt to write to an expired [BLOB handle] fails with an
  1.2975  ** error code of [SQLITE_ABORT].  ^Writes to the BLOB that occurred
  1.2976 @@ -5883,9 +6314,6 @@
  1.2977  ** have been overwritten by the statement that expired the BLOB handle
  1.2978  ** or by other independent statements.
  1.2979  **
  1.2980 -** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
  1.2981 -** Otherwise, an  [error code] or an [extended error code] is returned.)^
  1.2982 -**
  1.2983  ** This routine only works on a [BLOB handle] which has been created
  1.2984  ** by a prior successful call to [sqlite3_blob_open()] and which has not
  1.2985  ** been closed by [sqlite3_blob_close()].  Passing any other pointer in
  1.2986 @@ -5893,7 +6321,7 @@
  1.2987  **
  1.2988  ** See also: [sqlite3_blob_read()].
  1.2989  */
  1.2990 -SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
  1.2991 +SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
  1.2992  
  1.2993  /*
  1.2994  ** CAPI3REF: Virtual File System Objects
  1.2995 @@ -5924,9 +6352,9 @@
  1.2996  ** ^(If the default VFS is unregistered, another VFS is chosen as
  1.2997  ** the default.  The choice for the new VFS is arbitrary.)^
  1.2998  */
  1.2999 -SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
  1.3000 -SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
  1.3001 -SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
  1.3002 +SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfsName);
  1.3003 +SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
  1.3004 +SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs*);
  1.3005  
  1.3006  /*
  1.3007  ** CAPI3REF: Mutexes
  1.3008 @@ -5938,34 +6366,34 @@
  1.3009  **
  1.3010  ** The SQLite source code contains multiple implementations
  1.3011  ** of these mutex routines.  An appropriate implementation
  1.3012 -** is selected automatically at compile-time.  ^(The following
  1.3013 +** is selected automatically at compile-time.  The following
  1.3014  ** implementations are available in the SQLite core:
  1.3015  **
  1.3016  ** <ul>
  1.3017  ** <li>   SQLITE_MUTEX_PTHREADS
  1.3018  ** <li>   SQLITE_MUTEX_W32
  1.3019  ** <li>   SQLITE_MUTEX_NOOP
  1.3020 -** </ul>)^
  1.3021 -**
  1.3022 -** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
  1.3023 +** </ul>
  1.3024 +**
  1.3025 +** The SQLITE_MUTEX_NOOP implementation is a set of routines
  1.3026  ** that does no real locking and is appropriate for use in
  1.3027 -** a single-threaded application.  ^The SQLITE_MUTEX_PTHREADS and
  1.3028 +** a single-threaded application.  The SQLITE_MUTEX_PTHREADS and
  1.3029  ** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix
  1.3030  ** and Windows.
  1.3031  **
  1.3032 -** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
  1.3033 +** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
  1.3034  ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
  1.3035  ** implementation is included with the library. In this case the
  1.3036  ** application must supply a custom mutex implementation using the
  1.3037  ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function
  1.3038  ** before calling sqlite3_initialize() or any other public sqlite3_
  1.3039 -** function that calls sqlite3_initialize().)^
  1.3040 +** function that calls sqlite3_initialize().
  1.3041  **
  1.3042  ** ^The sqlite3_mutex_alloc() routine allocates a new
  1.3043 -** mutex and returns a pointer to it. ^If it returns NULL
  1.3044 -** that means that a mutex could not be allocated.  ^SQLite
  1.3045 -** will unwind its stack and return an error.  ^(The argument
  1.3046 -** to sqlite3_mutex_alloc() is one of these integer constants:
  1.3047 +** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()
  1.3048 +** routine returns NULL if it is unable to allocate the requested
  1.3049 +** mutex.  The argument to sqlite3_mutex_alloc() must one of these
  1.3050 +** integer constants:
  1.3051  **
  1.3052  ** <ul>
  1.3053  ** <li>  SQLITE_MUTEX_FAST
  1.3054 @@ -5978,7 +6406,11 @@
  1.3055  ** <li>  SQLITE_MUTEX_STATIC_PMEM
  1.3056  ** <li>  SQLITE_MUTEX_STATIC_APP1
  1.3057  ** <li>  SQLITE_MUTEX_STATIC_APP2
  1.3058 -** </ul>)^
  1.3059 +** <li>  SQLITE_MUTEX_STATIC_APP3
  1.3060 +** <li>  SQLITE_MUTEX_STATIC_VFS1
  1.3061 +** <li>  SQLITE_MUTEX_STATIC_VFS2
  1.3062 +** <li>  SQLITE_MUTEX_STATIC_VFS3
  1.3063 +** </ul>
  1.3064  **
  1.3065  ** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)
  1.3066  ** cause sqlite3_mutex_alloc() to create
  1.3067 @@ -5986,14 +6418,14 @@
  1.3068  ** is used but not necessarily so when SQLITE_MUTEX_FAST is used.
  1.3069  ** The mutex implementation does not need to make a distinction
  1.3070  ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
  1.3071 -** not want to.  ^SQLite will only request a recursive mutex in
  1.3072 -** cases where it really needs one.  ^If a faster non-recursive mutex
  1.3073 +** not want to.  SQLite will only request a recursive mutex in
  1.3074 +** cases where it really needs one.  If a faster non-recursive mutex
  1.3075  ** implementation is available on the host platform, the mutex subsystem
  1.3076  ** might return such a mutex in response to SQLITE_MUTEX_FAST.
  1.3077  **
  1.3078  ** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other
  1.3079  ** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return
  1.3080 -** a pointer to a static preexisting mutex.  ^Six static mutexes are
  1.3081 +** a pointer to a static preexisting mutex.  ^Nine static mutexes are
  1.3082  ** used by the current version of SQLite.  Future versions of SQLite
  1.3083  ** may add additional static mutexes.  Static mutexes are for internal
  1.3084  ** use by SQLite only.  Applications that use SQLite mutexes should
  1.3085 @@ -6002,16 +6434,13 @@
  1.3086  **
  1.3087  ** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
  1.3088  ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()
  1.3089 -** returns a different mutex on every call.  ^But for the static
  1.3090 +** returns a different mutex on every call.  ^For the static
  1.3091  ** mutex types, the same mutex is returned on every call that has
  1.3092  ** the same type number.
  1.3093  **
  1.3094  ** ^The sqlite3_mutex_free() routine deallocates a previously
  1.3095 -** allocated dynamic mutex.  ^SQLite is careful to deallocate every
  1.3096 -** dynamic mutex that it allocates.  The dynamic mutexes must not be in
  1.3097 -** use when they are deallocated.  Attempting to deallocate a static
  1.3098 -** mutex results in undefined behavior.  ^SQLite never deallocates
  1.3099 -** a static mutex.
  1.3100 +** allocated dynamic mutex.  Attempting to deallocate a static
  1.3101 +** mutex results in undefined behavior.
  1.3102  **
  1.3103  ** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
  1.3104  ** to enter a mutex.  ^If another thread is already within the mutex,
  1.3105 @@ -6019,23 +6448,21 @@
  1.3106  ** SQLITE_BUSY.  ^The sqlite3_mutex_try() interface returns [SQLITE_OK]
  1.3107  ** upon successful entry.  ^(Mutexes created using
  1.3108  ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.
  1.3109 -** In such cases the,
  1.3110 +** In such cases, the
  1.3111  ** mutex must be exited an equal number of times before another thread
  1.3112 -** can enter.)^  ^(If the same thread tries to enter any other
  1.3113 -** kind of mutex more than once, the behavior is undefined.
  1.3114 -** SQLite will never exhibit
  1.3115 -** such behavior in its own use of mutexes.)^
  1.3116 +** can enter.)^  If the same thread tries to enter any mutex other
  1.3117 +** than an SQLITE_MUTEX_RECURSIVE more than once, the behavior is undefined.
  1.3118  **
  1.3119  ** ^(Some systems (for example, Windows 95) do not support the operation
  1.3120  ** implemented by sqlite3_mutex_try().  On those systems, sqlite3_mutex_try()
  1.3121 -** will always return SQLITE_BUSY.  The SQLite core only ever uses
  1.3122 -** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^
  1.3123 +** will always return SQLITE_BUSY. The SQLite core only ever uses
  1.3124 +** sqlite3_mutex_try() as an optimization so this is acceptable 
  1.3125 +** behavior.)^
  1.3126  **
  1.3127  ** ^The sqlite3_mutex_leave() routine exits a mutex that was
  1.3128 -** previously entered by the same thread.   ^(The behavior
  1.3129 +** previously entered by the same thread.   The behavior
  1.3130  ** is undefined if the mutex is not currently entered by the
  1.3131 -** calling thread or is not currently allocated.  SQLite will
  1.3132 -** never do either.)^
  1.3133 +** calling thread or is not currently allocated.
  1.3134  **
  1.3135  ** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
  1.3136  ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
  1.3137 @@ -6043,11 +6470,11 @@
  1.3138  **
  1.3139  ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
  1.3140  */
  1.3141 -SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);
  1.3142 -SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);
  1.3143 -SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
  1.3144 -SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
  1.3145 -SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
  1.3146 +SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int);
  1.3147 +SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex*);
  1.3148 +SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex*);
  1.3149 +SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex*);
  1.3150 +SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex*);
  1.3151  
  1.3152  /*
  1.3153  ** CAPI3REF: Mutex Methods Object
  1.3154 @@ -6056,9 +6483,9 @@
  1.3155  ** used to allocate and use mutexes.
  1.3156  **
  1.3157  ** Usually, the default mutex implementations provided by SQLite are
  1.3158 -** sufficient, however the user has the option of substituting a custom
  1.3159 +** sufficient, however the application has the option of substituting a custom
  1.3160  ** implementation for specialized deployments or systems for which SQLite
  1.3161 -** does not provide a suitable implementation. In this case, the user
  1.3162 +** does not provide a suitable implementation. In this case, the application
  1.3163  ** creates and populates an instance of this structure to pass
  1.3164  ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.
  1.3165  ** Additionally, an instance of this structure can be used as an
  1.3166 @@ -6099,13 +6526,13 @@
  1.3167  ** (i.e. it is acceptable to provide an implementation that segfaults if
  1.3168  ** it is passed a NULL pointer).
  1.3169  **
  1.3170 -** The xMutexInit() method must be threadsafe.  ^It must be harmless to
  1.3171 +** The xMutexInit() method must be threadsafe.  It must be harmless to
  1.3172  ** invoke xMutexInit() multiple times within the same process and without
  1.3173  ** intervening calls to xMutexEnd().  Second and subsequent calls to
  1.3174  ** xMutexInit() must be no-ops.
  1.3175  **
  1.3176 -** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
  1.3177 -** and its associates).  ^Similarly, xMutexAlloc() must not use SQLite memory
  1.3178 +** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
  1.3179 +** and its associates).  Similarly, xMutexAlloc() must not use SQLite memory
  1.3180  ** allocation for a static mutex.  ^However xMutexAlloc() may use SQLite
  1.3181  ** memory allocation for a fast or recursive mutex.
  1.3182  **
  1.3183 @@ -6131,34 +6558,34 @@
  1.3184  ** CAPI3REF: Mutex Verification Routines
  1.3185  **
  1.3186  ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines
  1.3187 -** are intended for use inside assert() statements.  ^The SQLite core
  1.3188 +** are intended for use inside assert() statements.  The SQLite core
  1.3189  ** never uses these routines except inside an assert() and applications
  1.3190 -** are advised to follow the lead of the core.  ^The SQLite core only
  1.3191 +** are advised to follow the lead of the core.  The SQLite core only
  1.3192  ** provides implementations for these routines when it is compiled
  1.3193 -** with the SQLITE_DEBUG flag.  ^External mutex implementations
  1.3194 +** with the SQLITE_DEBUG flag.  External mutex implementations
  1.3195  ** are only required to provide these routines if SQLITE_DEBUG is
  1.3196  ** defined and if NDEBUG is not defined.
  1.3197  **
  1.3198 -** ^These routines should return true if the mutex in their argument
  1.3199 +** These routines should return true if the mutex in their argument
  1.3200  ** is held or not held, respectively, by the calling thread.
  1.3201  **
  1.3202 -** ^The implementation is not required to provide versions of these
  1.3203 +** The implementation is not required to provide versions of these
  1.3204  ** routines that actually work. If the implementation does not provide working
  1.3205  ** versions of these routines, it should at least provide stubs that always
  1.3206  ** return true so that one does not get spurious assertion failures.
  1.3207  **
  1.3208 -** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
  1.3209 +** If the argument to sqlite3_mutex_held() is a NULL pointer then
  1.3210  ** the routine should return 1.   This seems counter-intuitive since
  1.3211  ** clearly the mutex cannot be held if it does not exist.  But
  1.3212  ** the reason the mutex does not exist is because the build is not
  1.3213  ** using mutexes.  And we do not want the assert() containing the
  1.3214  ** call to sqlite3_mutex_held() to fail, so a non-zero return is
  1.3215 -** the appropriate thing to do.  ^The sqlite3_mutex_notheld()
  1.3216 +** the appropriate thing to do.  The sqlite3_mutex_notheld()
  1.3217  ** interface should also return 1 when given a NULL pointer.
  1.3218  */
  1.3219  #ifndef NDEBUG
  1.3220 -SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
  1.3221 -SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
  1.3222 +SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex*);
  1.3223 +SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex*);
  1.3224  #endif
  1.3225  
  1.3226  /*
  1.3227 @@ -6184,9 +6611,13 @@
  1.3228  #define SQLITE_MUTEX_STATIC_APP1      8  /* For use by application */
  1.3229  #define SQLITE_MUTEX_STATIC_APP2      9  /* For use by application */
  1.3230  #define SQLITE_MUTEX_STATIC_APP3     10  /* For use by application */
  1.3231 +#define SQLITE_MUTEX_STATIC_VFS1     11  /* For use by built-in VFS */
  1.3232 +#define SQLITE_MUTEX_STATIC_VFS2     12  /* For use by extension VFS */
  1.3233 +#define SQLITE_MUTEX_STATIC_VFS3     13  /* For use by application VFS */
  1.3234  
  1.3235  /*
  1.3236  ** CAPI3REF: Retrieve the mutex for a database connection
  1.3237 +** METHOD: sqlite3
  1.3238  **
  1.3239  ** ^This interface returns a pointer the [sqlite3_mutex] object that 
  1.3240  ** serializes access to the [database connection] given in the argument
  1.3241 @@ -6194,10 +6625,11 @@
  1.3242  ** ^If the [threading mode] is Single-thread or Multi-thread then this
  1.3243  ** routine returns a NULL pointer.
  1.3244  */
  1.3245 -SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
  1.3246 +SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3*);
  1.3247  
  1.3248  /*
  1.3249  ** CAPI3REF: Low-Level Control Of Database Files
  1.3250 +** METHOD: sqlite3
  1.3251  **
  1.3252  ** ^The [sqlite3_file_control()] interface makes a direct call to the
  1.3253  ** xFileControl method for the [sqlite3_io_methods] object associated
  1.3254 @@ -6228,7 +6660,7 @@
  1.3255  **
  1.3256  ** See also: [SQLITE_FCNTL_LOCKSTATE]
  1.3257  */
  1.3258 -SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
  1.3259 +SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
  1.3260  
  1.3261  /*
  1.3262  ** CAPI3REF: Testing Interface
  1.3263 @@ -6247,7 +6679,7 @@
  1.3264  ** Unlike most of the SQLite API, this function is not guaranteed to
  1.3265  ** operate consistently from one release to the next.
  1.3266  */
  1.3267 -SQLITE_API int sqlite3_test_control(int op, ...);
  1.3268 +SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...);
  1.3269  
  1.3270  /*
  1.3271  ** CAPI3REF: Testing Interface Operation Codes
  1.3272 @@ -6275,17 +6707,19 @@
  1.3273  #define SQLITE_TESTCTRL_ISKEYWORD               16
  1.3274  #define SQLITE_TESTCTRL_SCRATCHMALLOC           17
  1.3275  #define SQLITE_TESTCTRL_LOCALTIME_FAULT         18
  1.3276 -#define SQLITE_TESTCTRL_EXPLAIN_STMT            19
  1.3277 +#define SQLITE_TESTCTRL_EXPLAIN_STMT            19  /* NOT USED */
  1.3278  #define SQLITE_TESTCTRL_NEVER_CORRUPT           20
  1.3279  #define SQLITE_TESTCTRL_VDBE_COVERAGE           21
  1.3280  #define SQLITE_TESTCTRL_BYTEORDER               22
  1.3281  #define SQLITE_TESTCTRL_ISINIT                  23
  1.3282 -#define SQLITE_TESTCTRL_LAST                    23
  1.3283 +#define SQLITE_TESTCTRL_SORTER_MMAP             24
  1.3284 +#define SQLITE_TESTCTRL_IMPOSTER                25
  1.3285 +#define SQLITE_TESTCTRL_LAST                    25
  1.3286  
  1.3287  /*
  1.3288  ** CAPI3REF: SQLite Runtime Status
  1.3289  **
  1.3290 -** ^This interface is used to retrieve runtime status information
  1.3291 +** ^These interfaces are used to retrieve runtime status information
  1.3292  ** about the performance of SQLite, and optionally to reset various
  1.3293  ** highwater marks.  ^The first argument is an integer code for
  1.3294  ** the specific parameter to measure.  ^(Recognized integer codes
  1.3295 @@ -6299,19 +6733,22 @@
  1.3296  ** ^(Other parameters record only the highwater mark and not the current
  1.3297  ** value.  For these latter parameters nothing is written into *pCurrent.)^
  1.3298  **
  1.3299 -** ^The sqlite3_status() routine returns SQLITE_OK on success and a
  1.3300 -** non-zero [error code] on failure.
  1.3301 -**
  1.3302 -** This routine is threadsafe but is not atomic.  This routine can be
  1.3303 -** called while other threads are running the same or different SQLite
  1.3304 -** interfaces.  However the values returned in *pCurrent and
  1.3305 -** *pHighwater reflect the status of SQLite at different points in time
  1.3306 -** and it is possible that another thread might change the parameter
  1.3307 -** in between the times when *pCurrent and *pHighwater are written.
  1.3308 +** ^The sqlite3_status() and sqlite3_status64() routines return
  1.3309 +** SQLITE_OK on success and a non-zero [error code] on failure.
  1.3310 +**
  1.3311 +** If either the current value or the highwater mark is too large to
  1.3312 +** be represented by a 32-bit integer, then the values returned by
  1.3313 +** sqlite3_status() are undefined.
  1.3314  **
  1.3315  ** See also: [sqlite3_db_status()]
  1.3316  */
  1.3317 -SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
  1.3318 +SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
  1.3319 +SQLITE_API int SQLITE_STDCALL sqlite3_status64(
  1.3320 +  int op,
  1.3321 +  sqlite3_int64 *pCurrent,
  1.3322 +  sqlite3_int64 *pHighwater,
  1.3323 +  int resetFlag
  1.3324 +);
  1.3325  
  1.3326  
  1.3327  /*
  1.3328 @@ -6390,7 +6827,8 @@
  1.3329  ** The value written into the *pCurrent parameter is undefined.</dd>)^
  1.3330  **
  1.3331  ** [[SQLITE_STATUS_PARSER_STACK]] ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>
  1.3332 -** <dd>This parameter records the deepest parser stack.  It is only
  1.3333 +** <dd>The *pHighwater parameter records the deepest parser stack. 
  1.3334 +** The *pCurrent value is undefined.  The *pHighwater value is only
  1.3335  ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^
  1.3336  ** </dl>
  1.3337  **
  1.3338 @@ -6409,6 +6847,7 @@
  1.3339  
  1.3340  /*
  1.3341  ** CAPI3REF: Database Connection Status
  1.3342 +** METHOD: sqlite3
  1.3343  **
  1.3344  ** ^This interface is used to retrieve runtime status information 
  1.3345  ** about a single [database connection].  ^The first argument is the
  1.3346 @@ -6429,7 +6868,7 @@
  1.3347  **
  1.3348  ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
  1.3349  */
  1.3350 -SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
  1.3351 +SQLITE_API int SQLITE_STDCALL sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
  1.3352  
  1.3353  /*
  1.3354  ** CAPI3REF: Status Parameters for database connections
  1.3355 @@ -6471,12 +6910,12 @@
  1.3356  ** the current value is always zero.)^
  1.3357  **
  1.3358  ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
  1.3359 -** <dd>This parameter returns the approximate number of of bytes of heap
  1.3360 +** <dd>This parameter returns the approximate number of bytes of heap
  1.3361  ** memory used by all pager caches associated with the database connection.)^
  1.3362  ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
  1.3363  **
  1.3364  ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
  1.3365 -** <dd>This parameter returns the approximate number of of bytes of heap
  1.3366 +** <dd>This parameter returns the approximate number of bytes of heap
  1.3367  ** memory used to store the schema for all databases associated
  1.3368  ** with the connection - main, temp, and any [ATTACH]-ed databases.)^ 
  1.3369  ** ^The full amount of memory used by the schemas is reported, even if the
  1.3370 @@ -6485,7 +6924,7 @@
  1.3371  ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.
  1.3372  **
  1.3373  ** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>
  1.3374 -** <dd>This parameter returns the approximate number of of bytes of heap
  1.3375 +** <dd>This parameter returns the approximate number of bytes of heap
  1.3376  ** and lookaside memory used by all prepared statements associated with
  1.3377  ** the database connection.)^
  1.3378  ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0.
  1.3379 @@ -6537,6 +6976,7 @@
  1.3380  
  1.3381  /*
  1.3382  ** CAPI3REF: Prepared Statement Status
  1.3383 +** METHOD: sqlite3_stmt
  1.3384  **
  1.3385  ** ^(Each prepared statement maintains various
  1.3386  ** [SQLITE_STMTSTATUS counters] that measure the number
  1.3387 @@ -6558,7 +6998,7 @@
  1.3388  **
  1.3389  ** See also: [sqlite3_status()] and [sqlite3_db_status()].
  1.3390  */
  1.3391 -SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
  1.3392 +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
  1.3393  
  1.3394  /*
  1.3395  ** CAPI3REF: Status Parameters for prepared statements
  1.3396 @@ -6885,6 +7325,10 @@
  1.3397  ** must be different or else sqlite3_backup_init(D,N,S,M) will fail with
  1.3398  ** an error.
  1.3399  **
  1.3400 +** ^A call to sqlite3_backup_init() will fail, returning SQLITE_ERROR, if 
  1.3401 +** there is already a read or read-write transaction open on the 
  1.3402 +** destination database.
  1.3403 +**
  1.3404  ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is
  1.3405  ** returned and an error code and error message are stored in the
  1.3406  ** destination [database connection] D.
  1.3407 @@ -6977,20 +7421,20 @@
  1.3408  ** is not a permanent error and does not affect the return value of
  1.3409  ** sqlite3_backup_finish().
  1.3410  **
  1.3411 -** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]]
  1.3412 +** [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]]
  1.3413  ** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>
  1.3414  **
  1.3415 -** ^Each call to sqlite3_backup_step() sets two values inside
  1.3416 -** the [sqlite3_backup] object: the number of pages still to be backed
  1.3417 -** up and the total number of pages in the source database file.
  1.3418 -** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces
  1.3419 -** retrieve these two values, respectively.
  1.3420 -**
  1.3421 -** ^The values returned by these functions are only updated by
  1.3422 -** sqlite3_backup_step(). ^If the source database is modified during a backup
  1.3423 -** operation, then the values are not updated to account for any extra
  1.3424 -** pages that need to be updated or the size of the source database file
  1.3425 -** changing.
  1.3426 +** ^The sqlite3_backup_remaining() routine returns the number of pages still
  1.3427 +** to be backed up at the conclusion of the most recent sqlite3_backup_step().
  1.3428 +** ^The sqlite3_backup_pagecount() routine returns the total number of pages
  1.3429 +** in the source database at the conclusion of the most recent
  1.3430 +** sqlite3_backup_step().
  1.3431 +** ^(The values returned by these functions are only updated by
  1.3432 +** sqlite3_backup_step(). If the source database is modified in a way that
  1.3433 +** changes the size of the source database or the number of pages remaining,
  1.3434 +** those changes are not reflected in the output of sqlite3_backup_pagecount()
  1.3435 +** and sqlite3_backup_remaining() until after the next
  1.3436 +** sqlite3_backup_step().)^
  1.3437  **
  1.3438  ** <b>Concurrent Usage of Database Handles</b>
  1.3439  **
  1.3440 @@ -7023,19 +7467,20 @@
  1.3441  ** same time as another thread is invoking sqlite3_backup_step() it is
  1.3442  ** possible that they return invalid values.
  1.3443  */
  1.3444 -SQLITE_API sqlite3_backup *sqlite3_backup_init(
  1.3445 +SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init(
  1.3446    sqlite3 *pDest,                        /* Destination database handle */
  1.3447    const char *zDestName,                 /* Destination database name */
  1.3448    sqlite3 *pSource,                      /* Source database handle */
  1.3449    const char *zSourceName                /* Source database name */
  1.3450  );
  1.3451 -SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);
  1.3452 -SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);
  1.3453 -SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);
  1.3454 -SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
  1.3455 +SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage);
  1.3456 +SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p);
  1.3457 +SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p);
  1.3458 +SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p);
  1.3459  
  1.3460  /*
  1.3461  ** CAPI3REF: Unlock Notification
  1.3462 +** METHOD: sqlite3
  1.3463  **
  1.3464  ** ^When running in shared-cache mode, a database operation may fail with
  1.3465  ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
  1.3466 @@ -7148,7 +7593,7 @@
  1.3467  ** the special "DROP TABLE/INDEX" case, the extended error code is just 
  1.3468  ** SQLITE_LOCKED.)^
  1.3469  */
  1.3470 -SQLITE_API int sqlite3_unlock_notify(
  1.3471 +SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify(
  1.3472    sqlite3 *pBlocked,                          /* Waiting connection */
  1.3473    void (*xNotify)(void **apArg, int nArg),    /* Callback function to invoke */
  1.3474    void *pNotifyArg                            /* Argument to pass to xNotify */
  1.3475 @@ -7163,23 +7608,48 @@
  1.3476  ** strings in a case-independent fashion, using the same definition of "case
  1.3477  ** independence" that SQLite uses internally when comparing identifiers.
  1.3478  */
  1.3479 -SQLITE_API int sqlite3_stricmp(const char *, const char *);
  1.3480 -SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
  1.3481 +SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *, const char *);
  1.3482 +SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *, const char *, int);
  1.3483  
  1.3484  /*
  1.3485  ** CAPI3REF: String Globbing
  1.3486  *
  1.3487 -** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches
  1.3488 -** the glob pattern P, and it returns non-zero if string X does not match
  1.3489 -** the glob pattern P.  ^The definition of glob pattern matching used in
  1.3490 +** ^The [sqlite3_strglob(P,X)] interface returns zero if and only if
  1.3491 +** string X matches the [GLOB] pattern P.
  1.3492 +** ^The definition of [GLOB] pattern matching used in
  1.3493  ** [sqlite3_strglob(P,X)] is the same as for the "X GLOB P" operator in the
  1.3494 -** SQL dialect used by SQLite.  ^The sqlite3_strglob(P,X) function is case
  1.3495 -** sensitive.
  1.3496 +** SQL dialect understood by SQLite.  ^The [sqlite3_strglob(P,X)] function
  1.3497 +** is case sensitive.
  1.3498  **
  1.3499  ** Note that this routine returns zero on a match and non-zero if the strings
  1.3500  ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
  1.3501 -*/
  1.3502 -SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);
  1.3503 +**
  1.3504 +** See also: [sqlite3_strlike()].
  1.3505 +*/
  1.3506 +SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlob, const char *zStr);
  1.3507 +
  1.3508 +/*
  1.3509 +** CAPI3REF: String LIKE Matching
  1.3510 +*
  1.3511 +** ^The [sqlite3_strlike(P,X,E)] interface returns zero if and only if
  1.3512 +** string X matches the [LIKE] pattern P with escape character E.
  1.3513 +** ^The definition of [LIKE] pattern matching used in
  1.3514 +** [sqlite3_strlike(P,X,E)] is the same as for the "X LIKE P ESCAPE E"
  1.3515 +** operator in the SQL dialect understood by SQLite.  ^For "X LIKE P" without
  1.3516 +** the ESCAPE clause, set the E parameter of [sqlite3_strlike(P,X,E)] to 0.
  1.3517 +** ^As with the LIKE operator, the [sqlite3_strlike(P,X,E)] function is case
  1.3518 +** insensitive - equivalent upper and lower case ASCII characters match
  1.3519 +** one another.
  1.3520 +**
  1.3521 +** ^The [sqlite3_strlike(P,X,E)] function matches Unicode characters, though
  1.3522 +** only ASCII characters are case folded.
  1.3523 +**
  1.3524 +** Note that this routine returns zero on a match and non-zero if the strings
  1.3525 +** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
  1.3526 +**
  1.3527 +** See also: [sqlite3_strglob()].
  1.3528 +*/
  1.3529 +SQLITE_API int SQLITE_STDCALL sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc);
  1.3530  
  1.3531  /*
  1.3532  ** CAPI3REF: Error Logging Interface
  1.3533 @@ -7202,18 +7672,17 @@
  1.3534  ** a few hundred characters, it will be truncated to the length of the
  1.3535  ** buffer.
  1.3536  */
  1.3537 -SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
  1.3538 +SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...);
  1.3539  
  1.3540  /*
  1.3541  ** CAPI3REF: Write-Ahead Log Commit Hook
  1.3542 +** METHOD: sqlite3
  1.3543  **
  1.3544  ** ^The [sqlite3_wal_hook()] function is used to register a callback that
  1.3545 -** will be invoked each time a database connection commits data to a
  1.3546 -** [write-ahead log] (i.e. whenever a transaction is committed in
  1.3547 -** [journal_mode | journal_mode=WAL mode]). 
  1.3548 -**
  1.3549 -** ^The callback is invoked by SQLite after the commit has taken place and 
  1.3550 -** the associated write-lock on the database released, so the implementation 
  1.3551 +** is invoked each time data is committed to a database in wal mode.
  1.3552 +**
  1.3553 +** ^(The callback is invoked by SQLite after the commit has taken place and 
  1.3554 +** the associated write-lock on the database released)^, so the implementation 
  1.3555  ** may read, write or [checkpoint] the database as required.
  1.3556  **
  1.3557  ** ^The first parameter passed to the callback function when it is invoked
  1.3558 @@ -7239,7 +7708,7 @@
  1.3559  ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
  1.3560  ** those overwrite any prior [sqlite3_wal_hook()] settings.
  1.3561  */
  1.3562 -SQLITE_API void *sqlite3_wal_hook(
  1.3563 +SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
  1.3564    sqlite3*, 
  1.3565    int(*)(void *,sqlite3*,const char*,int),
  1.3566    void*
  1.3567 @@ -7247,6 +7716,7 @@
  1.3568  
  1.3569  /*
  1.3570  ** CAPI3REF: Configure an auto-checkpoint
  1.3571 +** METHOD: sqlite3
  1.3572  **
  1.3573  ** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around
  1.3574  ** [sqlite3_wal_hook()] that causes any database on [database connection] D
  1.3575 @@ -7273,104 +7743,123 @@
  1.3576  ** is only necessary if the default setting is found to be suboptimal
  1.3577  ** for a particular application.
  1.3578  */
  1.3579 -SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
  1.3580 +SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
  1.3581  
  1.3582  /*
  1.3583  ** CAPI3REF: Checkpoint a database
  1.3584 -**
  1.3585 -** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X
  1.3586 -** on [database connection] D to be [checkpointed].  ^If X is NULL or an
  1.3587 -** empty string, then a checkpoint is run on all databases of
  1.3588 -** connection D.  ^If the database connection D is not in
  1.3589 -** [WAL | write-ahead log mode] then this interface is a harmless no-op.
  1.3590 -** ^The [sqlite3_wal_checkpoint(D,X)] interface initiates a
  1.3591 -** [sqlite3_wal_checkpoint_v2|PASSIVE] checkpoint.
  1.3592 -** Use the [sqlite3_wal_checkpoint_v2()] interface to get a FULL
  1.3593 -** or RESET checkpoint.
  1.3594 -**
  1.3595 -** ^The [wal_checkpoint pragma] can be used to invoke this interface
  1.3596 -** from SQL.  ^The [sqlite3_wal_autocheckpoint()] interface and the
  1.3597 -** [wal_autocheckpoint pragma] can be used to cause this interface to be
  1.3598 -** run whenever the WAL reaches a certain size threshold.
  1.3599 -**
  1.3600 -** See also: [sqlite3_wal_checkpoint_v2()]
  1.3601 -*/
  1.3602 -SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
  1.3603 +** METHOD: sqlite3
  1.3604 +**
  1.3605 +** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
  1.3606 +** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^
  1.3607 +**
  1.3608 +** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the 
  1.3609 +** [write-ahead log] for database X on [database connection] D to be
  1.3610 +** transferred into the database file and for the write-ahead log to
  1.3611 +** be reset.  See the [checkpointing] documentation for addition
  1.3612 +** information.
  1.3613 +**
  1.3614 +** This interface used to be the only way to cause a checkpoint to
  1.3615 +** occur.  But then the newer and more powerful [sqlite3_wal_checkpoint_v2()]
  1.3616 +** interface was added.  This interface is retained for backwards
  1.3617 +** compatibility and as a convenience for applications that need to manually
  1.3618 +** start a callback but which do not need the full power (and corresponding
  1.3619 +** complication) of [sqlite3_wal_checkpoint_v2()].
  1.3620 +*/
  1.3621 +SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
  1.3622  
  1.3623  /*
  1.3624  ** CAPI3REF: Checkpoint a database
  1.3625 -**
  1.3626 -** Run a checkpoint operation on WAL database zDb attached to database 
  1.3627 -** handle db. The specific operation is determined by the value of the 
  1.3628 -** eMode parameter:
  1.3629 +** METHOD: sqlite3
  1.3630 +**
  1.3631 +** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
  1.3632 +** operation on database X of [database connection] D in mode M.  Status
  1.3633 +** information is written back into integers pointed to by L and C.)^
  1.3634 +** ^(The M parameter must be a valid [checkpoint mode]:)^
  1.3635  **
  1.3636  ** <dl>
  1.3637  ** <dt>SQLITE_CHECKPOINT_PASSIVE<dd>
  1.3638 -**   Checkpoint as many frames as possible without waiting for any database 
  1.3639 -**   readers or writers to finish. Sync the db file if all frames in the log
  1.3640 -**   are checkpointed. This mode is the same as calling 
  1.3641 -**   sqlite3_wal_checkpoint(). The [sqlite3_busy_handler|busy-handler callback]
  1.3642 -**   is never invoked.
  1.3643 +**   ^Checkpoint as many frames as possible without waiting for any database 
  1.3644 +**   readers or writers to finish, then sync the database file if all frames 
  1.3645 +**   in the log were checkpointed. ^The [busy-handler callback]
  1.3646 +**   is never invoked in the SQLITE_CHECKPOINT_PASSIVE mode.  
  1.3647 +**   ^On the other hand, passive mode might leave the checkpoint unfinished
  1.3648 +**   if there are concurrent readers or writers.
  1.3649  **
  1.3650  ** <dt>SQLITE_CHECKPOINT_FULL<dd>
  1.3651 -**   This mode blocks (it invokes the
  1.3652 +**   ^This mode blocks (it invokes the
  1.3653  **   [sqlite3_busy_handler|busy-handler callback]) until there is no
  1.3654  **   database writer and all readers are reading from the most recent database
  1.3655 -**   snapshot. It then checkpoints all frames in the log file and syncs the
  1.3656 -**   database file. This call blocks database writers while it is running,
  1.3657 -**   but not database readers.
  1.3658 +**   snapshot. ^It then checkpoints all frames in the log file and syncs the
  1.3659 +**   database file. ^This mode blocks new database writers while it is pending,
  1.3660 +**   but new database readers are allowed to continue unimpeded.
  1.3661  **
  1.3662  ** <dt>SQLITE_CHECKPOINT_RESTART<dd>
  1.3663 -**   This mode works the same way as SQLITE_CHECKPOINT_FULL, except after 
  1.3664 -**   checkpointing the log file it blocks (calls the 
  1.3665 -**   [sqlite3_busy_handler|busy-handler callback])
  1.3666 -**   until all readers are reading from the database file only. This ensures 
  1.3667 -**   that the next client to write to the database file restarts the log file 
  1.3668 -**   from the beginning. This call blocks database writers while it is running,
  1.3669 -**   but not database readers.
  1.3670 +**   ^This mode works the same way as SQLITE_CHECKPOINT_FULL with the addition
  1.3671 +**   that after checkpointing the log file it blocks (calls the 
  1.3672 +**   [busy-handler callback])
  1.3673 +**   until all readers are reading from the database file only. ^This ensures 
  1.3674 +**   that the next writer will restart the log file from the beginning.
  1.3675 +**   ^Like SQLITE_CHECKPOINT_FULL, this mode blocks new
  1.3676 +**   database writer attempts while it is pending, but does not impede readers.
  1.3677 +**
  1.3678 +** <dt>SQLITE_CHECKPOINT_TRUNCATE<dd>
  1.3679 +**   ^This mode works the same way as SQLITE_CHECKPOINT_RESTART with the
  1.3680 +**   addition that it also truncates the log file to zero bytes just prior
  1.3681 +**   to a successful return.
  1.3682  ** </dl>
  1.3683  **
  1.3684 -** If pnLog is not NULL, then *pnLog is set to the total number of frames in
  1.3685 -** the log file before returning. If pnCkpt is not NULL, then *pnCkpt is set to
  1.3686 -** the total number of checkpointed frames (including any that were already
  1.3687 -** checkpointed when this function is called). *pnLog and *pnCkpt may be
  1.3688 -** populated even if sqlite3_wal_checkpoint_v2() returns other than SQLITE_OK.
  1.3689 -** If no values are available because of an error, they are both set to -1
  1.3690 -** before returning to communicate this to the caller.
  1.3691 -**
  1.3692 -** All calls obtain an exclusive "checkpoint" lock on the database file. If
  1.3693 +** ^If pnLog is not NULL, then *pnLog is set to the total number of frames in
  1.3694 +** the log file or to -1 if the checkpoint could not run because
  1.3695 +** of an error or because the database is not in [WAL mode]. ^If pnCkpt is not
  1.3696 +** NULL,then *pnCkpt is set to the total number of checkpointed frames in the
  1.3697 +** log file (including any that were already checkpointed before the function
  1.3698 +** was called) or to -1 if the checkpoint could not run due to an error or
  1.3699 +** because the database is not in WAL mode. ^Note that upon successful
  1.3700 +** completion of an SQLITE_CHECKPOINT_TRUNCATE, the log file will have been
  1.3701 +** truncated to zero bytes and so both *pnLog and *pnCkpt will be set to zero.
  1.3702 +**
  1.3703 +** ^All calls obtain an exclusive "checkpoint" lock on the database file. ^If
  1.3704  ** any other process is running a checkpoint operation at the same time, the 
  1.3705 -** lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a 
  1.3706 +** lock cannot be obtained and SQLITE_BUSY is returned. ^Even if there is a 
  1.3707  ** busy-handler configured, it will not be invoked in this case.
  1.3708  **
  1.3709 -** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive 
  1.3710 -** "writer" lock on the database file. If the writer lock cannot be obtained
  1.3711 -** immediately, and a busy-handler is configured, it is invoked and the writer
  1.3712 -** lock retried until either the busy-handler returns 0 or the lock is
  1.3713 -** successfully obtained. The busy-handler is also invoked while waiting for
  1.3714 -** database readers as described above. If the busy-handler returns 0 before
  1.3715 +** ^The SQLITE_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the 
  1.3716 +** exclusive "writer" lock on the database file. ^If the writer lock cannot be
  1.3717 +** obtained immediately, and a busy-handler is configured, it is invoked and
  1.3718 +** the writer lock retried until either the busy-handler returns 0 or the lock
  1.3719 +** is successfully obtained. ^The busy-handler is also invoked while waiting for
  1.3720 +** database readers as described above. ^If the busy-handler returns 0 before
  1.3721  ** the writer lock is obtained or while waiting for database readers, the
  1.3722  ** checkpoint operation proceeds from that point in the same way as 
  1.3723  ** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible 
  1.3724 -** without blocking any further. SQLITE_BUSY is returned in this case.
  1.3725 -**
  1.3726 -** If parameter zDb is NULL or points to a zero length string, then the
  1.3727 -** specified operation is attempted on all WAL databases. In this case the
  1.3728 -** values written to output parameters *pnLog and *pnCkpt are undefined. If 
  1.3729 +** without blocking any further. ^SQLITE_BUSY is returned in this case.
  1.3730 +**
  1.3731 +** ^If parameter zDb is NULL or points to a zero length string, then the
  1.3732 +** specified operation is attempted on all WAL databases [attached] to 
  1.3733 +** [database connection] db.  In this case the
  1.3734 +** values written to output parameters *pnLog and *pnCkpt are undefined. ^If 
  1.3735  ** an SQLITE_BUSY error is encountered when processing one or more of the 
  1.3736  ** attached WAL databases, the operation is still attempted on any remaining 
  1.3737 -** attached databases and SQLITE_BUSY is returned to the caller. If any other 
  1.3738 +** attached databases and SQLITE_BUSY is returned at the end. ^If any other 
  1.3739  ** error occurs while processing an attached database, processing is abandoned 
  1.3740 -** and the error code returned to the caller immediately. If no error 
  1.3741 +** and the error code is returned to the caller immediately. ^If no error 
  1.3742  ** (SQLITE_BUSY or otherwise) is encountered while processing the attached 
  1.3743  ** databases, SQLITE_OK is returned.
  1.3744  **
  1.3745 -** If database zDb is the name of an attached database that is not in WAL
  1.3746 -** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. If
  1.3747 +** ^If database zDb is the name of an attached database that is not in WAL
  1.3748 +** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. ^If
  1.3749  ** zDb is not NULL (or a zero length string) and is not the name of any
  1.3750  ** attached database, SQLITE_ERROR is returned to the caller.
  1.3751 -*/
  1.3752 -SQLITE_API int sqlite3_wal_checkpoint_v2(
  1.3753 +**
  1.3754 +** ^Unless it returns SQLITE_MISUSE,
  1.3755 +** the sqlite3_wal_checkpoint_v2() interface
  1.3756 +** sets the error information that is queried by
  1.3757 +** [sqlite3_errcode()] and [sqlite3_errmsg()].
  1.3758 +**
  1.3759 +** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
  1.3760 +** from SQL.
  1.3761 +*/
  1.3762 +SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
  1.3763    sqlite3 *db,                    /* Database handle */
  1.3764    const char *zDb,                /* Name of attached database (or NULL) */
  1.3765    int eMode,                      /* SQLITE_CHECKPOINT_* value */
  1.3766 @@ -7379,16 +7868,18 @@
  1.3767  );
  1.3768  
  1.3769  /*
  1.3770 -** CAPI3REF: Checkpoint operation parameters
  1.3771 -**
  1.3772 -** These constants can be used as the 3rd parameter to
  1.3773 -** [sqlite3_wal_checkpoint_v2()].  See the [sqlite3_wal_checkpoint_v2()]
  1.3774 -** documentation for additional information about the meaning and use of
  1.3775 -** each of these values.
  1.3776 -*/
  1.3777 -#define SQLITE_CHECKPOINT_PASSIVE 0
  1.3778 -#define SQLITE_CHECKPOINT_FULL    1
  1.3779 -#define SQLITE_CHECKPOINT_RESTART 2
  1.3780 +** CAPI3REF: Checkpoint Mode Values
  1.3781 +** KEYWORDS: {checkpoint mode}
  1.3782 +**
  1.3783 +** These constants define all valid values for the "checkpoint mode" passed
  1.3784 +** as the third parameter to the [sqlite3_wal_checkpoint_v2()] interface.
  1.3785 +** See the [sqlite3_wal_checkpoint_v2()] documentation for details on the
  1.3786 +** meaning of each of these checkpoint modes.
  1.3787 +*/
  1.3788 +#define SQLITE_CHECKPOINT_PASSIVE  0  /* Do as much as possible w/o blocking */
  1.3789 +#define SQLITE_CHECKPOINT_FULL     1  /* Wait for writers, then checkpoint */
  1.3790 +#define SQLITE_CHECKPOINT_RESTART  2  /* Like FULL but wait for for readers */
  1.3791 +#define SQLITE_CHECKPOINT_TRUNCATE 3  /* Like RESTART but also truncate WAL */
  1.3792  
  1.3793  /*
  1.3794  ** CAPI3REF: Virtual Table Interface Configuration
  1.3795 @@ -7404,7 +7895,7 @@
  1.3796  ** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].)  Further options
  1.3797  ** may be added in the future.
  1.3798  */
  1.3799 -SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
  1.3800 +SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3*, int op, ...);
  1.3801  
  1.3802  /*
  1.3803  ** CAPI3REF: Virtual Table Configuration Options
  1.3804 @@ -7457,7 +7948,7 @@
  1.3805  ** of the SQL statement that triggered the call to the [xUpdate] method of the
  1.3806  ** [virtual table].
  1.3807  */
  1.3808 -SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
  1.3809 +SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *);
  1.3810  
  1.3811  /*
  1.3812  ** CAPI3REF: Conflict resolution modes
  1.3813 @@ -7477,7 +7968,232 @@
  1.3814  /* #define SQLITE_ABORT 4  // Also an error code */
  1.3815  #define SQLITE_REPLACE  5
  1.3816  
  1.3817 -
  1.3818 +/*
  1.3819 +** CAPI3REF: Prepared Statement Scan Status Opcodes
  1.3820 +** KEYWORDS: {scanstatus options}
  1.3821 +**
  1.3822 +** The following constants can be used for the T parameter to the
  1.3823 +** [sqlite3_stmt_scanstatus(S,X,T,V)] interface.  Each constant designates a
  1.3824 +** different metric for sqlite3_stmt_scanstatus() to return.
  1.3825 +**
  1.3826 +** When the value returned to V is a string, space to hold that string is
  1.3827 +** managed by the prepared statement S and will be automatically freed when
  1.3828 +** S is finalized.
  1.3829 +**
  1.3830 +** <dl>
  1.3831 +** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>
  1.3832 +** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be
  1.3833 +** set to the total number of times that the X-th loop has run.</dd>
  1.3834 +**
  1.3835 +** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt>
  1.3836 +** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set
  1.3837 +** to the total number of rows examined by all iterations of the X-th loop.</dd>
  1.3838 +**
  1.3839 +** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>
  1.3840 +** <dd>^The "double" variable pointed to by the T parameter will be set to the
  1.3841 +** query planner's estimate for the average number of rows output from each
  1.3842 +** iteration of the X-th loop.  If the query planner's estimates was accurate,
  1.3843 +** then this value will approximate the quotient NVISIT/NLOOP and the
  1.3844 +** product of this value for all prior loops with the same SELECTID will
  1.3845 +** be the NLOOP value for the current loop.
  1.3846 +**
  1.3847 +** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>
  1.3848 +** <dd>^The "const char *" variable pointed to by the T parameter will be set
  1.3849 +** to a zero-terminated UTF-8 string containing the name of the index or table
  1.3850 +** used for the X-th loop.
  1.3851 +**
  1.3852 +** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>
  1.3853 +** <dd>^The "const char *" variable pointed to by the T parameter will be set
  1.3854 +** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]
  1.3855 +** description for the X-th loop.
  1.3856 +**
  1.3857 +** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt>
  1.3858 +** <dd>^The "int" variable pointed to by the T parameter will be set to the
  1.3859 +** "select-id" for the X-th loop.  The select-id identifies which query or
  1.3860 +** subquery the loop is part of.  The main query has a select-id of zero.
  1.3861 +** The select-id is the same value as is output in the first column
  1.3862 +** of an [EXPLAIN QUERY PLAN] query.
  1.3863 +** </dl>
  1.3864 +*/
  1.3865 +#define SQLITE_SCANSTAT_NLOOP    0
  1.3866 +#define SQLITE_SCANSTAT_NVISIT   1
  1.3867 +#define SQLITE_SCANSTAT_EST      2
  1.3868 +#define SQLITE_SCANSTAT_NAME     3
  1.3869 +#define SQLITE_SCANSTAT_EXPLAIN  4
  1.3870 +#define SQLITE_SCANSTAT_SELECTID 5
  1.3871 +
  1.3872 +/*
  1.3873 +** CAPI3REF: Prepared Statement Scan Status
  1.3874 +** METHOD: sqlite3_stmt
  1.3875 +**
  1.3876 +** This interface returns information about the predicted and measured
  1.3877 +** performance for pStmt.  Advanced applications can use this
  1.3878 +** interface to compare the predicted and the measured performance and
  1.3879 +** issue warnings and/or rerun [ANALYZE] if discrepancies are found.
  1.3880 +**
  1.3881 +** Since this interface is expected to be rarely used, it is only
  1.3882 +** available if SQLite is compiled using the [SQLITE_ENABLE_STMT_SCANSTATUS]
  1.3883 +** compile-time option.
  1.3884 +**
  1.3885 +** The "iScanStatusOp" parameter determines which status information to return.
  1.3886 +** The "iScanStatusOp" must be one of the [scanstatus options] or the behavior
  1.3887 +** of this interface is undefined.
  1.3888 +** ^The requested measurement is written into a variable pointed to by
  1.3889 +** the "pOut" parameter.
  1.3890 +** Parameter "idx" identifies the specific loop to retrieve statistics for.
  1.3891 +** Loops are numbered starting from zero. ^If idx is out of range - less than
  1.3892 +** zero or greater than or equal to the total number of loops used to implement
  1.3893 +** the statement - a non-zero value is returned and the variable that pOut
  1.3894 +** points to is unchanged.
  1.3895 +**
  1.3896 +** ^Statistics might not be available for all loops in all statements. ^In cases
  1.3897 +** where there exist loops with no available statistics, this function behaves
  1.3898 +** as if the loop did not exist - it returns non-zero and leave the variable
  1.3899 +** that pOut points to unchanged.
  1.3900 +**
  1.3901 +** See also: [sqlite3_stmt_scanstatus_reset()]
  1.3902 +*/
  1.3903 +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_scanstatus(
  1.3904 +  sqlite3_stmt *pStmt,      /* Prepared statement for which info desired */
  1.3905 +  int idx,                  /* Index of loop to report on */
  1.3906 +  int iScanStatusOp,        /* Information desired.  SQLITE_SCANSTAT_* */
  1.3907 +  void *pOut                /* Result written here */
  1.3908 +);     
  1.3909 +
  1.3910 +/*
  1.3911 +** CAPI3REF: Zero Scan-Status Counters
  1.3912 +** METHOD: sqlite3_stmt
  1.3913 +**
  1.3914 +** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.
  1.3915 +**
  1.3916 +** This API is only available if the library is built with pre-processor
  1.3917 +** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.
  1.3918 +*/
  1.3919 +SQLITE_API void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
  1.3920 +
  1.3921 +/*
  1.3922 +** CAPI3REF: Flush caches to disk mid-transaction
  1.3923 +**
  1.3924 +** ^If a write-transaction is open on [database connection] D when the
  1.3925 +** [sqlite3_db_cacheflush(D)] interface invoked, any dirty
  1.3926 +** pages in the pager-cache that are not currently in use are written out 
  1.3927 +** to disk. A dirty page may be in use if a database cursor created by an
  1.3928 +** active SQL statement is reading from it, or if it is page 1 of a database
  1.3929 +** file (page 1 is always "in use").  ^The [sqlite3_db_cacheflush(D)]
  1.3930 +** interface flushes caches for all schemas - "main", "temp", and
  1.3931 +** any [attached] databases.
  1.3932 +**
  1.3933 +** ^If this function needs to obtain extra database locks before dirty pages 
  1.3934 +** can be flushed to disk, it does so. ^If those locks cannot be obtained 
  1.3935 +** immediately and there is a busy-handler callback configured, it is invoked
  1.3936 +** in the usual manner. ^If the required lock still cannot be obtained, then
  1.3937 +** the database is skipped and an attempt made to flush any dirty pages
  1.3938 +** belonging to the next (if any) database. ^If any databases are skipped
  1.3939 +** because locks cannot be obtained, but no other error occurs, this
  1.3940 +** function returns SQLITE_BUSY.
  1.3941 +**
  1.3942 +** ^If any other error occurs while flushing dirty pages to disk (for
  1.3943 +** example an IO error or out-of-memory condition), then processing is
  1.3944 +** abandoned and an SQLite [error code] is returned to the caller immediately.
  1.3945 +**
  1.3946 +** ^Otherwise, if no error occurs, [sqlite3_db_cacheflush()] returns SQLITE_OK.
  1.3947 +**
  1.3948 +** ^This function does not set the database handle error code or message
  1.3949 +** returned by the [sqlite3_errcode()] and [sqlite3_errmsg()] functions.
  1.3950 +*/
  1.3951 +SQLITE_API int SQLITE_STDCALL sqlite3_db_cacheflush(sqlite3*);
  1.3952 +
  1.3953 +/*
  1.3954 +** CAPI3REF: Database Snapshot
  1.3955 +** KEYWORDS: {snapshot}
  1.3956 +** EXPERIMENTAL
  1.3957 +**
  1.3958 +** An instance of the snapshot object records the state of a [WAL mode]
  1.3959 +** database for some specific point in history.
  1.3960 +**
  1.3961 +** In [WAL mode], multiple [database connections] that are open on the
  1.3962 +** same database file can each be reading a different historical version
  1.3963 +** of the database file.  When a [database connection] begins a read
  1.3964 +** transaction, that connection sees an unchanging copy of the database
  1.3965 +** as it existed for the point in time when the transaction first started.
  1.3966 +** Subsequent changes to the database from other connections are not seen
  1.3967 +** by the reader until a new read transaction is started.
  1.3968 +**
  1.3969 +** The sqlite3_snapshot object records state information about an historical
  1.3970 +** version of the database file so that it is possible to later open a new read
  1.3971 +** transaction that sees that historical version of the database rather than
  1.3972 +** the most recent version.
  1.3973 +**
  1.3974 +** The constructor for this object is [sqlite3_snapshot_get()].  The
  1.3975 +** [sqlite3_snapshot_open()] method causes a fresh read transaction to refer
  1.3976 +** to an historical snapshot (if possible).  The destructor for 
  1.3977 +** sqlite3_snapshot objects is [sqlite3_snapshot_free()].
  1.3978 +*/
  1.3979 +typedef struct sqlite3_snapshot sqlite3_snapshot;
  1.3980 +
  1.3981 +/*
  1.3982 +** CAPI3REF: Record A Database Snapshot
  1.3983 +** EXPERIMENTAL
  1.3984 +**
  1.3985 +** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a
  1.3986 +** new [sqlite3_snapshot] object that records the current state of
  1.3987 +** schema S in database connection D.  ^On success, the
  1.3988 +** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
  1.3989 +** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.
  1.3990 +** ^If schema S of [database connection] D is not a [WAL mode] database
  1.3991 +** that is in a read transaction, then [sqlite3_snapshot_get(D,S,P)]
  1.3992 +** leaves the *P value unchanged and returns an appropriate [error code].
  1.3993 +**
  1.3994 +** The [sqlite3_snapshot] object returned from a successful call to
  1.3995 +** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()]
  1.3996 +** to avoid a memory leak.
  1.3997 +**
  1.3998 +** The [sqlite3_snapshot_get()] interface is only available when the
  1.3999 +** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
  1.4000 +*/
  1.4001 +SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_snapshot_get(
  1.4002 +  sqlite3 *db,
  1.4003 +  const char *zSchema,
  1.4004 +  sqlite3_snapshot **ppSnapshot
  1.4005 +);
  1.4006 +
  1.4007 +/*
  1.4008 +** CAPI3REF: Start a read transaction on an historical snapshot
  1.4009 +** EXPERIMENTAL
  1.4010 +**
  1.4011 +** ^The [sqlite3_snapshot_open(D,S,P)] interface attempts to move the
  1.4012 +** read transaction that is currently open on schema S of
  1.4013 +** [database connection] D so that it refers to historical [snapshot] P.
  1.4014 +** ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK on success
  1.4015 +** or an appropriate [error code] if it fails.
  1.4016 +**
  1.4017 +** ^In order to succeed, a call to [sqlite3_snapshot_open(D,S,P)] must be
  1.4018 +** the first operation, apart from other sqlite3_snapshot_open() calls,
  1.4019 +** following the [BEGIN] that starts a new read transaction.
  1.4020 +** ^A [snapshot] will fail to open if it has been overwritten by a 
  1.4021 +** [checkpoint].  
  1.4022 +**
  1.4023 +** The [sqlite3_snapshot_open()] interface is only available when the
  1.4024 +** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
  1.4025 +*/
  1.4026 +SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_snapshot_open(
  1.4027 +  sqlite3 *db,
  1.4028 +  const char *zSchema,
  1.4029 +  sqlite3_snapshot *pSnapshot
  1.4030 +);
  1.4031 +
  1.4032 +/*
  1.4033 +** CAPI3REF: Destroy a snapshot
  1.4034 +** EXPERIMENTAL
  1.4035 +**
  1.4036 +** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.
  1.4037 +** The application must eventually free every [sqlite3_snapshot] object
  1.4038 +** using this routine to avoid a memory leak.
  1.4039 +**
  1.4040 +** The [sqlite3_snapshot_free()] interface is only available when the
  1.4041 +** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
  1.4042 +*/
  1.4043 +SQLITE_API SQLITE_EXPERIMENTAL void SQLITE_STDCALL sqlite3_snapshot_free(sqlite3_snapshot*);
  1.4044  
  1.4045  /*
  1.4046  ** Undo the hack that converts floating point types to integer for
  1.4047 @@ -7531,7 +8247,7 @@
  1.4048  **
  1.4049  **   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
  1.4050  */
  1.4051 -SQLITE_API int sqlite3_rtree_geometry_callback(
  1.4052 +SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback(
  1.4053    sqlite3 *db,
  1.4054    const char *zGeom,
  1.4055    int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),
  1.4056 @@ -7557,7 +8273,7 @@
  1.4057  **
  1.4058  **   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)
  1.4059  */
  1.4060 -SQLITE_API int sqlite3_rtree_query_callback(
  1.4061 +SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback(
  1.4062    sqlite3 *db,
  1.4063    const char *zQueryFunc,
  1.4064    int (*xQueryFunc)(sqlite3_rtree_query_info*),
  1.4065 @@ -7591,6 +8307,8 @@
  1.4066    int eParentWithin;                /* Visibility of parent node */
  1.4067    int eWithin;                      /* OUT: Visiblity */
  1.4068    sqlite3_rtree_dbl rScore;         /* OUT: Write the score here */
  1.4069 +  /* The following fields are only available in 3.8.11 and later */
  1.4070 +  sqlite3_value **apSqlParam;       /* Original SQL values of parameters */
  1.4071  };
  1.4072  
  1.4073  /*
  1.4074 @@ -7607,6 +8325,584 @@
  1.4075  
  1.4076  #endif  /* ifndef _SQLITE3RTREE_H_ */
  1.4077  
  1.4078 +/*
  1.4079 +** 2014 May 31
  1.4080 +**
  1.4081 +** The author disclaims copyright to this source code.  In place of
  1.4082 +** a legal notice, here is a blessing:
  1.4083 +**
  1.4084 +**    May you do good and not evil.
  1.4085 +**    May you find forgiveness for yourself and forgive others.
  1.4086 +**    May you share freely, never taking more than you give.
  1.4087 +**
  1.4088 +******************************************************************************
  1.4089 +**
  1.4090 +** Interfaces to extend FTS5. Using the interfaces defined in this file, 
  1.4091 +** FTS5 may be extended with:
  1.4092 +**
  1.4093 +**     * custom tokenizers, and
  1.4094 +**     * custom auxiliary functions.
  1.4095 +*/
  1.4096 +
  1.4097 +
  1.4098 +#ifndef _FTS5_H
  1.4099 +#define _FTS5_H
  1.4100 +
  1.4101 +
  1.4102 +#if 0
  1.4103 +extern "C" {
  1.4104 +#endif
  1.4105 +
  1.4106 +/*************************************************************************
  1.4107 +** CUSTOM AUXILIARY FUNCTIONS
  1.4108 +**
  1.4109 +** Virtual table implementations may overload SQL functions by implementing
  1.4110 +** the sqlite3_module.xFindFunction() method.
  1.4111 +*/
  1.4112 +
  1.4113 +typedef struct Fts5ExtensionApi Fts5ExtensionApi;
  1.4114 +typedef struct Fts5Context Fts5Context;
  1.4115 +typedef struct Fts5PhraseIter Fts5PhraseIter;
  1.4116 +
  1.4117 +typedef void (*fts5_extension_function)(
  1.4118 +  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */
  1.4119 +  Fts5Context *pFts,              /* First arg to pass to pApi functions */
  1.4120 +  sqlite3_context *pCtx,          /* Context for returning result/error */
  1.4121 +  int nVal,                       /* Number of values in apVal[] array */
  1.4122 +  sqlite3_value **apVal           /* Array of trailing arguments */
  1.4123 +);
  1.4124 +
  1.4125 +struct Fts5PhraseIter {
  1.4126 +  const unsigned char *a;
  1.4127 +  const unsigned char *b;
  1.4128 +};
  1.4129 +
  1.4130 +/*
  1.4131 +** EXTENSION API FUNCTIONS
  1.4132 +**
  1.4133 +** xUserData(pFts):
  1.4134 +**   Return a copy of the context pointer the extension function was 
  1.4135 +**   registered with.
  1.4136 +**
  1.4137 +** xColumnTotalSize(pFts, iCol, pnToken):
  1.4138 +**   If parameter iCol is less than zero, set output variable *pnToken
  1.4139 +**   to the total number of tokens in the FTS5 table. Or, if iCol is
  1.4140 +**   non-negative but less than the number of columns in the table, return
  1.4141 +**   the total number of tokens in column iCol, considering all rows in 
  1.4142 +**   the FTS5 table.
  1.4143 +**
  1.4144 +**   If parameter iCol is greater than or equal to the number of columns
  1.4145 +**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
  1.4146 +**   an OOM condition or IO error), an appropriate SQLite error code is 
  1.4147 +**   returned.
  1.4148 +**
  1.4149 +** xColumnCount(pFts):
  1.4150 +**   Return the number of columns in the table.
  1.4151 +**
  1.4152 +** xColumnSize(pFts, iCol, pnToken):
  1.4153 +**   If parameter iCol is less than zero, set output variable *pnToken
  1.4154 +**   to the total number of tokens in the current row. Or, if iCol is
  1.4155 +**   non-negative but less than the number of columns in the table, set
  1.4156 +**   *pnToken to the number of tokens in column iCol of the current row.
  1.4157 +**
  1.4158 +**   If parameter iCol is greater than or equal to the number of columns
  1.4159 +**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
  1.4160 +**   an OOM condition or IO error), an appropriate SQLite error code is 
  1.4161 +**   returned.
  1.4162 +**
  1.4163 +**   This function may be quite inefficient if used with an FTS5 table
  1.4164 +**   created with the "columnsize=0" option.
  1.4165 +**
  1.4166 +** xColumnText:
  1.4167 +**   This function attempts to retrieve the text of column iCol of the
  1.4168 +**   current document. If successful, (*pz) is set to point to a buffer
  1.4169 +**   containing the text in utf-8 encoding, (*pn) is set to the size in bytes
  1.4170 +**   (not characters) of the buffer and SQLITE_OK is returned. Otherwise,
  1.4171 +**   if an error occurs, an SQLite error code is returned and the final values
  1.4172 +**   of (*pz) and (*pn) are undefined.
  1.4173 +**
  1.4174 +** xPhraseCount:
  1.4175 +**   Returns the number of phrases in the current query expression.
  1.4176 +**
  1.4177 +** xPhraseSize:
  1.4178 +**   Returns the number of tokens in phrase iPhrase of the query. Phrases
  1.4179 +**   are numbered starting from zero.
  1.4180 +**
  1.4181 +** xInstCount:
  1.4182 +**   Set *pnInst to the total number of occurrences of all phrases within
  1.4183 +**   the query within the current row. Return SQLITE_OK if successful, or
  1.4184 +**   an error code (i.e. SQLITE_NOMEM) if an error occurs.
  1.4185 +**
  1.4186 +**   This API can be quite slow if used with an FTS5 table created with the
  1.4187 +**   "detail=none" or "detail=column" option. If the FTS5 table is created 
  1.4188 +**   with either "detail=none" or "detail=column" and "content=" option 
  1.4189 +**   (i.e. if it is a contentless table), then this API always returns 0.
  1.4190 +**
  1.4191 +** xInst:
  1.4192 +**   Query for the details of phrase match iIdx within the current row.
  1.4193 +**   Phrase matches are numbered starting from zero, so the iIdx argument
  1.4194 +**   should be greater than or equal to zero and smaller than the value
  1.4195 +**   output by xInstCount().
  1.4196 +**
  1.4197 +**   Usually, output parameter *piPhrase is set to the phrase number, *piCol
  1.4198 +**   to the column in which it occurs and *piOff the token offset of the
  1.4199 +**   first token of the phrase. The exception is if the table was created
  1.4200 +**   with the offsets=0 option specified. In this case *piOff is always
  1.4201 +**   set to -1.
  1.4202 +**
  1.4203 +**   Returns SQLITE_OK if successful, or an error code (i.e. SQLITE_NOMEM) 
  1.4204 +**   if an error occurs.
  1.4205 +**
  1.4206 +**   This API can be quite slow if used with an FTS5 table created with the
  1.4207 +**   "detail=none" or "detail=column" option. 
  1.4208 +**
  1.4209 +** xRowid:
  1.4210 +**   Returns the rowid of the current row.
  1.4211 +**
  1.4212 +** xTokenize:
  1.4213 +**   Tokenize text using the tokenizer belonging to the FTS5 table.
  1.4214 +**
  1.4215 +** xQueryPhrase(pFts5, iPhrase, pUserData, xCallback):
  1.4216 +**   This API function is used to query the FTS table for phrase iPhrase
  1.4217 +**   of the current query. Specifically, a query equivalent to:
  1.4218 +**
  1.4219 +**       ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid
  1.4220 +**
  1.4221 +**   with $p set to a phrase equivalent to the phrase iPhrase of the
  1.4222 +**   current query is executed. For each row visited, the callback function
  1.4223 +**   passed as the fourth argument is invoked. The context and API objects 
  1.4224 +**   passed to the callback function may be used to access the properties of
  1.4225 +**   each matched row. Invoking Api.xUserData() returns a copy of the pointer
  1.4226 +**   passed as the third argument to pUserData.
  1.4227 +**
  1.4228 +**   If the callback function returns any value other than SQLITE_OK, the
  1.4229 +**   query is abandoned and the xQueryPhrase function returns immediately.
  1.4230 +**   If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK.
  1.4231 +**   Otherwise, the error code is propagated upwards.
  1.4232 +**
  1.4233 +**   If the query runs to completion without incident, SQLITE_OK is returned.
  1.4234 +**   Or, if some error occurs before the query completes or is aborted by
  1.4235 +**   the callback, an SQLite error code is returned.
  1.4236 +**
  1.4237 +**
  1.4238 +** xSetAuxdata(pFts5, pAux, xDelete)
  1.4239 +**
  1.4240 +**   Save the pointer passed as the second argument as the extension functions 
  1.4241 +**   "auxiliary data". The pointer may then be retrieved by the current or any
  1.4242 +**   future invocation of the same fts5 extension function made as part of
  1.4243 +**   of the same MATCH query using the xGetAuxdata() API.
  1.4244 +**
  1.4245 +**   Each extension function is allocated a single auxiliary data slot for
  1.4246 +**   each FTS query (MATCH expression). If the extension function is invoked 
  1.4247 +**   more than once for a single FTS query, then all invocations share a 
  1.4248 +**   single auxiliary data context.
  1.4249 +**
  1.4250 +**   If there is already an auxiliary data pointer when this function is
  1.4251 +**   invoked, then it is replaced by the new pointer. If an xDelete callback
  1.4252 +**   was specified along with the original pointer, it is invoked at this
  1.4253 +**   point.
  1.4254 +**
  1.4255 +**   The xDelete callback, if one is specified, is also invoked on the
  1.4256 +**   auxiliary data pointer after the FTS5 query has finished.
  1.4257 +**
  1.4258 +**   If an error (e.g. an OOM condition) occurs within this function, an
  1.4259 +**   the auxiliary data is set to NULL and an error code returned. If the
  1.4260 +**   xDelete parameter was not NULL, it is invoked on the auxiliary data
  1.4261 +**   pointer before returning.
  1.4262 +**
  1.4263 +**
  1.4264 +** xGetAuxdata(pFts5, bClear)
  1.4265 +**
  1.4266 +**   Returns the current auxiliary data pointer for the fts5 extension 
  1.4267 +**   function. See the xSetAuxdata() method for details.
  1.4268 +**
  1.4269 +**   If the bClear argument is non-zero, then the auxiliary data is cleared
  1.4270 +**   (set to NULL) before this function returns. In this case the xDelete,
  1.4271 +**   if any, is not invoked.
  1.4272 +**
  1.4273 +**
  1.4274 +** xRowCount(pFts5, pnRow)
  1.4275 +**
  1.4276 +**   This function is used to retrieve the total number of rows in the table.
  1.4277 +**   In other words, the same value that would be returned by:
  1.4278 +**
  1.4279 +**        SELECT count(*) FROM ftstable;
  1.4280 +**
  1.4281 +** xPhraseFirst()
  1.4282 +**   This function is used, along with type Fts5PhraseIter and the xPhraseNext
  1.4283 +**   method, to iterate through all instances of a single query phrase within
  1.4284 +**   the current row. This is the same information as is accessible via the
  1.4285 +**   xInstCount/xInst APIs. While the xInstCount/xInst APIs are more convenient
  1.4286 +**   to use, this API may be faster under some circumstances. To iterate 
  1.4287 +**   through instances of phrase iPhrase, use the following code:
  1.4288 +**
  1.4289 +**       Fts5PhraseIter iter;
  1.4290 +**       int iCol, iOff;
  1.4291 +**       for(pApi->xPhraseFirst(pFts, iPhrase, &iter, &iCol, &iOff);
  1.4292 +**           iCol>=0;
  1.4293 +**           pApi->xPhraseNext(pFts, &iter, &iCol, &iOff)
  1.4294 +**       ){
  1.4295 +**         // An instance of phrase iPhrase at offset iOff of column iCol
  1.4296 +**       }
  1.4297 +**
  1.4298 +**   The Fts5PhraseIter structure is defined above. Applications should not
  1.4299 +**   modify this structure directly - it should only be used as shown above
  1.4300 +**   with the xPhraseFirst() and xPhraseNext() API methods (and by
  1.4301 +**   xPhraseFirstColumn() and xPhraseNextColumn() as illustrated below).
  1.4302 +**
  1.4303 +**   This API can be quite slow if used with an FTS5 table created with the
  1.4304 +**   "detail=none" or "detail=column" option. If the FTS5 table is created 
  1.4305 +**   with either "detail=none" or "detail=column" and "content=" option 
  1.4306 +**   (i.e. if it is a contentless table), then this API always iterates
  1.4307 +**   through an empty set (all calls to xPhraseFirst() set iCol to -1).
  1.4308 +**
  1.4309 +** xPhraseNext()
  1.4310 +**   See xPhraseFirst above.
  1.4311 +**
  1.4312 +** xPhraseFirstColumn()
  1.4313 +**   This function and xPhraseNextColumn() are similar to the xPhraseFirst()
  1.4314 +**   and xPhraseNext() APIs described above. The difference is that instead
  1.4315 +**   of iterating through all instances of a phrase in the current row, these
  1.4316 +**   APIs are used to iterate through the set of columns in the current row
  1.4317 +**   that contain one or more instances of a specified phrase. For example:
  1.4318 +**
  1.4319 +**       Fts5PhraseIter iter;
  1.4320 +**       int iCol;
  1.4321 +**       for(pApi->xPhraseFirstColumn(pFts, iPhrase, &iter, &iCol);
  1.4322 +**           iCol>=0;
  1.4323 +**           pApi->xPhraseNextColumn(pFts, &iter, &iCol)
  1.4324 +**       ){
  1.4325 +**         // Column iCol contains at least one instance of phrase iPhrase
  1.4326 +**       }
  1.4327 +**
  1.4328 +**   This API can be quite slow if used with an FTS5 table created with the
  1.4329 +**   "detail=none" option. If the FTS5 table is created with either 
  1.4330 +**   "detail=none" "content=" option (i.e. if it is a contentless table), 
  1.4331 +**   then this API always iterates through an empty set (all calls to 
  1.4332 +**   xPhraseFirstColumn() set iCol to -1).
  1.4333 +**
  1.4334 +**   The information accessed using this API and its companion
  1.4335 +**   xPhraseFirstColumn() may also be obtained using xPhraseFirst/xPhraseNext
  1.4336 +**   (or xInst/xInstCount). The chief advantage of this API is that it is
  1.4337 +**   significantly more efficient than those alternatives when used with
  1.4338 +**   "detail=column" tables.  
  1.4339 +**
  1.4340 +** xPhraseNextColumn()
  1.4341 +**   See xPhraseFirstColumn above.
  1.4342 +*/
  1.4343 +struct Fts5ExtensionApi {
  1.4344 +  int iVersion;                   /* Currently always set to 3 */
  1.4345 +
  1.4346 +  void *(*xUserData)(Fts5Context*);
  1.4347 +
  1.4348 +  int (*xColumnCount)(Fts5Context*);
  1.4349 +  int (*xRowCount)(Fts5Context*, sqlite3_int64 *pnRow);
  1.4350 +  int (*xColumnTotalSize)(Fts5Context*, int iCol, sqlite3_int64 *pnToken);
  1.4351 +
  1.4352 +  int (*xTokenize)(Fts5Context*, 
  1.4353 +    const char *pText, int nText, /* Text to tokenize */
  1.4354 +    void *pCtx,                   /* Context passed to xToken() */
  1.4355 +    int (*xToken)(void*, int, const char*, int, int, int)       /* Callback */
  1.4356 +  );
  1.4357 +
  1.4358 +  int (*xPhraseCount)(Fts5Context*);
  1.4359 +  int (*xPhraseSize)(Fts5Context*, int iPhrase);
  1.4360 +
  1.4361 +  int (*xInstCount)(Fts5Context*, int *pnInst);
  1.4362 +  int (*xInst)(Fts5Context*, int iIdx, int *piPhrase, int *piCol, int *piOff);
  1.4363 +
  1.4364 +  sqlite3_int64 (*xRowid)(Fts5Context*);
  1.4365 +  int (*xColumnText)(Fts5Context*, int iCol, const char **pz, int *pn);
  1.4366 +  int (*xColumnSize)(Fts5Context*, int iCol, int *pnToken);
  1.4367 +
  1.4368 +  int (*xQueryPhrase)(Fts5Context*, int iPhrase, void *pUserData,
  1.4369 +    int(*)(const Fts5ExtensionApi*,Fts5Context*,void*)
  1.4370 +  );
  1.4371 +  int (*xSetAuxdata)(Fts5Context*, void *pAux, void(*xDelete)(void*));
  1.4372 +  void *(*xGetAuxdata)(Fts5Context*, int bClear);
  1.4373 +
  1.4374 +  int (*xPhraseFirst)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*, int*);
  1.4375 +  void (*xPhraseNext)(Fts5Context*, Fts5PhraseIter*, int *piCol, int *piOff);
  1.4376 +
  1.4377 +  int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*);
  1.4378 +  void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol);
  1.4379 +};
  1.4380 +
  1.4381 +/* 
  1.4382 +** CUSTOM AUXILIARY FUNCTIONS
  1.4383 +*************************************************************************/
  1.4384 +
  1.4385 +/*************************************************************************
  1.4386 +** CUSTOM TOKENIZERS
  1.4387 +**
  1.4388 +** Applications may also register custom tokenizer types. A tokenizer 
  1.4389 +** is registered by providing fts5 with a populated instance of the 
  1.4390 +** following structure. All structure methods must be defined, setting
  1.4391 +** any member of the fts5_tokenizer struct to NULL leads to undefined
  1.4392 +** behaviour. The structure methods are expected to function as follows:
  1.4393 +**
  1.4394 +** xCreate:
  1.4395 +**   This function is used to allocate and inititalize a tokenizer instance.
  1.4396 +**   A tokenizer instance is required to actually tokenize text.
  1.4397 +**
  1.4398 +**   The first argument passed to this function is a copy of the (void*)
  1.4399 +**   pointer provided by the application when the fts5_tokenizer object
  1.4400 +**   was registered with FTS5 (the third argument to xCreateTokenizer()). 
  1.4401 +**   The second and third arguments are an array of nul-terminated strings
  1.4402 +**   containing the tokenizer arguments, if any, specified following the
  1.4403 +**   tokenizer name as part of the CREATE VIRTUAL TABLE statement used
  1.4404 +**   to create the FTS5 table.
  1.4405 +**
  1.4406 +**   The final argument is an output variable. If successful, (*ppOut) 
  1.4407 +**   should be set to point to the new tokenizer handle and SQLITE_OK
  1.4408 +**   returned. If an error occurs, some value other than SQLITE_OK should
  1.4409 +**   be returned. In this case, fts5 assumes that the final value of *ppOut 
  1.4410 +**   is undefined.
  1.4411 +**
  1.4412 +** xDelete:
  1.4413 +**   This function is invoked to delete a tokenizer handle previously
  1.4414 +**   allocated using xCreate(). Fts5 guarantees that this function will
  1.4415 +**   be invoked exactly once for each successful call to xCreate().
  1.4416 +**
  1.4417 +** xTokenize:
  1.4418 +**   This function is expected to tokenize the nText byte string indicated 
  1.4419 +**   by argument pText. pText may or may not be nul-terminated. The first
  1.4420 +**   argument passed to this function is a pointer to an Fts5Tokenizer object
  1.4421 +**   returned by an earlier call to xCreate().
  1.4422 +**
  1.4423 +**   The second argument indicates the reason that FTS5 is requesting
  1.4424 +**   tokenization of the supplied text. This is always one of the following
  1.4425 +**   four values:
  1.4426 +**
  1.4427 +**   <ul><li> <b>FTS5_TOKENIZE_DOCUMENT</b> - A document is being inserted into
  1.4428 +**            or removed from the FTS table. The tokenizer is being invoked to
  1.4429 +**            determine the set of tokens to add to (or delete from) the
  1.4430 +**            FTS index.
  1.4431 +**
  1.4432 +**       <li> <b>FTS5_TOKENIZE_QUERY</b> - A MATCH query is being executed 
  1.4433 +**            against the FTS index. The tokenizer is being called to tokenize 
  1.4434 +**            a bareword or quoted string specified as part of the query.
  1.4435 +**
  1.4436 +**       <li> <b>(FTS5_TOKENIZE_QUERY | FTS5_TOKENIZE_PREFIX)</b> - Same as
  1.4437 +**            FTS5_TOKENIZE_QUERY, except that the bareword or quoted string is
  1.4438 +**            followed by a "*" character, indicating that the last token
  1.4439 +**            returned by the tokenizer will be treated as a token prefix.
  1.4440 +**
  1.4441 +**       <li> <b>FTS5_TOKENIZE_AUX</b> - The tokenizer is being invoked to 
  1.4442 +**            satisfy an fts5_api.xTokenize() request made by an auxiliary
  1.4443 +**            function. Or an fts5_api.xColumnSize() request made by the same
  1.4444 +**            on a columnsize=0 database.  
  1.4445 +**   </ul>
  1.4446 +**
  1.4447 +**   For each token in the input string, the supplied callback xToken() must
  1.4448 +**   be invoked. The first argument to it should be a copy of the pointer
  1.4449 +**   passed as the second argument to xTokenize(). The third and fourth
  1.4450 +**   arguments are a pointer to a buffer containing the token text, and the
  1.4451 +**   size of the token in bytes. The 4th and 5th arguments are the byte offsets
  1.4452 +**   of the first byte of and first byte immediately following the text from
  1.4453 +**   which the token is derived within the input.
  1.4454 +**
  1.4455 +**   The second argument passed to the xToken() callback ("tflags") should
  1.4456 +**   normally be set to 0. The exception is if the tokenizer supports 
  1.4457 +**   synonyms. In this case see the discussion below for details.
  1.4458 +**
  1.4459 +**   FTS5 assumes the xToken() callback is invoked for each token in the 
  1.4460 +**   order that they occur within the input text.
  1.4461 +**
  1.4462 +**   If an xToken() callback returns any value other than SQLITE_OK, then
  1.4463 +**   the tokenization should be abandoned and the xTokenize() method should
  1.4464 +**   immediately return a copy of the xToken() return value. Or, if the
  1.4465 +**   input buffer is exhausted, xTokenize() should return SQLITE_OK. Finally,
  1.4466 +**   if an error occurs with the xTokenize() implementation itself, it
  1.4467 +**   may abandon the tokenization and return any error code other than
  1.4468 +**   SQLITE_OK or SQLITE_DONE.
  1.4469 +**
  1.4470 +** SYNONYM SUPPORT
  1.4471 +**
  1.4472 +**   Custom tokenizers may also support synonyms. Consider a case in which a
  1.4473 +**   user wishes to query for a phrase such as "first place". Using the 
  1.4474 +**   built-in tokenizers, the FTS5 query 'first + place' will match instances
  1.4475 +**   of "first place" within the document set, but not alternative forms
  1.4476 +**   such as "1st place". In some applications, it would be better to match
  1.4477 +**   all instances of "first place" or "1st place" regardless of which form
  1.4478 +**   the user specified in the MATCH query text.
  1.4479 +**
  1.4480 +**   There are several ways to approach this in FTS5:
  1.4481 +**
  1.4482 +**   <ol><li> By mapping all synonyms to a single token. In this case, the 
  1.4483 +**            In the above example, this means that the tokenizer returns the
  1.4484 +**            same token for inputs "first" and "1st". Say that token is in
  1.4485 +**            fact "first", so that when the user inserts the document "I won
  1.4486 +**            1st place" entries are added to the index for tokens "i", "won",
  1.4487 +**            "first" and "place". If the user then queries for '1st + place',
  1.4488 +**            the tokenizer substitutes "first" for "1st" and the query works
  1.4489 +**            as expected.
  1.4490 +**
  1.4491 +**       <li> By adding multiple synonyms for a single term to the FTS index.
  1.4492 +**            In this case, when tokenizing query text, the tokenizer may 
  1.4493 +**            provide multiple synonyms for a single term within the document.
  1.4494 +**            FTS5 then queries the index for each synonym individually. For
  1.4495 +**            example, faced with the query:
  1.4496 +**
  1.4497 +**   <codeblock>
  1.4498 +**     ... MATCH 'first place'</codeblock>
  1.4499 +**
  1.4500 +**            the tokenizer offers both "1st" and "first" as synonyms for the
  1.4501 +**            first token in the MATCH query and FTS5 effectively runs a query 
  1.4502 +**            similar to:
  1.4503 +**
  1.4504 +**   <codeblock>
  1.4505 +**     ... MATCH '(first OR 1st) place'</codeblock>
  1.4506 +**
  1.4507 +**            except that, for the purposes of auxiliary functions, the query
  1.4508 +**            still appears to contain just two phrases - "(first OR 1st)" 
  1.4509 +**            being treated as a single phrase.
  1.4510 +**
  1.4511 +**       <li> By adding multiple synonyms for a single term to the FTS index.
  1.4512 +**            Using this method, when tokenizing document text, the tokenizer
  1.4513 +**            provides multiple synonyms for each token. So that when a 
  1.4514 +**            document such as "I won first place" is tokenized, entries are
  1.4515 +**            added to the FTS index for "i", "won", "first", "1st" and
  1.4516 +**            "place".
  1.4517 +**
  1.4518 +**            This way, even if the tokenizer does not provide synonyms
  1.4519 +**            when tokenizing query text (it should not - to do would be
  1.4520 +**            inefficient), it doesn't matter if the user queries for 
  1.4521 +**            'first + place' or '1st + place', as there are entires in the
  1.4522 +**            FTS index corresponding to both forms of the first token.
  1.4523 +**   </ol>
  1.4524 +**
  1.4525 +**   Whether it is parsing document or query text, any call to xToken that
  1.4526 +**   specifies a <i>tflags</i> argument with the FTS5_TOKEN_COLOCATED bit
  1.4527 +**   is considered to supply a synonym for the previous token. For example,
  1.4528 +**   when parsing the document "I won first place", a tokenizer that supports
  1.4529 +**   synonyms would call xToken() 5 times, as follows:
  1.4530 +**
  1.4531 +**   <codeblock>
  1.4532 +**       xToken(pCtx, 0, "i",                      1,  0,  1);
  1.4533 +**       xToken(pCtx, 0, "won",                    3,  2,  5);
  1.4534 +**       xToken(pCtx, 0, "first",                  5,  6, 11);
  1.4535 +**       xToken(pCtx, FTS5_TOKEN_COLOCATED, "1st", 3,  6, 11);
  1.4536 +**       xToken(pCtx, 0, "place",                  5, 12, 17);
  1.4537 +**</codeblock>
  1.4538 +**
  1.4539 +**   It is an error to specify the FTS5_TOKEN_COLOCATED flag the first time
  1.4540 +**   xToken() is called. Multiple synonyms may be specified for a single token
  1.4541 +**   by making multiple calls to xToken(FTS5_TOKEN_COLOCATED) in sequence. 
  1.4542 +**   There is no limit to the number of synonyms that may be provided for a
  1.4543 +**   single token.
  1.4544 +**
  1.4545 +**   In many cases, method (1) above is the best approach. It does not add 
  1.4546 +**   extra data to the FTS index or require FTS5 to query for multiple terms,
  1.4547 +**   so it is efficient in terms of disk space and query speed. However, it
  1.4548 +**   does not support prefix queries very well. If, as suggested above, the
  1.4549 +**   token "first" is subsituted for "1st" by the tokenizer, then the query:
  1.4550 +**
  1.4551 +**   <codeblock>
  1.4552 +**     ... MATCH '1s*'</codeblock>
  1.4553 +**
  1.4554 +**   will not match documents that contain the token "1st" (as the tokenizer
  1.4555 +**   will probably not map "1s" to any prefix of "first").
  1.4556 +**
  1.4557 +**   For full prefix support, method (3) may be preferred. In this case, 
  1.4558 +**   because the index contains entries for both "first" and "1st", prefix
  1.4559 +**   queries such as 'fi*' or '1s*' will match correctly. However, because
  1.4560 +**   extra entries are added to the FTS index, this method uses more space
  1.4561 +**   within the database.
  1.4562 +**
  1.4563 +**   Method (2) offers a midpoint between (1) and (3). Using this method,
  1.4564 +**   a query such as '1s*' will match documents that contain the literal 
  1.4565 +**   token "1st", but not "first" (assuming the tokenizer is not able to
  1.4566 +**   provide synonyms for prefixes). However, a non-prefix query like '1st'
  1.4567 +**   will match against "1st" and "first". This method does not require
  1.4568 +**   extra disk space, as no extra entries are added to the FTS index. 
  1.4569 +**   On the other hand, it may require more CPU cycles to run MATCH queries,
  1.4570 +**   as separate queries of the FTS index are required for each synonym.
  1.4571 +**
  1.4572 +**   When using methods (2) or (3), it is important that the tokenizer only
  1.4573 +**   provide synonyms when tokenizing document text (method (2)) or query
  1.4574 +**   text (method (3)), not both. Doing so will not cause any errors, but is
  1.4575 +**   inefficient.
  1.4576 +*/
  1.4577 +typedef struct Fts5Tokenizer Fts5Tokenizer;
  1.4578 +typedef struct fts5_tokenizer fts5_tokenizer;
  1.4579 +struct fts5_tokenizer {
  1.4580 +  int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut);
  1.4581 +  void (*xDelete)(Fts5Tokenizer*);
  1.4582 +  int (*xTokenize)(Fts5Tokenizer*, 
  1.4583 +      void *pCtx,
  1.4584 +      int flags,            /* Mask of FTS5_TOKENIZE_* flags */
  1.4585 +      const char *pText, int nText, 
  1.4586 +      int (*xToken)(
  1.4587 +        void *pCtx,         /* Copy of 2nd argument to xTokenize() */
  1.4588 +        int tflags,         /* Mask of FTS5_TOKEN_* flags */
  1.4589 +        const char *pToken, /* Pointer to buffer containing token */
  1.4590 +        int nToken,         /* Size of token in bytes */
  1.4591 +        int iStart,         /* Byte offset of token within input text */
  1.4592 +        int iEnd            /* Byte offset of end of token within input text */
  1.4593 +      )
  1.4594 +  );
  1.4595 +};
  1.4596 +
  1.4597 +/* Flags that may be passed as the third argument to xTokenize() */
  1.4598 +#define FTS5_TOKENIZE_QUERY     0x0001
  1.4599 +#define FTS5_TOKENIZE_PREFIX    0x0002
  1.4600 +#define FTS5_TOKENIZE_DOCUMENT  0x0004
  1.4601 +#define FTS5_TOKENIZE_AUX       0x0008
  1.4602 +
  1.4603 +/* Flags that may be passed by the tokenizer implementation back to FTS5
  1.4604 +** as the third argument to the supplied xToken callback. */
  1.4605 +#define FTS5_TOKEN_COLOCATED    0x0001      /* Same position as prev. token */
  1.4606 +
  1.4607 +/*
  1.4608 +** END OF CUSTOM TOKENIZERS
  1.4609 +*************************************************************************/
  1.4610 +
  1.4611 +/*************************************************************************
  1.4612 +** FTS5 EXTENSION REGISTRATION API
  1.4613 +*/
  1.4614 +typedef struct fts5_api fts5_api;
  1.4615 +struct fts5_api {
  1.4616 +  int iVersion;                   /* Currently always set to 2 */
  1.4617 +
  1.4618 +  /* Create a new tokenizer */
  1.4619 +  int (*xCreateTokenizer)(
  1.4620 +    fts5_api *pApi,
  1.4621 +    const char *zName,
  1.4622 +    void *pContext,
  1.4623 +    fts5_tokenizer *pTokenizer,
  1.4624 +    void (*xDestroy)(void*)
  1.4625 +  );
  1.4626 +
  1.4627 +  /* Find an existing tokenizer */
  1.4628 +  int (*xFindTokenizer)(
  1.4629 +    fts5_api *pApi,
  1.4630 +    const char *zName,
  1.4631 +    void **ppContext,
  1.4632 +    fts5_tokenizer *pTokenizer
  1.4633 +  );
  1.4634 +
  1.4635 +  /* Create a new auxiliary function */
  1.4636 +  int (*xCreateFunction)(
  1.4637 +    fts5_api *pApi,
  1.4638 +    const char *zName,
  1.4639 +    void *pContext,
  1.4640 +    fts5_extension_function xFunction,
  1.4641 +    void (*xDestroy)(void*)
  1.4642 +  );
  1.4643 +};
  1.4644 +
  1.4645 +/*
  1.4646 +** END OF REGISTRATION API
  1.4647 +*************************************************************************/
  1.4648 +
  1.4649 +#if 0
  1.4650 +}  /* end of the 'extern "C"' block */
  1.4651 +#endif
  1.4652 +
  1.4653 +#endif /* _FTS5_H */
  1.4654 +
  1.4655 +
  1.4656  
  1.4657  /************** End of sqlite3.h *********************************************/
  1.4658  /************** Continuing where we left off in sqliteInt.h ******************/
  1.4659 @@ -7721,15 +9017,17 @@
  1.4660  #endif
  1.4661  
  1.4662  /*
  1.4663 -** The maximum number of in-memory pages to use for the main database
  1.4664 -** table and for temporary tables.  The SQLITE_DEFAULT_CACHE_SIZE
  1.4665 +** The suggested maximum number of in-memory pages to use for
  1.4666 +** the main database table and for temporary tables.
  1.4667 +**
  1.4668 +** IMPLEMENTATION-OF: R-31093-59126 The default suggested cache size
  1.4669 +** is 2000 pages.
  1.4670 +** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be
  1.4671 +** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options.
  1.4672  */
  1.4673  #ifndef SQLITE_DEFAULT_CACHE_SIZE
  1.4674  # define SQLITE_DEFAULT_CACHE_SIZE  2000
  1.4675  #endif
  1.4676 -#ifndef SQLITE_DEFAULT_TEMP_CACHE_SIZE
  1.4677 -# define SQLITE_DEFAULT_TEMP_CACHE_SIZE  500
  1.4678 -#endif
  1.4679  
  1.4680  /*
  1.4681  ** The default number of frames to accumulate in the log file before
  1.4682 @@ -7842,15 +9140,6 @@
  1.4683  #pragma warn -spa /* Suspicious pointer arithmetic */
  1.4684  #endif
  1.4685  
  1.4686 -/* Needed for various definitions... */
  1.4687 -#ifndef _GNU_SOURCE
  1.4688 -# define _GNU_SOURCE
  1.4689 -#endif
  1.4690 -
  1.4691 -#if defined(__OpenBSD__) && !defined(_BSD_SOURCE)
  1.4692 -# define _BSD_SOURCE
  1.4693 -#endif
  1.4694 -
  1.4695  /*
  1.4696  ** Include standard header files as necessary
  1.4697  */
  1.4698 @@ -7892,6 +9181,51 @@
  1.4699  #endif
  1.4700  
  1.4701  /*
  1.4702 +** The SQLITE_WITHIN(P,S,E) macro checks to see if pointer P points to
  1.4703 +** something between S (inclusive) and E (exclusive).
  1.4704 +**
  1.4705 +** In other words, S is a buffer and E is a pointer to the first byte after
  1.4706 +** the end of buffer S.  This macro returns true if P points to something
  1.4707 +** contained within the buffer S.
  1.4708 +*/
  1.4709 +#if defined(HAVE_STDINT_H)
  1.4710 +# define SQLITE_WITHIN(P,S,E) \
  1.4711 +    ((uintptr_t)(P)>=(uintptr_t)(S) && (uintptr_t)(P)<(uintptr_t)(E))
  1.4712 +#else
  1.4713 +# define SQLITE_WITHIN(P,S,E) ((P)>=(S) && (P)<(E))
  1.4714 +#endif
  1.4715 +
  1.4716 +/*
  1.4717 +** A macro to hint to the compiler that a function should not be
  1.4718 +** inlined.
  1.4719 +*/
  1.4720 +#if defined(__GNUC__)
  1.4721 +#  define SQLITE_NOINLINE  __attribute__((noinline))
  1.4722 +#elif defined(_MSC_VER) && _MSC_VER>=1310
  1.4723 +#  define SQLITE_NOINLINE  __declspec(noinline)
  1.4724 +#else
  1.4725 +#  define SQLITE_NOINLINE
  1.4726 +#endif
  1.4727 +
  1.4728 +/*
  1.4729 +** Make sure that the compiler intrinsics we desire are enabled when
  1.4730 +** compiling with an appropriate version of MSVC unless prevented by
  1.4731 +** the SQLITE_DISABLE_INTRINSIC define.
  1.4732 +*/
  1.4733 +#if !defined(SQLITE_DISABLE_INTRINSIC)
  1.4734 +#  if defined(_MSC_VER) && _MSC_VER>=1300
  1.4735 +#    if !defined(_WIN32_WCE)
  1.4736 +#      include <intrin.h>
  1.4737 +#      pragma intrinsic(_byteswap_ushort)
  1.4738 +#      pragma intrinsic(_byteswap_ulong)
  1.4739 +#      pragma intrinsic(_ReadWriteBarrier)
  1.4740 +#    else
  1.4741 +#      include <cmnintrin.h>
  1.4742 +#    endif
  1.4743 +#  endif
  1.4744 +#endif
  1.4745 +
  1.4746 +/*
  1.4747  ** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2.
  1.4748  ** 0 means mutexes are permanently disable and the library is never
  1.4749  ** threadsafe.  1 means the library is serialized which is the highest
  1.4750 @@ -7919,10 +9253,9 @@
  1.4751  #endif
  1.4752  
  1.4753  /*
  1.4754 -** The SQLITE_DEFAULT_MEMSTATUS macro must be defined as either 0 or 1.
  1.4755 -** It determines whether or not the features related to 
  1.4756 -** SQLITE_CONFIG_MEMSTATUS are available by default or not. This value can
  1.4757 -** be overridden at runtime using the sqlite3_config() API.
  1.4758 +** EVIDENCE-OF: R-25715-37072 Memory allocation statistics are enabled by
  1.4759 +** default unless SQLite is compiled with SQLITE_DEFAULT_MEMSTATUS=0 in
  1.4760 +** which case memory allocation statistics are disabled by default.
  1.4761  */
  1.4762  #if !defined(SQLITE_DEFAULT_MEMSTATUS)
  1.4763  # define SQLITE_DEFAULT_MEMSTATUS 1
  1.4764 @@ -8077,7 +9410,48 @@
  1.4765  #endif
  1.4766  
  1.4767  /*
  1.4768 -** Return true (non-zero) if the input is a integer that is too large
  1.4769 +** Some malloc failures are only possible if SQLITE_TEST_REALLOC_STRESS is
  1.4770 +** defined.  We need to defend against those failures when testing with
  1.4771 +** SQLITE_TEST_REALLOC_STRESS, but we don't want the unreachable branches
  1.4772 +** during a normal build.  The following macro can be used to disable tests
  1.4773 +** that are always false except when SQLITE_TEST_REALLOC_STRESS is set.
  1.4774 +*/
  1.4775 +#if defined(SQLITE_TEST_REALLOC_STRESS)
  1.4776 +# define ONLY_IF_REALLOC_STRESS(X)  (X)
  1.4777 +#elif !defined(NDEBUG)
  1.4778 +# define ONLY_IF_REALLOC_STRESS(X)  ((X)?(assert(0),1):0)
  1.4779 +#else
  1.4780 +# define ONLY_IF_REALLOC_STRESS(X)  (0)
  1.4781 +#endif
  1.4782 +
  1.4783 +/*
  1.4784 +** Declarations used for tracing the operating system interfaces.
  1.4785 +*/
  1.4786 +#if defined(SQLITE_FORCE_OS_TRACE) || defined(SQLITE_TEST) || \
  1.4787 +    (defined(SQLITE_DEBUG) && SQLITE_OS_WIN)
  1.4788 +  extern int sqlite3OSTrace;
  1.4789 +# define OSTRACE(X)          if( sqlite3OSTrace ) sqlite3DebugPrintf X
  1.4790 +# define SQLITE_HAVE_OS_TRACE
  1.4791 +#else
  1.4792 +# define OSTRACE(X)
  1.4793 +# undef  SQLITE_HAVE_OS_TRACE
  1.4794 +#endif
  1.4795 +
  1.4796 +/*
  1.4797 +** Is the sqlite3ErrName() function needed in the build?  Currently,
  1.4798 +** it is needed by "mutex_w32.c" (when debugging), "os_win.c" (when
  1.4799 +** OSTRACE is enabled), and by several "test*.c" files (which are
  1.4800 +** compiled using SQLITE_TEST).
  1.4801 +*/
  1.4802 +#if defined(SQLITE_HAVE_OS_TRACE) || defined(SQLITE_TEST) || \
  1.4803 +    (defined(SQLITE_DEBUG) && SQLITE_OS_WIN)
  1.4804 +# define SQLITE_NEED_ERR_NAME
  1.4805 +#else
  1.4806 +# undef  SQLITE_NEED_ERR_NAME
  1.4807 +#endif
  1.4808 +
  1.4809 +/*
  1.4810 +** Return true (non-zero) if the input is an integer that is too large
  1.4811  ** to fit in 32-bits.  This macro is used inside of various testcase()
  1.4812  ** macros to verify that we have tested SQLite for large-file support.
  1.4813  */
  1.4814 @@ -8156,15 +9530,15 @@
  1.4815  struct HashElem {
  1.4816    HashElem *next, *prev;       /* Next and previous elements in the table */
  1.4817    void *data;                  /* Data associated with this element */
  1.4818 -  const char *pKey; int nKey;  /* Key associated with this element */
  1.4819 +  const char *pKey;            /* Key associated with this element */
  1.4820  };
  1.4821  
  1.4822  /*
  1.4823  ** Access routines.  To delete, insert a NULL pointer.
  1.4824  */
  1.4825  SQLITE_PRIVATE void sqlite3HashInit(Hash*);
  1.4826 -SQLITE_PRIVATE void *sqlite3HashInsert(Hash*, const char *pKey, int nKey, void *pData);
  1.4827 -SQLITE_PRIVATE void *sqlite3HashFind(const Hash*, const char *pKey, int nKey);
  1.4828 +SQLITE_PRIVATE void *sqlite3HashInsert(Hash*, const char *pKey, void *pData);
  1.4829 +SQLITE_PRIVATE void *sqlite3HashFind(const Hash*, const char *pKey);
  1.4830  SQLITE_PRIVATE void sqlite3HashClear(Hash*);
  1.4831  
  1.4832  /*
  1.4833 @@ -8345,16 +9719,24 @@
  1.4834  #define TK_TO_REAL                        147
  1.4835  #define TK_ISNOT                          148
  1.4836  #define TK_END_OF_FILE                    149
  1.4837 -#define TK_ILLEGAL                        150
  1.4838 -#define TK_SPACE                          151
  1.4839 -#define TK_UNCLOSED_STRING                152
  1.4840 -#define TK_FUNCTION                       153
  1.4841 -#define TK_COLUMN                         154
  1.4842 -#define TK_AGG_FUNCTION                   155
  1.4843 -#define TK_AGG_COLUMN                     156
  1.4844 -#define TK_UMINUS                         157
  1.4845 -#define TK_UPLUS                          158
  1.4846 -#define TK_REGISTER                       159
  1.4847 +#define TK_UNCLOSED_STRING                150
  1.4848 +#define TK_FUNCTION                       151
  1.4849 +#define TK_COLUMN                         152
  1.4850 +#define TK_AGG_FUNCTION                   153
  1.4851 +#define TK_AGG_COLUMN                     154
  1.4852 +#define TK_UMINUS                         155
  1.4853 +#define TK_UPLUS                          156
  1.4854 +#define TK_REGISTER                       157
  1.4855 +#define TK_ASTERISK                       158
  1.4856 +#define TK_SPACE                          159
  1.4857 +#define TK_ILLEGAL                        160
  1.4858 +
  1.4859 +/* The token codes above must all fit in 8 bits */
  1.4860 +#define TKFLG_MASK           0xff  
  1.4861 +
  1.4862 +/* Flags that can be added to a token code when it is not
  1.4863 +** being stored in a u8: */
  1.4864 +#define TKFLG_DONTFOLD       0x100  /* Omit constant folding optimizations */
  1.4865  
  1.4866  /************** End of parse.h ***********************************************/
  1.4867  /************** Continuing where we left off in sqliteInt.h ******************/
  1.4868 @@ -8424,6 +9806,36 @@
  1.4869  #endif
  1.4870  
  1.4871  /*
  1.4872 +** If no value has been provided for SQLITE_MAX_WORKER_THREADS, or if
  1.4873 +** SQLITE_TEMP_STORE is set to 3 (never use temporary files), set it 
  1.4874 +** to zero.
  1.4875 +*/
  1.4876 +#if SQLITE_TEMP_STORE==3 || SQLITE_THREADSAFE==0
  1.4877 +# undef SQLITE_MAX_WORKER_THREADS
  1.4878 +# define SQLITE_MAX_WORKER_THREADS 0
  1.4879 +#endif
  1.4880 +#ifndef SQLITE_MAX_WORKER_THREADS
  1.4881 +# define SQLITE_MAX_WORKER_THREADS 8
  1.4882 +#endif
  1.4883 +#ifndef SQLITE_DEFAULT_WORKER_THREADS
  1.4884 +# define SQLITE_DEFAULT_WORKER_THREADS 0
  1.4885 +#endif
  1.4886 +#if SQLITE_DEFAULT_WORKER_THREADS>SQLITE_MAX_WORKER_THREADS
  1.4887 +# undef SQLITE_MAX_WORKER_THREADS
  1.4888 +# define SQLITE_MAX_WORKER_THREADS SQLITE_DEFAULT_WORKER_THREADS
  1.4889 +#endif
  1.4890 +
  1.4891 +/*
  1.4892 +** The default initial allocation for the pagecache when using separate
  1.4893 +** pagecaches for each database connection.  A positive number is the
  1.4894 +** number of pages.  A negative number N translations means that a buffer
  1.4895 +** of -1024*N bytes is allocated and used for as many pages as it will hold.
  1.4896 +*/
  1.4897 +#ifndef SQLITE_DEFAULT_PCACHE_INITSZ
  1.4898 +# define SQLITE_DEFAULT_PCACHE_INITSZ 100
  1.4899 +#endif
  1.4900 +
  1.4901 +/*
  1.4902  ** GCC does not define the offsetof() macro so we'll have to do it
  1.4903  ** ourselves.
  1.4904  */
  1.4905 @@ -8438,6 +9850,11 @@
  1.4906  #define MAX(A,B) ((A)>(B)?(A):(B))
  1.4907  
  1.4908  /*
  1.4909 +** Swap two objects of type TYPE.
  1.4910 +*/
  1.4911 +#define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;}
  1.4912 +
  1.4913 +/*
  1.4914  ** Check to see if this machine uses EBCDIC.  (Yes, believe it or
  1.4915  ** not, there are still machines out there that use EBCDIC.)
  1.4916  */
  1.4917 @@ -8526,7 +9943,7 @@
  1.4918  ** gives a possible range of values of approximately 1.0e986 to 1e-986.
  1.4919  ** But the allowed values are "grainy".  Not every value is representable.
  1.4920  ** For example, quantities 16 and 17 are both represented by a LogEst
  1.4921 -** of 40.  However, since LogEst quantaties are suppose to be estimates,
  1.4922 +** of 40.  However, since LogEst quantities are suppose to be estimates,
  1.4923  ** not exact values, this imprecision is not a problem.
  1.4924  **
  1.4925  ** "LogEst" is short for "Logarithmic Estimate".
  1.4926 @@ -8546,6 +9963,20 @@
  1.4927  typedef INT16_TYPE LogEst;
  1.4928  
  1.4929  /*
  1.4930 +** Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer
  1.4931 +*/
  1.4932 +#ifndef SQLITE_PTRSIZE
  1.4933 +# if defined(__SIZEOF_POINTER__)
  1.4934 +#   define SQLITE_PTRSIZE __SIZEOF_POINTER__
  1.4935 +# elif defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \
  1.4936 +       defined(_M_ARM)   || defined(__arm__)    || defined(__x86)
  1.4937 +#   define SQLITE_PTRSIZE 4
  1.4938 +# else
  1.4939 +#   define SQLITE_PTRSIZE 8
  1.4940 +# endif
  1.4941 +#endif
  1.4942 +
  1.4943 +/*
  1.4944  ** Macros to determine whether the machine is big or little endian,
  1.4945  ** and whether or not that determination is run-time or compile-time.
  1.4946  **
  1.4947 @@ -8554,11 +9985,6 @@
  1.4948  ** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined
  1.4949  ** at run-time.
  1.4950  */
  1.4951 -#ifdef SQLITE_AMALGAMATION
  1.4952 -SQLITE_PRIVATE const int sqlite3one = 1;
  1.4953 -#else
  1.4954 -SQLITE_PRIVATE const int sqlite3one;
  1.4955 -#endif
  1.4956  #if (defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \
  1.4957       defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)  ||    \
  1.4958       defined(_M_AMD64) || defined(_M_ARM)     || defined(__x86)   ||    \
  1.4959 @@ -8576,6 +10002,11 @@
  1.4960  # define SQLITE_UTF16NATIVE  SQLITE_UTF16BE
  1.4961  #endif
  1.4962  #if !defined(SQLITE_BYTEORDER)
  1.4963 +# ifdef SQLITE_AMALGAMATION
  1.4964 +  const int sqlite3one = 1;
  1.4965 +# else
  1.4966 +  extern const int sqlite3one;
  1.4967 +# endif
  1.4968  # define SQLITE_BYTEORDER    0     /* 0 means "unknown at compile-time" */
  1.4969  # define SQLITE_BIGENDIAN    (*(char *)(&sqlite3one)==0)
  1.4970  # define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1)
  1.4971 @@ -8607,7 +10038,7 @@
  1.4972  ** all alignment restrictions correct.
  1.4973  **
  1.4974  ** Except, if SQLITE_4_BYTE_ALIGNED_MALLOC is defined, then the
  1.4975 -** underlying malloc() implemention might return us 4-byte aligned
  1.4976 +** underlying malloc() implementation might return us 4-byte aligned
  1.4977  ** pointers.  In that case, only verify 4-byte alignment.
  1.4978  */
  1.4979  #ifdef SQLITE_4_BYTE_ALIGNED_MALLOC
  1.4980 @@ -8629,16 +10060,14 @@
  1.4981  */
  1.4982  #ifdef __APPLE__
  1.4983  # include <TargetConditionals.h>
  1.4984 -# if TARGET_OS_IPHONE
  1.4985 -#   undef SQLITE_MAX_MMAP_SIZE
  1.4986 -#   define SQLITE_MAX_MMAP_SIZE 0
  1.4987 -# endif
  1.4988  #endif
  1.4989  #ifndef SQLITE_MAX_MMAP_SIZE
  1.4990  # if defined(__linux__) \
  1.4991    || defined(_WIN32) \
  1.4992    || (defined(__APPLE__) && defined(__MACH__)) \
  1.4993 -  || defined(__sun)
  1.4994 +  || defined(__sun) \
  1.4995 +  || defined(__FreeBSD__) \
  1.4996 +  || defined(__DragonFly__)
  1.4997  #   define SQLITE_MAX_MMAP_SIZE 0x7fff0000  /* 2147418112 */
  1.4998  # else
  1.4999  #   define SQLITE_MAX_MMAP_SIZE 0
  1.5000 @@ -8675,6 +10104,16 @@
  1.5001  #endif
  1.5002  
  1.5003  /*
  1.5004 +** SELECTTRACE_ENABLED will be either 1 or 0 depending on whether or not
  1.5005 +** the Select query generator tracing logic is turned on.
  1.5006 +*/
  1.5007 +#if defined(SQLITE_DEBUG) || defined(SQLITE_ENABLE_SELECTTRACE)
  1.5008 +# define SELECTTRACE_ENABLED 1
  1.5009 +#else
  1.5010 +# define SELECTTRACE_ENABLED 0
  1.5011 +#endif
  1.5012 +
  1.5013 +/*
  1.5014  ** An instance of the following structure is used to store the busy-handler
  1.5015  ** callback for a given sqlite handle. 
  1.5016  **
  1.5017 @@ -8747,8 +10186,8 @@
  1.5018    #define SQLITE_WSD const
  1.5019    #define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v)))
  1.5020    #define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config)
  1.5021 -SQLITE_API   int sqlite3_wsd_init(int N, int J);
  1.5022 -SQLITE_API   void *sqlite3_wsd_find(void *K, int L);
  1.5023 +SQLITE_API int SQLITE_STDCALL sqlite3_wsd_init(int N, int J);
  1.5024 +SQLITE_API void *SQLITE_STDCALL sqlite3_wsd_find(void *K, int L);
  1.5025  #else
  1.5026    #define SQLITE_WSD 
  1.5027    #define GLOBAL(t,v) v
  1.5028 @@ -8806,12 +10245,14 @@
  1.5029  typedef struct RowSet RowSet;
  1.5030  typedef struct Savepoint Savepoint;
  1.5031  typedef struct Select Select;
  1.5032 +typedef struct SQLiteThread SQLiteThread;
  1.5033  typedef struct SelectDest SelectDest;
  1.5034  typedef struct SrcList SrcList;
  1.5035  typedef struct StrAccum StrAccum;
  1.5036  typedef struct Table Table;
  1.5037  typedef struct TableLock TableLock;
  1.5038  typedef struct Token Token;
  1.5039 +typedef struct TreeView TreeView;
  1.5040  typedef struct Trigger Trigger;
  1.5041  typedef struct TriggerPrg TriggerPrg;
  1.5042  typedef struct TriggerStep TriggerStep;
  1.5043 @@ -8850,7 +10291,7 @@
  1.5044  /* TODO: This definition is just included so other modules compile. It
  1.5045  ** needs to be revisited.
  1.5046  */
  1.5047 -#define SQLITE_N_BTREE_META 10
  1.5048 +#define SQLITE_N_BTREE_META 16
  1.5049  
  1.5050  /*
  1.5051  ** If defined as non-zero, auto-vacuum is enabled by default. Otherwise
  1.5052 @@ -8894,6 +10335,7 @@
  1.5053  
  1.5054  SQLITE_PRIVATE int sqlite3BtreeClose(Btree*);
  1.5055  SQLITE_PRIVATE int sqlite3BtreeSetCacheSize(Btree*,int);
  1.5056 +SQLITE_PRIVATE int sqlite3BtreeSetSpillSize(Btree*,int);
  1.5057  #if SQLITE_MAX_MMAP_SIZE>0
  1.5058  SQLITE_PRIVATE   int sqlite3BtreeSetMmapLimit(Btree*,sqlite3_int64);
  1.5059  #endif
  1.5060 @@ -8904,17 +10346,15 @@
  1.5061  SQLITE_PRIVATE int sqlite3BtreeMaxPageCount(Btree*,int);
  1.5062  SQLITE_PRIVATE u32 sqlite3BtreeLastPage(Btree*);
  1.5063  SQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree*,int);
  1.5064 -SQLITE_PRIVATE int sqlite3BtreeGetReserve(Btree*);
  1.5065 -#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_DEBUG)
  1.5066 +SQLITE_PRIVATE int sqlite3BtreeGetOptimalReserve(Btree*);
  1.5067  SQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p);
  1.5068 -#endif
  1.5069  SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *, int);
  1.5070  SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *);
  1.5071  SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree*,int);
  1.5072  SQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);
  1.5073  SQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree*, int);
  1.5074  SQLITE_PRIVATE int sqlite3BtreeCommit(Btree*);
  1.5075 -SQLITE_PRIVATE int sqlite3BtreeRollback(Btree*,int);
  1.5076 +SQLITE_PRIVATE int sqlite3BtreeRollback(Btree*,int,int);
  1.5077  SQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree*,int);
  1.5078  SQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree*, int*, int flags);
  1.5079  SQLITE_PRIVATE int sqlite3BtreeIsInTrans(Btree*);
  1.5080 @@ -8947,7 +10387,7 @@
  1.5081  SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree*, int, int*);
  1.5082  SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree*, int, int*);
  1.5083  SQLITE_PRIVATE int sqlite3BtreeClearTableOfCursor(BtCursor*);
  1.5084 -SQLITE_PRIVATE void sqlite3BtreeTripAllCursors(Btree*, int);
  1.5085 +SQLITE_PRIVATE int sqlite3BtreeTripAllCursors(Btree*, int, int);
  1.5086  
  1.5087  SQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue);
  1.5088  SQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
  1.5089 @@ -8965,6 +10405,11 @@
  1.5090  ** For example, the free-page-count field is located at byte offset 36 of
  1.5091  ** the database file header. The incr-vacuum-flag field is located at
  1.5092  ** byte offset 64 (== 36+4*7).
  1.5093 +**
  1.5094 +** The BTREE_DATA_VERSION value is not really a value stored in the header.
  1.5095 +** It is a read-only number computed by the pager.  But we merge it with
  1.5096 +** the header value access routines since its access pattern is the same.
  1.5097 +** Call it a "virtual meta value".
  1.5098  */
  1.5099  #define BTREE_FREE_PAGE_COUNT     0
  1.5100  #define BTREE_SCHEMA_VERSION      1
  1.5101 @@ -8975,12 +10420,78 @@
  1.5102  #define BTREE_USER_VERSION        6
  1.5103  #define BTREE_INCR_VACUUM         7
  1.5104  #define BTREE_APPLICATION_ID      8
  1.5105 -
  1.5106 -/*
  1.5107 -** Values that may be OR'd together to form the second argument of an
  1.5108 -** sqlite3BtreeCursorHints() call.
  1.5109 -*/
  1.5110 -#define BTREE_BULKLOAD 0x00000001
  1.5111 +#define BTREE_DATA_VERSION        15  /* A virtual meta-value */
  1.5112 +
  1.5113 +/*
  1.5114 +** Kinds of hints that can be passed into the sqlite3BtreeCursorHint()
  1.5115 +** interface.
  1.5116 +**
  1.5117 +** BTREE_HINT_RANGE  (arguments: Expr*, Mem*)
  1.5118 +**
  1.5119 +**     The first argument is an Expr* (which is guaranteed to be constant for
  1.5120 +**     the lifetime of the cursor) that defines constraints on which rows
  1.5121 +**     might be fetched with this cursor.  The Expr* tree may contain
  1.5122 +**     TK_REGISTER nodes that refer to values stored in the array of registers
  1.5123 +**     passed as the second parameter.  In other words, if Expr.op==TK_REGISTER
  1.5124 +**     then the value of the node is the value in Mem[pExpr.iTable].  Any
  1.5125 +**     TK_COLUMN node in the expression tree refers to the Expr.iColumn-th
  1.5126 +**     column of the b-tree of the cursor.  The Expr tree will not contain
  1.5127 +**     any function calls nor subqueries nor references to b-trees other than
  1.5128 +**     the cursor being hinted.
  1.5129 +**
  1.5130 +**     The design of the _RANGE hint is aid b-tree implementations that try
  1.5131 +**     to prefetch content from remote machines - to provide those
  1.5132 +**     implementations with limits on what needs to be prefetched and thereby
  1.5133 +**     reduce network bandwidth.
  1.5134 +**
  1.5135 +** Note that BTREE_HINT_FLAGS with BTREE_BULKLOAD is the only hint used by
  1.5136 +** standard SQLite.  The other hints are provided for extentions that use
  1.5137 +** the SQLite parser and code generator but substitute their own storage
  1.5138 +** engine.
  1.5139 +*/
  1.5140 +#define BTREE_HINT_RANGE 0       /* Range constraints on queries */
  1.5141 +
  1.5142 +/*
  1.5143 +** Values that may be OR'd together to form the argument to the
  1.5144 +** BTREE_HINT_FLAGS hint for sqlite3BtreeCursorHint():
  1.5145 +**
  1.5146 +** The BTREE_BULKLOAD flag is set on index cursors when the index is going
  1.5147 +** to be filled with content that is already in sorted order.
  1.5148 +**
  1.5149 +** The BTREE_SEEK_EQ flag is set on cursors that will get OP_SeekGE or
  1.5150 +** OP_SeekLE opcodes for a range search, but where the range of entries
  1.5151 +** selected will all have the same key.  In other words, the cursor will
  1.5152 +** be used only for equality key searches.
  1.5153 +**
  1.5154 +*/
  1.5155 +#define BTREE_BULKLOAD 0x00000001  /* Used to full index in sorted order */
  1.5156 +#define BTREE_SEEK_EQ  0x00000002  /* EQ seeks only - no range seeks */
  1.5157 +
  1.5158 +/* 
  1.5159 +** Flags passed as the third argument to sqlite3BtreeCursor().
  1.5160 +**
  1.5161 +** For read-only cursors the wrFlag argument is always zero. For read-write
  1.5162 +** cursors it may be set to either (BTREE_WRCSR|BTREE_FORDELETE) or just
  1.5163 +** (BTREE_WRCSR). If the BTREE_FORDELETE bit is set, then the cursor will
  1.5164 +** only be used by SQLite for the following:
  1.5165 +**
  1.5166 +**   * to seek to and then delete specific entries, and/or
  1.5167 +**
  1.5168 +**   * to read values that will be used to create keys that other
  1.5169 +**     BTREE_FORDELETE cursors will seek to and delete.
  1.5170 +**
  1.5171 +** The BTREE_FORDELETE flag is an optimization hint.  It is not used by
  1.5172 +** by this, the native b-tree engine of SQLite, but it is available to
  1.5173 +** alternative storage engines that might be substituted in place of this
  1.5174 +** b-tree system.  For alternative storage engines in which a delete of
  1.5175 +** the main table row automatically deletes corresponding index rows,
  1.5176 +** the FORDELETE flag hint allows those alternative storage engines to
  1.5177 +** skip a lot of work.  Namely:  FORDELETE cursors may treat all SEEK
  1.5178 +** and DELETE operations as no-ops, and any READ operation against a
  1.5179 +** FORDELETE cursor may return a null row: 0x01 0x00.
  1.5180 +*/
  1.5181 +#define BTREE_WRCSR     0x00000004     /* read-write cursor */
  1.5182 +#define BTREE_FORDELETE 0x00000008     /* Cursor is for seek/delete only */
  1.5183  
  1.5184  SQLITE_PRIVATE int sqlite3BtreeCursor(
  1.5185    Btree*,                              /* BTree containing table to open */
  1.5186 @@ -8991,6 +10502,10 @@
  1.5187  );
  1.5188  SQLITE_PRIVATE int sqlite3BtreeCursorSize(void);
  1.5189  SQLITE_PRIVATE void sqlite3BtreeCursorZero(BtCursor*);
  1.5190 +SQLITE_PRIVATE void sqlite3BtreeCursorHintFlags(BtCursor*, unsigned);
  1.5191 +#ifdef SQLITE_ENABLE_CURSOR_HINTS
  1.5192 +SQLITE_PRIVATE void sqlite3BtreeCursorHint(BtCursor*, int, ...);
  1.5193 +#endif
  1.5194  
  1.5195  SQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor*);
  1.5196  SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked(
  1.5197 @@ -9000,8 +10515,14 @@
  1.5198    int bias,
  1.5199    int *pRes
  1.5200  );
  1.5201 -SQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor*, int*);
  1.5202 -SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor*);
  1.5203 +SQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor*);
  1.5204 +SQLITE_PRIVATE int sqlite3BtreeCursorRestore(BtCursor*, int*);
  1.5205 +SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor*, u8 flags);
  1.5206 +
  1.5207 +/* Allowed flags for the 2nd argument to sqlite3BtreeDelete() */
  1.5208 +#define BTREE_SAVEPOSITION 0x02  /* Leave cursor pointing at NEXT or PREV */
  1.5209 +#define BTREE_AUXDELETE    0x04  /* not the primary delete operation */
  1.5210 +
  1.5211  SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey,
  1.5212                                    const void *pData, int nData,
  1.5213                                    int nZero, int bias, int seekResult);
  1.5214 @@ -9024,8 +10545,9 @@
  1.5215  SQLITE_PRIVATE void sqlite3BtreeIncrblobCursor(BtCursor *);
  1.5216  SQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *);
  1.5217  SQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBt, int iVersion);
  1.5218 -SQLITE_PRIVATE void sqlite3BtreeCursorHints(BtCursor *, unsigned int mask);
  1.5219 +SQLITE_PRIVATE int sqlite3BtreeCursorHasHint(BtCursor*, unsigned int mask);
  1.5220  SQLITE_PRIVATE int sqlite3BtreeIsReadonly(Btree *pBt);
  1.5221 +SQLITE_PRIVATE int sqlite3HeaderSizeBtree(void);
  1.5222  
  1.5223  #ifndef NDEBUG
  1.5224  SQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor*);
  1.5225 @@ -9052,15 +10574,17 @@
  1.5226  #ifndef SQLITE_OMIT_SHARED_CACHE
  1.5227  SQLITE_PRIVATE   void sqlite3BtreeEnter(Btree*);
  1.5228  SQLITE_PRIVATE   void sqlite3BtreeEnterAll(sqlite3*);
  1.5229 +SQLITE_PRIVATE   int sqlite3BtreeSharable(Btree*);
  1.5230 +SQLITE_PRIVATE   void sqlite3BtreeEnterCursor(BtCursor*);
  1.5231  #else
  1.5232  # define sqlite3BtreeEnter(X) 
  1.5233  # define sqlite3BtreeEnterAll(X)
  1.5234 +# define sqlite3BtreeSharable(X) 0
  1.5235 +# define sqlite3BtreeEnterCursor(X)
  1.5236  #endif
  1.5237  
  1.5238  #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE
  1.5239 -SQLITE_PRIVATE   int sqlite3BtreeSharable(Btree*);
  1.5240  SQLITE_PRIVATE   void sqlite3BtreeLeave(Btree*);
  1.5241 -SQLITE_PRIVATE   void sqlite3BtreeEnterCursor(BtCursor*);
  1.5242  SQLITE_PRIVATE   void sqlite3BtreeLeaveCursor(BtCursor*);
  1.5243  SQLITE_PRIVATE   void sqlite3BtreeLeaveAll(sqlite3*);
  1.5244  #ifndef NDEBUG
  1.5245 @@ -9071,9 +10595,7 @@
  1.5246  #endif
  1.5247  #else
  1.5248  
  1.5249 -# define sqlite3BtreeSharable(X) 0
  1.5250  # define sqlite3BtreeLeave(X)
  1.5251 -# define sqlite3BtreeEnterCursor(X)
  1.5252  # define sqlite3BtreeLeaveCursor(X)
  1.5253  # define sqlite3BtreeLeaveAll(X)
  1.5254  
  1.5255 @@ -9137,19 +10659,23 @@
  1.5256    int p1;             /* First operand */
  1.5257    int p2;             /* Second parameter (often the jump destination) */
  1.5258    int p3;             /* The third parameter */
  1.5259 -  union {             /* fourth parameter */
  1.5260 +  union p4union {     /* fourth parameter */
  1.5261      int i;                 /* Integer value if p4type==P4_INT32 */
  1.5262      void *p;               /* Generic pointer */
  1.5263      char *z;               /* Pointer to data for string (char array) types */
  1.5264      i64 *pI64;             /* Used when p4type is P4_INT64 */
  1.5265      double *pReal;         /* Used when p4type is P4_REAL */
  1.5266      FuncDef *pFunc;        /* Used when p4type is P4_FUNCDEF */
  1.5267 +    sqlite3_context *pCtx; /* Used when p4type is P4_FUNCCTX */
  1.5268      CollSeq *pColl;        /* Used when p4type is P4_COLLSEQ */
  1.5269      Mem *pMem;             /* Used when p4type is P4_MEM */
  1.5270      VTable *pVtab;         /* Used when p4type is P4_VTAB */
  1.5271      KeyInfo *pKeyInfo;     /* Used when p4type is P4_KEYINFO */
  1.5272      int *ai;               /* Used when p4type is P4_INTARRAY */
  1.5273      SubProgram *pProgram;  /* Used when p4type is P4_SUBPROGRAM */
  1.5274 +#ifdef SQLITE_ENABLE_CURSOR_HINTS
  1.5275 +    Expr *pExpr;           /* Used when p4type is P4_EXPR */
  1.5276 +#endif
  1.5277      int (*xAdvance)(BtCursor *, int *);
  1.5278    } p4;
  1.5279  #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
  1.5280 @@ -9200,6 +10726,7 @@
  1.5281  #define P4_COLLSEQ  (-4)  /* P4 is a pointer to a CollSeq structure */
  1.5282  #define P4_FUNCDEF  (-5)  /* P4 is a pointer to a FuncDef structure */
  1.5283  #define P4_KEYINFO  (-6)  /* P4 is a pointer to a KeyInfo structure */
  1.5284 +#define P4_EXPR     (-7)  /* P4 is a pointer to an Expr tree */
  1.5285  #define P4_MEM      (-8)  /* P4 is a pointer to a Mem*    structure */
  1.5286  #define P4_TRANSIENT  0   /* P4 is a pointer to a transient string */
  1.5287  #define P4_VTAB     (-10) /* P4 is a pointer to an sqlite3_vtab structure */
  1.5288 @@ -9210,6 +10737,7 @@
  1.5289  #define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */
  1.5290  #define P4_SUBPROGRAM  (-18) /* P4 is a pointer to a SubProgram structure */
  1.5291  #define P4_ADVANCE  (-19) /* P4 is a pointer to BtreeNext() or BtreePrev() */
  1.5292 +#define P4_FUNCCTX  (-20) /* P4 is a pointer to an sqlite3_context object */
  1.5293  
  1.5294  /* Error message codes for OP_Halt */
  1.5295  #define P5_ConstraintNotNull 1
  1.5296 @@ -9251,82 +10779,83 @@
  1.5297  /************** Include opcodes.h in the middle of vdbe.h ********************/
  1.5298  /************** Begin file opcodes.h *****************************************/
  1.5299  /* Automatically generated.  Do not edit */
  1.5300 -/* See the mkopcodeh.awk script for details */
  1.5301 -#define OP_Function        1 /* synopsis: r[P3]=func(r[P2@P5])             */
  1.5302 -#define OP_Savepoint       2
  1.5303 -#define OP_AutoCommit      3
  1.5304 -#define OP_Transaction     4
  1.5305 -#define OP_SorterNext      5
  1.5306 -#define OP_PrevIfOpen      6
  1.5307 -#define OP_NextIfOpen      7
  1.5308 -#define OP_Prev            8
  1.5309 -#define OP_Next            9
  1.5310 -#define OP_AggStep        10 /* synopsis: accum=r[P3] step(r[P2@P5])       */
  1.5311 -#define OP_Checkpoint     11
  1.5312 -#define OP_JournalMode    12
  1.5313 -#define OP_Vacuum         13
  1.5314 -#define OP_VFilter        14 /* synopsis: iplan=r[P3] zplan='P4'           */
  1.5315 -#define OP_VUpdate        15 /* synopsis: data=r[P3@P2]                    */
  1.5316 -#define OP_Goto           16
  1.5317 -#define OP_Gosub          17
  1.5318 -#define OP_Return         18
  1.5319 +/* See the tool/mkopcodeh.tcl script for details */
  1.5320 +#define OP_Savepoint       0
  1.5321 +#define OP_AutoCommit      1
  1.5322 +#define OP_Transaction     2
  1.5323 +#define OP_SorterNext      3
  1.5324 +#define OP_PrevIfOpen      4
  1.5325 +#define OP_NextIfOpen      5
  1.5326 +#define OP_Prev            6
  1.5327 +#define OP_Next            7
  1.5328 +#define OP_Checkpoint      8
  1.5329 +#define OP_JournalMode     9
  1.5330 +#define OP_Vacuum         10
  1.5331 +#define OP_VFilter        11 /* synopsis: iplan=r[P3] zplan='P4'           */
  1.5332 +#define OP_VUpdate        12 /* synopsis: data=r[P3@P2]                    */
  1.5333 +#define OP_Goto           13
  1.5334 +#define OP_Gosub          14
  1.5335 +#define OP_Return         15
  1.5336 +#define OP_InitCoroutine  16
  1.5337 +#define OP_EndCoroutine   17
  1.5338 +#define OP_Yield          18
  1.5339  #define OP_Not            19 /* same as TK_NOT, synopsis: r[P2]= !r[P1]    */
  1.5340 -#define OP_InitCoroutine  20
  1.5341 -#define OP_EndCoroutine   21
  1.5342 -#define OP_Yield          22
  1.5343 -#define OP_HaltIfNull     23 /* synopsis: if r[P3]=null halt               */
  1.5344 -#define OP_Halt           24
  1.5345 -#define OP_Integer        25 /* synopsis: r[P2]=P1                         */
  1.5346 -#define OP_Int64          26 /* synopsis: r[P2]=P4                         */
  1.5347 -#define OP_String         27 /* synopsis: r[P2]='P4' (len=P1)              */
  1.5348 -#define OP_Null           28 /* synopsis: r[P2..P3]=NULL                   */
  1.5349 -#define OP_SoftNull       29 /* synopsis: r[P1]=NULL                       */
  1.5350 -#define OP_Blob           30 /* synopsis: r[P2]=P4 (len=P1)                */
  1.5351 -#define OP_Variable       31 /* synopsis: r[P2]=parameter(P1,P4)           */
  1.5352 -#define OP_Move           32 /* synopsis: r[P2@P3]=r[P1@P3]                */
  1.5353 -#define OP_Copy           33 /* synopsis: r[P2@P3+1]=r[P1@P3+1]            */
  1.5354 -#define OP_SCopy          34 /* synopsis: r[P2]=r[P1]                      */
  1.5355 -#define OP_ResultRow      35 /* synopsis: output=r[P1@P2]                  */
  1.5356 -#define OP_CollSeq        36
  1.5357 +#define OP_HaltIfNull     20 /* synopsis: if r[P3]=null halt               */
  1.5358 +#define OP_Halt           21
  1.5359 +#define OP_Integer        22 /* synopsis: r[P2]=P1                         */
  1.5360 +#define OP_Int64          23 /* synopsis: r[P2]=P4                         */
  1.5361 +#define OP_String         24 /* synopsis: r[P2]='P4' (len=P1)              */
  1.5362 +#define OP_Null           25 /* synopsis: r[P2..P3]=NULL                   */
  1.5363 +#define OP_SoftNull       26 /* synopsis: r[P1]=NULL                       */
  1.5364 +#define OP_Blob           27 /* synopsis: r[P2]=P4 (len=P1)                */
  1.5365 +#define OP_Variable       28 /* synopsis: r[P2]=parameter(P1,P4)           */
  1.5366 +#define OP_Move           29 /* synopsis: r[P2@P3]=r[P1@P3]                */
  1.5367 +#define OP_Copy           30 /* synopsis: r[P2@P3+1]=r[P1@P3+1]            */
  1.5368 +#define OP_SCopy          31 /* synopsis: r[P2]=r[P1]                      */
  1.5369 +#define OP_IntCopy        32 /* synopsis: r[P2]=r[P1]                      */
  1.5370 +#define OP_ResultRow      33 /* synopsis: output=r[P1@P2]                  */
  1.5371 +#define OP_CollSeq        34
  1.5372 +#define OP_Function0      35 /* synopsis: r[P3]=func(r[P2@P5])             */
  1.5373 +#define OP_Function       36 /* synopsis: r[P3]=func(r[P2@P5])             */
  1.5374  #define OP_AddImm         37 /* synopsis: r[P1]=r[P1]+P2                   */
  1.5375  #define OP_MustBeInt      38
  1.5376  #define OP_RealAffinity   39
  1.5377 -#define OP_Permutation    40
  1.5378 -#define OP_Compare        41 /* synopsis: r[P1@P3] <-> r[P2@P3]            */
  1.5379 -#define OP_Jump           42
  1.5380 -#define OP_Once           43
  1.5381 -#define OP_If             44
  1.5382 -#define OP_IfNot          45
  1.5383 -#define OP_Column         46 /* synopsis: r[P3]=PX                         */
  1.5384 -#define OP_Affinity       47 /* synopsis: affinity(r[P1@P2])               */
  1.5385 -#define OP_MakeRecord     48 /* synopsis: r[P3]=mkrec(r[P1@P2])            */
  1.5386 -#define OP_Count          49 /* synopsis: r[P2]=count()                    */
  1.5387 -#define OP_ReadCookie     50
  1.5388 -#define OP_SetCookie      51
  1.5389 -#define OP_ReopenIdx      52 /* synopsis: root=P2 iDb=P3                   */
  1.5390 -#define OP_OpenRead       53 /* synopsis: root=P2 iDb=P3                   */
  1.5391 -#define OP_OpenWrite      54 /* synopsis: root=P2 iDb=P3                   */
  1.5392 -#define OP_OpenAutoindex  55 /* synopsis: nColumn=P2                       */
  1.5393 -#define OP_OpenEphemeral  56 /* synopsis: nColumn=P2                       */
  1.5394 -#define OP_SorterOpen     57
  1.5395 -#define OP_OpenPseudo     58 /* synopsis: P3 columns in r[P2]              */
  1.5396 -#define OP_Close          59
  1.5397 -#define OP_SeekLT         60 /* synopsis: key=r[P3@P4]                     */
  1.5398 -#define OP_SeekLE         61 /* synopsis: key=r[P3@P4]                     */
  1.5399 -#define OP_SeekGE         62 /* synopsis: key=r[P3@P4]                     */
  1.5400 -#define OP_SeekGT         63 /* synopsis: key=r[P3@P4]                     */
  1.5401 -#define OP_Seek           64 /* synopsis: intkey=r[P2]                     */
  1.5402 -#define OP_NoConflict     65 /* synopsis: key=r[P3@P4]                     */
  1.5403 -#define OP_NotFound       66 /* synopsis: key=r[P3@P4]                     */
  1.5404 -#define OP_Found          67 /* synopsis: key=r[P3@P4]                     */
  1.5405 -#define OP_NotExists      68 /* synopsis: intkey=r[P3]                     */
  1.5406 -#define OP_Sequence       69 /* synopsis: r[P2]=cursor[P1].ctr++           */
  1.5407 -#define OP_NewRowid       70 /* synopsis: r[P2]=rowid                      */
  1.5408 +#define OP_Cast           40 /* synopsis: affinity(r[P1])                  */
  1.5409 +#define OP_Permutation    41
  1.5410 +#define OP_Compare        42 /* synopsis: r[P1@P3] <-> r[P2@P3]            */
  1.5411 +#define OP_Jump           43
  1.5412 +#define OP_Once           44
  1.5413 +#define OP_If             45
  1.5414 +#define OP_IfNot          46
  1.5415 +#define OP_Column         47 /* synopsis: r[P3]=PX                         */
  1.5416 +#define OP_Affinity       48 /* synopsis: affinity(r[P1@P2])               */
  1.5417 +#define OP_MakeRecord     49 /* synopsis: r[P3]=mkrec(r[P1@P2])            */
  1.5418 +#define OP_Count          50 /* synopsis: r[P2]=count()                    */
  1.5419 +#define OP_ReadCookie     51
  1.5420 +#define OP_SetCookie      52
  1.5421 +#define OP_ReopenIdx      53 /* synopsis: root=P2 iDb=P3                   */
  1.5422 +#define OP_OpenRead       54 /* synopsis: root=P2 iDb=P3                   */
  1.5423 +#define OP_OpenWrite      55 /* synopsis: root=P2 iDb=P3                   */
  1.5424 +#define OP_OpenAutoindex  56 /* synopsis: nColumn=P2                       */
  1.5425 +#define OP_OpenEphemeral  57 /* synopsis: nColumn=P2                       */
  1.5426 +#define OP_SorterOpen     58
  1.5427 +#define OP_SequenceTest   59 /* synopsis: if( cursor[P1].ctr++ ) pc = P2   */
  1.5428 +#define OP_OpenPseudo     60 /* synopsis: P3 columns in r[P2]              */
  1.5429 +#define OP_Close          61
  1.5430 +#define OP_ColumnsUsed    62
  1.5431 +#define OP_SeekLT         63 /* synopsis: key=r[P3@P4]                     */
  1.5432 +#define OP_SeekLE         64 /* synopsis: key=r[P3@P4]                     */
  1.5433 +#define OP_SeekGE         65 /* synopsis: key=r[P3@P4]                     */
  1.5434 +#define OP_SeekGT         66 /* synopsis: key=r[P3@P4]                     */
  1.5435 +#define OP_NoConflict     67 /* synopsis: key=r[P3@P4]                     */
  1.5436 +#define OP_NotFound       68 /* synopsis: key=r[P3@P4]                     */
  1.5437 +#define OP_Found          69 /* synopsis: key=r[P3@P4]                     */
  1.5438 +#define OP_NotExists      70 /* synopsis: intkey=r[P3]                     */
  1.5439  #define OP_Or             71 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
  1.5440  #define OP_And            72 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
  1.5441 -#define OP_Insert         73 /* synopsis: intkey=r[P3] data=r[P2]          */
  1.5442 -#define OP_InsertInt      74 /* synopsis: intkey=P3 data=r[P2]             */
  1.5443 -#define OP_Delete         75
  1.5444 +#define OP_Sequence       73 /* synopsis: r[P2]=cursor[P1].ctr++           */
  1.5445 +#define OP_NewRowid       74 /* synopsis: r[P2]=rowid                      */
  1.5446 +#define OP_Insert         75 /* synopsis: intkey=r[P3] data=r[P2]          */
  1.5447  #define OP_IsNull         76 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
  1.5448  #define OP_NotNull        77 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
  1.5449  #define OP_Ne             78 /* same as TK_NE, synopsis: if r[P1]!=r[P3] goto P2 */
  1.5450 @@ -9335,7 +10864,7 @@
  1.5451  #define OP_Le             81 /* same as TK_LE, synopsis: if r[P1]<=r[P3] goto P2 */
  1.5452  #define OP_Lt             82 /* same as TK_LT, synopsis: if r[P1]<r[P3] goto P2 */
  1.5453  #define OP_Ge             83 /* same as TK_GE, synopsis: if r[P1]>=r[P3] goto P2 */
  1.5454 -#define OP_ResetCount     84
  1.5455 +#define OP_InsertInt      84 /* synopsis: intkey=P3 data=r[P2]             */
  1.5456  #define OP_BitAnd         85 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
  1.5457  #define OP_BitOr          86 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
  1.5458  #define OP_ShiftLeft      87 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
  1.5459 @@ -9346,104 +10875,106 @@
  1.5460  #define OP_Divide         92 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
  1.5461  #define OP_Remainder      93 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
  1.5462  #define OP_Concat         94 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
  1.5463 -#define OP_SorterCompare  95 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
  1.5464 +#define OP_Delete         95
  1.5465  #define OP_BitNot         96 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
  1.5466  #define OP_String8        97 /* same as TK_STRING, synopsis: r[P2]='P4'    */
  1.5467 -#define OP_SorterData     98 /* synopsis: r[P2]=data                       */
  1.5468 -#define OP_RowKey         99 /* synopsis: r[P2]=key                        */
  1.5469 -#define OP_RowData       100 /* synopsis: r[P2]=data                       */
  1.5470 -#define OP_Rowid         101 /* synopsis: r[P2]=rowid                      */
  1.5471 -#define OP_NullRow       102
  1.5472 -#define OP_Last          103
  1.5473 -#define OP_SorterSort    104
  1.5474 -#define OP_Sort          105
  1.5475 -#define OP_Rewind        106
  1.5476 -#define OP_SorterInsert  107
  1.5477 -#define OP_IdxInsert     108 /* synopsis: key=r[P2]                        */
  1.5478 -#define OP_IdxDelete     109 /* synopsis: key=r[P2@P3]                     */
  1.5479 -#define OP_IdxRowid      110 /* synopsis: r[P2]=rowid                      */
  1.5480 -#define OP_IdxLE         111 /* synopsis: key=r[P3@P4]                     */
  1.5481 -#define OP_IdxGT         112 /* synopsis: key=r[P3@P4]                     */
  1.5482 -#define OP_IdxLT         113 /* synopsis: key=r[P3@P4]                     */
  1.5483 -#define OP_IdxGE         114 /* synopsis: key=r[P3@P4]                     */
  1.5484 -#define OP_Destroy       115
  1.5485 -#define OP_Clear         116
  1.5486 -#define OP_ResetSorter   117
  1.5487 -#define OP_CreateIndex   118 /* synopsis: r[P2]=root iDb=P1                */
  1.5488 -#define OP_CreateTable   119 /* synopsis: r[P2]=root iDb=P1                */
  1.5489 -#define OP_ParseSchema   120
  1.5490 -#define OP_LoadAnalysis  121
  1.5491 -#define OP_DropTable     122
  1.5492 -#define OP_DropIndex     123
  1.5493 -#define OP_DropTrigger   124
  1.5494 -#define OP_IntegrityCk   125
  1.5495 -#define OP_RowSetAdd     126 /* synopsis: rowset(P1)=r[P2]                 */
  1.5496 -#define OP_RowSetRead    127 /* synopsis: r[P3]=rowset(P1)                 */
  1.5497 -#define OP_RowSetTest    128 /* synopsis: if r[P3] in rowset(P1) goto P2   */
  1.5498 -#define OP_Program       129
  1.5499 -#define OP_Param         130
  1.5500 -#define OP_FkCounter     131 /* synopsis: fkctr[P1]+=P2                    */
  1.5501 -#define OP_FkIfZero      132 /* synopsis: if fkctr[P1]==0 goto P2          */
  1.5502 +#define OP_ResetCount     98
  1.5503 +#define OP_SorterCompare  99 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
  1.5504 +#define OP_SorterData    100 /* synopsis: r[P2]=data                       */
  1.5505 +#define OP_RowKey        101 /* synopsis: r[P2]=key                        */
  1.5506 +#define OP_RowData       102 /* synopsis: r[P2]=data                       */
  1.5507 +#define OP_Rowid         103 /* synopsis: r[P2]=rowid                      */
  1.5508 +#define OP_NullRow       104
  1.5509 +#define OP_Last          105
  1.5510 +#define OP_SorterSort    106
  1.5511 +#define OP_Sort          107
  1.5512 +#define OP_Rewind        108
  1.5513 +#define OP_SorterInsert  109
  1.5514 +#define OP_IdxInsert     110 /* synopsis: key=r[P2]                        */
  1.5515 +#define OP_IdxDelete     111 /* synopsis: key=r[P2@P3]                     */
  1.5516 +#define OP_Seek          112 /* synopsis: Move P3 to P1.rowid              */
  1.5517 +#define OP_IdxRowid      113 /* synopsis: r[P2]=rowid                      */
  1.5518 +#define OP_IdxLE         114 /* synopsis: key=r[P3@P4]                     */
  1.5519 +#define OP_IdxGT         115 /* synopsis: key=r[P3@P4]                     */
  1.5520 +#define OP_IdxLT         116 /* synopsis: key=r[P3@P4]                     */
  1.5521 +#define OP_IdxGE         117 /* synopsis: key=r[P3@P4]                     */
  1.5522 +#define OP_Destroy       118
  1.5523 +#define OP_Clear         119
  1.5524 +#define OP_ResetSorter   120
  1.5525 +#define OP_CreateIndex   121 /* synopsis: r[P2]=root iDb=P1                */
  1.5526 +#define OP_CreateTable   122 /* synopsis: r[P2]=root iDb=P1                */
  1.5527 +#define OP_ParseSchema   123
  1.5528 +#define OP_LoadAnalysis  124
  1.5529 +#define OP_DropTable     125
  1.5530 +#define OP_DropIndex     126
  1.5531 +#define OP_DropTrigger   127
  1.5532 +#define OP_IntegrityCk   128
  1.5533 +#define OP_RowSetAdd     129 /* synopsis: rowset(P1)=r[P2]                 */
  1.5534 +#define OP_RowSetRead    130 /* synopsis: r[P3]=rowset(P1)                 */
  1.5535 +#define OP_RowSetTest    131 /* synopsis: if r[P3] in rowset(P1) goto P2   */
  1.5536 +#define OP_Program       132
  1.5537  #define OP_Real          133 /* same as TK_FLOAT, synopsis: r[P2]=P4       */
  1.5538 -#define OP_MemMax        134 /* synopsis: r[P1]=max(r[P1],r[P2])           */
  1.5539 -#define OP_IfPos         135 /* synopsis: if r[P1]>0 goto P2               */
  1.5540 -#define OP_IfNeg         136 /* synopsis: r[P1]+=P3, if r[P1]<0 goto P2    */
  1.5541 -#define OP_IfZero        137 /* synopsis: r[P1]+=P3, if r[P1]==0 goto P2   */
  1.5542 -#define OP_AggFinal      138 /* synopsis: accum=r[P1] N=P2                 */
  1.5543 -#define OP_IncrVacuum    139
  1.5544 -#define OP_Expire        140
  1.5545 -#define OP_TableLock     141 /* synopsis: iDb=P1 root=P2 write=P3          */
  1.5546 -#define OP_VBegin        142
  1.5547 -#define OP_ToText        143 /* same as TK_TO_TEXT                         */
  1.5548 -#define OP_ToBlob        144 /* same as TK_TO_BLOB                         */
  1.5549 -#define OP_ToNumeric     145 /* same as TK_TO_NUMERIC                      */
  1.5550 -#define OP_ToInt         146 /* same as TK_TO_INT                          */
  1.5551 -#define OP_ToReal        147 /* same as TK_TO_REAL                         */
  1.5552 -#define OP_VCreate       148
  1.5553 -#define OP_VDestroy      149
  1.5554 -#define OP_VOpen         150
  1.5555 -#define OP_VColumn       151 /* synopsis: r[P3]=vcolumn(P2)                */
  1.5556 -#define OP_VNext         152
  1.5557 -#define OP_VRename       153
  1.5558 -#define OP_Pagecount     154
  1.5559 -#define OP_MaxPgcnt      155
  1.5560 -#define OP_Init          156 /* synopsis: Start at P2                      */
  1.5561 -#define OP_Noop          157
  1.5562 -#define OP_Explain       158
  1.5563 -
  1.5564 +#define OP_Param         134
  1.5565 +#define OP_FkCounter     135 /* synopsis: fkctr[P1]+=P2                    */
  1.5566 +#define OP_FkIfZero      136 /* synopsis: if fkctr[P1]==0 goto P2          */
  1.5567 +#define OP_MemMax        137 /* synopsis: r[P1]=max(r[P1],r[P2])           */
  1.5568 +#define OP_IfPos         138 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
  1.5569 +#define OP_OffsetLimit   139 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
  1.5570 +#define OP_IfNotZero     140 /* synopsis: if r[P1]!=0 then r[P1]-=P3, goto P2 */
  1.5571 +#define OP_DecrJumpZero  141 /* synopsis: if (--r[P1])==0 goto P2          */
  1.5572 +#define OP_JumpZeroIncr  142 /* synopsis: if (r[P1]++)==0 ) goto P2        */
  1.5573 +#define OP_AggStep0      143 /* synopsis: accum=r[P3] step(r[P2@P5])       */
  1.5574 +#define OP_AggStep       144 /* synopsis: accum=r[P3] step(r[P2@P5])       */
  1.5575 +#define OP_AggFinal      145 /* synopsis: accum=r[P1] N=P2                 */
  1.5576 +#define OP_IncrVacuum    146
  1.5577 +#define OP_Expire        147
  1.5578 +#define OP_TableLock     148 /* synopsis: iDb=P1 root=P2 write=P3          */
  1.5579 +#define OP_VBegin        149
  1.5580 +#define OP_VCreate       150
  1.5581 +#define OP_VDestroy      151
  1.5582 +#define OP_VOpen         152
  1.5583 +#define OP_VColumn       153 /* synopsis: r[P3]=vcolumn(P2)                */
  1.5584 +#define OP_VNext         154
  1.5585 +#define OP_VRename       155
  1.5586 +#define OP_Pagecount     156
  1.5587 +#define OP_MaxPgcnt      157
  1.5588 +#define OP_Init          158 /* synopsis: Start at P2                      */
  1.5589 +#define OP_CursorHint    159
  1.5590 +#define OP_Noop          160
  1.5591 +#define OP_Explain       161
  1.5592  
  1.5593  /* Properties such as "out2" or "jump" that are specified in
  1.5594  ** comments following the "case" for each opcode in the vdbe.c
  1.5595  ** are encoded into bitvectors as follows:
  1.5596  */
  1.5597 -#define OPFLG_JUMP            0x0001  /* jump:  P2 holds jmp target */
  1.5598 -#define OPFLG_OUT2_PRERELEASE 0x0002  /* out2-prerelease: */
  1.5599 -#define OPFLG_IN1             0x0004  /* in1:   P1 is an input */
  1.5600 -#define OPFLG_IN2             0x0008  /* in2:   P2 is an input */
  1.5601 -#define OPFLG_IN3             0x0010  /* in3:   P3 is an input */
  1.5602 -#define OPFLG_OUT2            0x0020  /* out2:  P2 is an output */
  1.5603 -#define OPFLG_OUT3            0x0040  /* out3:  P3 is an output */
  1.5604 +#define OPFLG_JUMP        0x01  /* jump:  P2 holds jmp target */
  1.5605 +#define OPFLG_IN1         0x02  /* in1:   P1 is an input */
  1.5606 +#define OPFLG_IN2         0x04  /* in2:   P2 is an input */
  1.5607 +#define OPFLG_IN3         0x08  /* in3:   P3 is an input */
  1.5608 +#define OPFLG_OUT2        0x10  /* out2:  P2 is an output */
  1.5609 +#define OPFLG_OUT3        0x20  /* out3:  P3 is an output */
  1.5610  #define OPFLG_INITIALIZER {\
  1.5611 -/*   0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,\
  1.5612 -/*   8 */ 0x01, 0x01, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00,\
  1.5613 -/*  16 */ 0x01, 0x01, 0x04, 0x24, 0x01, 0x04, 0x05, 0x10,\
  1.5614 -/*  24 */ 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02,\
  1.5615 -/*  32 */ 0x00, 0x00, 0x20, 0x00, 0x00, 0x04, 0x05, 0x04,\
  1.5616 -/*  40 */ 0x00, 0x00, 0x01, 0x01, 0x05, 0x05, 0x00, 0x00,\
  1.5617 -/*  48 */ 0x00, 0x02, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00,\
  1.5618 -/*  56 */ 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11,\
  1.5619 -/*  64 */ 0x08, 0x11, 0x11, 0x11, 0x11, 0x02, 0x02, 0x4c,\
  1.5620 -/*  72 */ 0x4c, 0x00, 0x00, 0x00, 0x05, 0x05, 0x15, 0x15,\
  1.5621 -/*  80 */ 0x15, 0x15, 0x15, 0x15, 0x00, 0x4c, 0x4c, 0x4c,\
  1.5622 -/*  88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x00,\
  1.5623 -/*  96 */ 0x24, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01,\
  1.5624 -/* 104 */ 0x01, 0x01, 0x01, 0x08, 0x08, 0x00, 0x02, 0x01,\
  1.5625 -/* 112 */ 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x02, 0x02,\
  1.5626 -/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x45,\
  1.5627 -/* 128 */ 0x15, 0x01, 0x02, 0x00, 0x01, 0x02, 0x08, 0x05,\
  1.5628 -/* 136 */ 0x05, 0x05, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04,\
  1.5629 -/* 144 */ 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00,\
  1.5630 -/* 152 */ 0x01, 0x00, 0x02, 0x02, 0x01, 0x00, 0x00,}
  1.5631 +/*   0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01,\
  1.5632 +/*   8 */ 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x01, 0x02,\
  1.5633 +/*  16 */ 0x01, 0x02, 0x03, 0x12, 0x08, 0x00, 0x10, 0x10,\
  1.5634 +/*  24 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\
  1.5635 +/*  32 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02,\
  1.5636 +/*  40 */ 0x02, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x00,\
  1.5637 +/*  48 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,\
  1.5638 +/*  56 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,\
  1.5639 +/*  64 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x26,\
  1.5640 +/*  72 */ 0x26, 0x10, 0x10, 0x00, 0x03, 0x03, 0x0b, 0x0b,\
  1.5641 +/*  80 */ 0x0b, 0x0b, 0x0b, 0x0b, 0x00, 0x26, 0x26, 0x26,\
  1.5642 +/*  88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00,\
  1.5643 +/*  96 */ 0x12, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\
  1.5644 +/* 104 */ 0x00, 0x01, 0x01, 0x01, 0x01, 0x04, 0x04, 0x00,\
  1.5645 +/* 112 */ 0x00, 0x10, 0x01, 0x01, 0x01, 0x01, 0x10, 0x00,\
  1.5646 +/* 120 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
  1.5647 +/* 128 */ 0x00, 0x06, 0x23, 0x0b, 0x01, 0x10, 0x10, 0x00,\
  1.5648 +/* 136 */ 0x01, 0x04, 0x03, 0x1a, 0x03, 0x03, 0x03, 0x00,\
  1.5649 +/* 144 */ 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,\
  1.5650 +/* 152 */ 0x00, 0x00, 0x01, 0x00, 0x10, 0x10, 0x01, 0x00,\
  1.5651 +/* 160 */ 0x00, 0x00,}
  1.5652  
  1.5653  /************** End of opcodes.h *********************************************/
  1.5654  /************** Continuing where we left off in vdbe.h ***********************/
  1.5655 @@ -9456,17 +10987,28 @@
  1.5656  SQLITE_PRIVATE int sqlite3VdbeAddOp0(Vdbe*,int);
  1.5657  SQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe*,int,int);
  1.5658  SQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe*,int,int,int);
  1.5659 +SQLITE_PRIVATE int sqlite3VdbeGoto(Vdbe*,int);
  1.5660 +SQLITE_PRIVATE int sqlite3VdbeLoadString(Vdbe*,int,const char*);
  1.5661 +SQLITE_PRIVATE void sqlite3VdbeMultiLoad(Vdbe*,int,const char*,...);
  1.5662  SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int);
  1.5663  SQLITE_PRIVATE int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int);
  1.5664 +SQLITE_PRIVATE int sqlite3VdbeAddOp4Dup8(Vdbe*,int,int,int,int,const u8*,int);
  1.5665  SQLITE_PRIVATE int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int);
  1.5666 -SQLITE_PRIVATE int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp, int iLineno);
  1.5667 +SQLITE_PRIVATE void sqlite3VdbeEndCoroutine(Vdbe*,int);
  1.5668 +#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)
  1.5669 +SQLITE_PRIVATE   void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N);
  1.5670 +#else
  1.5671 +# define sqlite3VdbeVerifyNoMallocRequired(A,B)
  1.5672 +#endif
  1.5673 +SQLITE_PRIVATE VdbeOp *sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp, int iLineno);
  1.5674  SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*);
  1.5675 +SQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe*, u32 addr, u8);
  1.5676  SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, u32 addr, int P1);
  1.5677  SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, u32 addr, int P2);
  1.5678  SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, u32 addr, int P3);
  1.5679  SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u8 P5);
  1.5680  SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr);
  1.5681 -SQLITE_PRIVATE void sqlite3VdbeChangeToNoop(Vdbe*, int addr);
  1.5682 +SQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe*, int addr);
  1.5683  SQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op);
  1.5684  SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N);
  1.5685  SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse*, Index*);
  1.5686 @@ -9501,10 +11043,11 @@
  1.5687  SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
  1.5688  
  1.5689  SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,UnpackedRecord*);
  1.5690 -SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*,int);
  1.5691 +SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);
  1.5692 +SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(int, const void *, UnpackedRecord *, int);
  1.5693  SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo *, char *, int, char **);
  1.5694  
  1.5695 -typedef int (*RecordCompare)(int,const void*,UnpackedRecord*,int);
  1.5696 +typedef int (*RecordCompare)(int,const void*,UnpackedRecord*);
  1.5697  SQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*);
  1.5698  
  1.5699  #ifndef SQLITE_OMIT_TRIGGER
  1.5700 @@ -9571,6 +11114,12 @@
  1.5701  # define VDBE_OFFSET_LINENO(x) 0
  1.5702  #endif
  1.5703  
  1.5704 +#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
  1.5705 +SQLITE_PRIVATE void sqlite3VdbeScanStatus(Vdbe*, int, int, int, LogEst, const char*);
  1.5706 +#else
  1.5707 +# define sqlite3VdbeScanStatus(a,b,c,d,e)
  1.5708 +#endif
  1.5709 +
  1.5710  #endif
  1.5711  
  1.5712  /************** End of vdbe.h ************************************************/
  1.5713 @@ -9658,7 +11207,7 @@
  1.5714  #define PAGER_JOURNALMODE_WAL         5   /* Use write-ahead logging */
  1.5715  
  1.5716  /*
  1.5717 -** Flags that make up the mask passed to sqlite3PagerAcquire().
  1.5718 +** Flags that make up the mask passed to sqlite3PagerGet().
  1.5719  */
  1.5720  #define PAGER_GET_NOCONTENT     0x01  /* Do not load data from disk */
  1.5721  #define PAGER_GET_READONLY      0x02  /* Read-only page is acceptable */
  1.5722 @@ -9669,11 +11218,12 @@
  1.5723  #define PAGER_SYNCHRONOUS_OFF       0x01  /* PRAGMA synchronous=OFF */
  1.5724  #define PAGER_SYNCHRONOUS_NORMAL    0x02  /* PRAGMA synchronous=NORMAL */
  1.5725  #define PAGER_SYNCHRONOUS_FULL      0x03  /* PRAGMA synchronous=FULL */
  1.5726 -#define PAGER_SYNCHRONOUS_MASK      0x03  /* Mask for three values above */
  1.5727 -#define PAGER_FULLFSYNC             0x04  /* PRAGMA fullfsync=ON */
  1.5728 -#define PAGER_CKPT_FULLFSYNC        0x08  /* PRAGMA checkpoint_fullfsync=ON */
  1.5729 -#define PAGER_CACHESPILL            0x10  /* PRAGMA cache_spill=ON */
  1.5730 -#define PAGER_FLAGS_MASK            0x1c  /* All above except SYNCHRONOUS */
  1.5731 +#define PAGER_SYNCHRONOUS_EXTRA     0x04  /* PRAGMA synchronous=EXTRA */
  1.5732 +#define PAGER_SYNCHRONOUS_MASK      0x07  /* Mask for four values above */
  1.5733 +#define PAGER_FULLFSYNC             0x08  /* PRAGMA fullfsync=ON */
  1.5734 +#define PAGER_CKPT_FULLFSYNC        0x10  /* PRAGMA checkpoint_fullfsync=ON */
  1.5735 +#define PAGER_CACHESPILL            0x20  /* PRAGMA cache_spill=ON */
  1.5736 +#define PAGER_FLAGS_MASK            0x38  /* All above except SYNCHRONOUS */
  1.5737  
  1.5738  /*
  1.5739  ** The remainder of this file contains the declarations of the functions
  1.5740 @@ -9697,8 +11247,12 @@
  1.5741  /* Functions used to configure a Pager object. */
  1.5742  SQLITE_PRIVATE void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *);
  1.5743  SQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager*, u32*, int);
  1.5744 +#ifdef SQLITE_HAS_CODEC
  1.5745 +SQLITE_PRIVATE void sqlite3PagerAlignReserve(Pager*,Pager*);
  1.5746 +#endif
  1.5747  SQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager*, int);
  1.5748  SQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager*, int);
  1.5749 +SQLITE_PRIVATE int sqlite3PagerSetSpillsize(Pager*, int);
  1.5750  SQLITE_PRIVATE void sqlite3PagerSetMmapLimit(Pager *, sqlite3_int64);
  1.5751  SQLITE_PRIVATE void sqlite3PagerShrink(Pager*);
  1.5752  SQLITE_PRIVATE void sqlite3PagerSetFlags(Pager*,unsigned);
  1.5753 @@ -9708,10 +11262,10 @@
  1.5754  SQLITE_PRIVATE int sqlite3PagerOkToChangeJournalMode(Pager*);
  1.5755  SQLITE_PRIVATE i64 sqlite3PagerJournalSizeLimit(Pager *, i64);
  1.5756  SQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager*);
  1.5757 +SQLITE_PRIVATE int sqlite3PagerFlush(Pager*);
  1.5758  
  1.5759  /* Functions used to obtain and release page references. */ 
  1.5760 -SQLITE_PRIVATE int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag);
  1.5761 -#define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0)
  1.5762 +SQLITE_PRIVATE int sqlite3PagerGet(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag);
  1.5763  SQLITE_PRIVATE DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno);
  1.5764  SQLITE_PRIVATE void sqlite3PagerRef(DbPage*);
  1.5765  SQLITE_PRIVATE void sqlite3PagerUnref(DbPage*);
  1.5766 @@ -9743,6 +11297,10 @@
  1.5767  SQLITE_PRIVATE   int sqlite3PagerWalCallback(Pager *pPager);
  1.5768  SQLITE_PRIVATE   int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);
  1.5769  SQLITE_PRIVATE   int sqlite3PagerCloseWal(Pager *pPager);
  1.5770 +# ifdef SQLITE_ENABLE_SNAPSHOT
  1.5771 +SQLITE_PRIVATE   int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot);
  1.5772 +SQLITE_PRIVATE   int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot);
  1.5773 +# endif
  1.5774  #endif
  1.5775  
  1.5776  #ifdef SQLITE_ENABLE_ZIPVFS
  1.5777 @@ -9751,11 +11309,15 @@
  1.5778  
  1.5779  /* Functions used to query pager state and configuration. */
  1.5780  SQLITE_PRIVATE u8 sqlite3PagerIsreadonly(Pager*);
  1.5781 -SQLITE_PRIVATE int sqlite3PagerRefcount(Pager*);
  1.5782 +SQLITE_PRIVATE u32 sqlite3PagerDataVersion(Pager*);
  1.5783 +#ifdef SQLITE_DEBUG
  1.5784 +SQLITE_PRIVATE   int sqlite3PagerRefcount(Pager*);
  1.5785 +#endif
  1.5786  SQLITE_PRIVATE int sqlite3PagerMemUsed(Pager*);
  1.5787  SQLITE_PRIVATE const char *sqlite3PagerFilename(Pager*, int);
  1.5788 -SQLITE_PRIVATE const sqlite3_vfs *sqlite3PagerVfs(Pager*);
  1.5789 +SQLITE_PRIVATE sqlite3_vfs *sqlite3PagerVfs(Pager*);
  1.5790  SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager*);
  1.5791 +SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager*);
  1.5792  SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*);
  1.5793  SQLITE_PRIVATE int sqlite3PagerNosync(Pager*);
  1.5794  SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*);
  1.5795 @@ -9767,6 +11329,8 @@
  1.5796  /* Functions used to truncate the database file. */
  1.5797  SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno);
  1.5798  
  1.5799 +SQLITE_PRIVATE void sqlite3PagerRekey(DbPage*, Pgno, u16);
  1.5800 +
  1.5801  #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL)
  1.5802  SQLITE_PRIVATE void *sqlite3PagerCodec(DbPage *);
  1.5803  #endif
  1.5804 @@ -9840,14 +11404,16 @@
  1.5805  };
  1.5806  
  1.5807  /* Bit values for PgHdr.flags */
  1.5808 -#define PGHDR_DIRTY             0x002  /* Page has changed */
  1.5809 -#define PGHDR_NEED_SYNC         0x004  /* Fsync the rollback journal before
  1.5810 -                                       ** writing this page to the database */
  1.5811 -#define PGHDR_NEED_READ         0x008  /* Content is unread */
  1.5812 -#define PGHDR_REUSE_UNLIKELY    0x010  /* A hint that reuse is unlikely */
  1.5813 -#define PGHDR_DONT_WRITE        0x020  /* Do not write content to disk */
  1.5814 -
  1.5815 -#define PGHDR_MMAP              0x040  /* This is an mmap page object */
  1.5816 +#define PGHDR_CLEAN           0x001  /* Page not on the PCache.pDirty list */
  1.5817 +#define PGHDR_DIRTY           0x002  /* Page is on the PCache.pDirty list */
  1.5818 +#define PGHDR_WRITEABLE       0x004  /* Journaled and ready to modify */
  1.5819 +#define PGHDR_NEED_SYNC       0x008  /* Fsync the rollback journal before
  1.5820 +                                     ** writing this page to the database */
  1.5821 +#define PGHDR_NEED_READ       0x010  /* Content is unread */
  1.5822 +#define PGHDR_DONT_WRITE      0x020  /* Do not write content to disk */
  1.5823 +#define PGHDR_MMAP            0x040  /* This is an mmap page object */
  1.5824 +
  1.5825 +#define PGHDR_WAL_APPEND      0x080  /* Appended to wal file */
  1.5826  
  1.5827  /* Initialize and shutdown the page cache subsystem */
  1.5828  SQLITE_PRIVATE int sqlite3PcacheInitialize(void);
  1.5829 @@ -9862,7 +11428,7 @@
  1.5830  ** Under memory stress, invoke xStress to try to make pages clean.
  1.5831  ** Only clean and unpinned pages can be reclaimed.
  1.5832  */
  1.5833 -SQLITE_PRIVATE void sqlite3PcacheOpen(
  1.5834 +SQLITE_PRIVATE int sqlite3PcacheOpen(
  1.5835    int szPage,                    /* Size of every page */
  1.5836    int szExtra,                   /* Extra space associated with each page */
  1.5837    int bPurgeable,                /* True if pages are on backing store */
  1.5838 @@ -9872,7 +11438,7 @@
  1.5839  );
  1.5840  
  1.5841  /* Modify the page-size after the cache has been created. */
  1.5842 -SQLITE_PRIVATE void sqlite3PcacheSetPageSize(PCache *, int);
  1.5843 +SQLITE_PRIVATE int sqlite3PcacheSetPageSize(PCache *, int);
  1.5844  
  1.5845  /* Return the size in bytes of a PCache object.  Used to preallocate
  1.5846  ** storage space.
  1.5847 @@ -9882,7 +11448,9 @@
  1.5848  /* One release per successful fetch.  Page is pinned until released.
  1.5849  ** Reference counted. 
  1.5850  */
  1.5851 -SQLITE_PRIVATE int sqlite3PcacheFetch(PCache*, Pgno, int createFlag, PgHdr**);
  1.5852 +SQLITE_PRIVATE sqlite3_pcache_page *sqlite3PcacheFetch(PCache*, Pgno, int createFlag);
  1.5853 +SQLITE_PRIVATE int sqlite3PcacheFetchStress(PCache*, Pgno, sqlite3_pcache_page**);
  1.5854 +SQLITE_PRIVATE PgHdr *sqlite3PcacheFetchFinish(PCache*, Pgno, sqlite3_pcache_page *pPage);
  1.5855  SQLITE_PRIVATE void sqlite3PcacheRelease(PgHdr*);
  1.5856  
  1.5857  SQLITE_PRIVATE void sqlite3PcacheDrop(PgHdr*);         /* Remove page from cache */
  1.5858 @@ -9938,6 +11506,13 @@
  1.5859  SQLITE_PRIVATE int sqlite3PcacheGetCachesize(PCache *);
  1.5860  #endif
  1.5861  
  1.5862 +/* Set or get the suggested spill-size for the specified pager-cache.
  1.5863 +**
  1.5864 +** The spill-size is the minimum number of pages in cache before the cache
  1.5865 +** will attempt to spill dirty pages by calling xStress.
  1.5866 +*/
  1.5867 +SQLITE_PRIVATE int sqlite3PcacheSetSpillsize(PCache *, int);
  1.5868 +
  1.5869  /* Free up as much memory as possible from the page cache */
  1.5870  SQLITE_PRIVATE void sqlite3PcacheShrink(PCache*);
  1.5871  
  1.5872 @@ -9952,6 +11527,10 @@
  1.5873  
  1.5874  SQLITE_PRIVATE void sqlite3PCacheSetDefault(void);
  1.5875  
  1.5876 +/* Return the header size */
  1.5877 +SQLITE_PRIVATE int sqlite3HeaderSizePcache(void);
  1.5878 +SQLITE_PRIVATE int sqlite3HeaderSizePcache1(void);
  1.5879 +
  1.5880  #endif /* _PCACHE_H_ */
  1.5881  
  1.5882  /************** End of pcache.h **********************************************/
  1.5883 @@ -10142,7 +11721,7 @@
  1.5884  ** shared locks begins at SHARED_FIRST. 
  1.5885  **
  1.5886  ** The same locking strategy and
  1.5887 -** byte ranges are used for Unix.  This leaves open the possiblity of having
  1.5888 +** byte ranges are used for Unix.  This leaves open the possibility of having
  1.5889  ** clients on win95, winNT, and unix all talking to the same shared file
  1.5890  ** and all locking correctly.  To do so would require that samba (or whatever
  1.5891  ** tool is being used for file sharing) implements locks correctly between
  1.5892 @@ -10261,7 +11840,7 @@
  1.5893  ** Figure out what version of the code to use.  The choices are
  1.5894  **
  1.5895  **   SQLITE_MUTEX_OMIT         No mutex logic.  Not even stubs.  The
  1.5896 -**                             mutexes implemention cannot be overridden
  1.5897 +**                             mutexes implementation cannot be overridden
  1.5898  **                             at start-time.
  1.5899  **
  1.5900  **   SQLITE_MUTEX_NOOP         For single-threaded applications.  No
  1.5901 @@ -10381,7 +11960,7 @@
  1.5902  ** The number of different kinds of things that can be limited
  1.5903  ** using the sqlite3_limit() interface.
  1.5904  */
  1.5905 -#define SQLITE_N_LIMIT (SQLITE_LIMIT_TRIGGER_DEPTH+1)
  1.5906 +#define SQLITE_N_LIMIT (SQLITE_LIMIT_WORKER_THREADS+1)
  1.5907  
  1.5908  /*
  1.5909  ** Lookaside malloc is a set of fixed-size buffers that can be used
  1.5910 @@ -10404,8 +11983,8 @@
  1.5911  ** lookaside allocations are not used to construct the schema objects.
  1.5912  */
  1.5913  struct Lookaside {
  1.5914 +  u32 bDisable;           /* Only operate the lookaside when zero */
  1.5915    u16 sz;                 /* Size of each buffer in bytes */
  1.5916 -  u8 bEnabled;            /* False to disable new lookaside allocations */
  1.5917    u8 bMalloced;           /* True if pStart obtained from sqlite3_malloc() */
  1.5918    int nOut;               /* Number of buffers currently checked out */
  1.5919    int mxOut;              /* Highwater mark for nOut */
  1.5920 @@ -10428,6 +12007,45 @@
  1.5921    FuncDef *a[23];       /* Hash table for functions */
  1.5922  };
  1.5923  
  1.5924 +#ifdef SQLITE_USER_AUTHENTICATION
  1.5925 +/*
  1.5926 +** Information held in the "sqlite3" database connection object and used
  1.5927 +** to manage user authentication.
  1.5928 +*/
  1.5929 +typedef struct sqlite3_userauth sqlite3_userauth;
  1.5930 +struct sqlite3_userauth {
  1.5931 +  u8 authLevel;                 /* Current authentication level */
  1.5932 +  int nAuthPW;                  /* Size of the zAuthPW in bytes */
  1.5933 +  char *zAuthPW;                /* Password used to authenticate */
  1.5934 +  char *zAuthUser;              /* User name used to authenticate */
  1.5935 +};
  1.5936 +
  1.5937 +/* Allowed values for sqlite3_userauth.authLevel */
  1.5938 +#define UAUTH_Unknown     0     /* Authentication not yet checked */
  1.5939 +#define UAUTH_Fail        1     /* User authentication failed */
  1.5940 +#define UAUTH_User        2     /* Authenticated as a normal user */
  1.5941 +#define UAUTH_Admin       3     /* Authenticated as an administrator */
  1.5942 +
  1.5943 +/* Functions used only by user authorization logic */
  1.5944 +SQLITE_PRIVATE int sqlite3UserAuthTable(const char*);
  1.5945 +SQLITE_PRIVATE int sqlite3UserAuthCheckLogin(sqlite3*,const char*,u8*);
  1.5946 +SQLITE_PRIVATE void sqlite3UserAuthInit(sqlite3*);
  1.5947 +SQLITE_PRIVATE void sqlite3CryptFunc(sqlite3_context*,int,sqlite3_value**);
  1.5948 +
  1.5949 +#endif /* SQLITE_USER_AUTHENTICATION */
  1.5950 +
  1.5951 +/*
  1.5952 +** typedef for the authorization callback function.
  1.5953 +*/
  1.5954 +#ifdef SQLITE_USER_AUTHENTICATION
  1.5955 +  typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,
  1.5956 +                               const char*, const char*);
  1.5957 +#else
  1.5958 +  typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,
  1.5959 +                               const char*);
  1.5960 +#endif
  1.5961 +
  1.5962 +
  1.5963  /*
  1.5964  ** Each database connection is an instance of the following structure.
  1.5965  */
  1.5966 @@ -10445,9 +12063,11 @@
  1.5967    int errCode;                  /* Most recent error code (SQLITE_*) */
  1.5968    int errMask;                  /* & result codes with this before returning */
  1.5969    u16 dbOptFlags;               /* Flags to enable/disable optimizations */
  1.5970 +  u8 enc;                       /* Text encoding */
  1.5971    u8 autoCommit;                /* The auto-commit flag. */
  1.5972    u8 temp_store;                /* 1: file 2: memory 0: default */
  1.5973    u8 mallocFailed;              /* True if we have seen a malloc failure */
  1.5974 +  u8 bBenignMalloc;             /* Do not require OOMs if true */
  1.5975    u8 dfltLockMode;              /* Default locking-mode for attached dbs */
  1.5976    signed char nextAutovac;      /* Autovac setting after VACUUM if >=0 */
  1.5977    u8 suppressErr;               /* Do not issue error messages if true */
  1.5978 @@ -10458,16 +12078,19 @@
  1.5979    int nChange;                  /* Value returned by sqlite3_changes() */
  1.5980    int nTotalChange;             /* Value returned by sqlite3_total_changes() */
  1.5981    int aLimit[SQLITE_N_LIMIT];   /* Limits */
  1.5982 +  int nMaxSorterMmap;           /* Maximum size of regions mapped by sorter */
  1.5983    struct sqlite3InitInfo {      /* Information used during initialization */
  1.5984      int newTnum;                /* Rootpage of table being initialized */
  1.5985      u8 iDb;                     /* Which db file is being initialized */
  1.5986      u8 busy;                    /* TRUE if currently initializing */
  1.5987      u8 orphanTrigger;           /* Last statement is orphaned TEMP trigger */
  1.5988 +    u8 imposterTable;           /* Building an imposter table */
  1.5989    } init;
  1.5990    int nVdbeActive;              /* Number of VDBEs currently running */
  1.5991    int nVdbeRead;                /* Number of active VDBEs that read or write */
  1.5992    int nVdbeWrite;               /* Number of active VDBEs that read and write */
  1.5993    int nVdbeExec;                /* Number of nested calls to VdbeExec() */
  1.5994 +  int nVDestroy;                /* Number of active OP_VDestroy operations */
  1.5995    int nExtension;               /* Number of loaded extensions */
  1.5996    void **aExtension;            /* Array of shared library handles */
  1.5997    void (*xTrace)(void*,const char*);        /* Trace function */
  1.5998 @@ -10494,8 +12117,7 @@
  1.5999    } u1;
  1.6000    Lookaside lookaside;          /* Lookaside malloc configuration */
  1.6001  #ifndef SQLITE_OMIT_AUTHORIZATION
  1.6002 -  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*);
  1.6003 -                                /* Access authorization function */
  1.6004 +  sqlite3_xauth xAuth;          /* Access authorization function */
  1.6005    void *pAuthArg;               /* 1st argument to the access auth function */
  1.6006  #endif
  1.6007  #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
  1.6008 @@ -10521,7 +12143,6 @@
  1.6009    i64 nDeferredCons;            /* Net deferred constraints this transaction. */
  1.6010    i64 nDeferredImmCons;         /* Net deferred immediate constraints */
  1.6011    int *pnBytesFreed;            /* If not NULL, increment this in DbFree() */
  1.6012 -
  1.6013  #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
  1.6014    /* The following variables are all protected by the STATIC_MASTER 
  1.6015    ** mutex, not by sqlite3.mutex. They are used by code in notify.c. 
  1.6016 @@ -10539,22 +12160,26 @@
  1.6017    void (*xUnlockNotify)(void **, int);  /* Unlock notify callback */
  1.6018    sqlite3 *pNextBlocked;        /* Next in list of all blocked connections */
  1.6019  #endif
  1.6020 +#ifdef SQLITE_USER_AUTHENTICATION
  1.6021 +  sqlite3_userauth auth;        /* User authentication information */
  1.6022 +#endif
  1.6023  };
  1.6024  
  1.6025  /*
  1.6026  ** A macro to discover the encoding of a database.
  1.6027  */
  1.6028 -#define ENC(db) ((db)->aDb[0].pSchema->enc)
  1.6029 +#define SCHEMA_ENC(db) ((db)->aDb[0].pSchema->enc)
  1.6030 +#define ENC(db)        ((db)->enc)
  1.6031  
  1.6032  /*
  1.6033  ** Possible values for the sqlite3.flags.
  1.6034  */
  1.6035  #define SQLITE_VdbeTrace      0x00000001  /* True to trace VDBE execution */
  1.6036  #define SQLITE_InternChanges  0x00000002  /* Uncommitted Hash table changes */
  1.6037 -#define SQLITE_FullFSync      0x00000004  /* Use full fsync on the backend */
  1.6038 -#define SQLITE_CkptFullFSync  0x00000008  /* Use full fsync for checkpoint */
  1.6039 -#define SQLITE_CacheSpill     0x00000010  /* OK to spill pager cache */
  1.6040 -#define SQLITE_FullColNames   0x00000020  /* Show full column names on SELECT */
  1.6041 +#define SQLITE_FullColNames   0x00000004  /* Show full column names on SELECT */
  1.6042 +#define SQLITE_FullFSync      0x00000008  /* Use full fsync on the backend */
  1.6043 +#define SQLITE_CkptFullFSync  0x00000010  /* Use full fsync for checkpoint */
  1.6044 +#define SQLITE_CacheSpill     0x00000020  /* OK to spill pager cache */
  1.6045  #define SQLITE_ShortColNames  0x00000040  /* Show short columns names */
  1.6046  #define SQLITE_CountRows      0x00000080  /* Count rows changed by INSERT, */
  1.6047                                            /*   DELETE, or UPDATE and return */
  1.6048 @@ -10579,6 +12204,8 @@
  1.6049  #define SQLITE_DeferFKs       0x01000000  /* Defer all FK constraints */
  1.6050  #define SQLITE_QueryOnly      0x02000000  /* Disable database changes */
  1.6051  #define SQLITE_VdbeEQP        0x04000000  /* Debug EXPLAIN QUERY PLAN */
  1.6052 +#define SQLITE_Vacuum         0x08000000  /* Currently in a VACUUM */
  1.6053 +#define SQLITE_CellSizeCk     0x10000000  /* Check btree cell sizes on load */
  1.6054  
  1.6055  
  1.6056  /*
  1.6057 @@ -10597,8 +12224,8 @@
  1.6058  #define SQLITE_SubqCoroutine  0x0100   /* Evaluate subqueries as coroutines */
  1.6059  #define SQLITE_Transitive     0x0200   /* Transitive constraints */
  1.6060  #define SQLITE_OmitNoopJoin   0x0400   /* Omit unused tables in joins */
  1.6061 -#define SQLITE_Stat3          0x0800   /* Use the SQLITE_STAT3 table */
  1.6062 -#define SQLITE_AdjustOutEst   0x1000   /* Adjust output estimates using WHERE */
  1.6063 +#define SQLITE_Stat34         0x0800   /* Use STAT3 or STAT4 data */
  1.6064 +#define SQLITE_CursorHints    0x2000   /* Add OP_CursorHint opcodes */
  1.6065  #define SQLITE_AllOpts        0xffff   /* All optimizations */
  1.6066  
  1.6067  /*
  1.6068 @@ -10641,9 +12268,8 @@
  1.6069    u16 funcFlags;       /* Some combination of SQLITE_FUNC_* */
  1.6070    void *pUserData;     /* User data parameter */
  1.6071    FuncDef *pNext;      /* Next function with same name */
  1.6072 -  void (*xFunc)(sqlite3_context*,int,sqlite3_value**); /* Regular function */
  1.6073 -  void (*xStep)(sqlite3_context*,int,sqlite3_value**); /* Aggregate step */
  1.6074 -  void (*xFinalize)(sqlite3_context*);                /* Aggregate finalizer */
  1.6075 +  void (*xSFunc)(sqlite3_context*,int,sqlite3_value**); /* func or agg-step */
  1.6076 +  void (*xFinalize)(sqlite3_context*);                  /* Agg finalizer */
  1.6077    char *zName;         /* SQL name of the function. */
  1.6078    FuncDef *pHash;      /* Next with a different name but the same hash */
  1.6079    FuncDestructor *pDestructor;   /* Reference counted destructor function */
  1.6080 @@ -10671,20 +12297,24 @@
  1.6081  
  1.6082  /*
  1.6083  ** Possible values for FuncDef.flags.  Note that the _LENGTH and _TYPEOF
  1.6084 -** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG.  There
  1.6085 +** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG.  And
  1.6086 +** SQLITE_FUNC_CONSTANT must be the same as SQLITE_DETERMINISTIC.  There
  1.6087  ** are assert() statements in the code to verify this.
  1.6088  */
  1.6089 -#define SQLITE_FUNC_ENCMASK  0x003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */
  1.6090 -#define SQLITE_FUNC_LIKE     0x004 /* Candidate for the LIKE optimization */
  1.6091 -#define SQLITE_FUNC_CASE     0x008 /* Case-sensitive LIKE-type function */
  1.6092 -#define SQLITE_FUNC_EPHEM    0x010 /* Ephemeral.  Delete with VDBE */
  1.6093 -#define SQLITE_FUNC_NEEDCOLL 0x020 /* sqlite3GetFuncCollSeq() might be called */
  1.6094 -#define SQLITE_FUNC_LENGTH   0x040 /* Built-in length() function */
  1.6095 -#define SQLITE_FUNC_TYPEOF   0x080 /* Built-in typeof() function */
  1.6096 -#define SQLITE_FUNC_COUNT    0x100 /* Built-in count(*) aggregate */
  1.6097 -#define SQLITE_FUNC_COALESCE 0x200 /* Built-in coalesce() or ifnull() */
  1.6098 -#define SQLITE_FUNC_UNLIKELY 0x400 /* Built-in unlikely() function */
  1.6099 -#define SQLITE_FUNC_CONSTANT 0x800 /* Constant inputs give a constant output */
  1.6100 +#define SQLITE_FUNC_ENCMASK  0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */
  1.6101 +#define SQLITE_FUNC_LIKE     0x0004 /* Candidate for the LIKE optimization */
  1.6102 +#define SQLITE_FUNC_CASE     0x0008 /* Case-sensitive LIKE-type function */
  1.6103 +#define SQLITE_FUNC_EPHEM    0x0010 /* Ephemeral.  Delete with VDBE */
  1.6104 +#define SQLITE_FUNC_NEEDCOLL 0x0020 /* sqlite3GetFuncCollSeq() might be called*/
  1.6105 +#define SQLITE_FUNC_LENGTH   0x0040 /* Built-in length() function */
  1.6106 +#define SQLITE_FUNC_TYPEOF   0x0080 /* Built-in typeof() function */
  1.6107 +#define SQLITE_FUNC_COUNT    0x0100 /* Built-in count(*) aggregate */
  1.6108 +#define SQLITE_FUNC_COALESCE 0x0200 /* Built-in coalesce() or ifnull() */
  1.6109 +#define SQLITE_FUNC_UNLIKELY 0x0400 /* Built-in unlikely() function */
  1.6110 +#define SQLITE_FUNC_CONSTANT 0x0800 /* Constant inputs give a constant output */
  1.6111 +#define SQLITE_FUNC_MINMAX   0x1000 /* True for min() and max() aggregates */
  1.6112 +#define SQLITE_FUNC_SLOCHNG  0x2000 /* "Slow Change". Value constant during a
  1.6113 +                                    ** single query - might change over time */
  1.6114  
  1.6115  /*
  1.6116  ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
  1.6117 @@ -10700,6 +12330,12 @@
  1.6118  **   VFUNCTION(zName, nArg, iArg, bNC, xFunc)
  1.6119  **     Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag.
  1.6120  **
  1.6121 +**   DFUNCTION(zName, nArg, iArg, bNC, xFunc)
  1.6122 +**     Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag and
  1.6123 +**     adds the SQLITE_FUNC_SLOCHNG flag.  Used for date & time functions
  1.6124 +**     and functions like sqlite_version() that can change, but not during
  1.6125 +**     a single query.
  1.6126 +**
  1.6127  **   AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal)
  1.6128  **     Used to create an aggregate function definition implemented by
  1.6129  **     the C functions xStep and xFinal. The first four parameters
  1.6130 @@ -10716,22 +12352,28 @@
  1.6131  */
  1.6132  #define FUNCTION(zName, nArg, iArg, bNC, xFunc) \
  1.6133    {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
  1.6134 -   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0}
  1.6135 +   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, 0, 0}
  1.6136  #define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \
  1.6137    {nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
  1.6138 -   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0}
  1.6139 +   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, 0, 0}
  1.6140 +#define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \
  1.6141 +  {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
  1.6142 +   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, 0, 0}
  1.6143  #define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \
  1.6144    {nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\
  1.6145 -   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0}
  1.6146 +   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, 0, 0}
  1.6147  #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
  1.6148 -  {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
  1.6149 -   pArg, 0, xFunc, 0, 0, #zName, 0, 0}
  1.6150 +  {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
  1.6151 +   pArg, 0, xFunc, 0, #zName, 0, 0}
  1.6152  #define LIKEFUNC(zName, nArg, arg, flags) \
  1.6153    {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \
  1.6154 -   (void *)arg, 0, likeFunc, 0, 0, #zName, 0, 0}
  1.6155 +   (void *)arg, 0, likeFunc, 0, #zName, 0, 0}
  1.6156  #define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \
  1.6157    {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL), \
  1.6158 -   SQLITE_INT_TO_PTR(arg), 0, 0, xStep,xFinal,#zName,0,0}
  1.6159 +   SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,#zName,0,0}
  1.6160 +#define AGGREGATE2(zName, nArg, arg, nc, xStep, xFinal, extraFlags) \
  1.6161 +  {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|extraFlags, \
  1.6162 +   SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,#zName,0,0}
  1.6163  
  1.6164  /*
  1.6165  ** All current savepoints are stored in a linked list starting at
  1.6166 @@ -10765,6 +12407,7 @@
  1.6167    const char *zName;                   /* Name passed to create_module() */
  1.6168    void *pAux;                          /* pAux passed to create_module() */
  1.6169    void (*xDestroy)(void *);            /* Module destructor function */
  1.6170 +  Table *pEpoTab;                      /* Eponymous table for this module */
  1.6171  };
  1.6172  
  1.6173  /*
  1.6174 @@ -10779,7 +12422,7 @@
  1.6175    char *zColl;     /* Collating sequence.  If NULL, use the default */
  1.6176    u8 notNull;      /* An OE_ code for handling a NOT NULL constraint */
  1.6177    char affinity;   /* One of the SQLITE_AFF_... values */
  1.6178 -  u8 szEst;        /* Estimated size of this column.  INT==1 */
  1.6179 +  u8 szEst;        /* Estimated size of value in this column. sizeof(INT)==1 */
  1.6180    u8 colFlags;     /* Boolean properties.  See COLFLAG_ defines below */
  1.6181  };
  1.6182  
  1.6183 @@ -10810,6 +12453,7 @@
  1.6184  */
  1.6185  #define SQLITE_SO_ASC       0  /* Sort in ascending order */
  1.6186  #define SQLITE_SO_DESC      1  /* Sort in ascending order */
  1.6187 +#define SQLITE_SO_UNDEFINED -1 /* No sort order specified */
  1.6188  
  1.6189  /*
  1.6190  ** Column affinity types.
  1.6191 @@ -10818,18 +12462,18 @@
  1.6192  ** 't' for SQLITE_AFF_TEXT.  But we can save a little space and improve
  1.6193  ** the speed a little by numbering the values consecutively.  
  1.6194  **
  1.6195 -** But rather than start with 0 or 1, we begin with 'a'.  That way,
  1.6196 +** But rather than start with 0 or 1, we begin with 'A'.  That way,
  1.6197  ** when multiple affinity types are concatenated into a string and
  1.6198  ** used as the P4 operand, they will be more readable.
  1.6199  **
  1.6200  ** Note also that the numeric types are grouped together so that testing
  1.6201 -** for a numeric type is a single comparison.
  1.6202 -*/
  1.6203 -#define SQLITE_AFF_TEXT     'a'
  1.6204 -#define SQLITE_AFF_NONE     'b'
  1.6205 -#define SQLITE_AFF_NUMERIC  'c'
  1.6206 -#define SQLITE_AFF_INTEGER  'd'
  1.6207 -#define SQLITE_AFF_REAL     'e'
  1.6208 +** for a numeric type is a single comparison.  And the BLOB type is first.
  1.6209 +*/
  1.6210 +#define SQLITE_AFF_BLOB     'A'
  1.6211 +#define SQLITE_AFF_TEXT     'B'
  1.6212 +#define SQLITE_AFF_NUMERIC  'C'
  1.6213 +#define SQLITE_AFF_INTEGER  'D'
  1.6214 +#define SQLITE_AFF_REAL     'E'
  1.6215  
  1.6216  #define sqlite3IsNumericAffinity(X)  ((X)>=SQLITE_AFF_NUMERIC)
  1.6217  
  1.6218 @@ -10837,7 +12481,7 @@
  1.6219  ** The SQLITE_AFF_MASK values masks off the significant bits of an
  1.6220  ** affinity value. 
  1.6221  */
  1.6222 -#define SQLITE_AFF_MASK     0x67
  1.6223 +#define SQLITE_AFF_MASK     0x47
  1.6224  
  1.6225  /*
  1.6226  ** Additional bit values that can be ORed with an affinity without
  1.6227 @@ -10848,10 +12492,10 @@
  1.6228  ** operator is NULL.  It is added to certain comparison operators to
  1.6229  ** prove that the operands are always NOT NULL.
  1.6230  */
  1.6231 -#define SQLITE_JUMPIFNULL   0x08  /* jumps if either operand is NULL */
  1.6232 -#define SQLITE_STOREP2      0x10  /* Store result in reg[P2] rather than jump */
  1.6233 +#define SQLITE_JUMPIFNULL   0x10  /* jumps if either operand is NULL */
  1.6234 +#define SQLITE_STOREP2      0x20  /* Store result in reg[P2] rather than jump */
  1.6235  #define SQLITE_NULLEQ       0x80  /* NULL=NULL */
  1.6236 -#define SQLITE_NOTNULL      0x88  /* Assert that operands are never NULL */
  1.6237 +#define SQLITE_NOTNULL      0x90  /* Assert that operands are never NULL */
  1.6238  
  1.6239  /*
  1.6240  ** An object of this type is created for each virtual table present in
  1.6241 @@ -10906,34 +12550,8 @@
  1.6242  };
  1.6243  
  1.6244  /*
  1.6245 -** Each SQL table is represented in memory by an instance of the
  1.6246 -** following structure.
  1.6247 -**
  1.6248 -** Table.zName is the name of the table.  The case of the original
  1.6249 -** CREATE TABLE statement is stored, but case is not significant for
  1.6250 -** comparisons.
  1.6251 -**
  1.6252 -** Table.nCol is the number of columns in this table.  Table.aCol is a
  1.6253 -** pointer to an array of Column structures, one for each column.
  1.6254 -**
  1.6255 -** If the table has an INTEGER PRIMARY KEY, then Table.iPKey is the index of
  1.6256 -** the column that is that key.   Otherwise Table.iPKey is negative.  Note
  1.6257 -** that the datatype of the PRIMARY KEY must be INTEGER for this field to
  1.6258 -** be set.  An INTEGER PRIMARY KEY is used as the rowid for each row of
  1.6259 -** the table.  If a table has no INTEGER PRIMARY KEY, then a random rowid
  1.6260 -** is generated for each row of the table.  TF_HasPrimaryKey is set if
  1.6261 -** the table has any PRIMARY KEY, INTEGER or otherwise.
  1.6262 -**
  1.6263 -** Table.tnum is the page number for the root BTree page of the table in the
  1.6264 -** database file.  If Table.iDb is the index of the database table backend
  1.6265 -** in sqlite.aDb[].  0 is for the main database and 1 is for the file that
  1.6266 -** holds temporary tables and indices.  If TF_Ephemeral is set
  1.6267 -** then the table is stored in a file that is automatically deleted
  1.6268 -** when the VDBE cursor to the table is closed.  In this case Table.tnum 
  1.6269 -** refers VDBE cursor number that holds the table open, not to the root
  1.6270 -** page number.  Transient tables are used to hold the results of a
  1.6271 -** sub-query that appears instead of a real table name in the FROM clause 
  1.6272 -** of a SELECT statement.
  1.6273 +** The schema for each SQL table and view is represented in memory
  1.6274 +** by an instance of the following structure.
  1.6275  */
  1.6276  struct Table {
  1.6277    char *zName;         /* Name of the table or view */
  1.6278 @@ -10942,14 +12560,13 @@
  1.6279    Select *pSelect;     /* NULL for tables.  Points to definition if a view. */
  1.6280    FKey *pFKey;         /* Linked list of all foreign keys in this table */
  1.6281    char *zColAff;       /* String defining the affinity of each column */
  1.6282 -#ifndef SQLITE_OMIT_CHECK
  1.6283    ExprList *pCheck;    /* All CHECK constraints */
  1.6284 -#endif
  1.6285 -  LogEst nRowLogEst;   /* Estimated rows in table - from sqlite_stat1 table */
  1.6286 -  int tnum;            /* Root BTree node for this table (see note above) */
  1.6287 -  i16 iPKey;           /* If not negative, use aCol[iPKey] as the primary key */
  1.6288 +                       /*   ... also used as column name list in a VIEW */
  1.6289 +  int tnum;            /* Root BTree page for this table */
  1.6290 +  i16 iPKey;           /* If not negative, use aCol[iPKey] as the rowid */
  1.6291    i16 nCol;            /* Number of columns in this table */
  1.6292    u16 nRef;            /* Number of pointers to this Table */
  1.6293 +  LogEst nRowLogEst;   /* Estimated rows in table - from sqlite_stat1 table */
  1.6294    LogEst szTabRow;     /* Estimated size of each table row in bytes */
  1.6295  #ifdef SQLITE_ENABLE_COSTMULT
  1.6296    LogEst costMult;     /* Cost multiplier for using this table */
  1.6297 @@ -10961,7 +12578,7 @@
  1.6298  #endif
  1.6299  #ifndef SQLITE_OMIT_VIRTUALTABLE
  1.6300    int nModuleArg;      /* Number of arguments to the module */
  1.6301 -  char **azModuleArg;  /* Text of all module args. [0] is module name */
  1.6302 +  char **azModuleArg;  /* 0: module 1: schema 2: vtab name 3...: args */
  1.6303    VTable *pVTable;     /* List of VTable objects. */
  1.6304  #endif
  1.6305    Trigger *pTrigger;   /* List of triggers stored in pSchema */
  1.6306 @@ -10971,13 +12588,21 @@
  1.6307  
  1.6308  /*
  1.6309  ** Allowed values for Table.tabFlags.
  1.6310 +**
  1.6311 +** TF_OOOHidden applies to tables or view that have hidden columns that are
  1.6312 +** followed by non-hidden columns.  Example:  "CREATE VIRTUAL TABLE x USING
  1.6313 +** vtab1(a HIDDEN, b);".  Since "b" is a non-hidden column but "a" is hidden,
  1.6314 +** the TF_OOOHidden attribute would apply in this case.  Such tables require
  1.6315 +** special handling during INSERT processing.
  1.6316  */
  1.6317  #define TF_Readonly        0x01    /* Read-only system table */
  1.6318  #define TF_Ephemeral       0x02    /* An ephemeral table */
  1.6319  #define TF_HasPrimaryKey   0x04    /* Table has a primary key */
  1.6320  #define TF_Autoincrement   0x08    /* Integer primary key is autoincrement */
  1.6321  #define TF_Virtual         0x10    /* Is a virtual table */
  1.6322 -#define TF_WithoutRowid    0x20    /* No rowid used. PRIMARY KEY is the key */
  1.6323 +#define TF_WithoutRowid    0x20    /* No rowid.  PRIMARY KEY is the key */
  1.6324 +#define TF_NoVisibleRowid  0x40    /* No user-visible "rowid" column */
  1.6325 +#define TF_OOOHidden       0x80    /* Out-of-Order hidden columns */
  1.6326  
  1.6327  
  1.6328  /*
  1.6329 @@ -10987,14 +12612,31 @@
  1.6330  */
  1.6331  #ifndef SQLITE_OMIT_VIRTUALTABLE
  1.6332  #  define IsVirtual(X)      (((X)->tabFlags & TF_Virtual)!=0)
  1.6333 -#  define IsHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0)
  1.6334  #else
  1.6335  #  define IsVirtual(X)      0
  1.6336 -#  define IsHiddenColumn(X) 0
  1.6337 -#endif
  1.6338 +#endif
  1.6339 +
  1.6340 +/*
  1.6341 +** Macros to determine if a column is hidden.  IsOrdinaryHiddenColumn()
  1.6342 +** only works for non-virtual tables (ordinary tables and views) and is
  1.6343 +** always false unless SQLITE_ENABLE_HIDDEN_COLUMNS is defined.  The
  1.6344 +** IsHiddenColumn() macro is general purpose.
  1.6345 +*/
  1.6346 +#if defined(SQLITE_ENABLE_HIDDEN_COLUMNS)
  1.6347 +#  define IsHiddenColumn(X)         (((X)->colFlags & COLFLAG_HIDDEN)!=0)
  1.6348 +#  define IsOrdinaryHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0)
  1.6349 +#elif !defined(SQLITE_OMIT_VIRTUALTABLE)
  1.6350 +#  define IsHiddenColumn(X)         (((X)->colFlags & COLFLAG_HIDDEN)!=0)
  1.6351 +#  define IsOrdinaryHiddenColumn(X) 0
  1.6352 +#else
  1.6353 +#  define IsHiddenColumn(X)         0
  1.6354 +#  define IsOrdinaryHiddenColumn(X) 0
  1.6355 +#endif
  1.6356 +
  1.6357  
  1.6358  /* Does the table have a rowid */
  1.6359  #define HasRowid(X)     (((X)->tabFlags & TF_WithoutRowid)==0)
  1.6360 +#define VisibleRowid(X) (((X)->tabFlags & TF_NoVisibleRowid)==0)
  1.6361  
  1.6362  /*
  1.6363  ** Each foreign key constraint is an instance of the following structure.
  1.6364 @@ -11101,9 +12743,8 @@
  1.6365  };
  1.6366  
  1.6367  /*
  1.6368 -** An instance of the following structure holds information about a
  1.6369 -** single index record that has already been parsed out into individual
  1.6370 -** values.
  1.6371 +** This object holds a record which has been parsed out into individual
  1.6372 +** fields, for the purposes of doing a comparison.
  1.6373  **
  1.6374  ** A record is an object that contains one or more fields of data.
  1.6375  ** Records are used to store the content of a table row and to store
  1.6376 @@ -11111,20 +12752,40 @@
  1.6377  ** the OP_MakeRecord opcode of the VDBE and is disassembled by the
  1.6378  ** OP_Column opcode.
  1.6379  **
  1.6380 -** This structure holds a record that has already been disassembled
  1.6381 -** into its constituent fields.
  1.6382 -**
  1.6383 -** The r1 and r2 member variables are only used by the optimized comparison
  1.6384 -** functions vdbeRecordCompareInt() and vdbeRecordCompareString().
  1.6385 +** An instance of this object serves as a "key" for doing a search on
  1.6386 +** an index b+tree. The goal of the search is to find the entry that
  1.6387 +** is closed to the key described by this object.  This object might hold
  1.6388 +** just a prefix of the key.  The number of fields is given by
  1.6389 +** pKeyInfo->nField.
  1.6390 +**
  1.6391 +** The r1 and r2 fields are the values to return if this key is less than
  1.6392 +** or greater than a key in the btree, respectively.  These are normally
  1.6393 +** -1 and +1 respectively, but might be inverted to +1 and -1 if the b-tree
  1.6394 +** is in DESC order.
  1.6395 +**
  1.6396 +** The key comparison functions actually return default_rc when they find
  1.6397 +** an equals comparison.  default_rc can be -1, 0, or +1.  If there are
  1.6398 +** multiple entries in the b-tree with the same key (when only looking
  1.6399 +** at the first pKeyInfo->nFields,) then default_rc can be set to -1 to 
  1.6400 +** cause the search to find the last match, or +1 to cause the search to
  1.6401 +** find the first match.
  1.6402 +**
  1.6403 +** The key comparison functions will set eqSeen to true if they ever
  1.6404 +** get and equal results when comparing this structure to a b-tree record.
  1.6405 +** When default_rc!=0, the search might end up on the record immediately
  1.6406 +** before the first match or immediately after the last match.  The
  1.6407 +** eqSeen field will indicate whether or not an exact match exists in the
  1.6408 +** b-tree.
  1.6409  */
  1.6410  struct UnpackedRecord {
  1.6411    KeyInfo *pKeyInfo;  /* Collation and sort-order information */
  1.6412 +  Mem *aMem;          /* Values */
  1.6413    u16 nField;         /* Number of entries in apMem[] */
  1.6414    i8 default_rc;      /* Comparison result if keys are equal */
  1.6415 -  u8 isCorrupt;       /* Corruption detected by xRecordCompare() */
  1.6416 -  Mem *aMem;          /* Values */
  1.6417 -  int r1;             /* Value to return if (lhs > rhs) */
  1.6418 -  int r2;             /* Value to return if (rhs < lhs) */
  1.6419 +  u8 errCode;         /* Error detected by xRecordCompare (CORRUPT or NOMEM) */
  1.6420 +  i8 r1;              /* Value to return if (lhs > rhs) */
  1.6421 +  i8 r2;              /* Value to return if (rhs < lhs) */
  1.6422 +  u8 eqSeen;          /* True if an equality comparison has been seen */
  1.6423  };
  1.6424  
  1.6425  
  1.6426 @@ -11153,6 +12814,14 @@
  1.6427  ** and the value of Index.onError indicate the which conflict resolution 
  1.6428  ** algorithm to employ whenever an attempt is made to insert a non-unique
  1.6429  ** element.
  1.6430 +**
  1.6431 +** While parsing a CREATE TABLE or CREATE INDEX statement in order to
  1.6432 +** generate VDBE code (as opposed to parsing one read from an sqlite_master
  1.6433 +** table as part of parsing an existing database schema), transient instances
  1.6434 +** of this structure may be created. In this case the Index.tnum variable is
  1.6435 +** used to store the address of a VDBE instruction, not a database page
  1.6436 +** number (it cannot - the database page is not allocated until the VDBE
  1.6437 +** program is executed). See convertToWithoutRowidTable() for details.
  1.6438  */
  1.6439  struct Index {
  1.6440    char *zName;             /* Name of this index */
  1.6441 @@ -11163,9 +12832,9 @@
  1.6442    Index *pNext;            /* The next index associated with the same table */
  1.6443    Schema *pSchema;         /* Schema containing this index */
  1.6444    u8 *aSortOrder;          /* for each column: True==DESC, False==ASC */
  1.6445 -  char **azColl;           /* Array of collation sequence names for index */
  1.6446 +  const char **azColl;     /* Array of collation sequence names for index */
  1.6447    Expr *pPartIdxWhere;     /* WHERE clause for partial indices */
  1.6448 -  KeyInfo *pKeyInfo;       /* A KeyInfo object suitable for this index */
  1.6449 +  ExprList *aColExpr;      /* Column expressions */
  1.6450    int tnum;                /* DB Page containing root of this index */
  1.6451    LogEst szIdxRow;         /* Estimated average row size in bytes */
  1.6452    u16 nKeyCol;             /* Number of columns forming the key */
  1.6453 @@ -11176,11 +12845,14 @@
  1.6454    unsigned uniqNotNull:1;  /* True if UNIQUE and NOT NULL for all columns */
  1.6455    unsigned isResized:1;    /* True if resizeIndexObject() has been called */
  1.6456    unsigned isCovering:1;   /* True if this is a covering index */
  1.6457 +  unsigned noSkipScan:1;   /* Do not try to use skip-scan if true */
  1.6458  #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
  1.6459    int nSample;             /* Number of elements in aSample[] */
  1.6460    int nSampleCol;          /* Size of IndexSample.anEq[] and so on */
  1.6461    tRowcnt *aAvgEq;         /* Average nEq values for keys not in aSample */
  1.6462    IndexSample *aSample;    /* Samples of the left-most key */
  1.6463 +  tRowcnt *aiRowEst;       /* Non-logarithmic stat1 data for this index */
  1.6464 +  tRowcnt nRowEst0;        /* Non-logarithmic number of rows in the index */
  1.6465  #endif
  1.6466  };
  1.6467  
  1.6468 @@ -11197,6 +12869,12 @@
  1.6469  /* Return true if index X is a UNIQUE index */
  1.6470  #define IsUniqueIndex(X)      ((X)->onError!=OE_None)
  1.6471  
  1.6472 +/* The Index.aiColumn[] values are normally positive integer.  But
  1.6473 +** there are some negative values that have special meaning:
  1.6474 +*/
  1.6475 +#define XN_ROWID     (-1)     /* Indexed column is the rowid */
  1.6476 +#define XN_EXPR      (-2)     /* Indexed column is an expression */
  1.6477 +
  1.6478  /*
  1.6479  ** Each sample stored in the sqlite_stat3 table is represented in memory 
  1.6480  ** using a structure of this type.  See documentation at the top of the
  1.6481 @@ -11378,7 +13056,7 @@
  1.6482    int iTable;            /* TK_COLUMN: cursor number of table holding column
  1.6483                           ** TK_REGISTER: register number
  1.6484                           ** TK_TRIGGER: 1 -> new, 0 -> old
  1.6485 -                         ** EP_Unlikely:  1000 times likelihood */
  1.6486 +                         ** EP_Unlikely:  134217728 times likelihood */
  1.6487    ynVar iColumn;         /* TK_COLUMN: column index.  -1 for rowid.
  1.6488                           ** TK_VARIABLE: variable number (always >= 1). */
  1.6489    i16 iAgg;              /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
  1.6490 @@ -11393,7 +13071,7 @@
  1.6491  /*
  1.6492  ** The following are the meanings of bits in the Expr.flags field.
  1.6493  */
  1.6494 -#define EP_FromJoin  0x000001 /* Originated in ON or USING clause of a join */
  1.6495 +#define EP_FromJoin  0x000001 /* Originates in ON/USING clause of outer join */
  1.6496  #define EP_Agg       0x000002 /* Contains one or more aggregate functions */
  1.6497  #define EP_Resolved  0x000004 /* IDs have been resolved to COLUMNs */
  1.6498  #define EP_Error     0x000008 /* Expression contains one or more errors */
  1.6499 @@ -11412,7 +13090,15 @@
  1.6500  #define EP_MemToken  0x010000 /* Need to sqlite3DbFree() Expr.zToken */
  1.6501  #define EP_NoReduce  0x020000 /* Cannot EXPRDUP_REDUCE this Expr */
  1.6502  #define EP_Unlikely  0x040000 /* unlikely() or likelihood() function */
  1.6503 -#define EP_Constant  0x080000 /* Node is a constant */
  1.6504 +#define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */
  1.6505 +#define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */
  1.6506 +#define EP_Subquery  0x200000 /* Tree contains a TK_SELECT operator */
  1.6507 +#define EP_Alias     0x400000 /* Is an alias for a result set column */
  1.6508 +
  1.6509 +/*
  1.6510 +** Combinations of two or more EP_* flags
  1.6511 +*/
  1.6512 +#define EP_Propagate (EP_Collate|EP_Subquery) /* Propagate these bits up tree */
  1.6513  
  1.6514  /*
  1.6515  ** These macros can be used to test, set, or clear bits in the 
  1.6516 @@ -11570,11 +13256,15 @@
  1.6517      int addrFillSub;  /* Address of subroutine to manifest a subquery */
  1.6518      int regReturn;    /* Register holding return address of addrFillSub */
  1.6519      int regResult;    /* Registers holding results of a co-routine */
  1.6520 -    u8 jointype;      /* Type of join between this able and the previous */
  1.6521 -    unsigned notIndexed :1;    /* True if there is a NOT INDEXED clause */
  1.6522 -    unsigned isCorrelated :1;  /* True if sub-query is correlated */
  1.6523 -    unsigned viaCoroutine :1;  /* Implemented as a co-routine */
  1.6524 -    unsigned isRecursive :1;   /* True for recursive reference in WITH */
  1.6525 +    struct {
  1.6526 +      u8 jointype;      /* Type of join between this able and the previous */
  1.6527 +      unsigned notIndexed :1;    /* True if there is a NOT INDEXED clause */
  1.6528 +      unsigned isIndexedBy :1;   /* True if there is an INDEXED BY clause */
  1.6529 +      unsigned isTabFunc :1;     /* True if table-valued-function syntax */
  1.6530 +      unsigned isCorrelated :1;  /* True if sub-query is correlated */
  1.6531 +      unsigned viaCoroutine :1;  /* Implemented as a co-routine */
  1.6532 +      unsigned isRecursive :1;   /* True for recursive reference in WITH */
  1.6533 +    } fg;
  1.6534  #ifndef SQLITE_OMIT_EXPLAIN
  1.6535      u8 iSelectId;     /* If pSelect!=0, the id of the sub-select in EQP */
  1.6536  #endif
  1.6537 @@ -11582,8 +13272,11 @@
  1.6538      Expr *pOn;        /* The ON clause of a join */
  1.6539      IdList *pUsing;   /* The USING clause of a join */
  1.6540      Bitmask colUsed;  /* Bit N (1<<N) set if column N of pTab is used */
  1.6541 -    char *zIndex;     /* Identifier from "INDEXED BY <zIndex>" clause */
  1.6542 -    Index *pIndex;    /* Index structure corresponding to zIndex, if any */
  1.6543 +    union {
  1.6544 +      char *zIndexedBy;    /* Identifier from "INDEXED BY <zIndex>" clause */
  1.6545 +      ExprList *pFuncArg;  /* Arguments to table-valued-function */
  1.6546 +    } u1;
  1.6547 +    Index *pIBIndex;  /* Index structure corresponding to u1.zIndexedBy */
  1.6548    } a[1];             /* One entry for each identifier on the list */
  1.6549  };
  1.6550  
  1.6551 @@ -11611,12 +13304,13 @@
  1.6552  #define WHERE_OMIT_OPEN_CLOSE  0x0010 /* Table cursors are already open */
  1.6553  #define WHERE_FORCE_TABLE      0x0020 /* Do not use an index-only search */
  1.6554  #define WHERE_ONETABLE_ONLY    0x0040 /* Only code the 1st table in pTabList */
  1.6555 -#define WHERE_AND_ONLY         0x0080 /* Don't use indices for OR terms */
  1.6556 +#define WHERE_NO_AUTOINDEX     0x0080 /* Disallow automatic indexes */
  1.6557  #define WHERE_GROUPBY          0x0100 /* pOrderBy is really a GROUP BY */
  1.6558  #define WHERE_DISTINCTBY       0x0200 /* pOrderby is really a DISTINCT clause */
  1.6559  #define WHERE_WANT_DISTINCT    0x0400 /* All output needs to be distinct */
  1.6560  #define WHERE_SORTBYGROUP      0x0800 /* Support sqlite3WhereIsSorted() */
  1.6561  #define WHERE_REOPEN_IDX       0x1000 /* Try to use OP_ReopenIdx */
  1.6562 +#define WHERE_ONEPASS_MULTIROW 0x2000 /* ONEPASS is ok with multiple rows */
  1.6563  
  1.6564  /* Allowed return values from sqlite3WhereIsDistinct()
  1.6565  */
  1.6566 @@ -11654,17 +13348,23 @@
  1.6567    NameContext *pNext;  /* Next outer name context.  NULL for outermost */
  1.6568    int nRef;            /* Number of names resolved by this context */
  1.6569    int nErr;            /* Number of errors encountered while resolving names */
  1.6570 -  u8 ncFlags;          /* Zero or more NC_* flags defined below */
  1.6571 +  u16 ncFlags;         /* Zero or more NC_* flags defined below */
  1.6572  };
  1.6573  
  1.6574  /*
  1.6575  ** Allowed values for the NameContext, ncFlags field.
  1.6576 -*/
  1.6577 -#define NC_AllowAgg  0x01    /* Aggregate functions are allowed here */
  1.6578 -#define NC_HasAgg    0x02    /* One or more aggregate functions seen */
  1.6579 -#define NC_IsCheck   0x04    /* True if resolving names in a CHECK constraint */
  1.6580 -#define NC_InAggFunc 0x08    /* True if analyzing arguments to an agg func */
  1.6581 -#define NC_PartIdx   0x10    /* True if resolving a partial index WHERE */
  1.6582 +**
  1.6583 +** Note:  NC_MinMaxAgg must have the same value as SF_MinMaxAgg and
  1.6584 +** SQLITE_FUNC_MINMAX.
  1.6585 +** 
  1.6586 +*/
  1.6587 +#define NC_AllowAgg  0x0001  /* Aggregate functions are allowed here */
  1.6588 +#define NC_HasAgg    0x0002  /* One or more aggregate functions seen */
  1.6589 +#define NC_IsCheck   0x0004  /* True if resolving names in a CHECK constraint */
  1.6590 +#define NC_InAggFunc 0x0008  /* True if analyzing arguments to an agg func */
  1.6591 +#define NC_PartIdx   0x0010  /* True if resolving a partial index WHERE */
  1.6592 +#define NC_IdxExpr   0x0020  /* True if resolving columns of CREATE INDEX */
  1.6593 +#define NC_MinMaxAgg 0x1000  /* min/max aggregates seen.  See note above */
  1.6594  
  1.6595  /*
  1.6596  ** An instance of the following structure contains all information
  1.6597 @@ -11691,6 +13391,9 @@
  1.6598    u8 op;                 /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */
  1.6599    u16 selFlags;          /* Various SF_* values */
  1.6600    int iLimit, iOffset;   /* Memory registers holding LIMIT & OFFSET counters */
  1.6601 +#if SELECTTRACE_ENABLED
  1.6602 +  char zSelName[12];     /* Symbolic name of this SELECT use for debugging */
  1.6603 +#endif
  1.6604    int addrOpenEphm[2];   /* OP_OpenEphem opcodes related to this select */
  1.6605    u64 nSelectRow;        /* Estimated number of result rows */
  1.6606    SrcList *pSrc;         /* The FROM clause */
  1.6607 @@ -11710,18 +13413,21 @@
  1.6608  ** "Select Flag".
  1.6609  */
  1.6610  #define SF_Distinct        0x0001  /* Output should be DISTINCT */
  1.6611 -#define SF_Resolved        0x0002  /* Identifiers have been resolved */
  1.6612 -#define SF_Aggregate       0x0004  /* Contains aggregate functions */
  1.6613 -#define SF_UsesEphemeral   0x0008  /* Uses the OpenEphemeral opcode */
  1.6614 -#define SF_Expanded        0x0010  /* sqlite3SelectExpand() called on this */
  1.6615 -#define SF_HasTypeInfo     0x0020  /* FROM subqueries have Table metadata */
  1.6616 -                    /*     0x0040  NOT USED */
  1.6617 -#define SF_Values          0x0080  /* Synthesized from VALUES clause */
  1.6618 -                    /*     0x0100  NOT USED */
  1.6619 -#define SF_NestedFrom      0x0200  /* Part of a parenthesized FROM clause */
  1.6620 -#define SF_MaybeConvert    0x0400  /* Need convertCompoundSelectToSubquery() */
  1.6621 -#define SF_Recursive       0x0800  /* The recursive part of a recursive CTE */
  1.6622 -#define SF_Compound        0x1000  /* Part of a compound query */
  1.6623 +#define SF_All             0x0002  /* Includes the ALL keyword */
  1.6624 +#define SF_Resolved        0x0004  /* Identifiers have been resolved */
  1.6625 +#define SF_Aggregate       0x0008  /* Contains aggregate functions */
  1.6626 +#define SF_UsesEphemeral   0x0010  /* Uses the OpenEphemeral opcode */
  1.6627 +#define SF_Expanded        0x0020  /* sqlite3SelectExpand() called on this */
  1.6628 +#define SF_HasTypeInfo     0x0040  /* FROM subqueries have Table metadata */
  1.6629 +#define SF_Compound        0x0080  /* Part of a compound query */
  1.6630 +#define SF_Values          0x0100  /* Synthesized from VALUES clause */
  1.6631 +#define SF_MultiValue      0x0200  /* Single VALUES term with multiple rows */
  1.6632 +#define SF_NestedFrom      0x0400  /* Part of a parenthesized FROM clause */
  1.6633 +#define SF_MaybeConvert    0x0800  /* Need convertCompoundSelectToSubquery() */
  1.6634 +#define SF_MinMaxAgg       0x1000  /* Aggregate containing min() or max() */
  1.6635 +#define SF_Recursive       0x2000  /* The recursive part of a recursive CTE */
  1.6636 +#define SF_Converted       0x4000  /* By convertCompoundSelectToSubquery() */
  1.6637 +#define SF_IncludeHidden   0x8000  /* Include hidden columns in output */
  1.6638  
  1.6639  
  1.6640  /*
  1.6641 @@ -11825,7 +13531,7 @@
  1.6642  ** tables, the following information is attached to the Table.u.autoInc.p
  1.6643  ** pointer of each autoincrement table to record some side information that
  1.6644  ** the code generator needs.  We have to keep per-table autoincrement
  1.6645 -** information in case inserts are down within triggers.  Triggers do not
  1.6646 +** information in case inserts are done within triggers.  Triggers do not
  1.6647  ** normally coordinate their activities, but we do need to coordinate the
  1.6648  ** loading and saving of autoincrement information.
  1.6649  */
  1.6650 @@ -11917,6 +13623,7 @@
  1.6651    u8 mayAbort;         /* True if statement may throw an ABORT exception */
  1.6652    u8 hasCompound;      /* Need to invoke convertCompoundSelectToSubquery() */
  1.6653    u8 okConstFactor;    /* OK to factor out constants */
  1.6654 +  u8 disableLookaside; /* Number of times lookaside has been disabled */
  1.6655    int aTempReg[8];     /* Holding area for temporary registers */
  1.6656    int nRangeReg;       /* Size of the temporary register block */
  1.6657    int iRangeReg;       /* First register in temporary register block */
  1.6658 @@ -11926,9 +13633,10 @@
  1.6659    int nSet;            /* Number of sets used so far */
  1.6660    int nOnce;           /* Number of OP_Once instructions so far */
  1.6661    int nOpAlloc;        /* Number of slots allocated for Vdbe.aOp[] */
  1.6662 +  int szOpAlloc;       /* Bytes of memory space allocated for Vdbe.aOp[] */
  1.6663    int iFixedOp;        /* Never back out opcodes iFixedOp-1 or earlier */
  1.6664    int ckBase;          /* Base register of data during check constraints */
  1.6665 -  int iPartIdxTab;     /* Table corresponding to a partial index */
  1.6666 +  int iSelfTab;        /* Table of an index whose exprs are being coded */
  1.6667    int iCacheLevel;     /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
  1.6668    int iCacheCnt;       /* Counter used to generate aColCache[].lru values */
  1.6669    int nLabel;          /* Number of labels used */
  1.6670 @@ -11949,6 +13657,10 @@
  1.6671    int regRowid;        /* Register holding rowid of CREATE TABLE entry */
  1.6672    int regRoot;         /* Register holding root page number for new objects */
  1.6673    int nMaxArg;         /* Max args passed to user function by sub-program */
  1.6674 +#if SELECTTRACE_ENABLED
  1.6675 +  int nSelect;         /* Number of SELECT statements seen */
  1.6676 +  int nSelectIndent;   /* How far to indent SELECTTRACE() output */
  1.6677 +#endif
  1.6678  #ifndef SQLITE_OMIT_SHARED_CACHE
  1.6679    int nTableLock;        /* Number of locks in aTableLock */
  1.6680    TableLock *aTableLock; /* Required table locks for shared-cache mode */
  1.6681 @@ -11959,7 +13671,6 @@
  1.6682    Parse *pToplevel;    /* Parse structure for main program (or NULL) */
  1.6683    Table *pTriggerTab;  /* Table triggers are being coded for */
  1.6684    int addrCrTab;       /* Address of OP_CreateTable opcode on CREATE TABLE */
  1.6685 -  int addrSkipPK;      /* Address of instruction to skip PRIMARY KEY index */
  1.6686    u32 nQueryLoop;      /* Est number of iterations of a query (10*log2(N)) */
  1.6687    u32 oldmask;         /* Mask of old.* columns referenced */
  1.6688    u32 newmask;         /* Mask of new.* columns referenced */
  1.6689 @@ -11974,10 +13685,9 @@
  1.6690    ** in the recursive region.
  1.6691    ************************************************************************/
  1.6692  
  1.6693 -  int nVar;                 /* Number of '?' variables seen in the SQL so far */
  1.6694 +  ynVar nVar;               /* Number of '?' variables seen in the SQL so far */
  1.6695    int nzVar;                /* Number of available slots in azVar[] */
  1.6696    u8 iPkSortOrder;          /* ASC or DESC for INTEGER PRIMARY KEY */
  1.6697 -  u8 bFreeWith;             /* True if pWith should be freed with parser */
  1.6698    u8 explain;               /* True if the EXPLAIN flag is found on the query */
  1.6699  #ifndef SQLITE_OMIT_VIRTUALTABLE
  1.6700    u8 declareVtab;           /* True if inside sqlite3_declare_vtab() */
  1.6701 @@ -12004,6 +13714,7 @@
  1.6702    Table *pZombieTab;        /* List of Table objects to delete after code gen */
  1.6703    TriggerPrg *pTriggerPrg;  /* Linked list of coded triggers */
  1.6704    With *pWith;              /* Current WITH clause, or NULL */
  1.6705 +  With *pWithToFree;        /* Free this WITH object at the end of the parse */
  1.6706  };
  1.6707  
  1.6708  /*
  1.6709 @@ -12027,17 +13738,22 @@
  1.6710  /*
  1.6711  ** Bitfield flags for P5 value in various opcodes.
  1.6712  */
  1.6713 -#define OPFLAG_NCHANGE       0x01    /* Set to update db->nChange */
  1.6714 +#define OPFLAG_NCHANGE       0x01    /* OP_Insert: Set to update db->nChange */
  1.6715 +                                     /* Also used in P2 (not P5) of OP_Delete */
  1.6716 +#define OPFLAG_EPHEM         0x01    /* OP_Column: Ephemeral output is ok */
  1.6717  #define OPFLAG_LASTROWID     0x02    /* Set to update db->lastRowid */
  1.6718  #define OPFLAG_ISUPDATE      0x04    /* This OP_Insert is an sql UPDATE */
  1.6719  #define OPFLAG_APPEND        0x08    /* This is likely to be an append */
  1.6720  #define OPFLAG_USESEEKRESULT 0x10    /* Try to avoid a seek in BtreeInsert() */
  1.6721 -#define OPFLAG_CLEARCACHE    0x20    /* Clear pseudo-table cache in OP_Column */
  1.6722  #define OPFLAG_LENGTHARG     0x40    /* OP_Column only used for length() */
  1.6723  #define OPFLAG_TYPEOFARG     0x80    /* OP_Column only used for typeof() */
  1.6724  #define OPFLAG_BULKCSR       0x01    /* OP_Open** used to open bulk cursor */
  1.6725 -#define OPFLAG_P2ISREG       0x02    /* P2 to OP_Open** is a register number */
  1.6726 +#define OPFLAG_SEEKEQ        0x02    /* OP_Open** cursor uses EQ seek only */
  1.6727 +#define OPFLAG_FORDELETE     0x08    /* OP_Open should use BTREE_FORDELETE */
  1.6728 +#define OPFLAG_P2ISREG       0x10    /* P2 to OP_Open** is a register number */
  1.6729  #define OPFLAG_PERMUTE       0x01    /* OP_Compare: use the permutation */
  1.6730 +#define OPFLAG_SAVEPOSITION  0x02    /* OP_Delete: keep cursor position */
  1.6731 +#define OPFLAG_AUXDELETE     0x04    /* OP_Delete: index in a DELETE op */
  1.6732  
  1.6733  /*
  1.6734   * Each trigger present in the database schema is stored as an instance of
  1.6735 @@ -12095,7 +13811,7 @@
  1.6736   * orconf    -> stores the ON CONFLICT algorithm
  1.6737   * pSelect   -> If this is an INSERT INTO ... SELECT ... statement, then
  1.6738   *              this stores a pointer to the SELECT statement. Otherwise NULL.
  1.6739 - * target    -> A token holding the quoted name of the table to insert into.
  1.6740 + * zTarget   -> Dequoted name of the table to insert into.
  1.6741   * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then
  1.6742   *              this stores values to be inserted. Otherwise NULL.
  1.6743   * pIdList   -> If this is an INSERT INTO ... (<column-names>) VALUES ... 
  1.6744 @@ -12103,12 +13819,12 @@
  1.6745   *              inserted into.
  1.6746   *
  1.6747   * (op == TK_DELETE)
  1.6748 - * target    -> A token holding the quoted name of the table to delete from.
  1.6749 + * zTarget   -> Dequoted name of the table to delete from.
  1.6750   * pWhere    -> The WHERE clause of the DELETE statement if one is specified.
  1.6751   *              Otherwise NULL.
  1.6752   * 
  1.6753   * (op == TK_UPDATE)
  1.6754 - * target    -> A token holding the quoted name of the table to update rows of.
  1.6755 + * zTarget   -> Dequoted name of the table to update.
  1.6756   * pWhere    -> The WHERE clause of the UPDATE statement if one is specified.
  1.6757   *              Otherwise NULL.
  1.6758   * pExprList -> A list of the columns to update and the expressions to update
  1.6759 @@ -12120,8 +13836,8 @@
  1.6760    u8 op;               /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */
  1.6761    u8 orconf;           /* OE_Rollback etc. */
  1.6762    Trigger *pTrig;      /* The trigger that this step is a part of */
  1.6763 -  Select *pSelect;     /* SELECT statment or RHS of INSERT INTO .. SELECT ... */
  1.6764 -  Token target;        /* Target table for DELETE, UPDATE, INSERT */
  1.6765 +  Select *pSelect;     /* SELECT statement or RHS of INSERT INTO SELECT ... */
  1.6766 +  char *zTarget;       /* Target table for DELETE, UPDATE, INSERT */
  1.6767    Expr *pWhere;        /* The WHERE clause for DELETE or UPDATE steps */
  1.6768    ExprList *pExprList; /* SET clause for UPDATE. */
  1.6769    IdList *pIdList;     /* Column names for INSERT */
  1.6770 @@ -12152,14 +13868,20 @@
  1.6771    sqlite3 *db;         /* Optional database for lookaside.  Can be NULL */
  1.6772    char *zBase;         /* A base allocation.  Not from malloc. */
  1.6773    char *zText;         /* The string collected so far */
  1.6774 -  int  nChar;          /* Length of the string so far */
  1.6775 -  int  nAlloc;         /* Amount of space allocated in zText */
  1.6776 -  int  mxAlloc;        /* Maximum allowed string length */
  1.6777 -  u8   useMalloc;      /* 0: none,  1: sqlite3DbMalloc,  2: sqlite3_malloc */
  1.6778 +  u32  nChar;          /* Length of the string so far */
  1.6779 +  u32  nAlloc;         /* Amount of space allocated in zText */
  1.6780 +  u32  mxAlloc;        /* Maximum allowed allocation.  0 for no malloc usage */
  1.6781    u8   accError;       /* STRACCUM_NOMEM or STRACCUM_TOOBIG */
  1.6782 +  u8   printfFlags;    /* SQLITE_PRINTF flags below */
  1.6783  };
  1.6784  #define STRACCUM_NOMEM   1
  1.6785  #define STRACCUM_TOOBIG  2
  1.6786 +#define SQLITE_PRINTF_INTERNAL 0x01  /* Internal-use-only converters allowed */
  1.6787 +#define SQLITE_PRINTF_SQLFUNC  0x02  /* SQL function arguments to VXPrintf */
  1.6788 +#define SQLITE_PRINTF_MALLOCED 0x04  /* True if xText is allocated space */
  1.6789 +
  1.6790 +#define isMalloced(X)  (((X)->printfFlags & SQLITE_PRINTF_MALLOCED)!=0)
  1.6791 +
  1.6792  
  1.6793  /*
  1.6794  ** A pointer to this structure is used to communicate information
  1.6795 @@ -12203,6 +13925,7 @@
  1.6796    int nPage;                        /* Number of pages in pPage[] */
  1.6797    int mxParserStack;                /* maximum depth of the parser stack */
  1.6798    int sharedCacheEnabled;           /* true if shared-cache mode enabled */
  1.6799 +  u32 szPma;                        /* Maximum Sorter PMA size */
  1.6800    /* The above might be initialized to non-zero.  The following need to always
  1.6801    ** initially be zero, however. */
  1.6802    int isInit;                       /* True after initialization has finished */
  1.6803 @@ -12253,16 +13976,20 @@
  1.6804  ** Context pointer passed down through the tree-walk.
  1.6805  */
  1.6806  struct Walker {
  1.6807 +  Parse *pParse;                            /* Parser context.  */
  1.6808    int (*xExprCallback)(Walker*, Expr*);     /* Callback for expressions */
  1.6809    int (*xSelectCallback)(Walker*,Select*);  /* Callback for SELECTs */
  1.6810    void (*xSelectCallback2)(Walker*,Select*);/* Second callback for SELECTs */
  1.6811 -  Parse *pParse;                            /* Parser context.  */
  1.6812    int walkerDepth;                          /* Number of subqueries */
  1.6813 +  u8 eCode;                                 /* A small processing code */
  1.6814    union {                                   /* Extra data for callback */
  1.6815      NameContext *pNC;                          /* Naming context */
  1.6816 -    int i;                                     /* Integer value */
  1.6817 +    int n;                                     /* A counter */
  1.6818 +    int iCur;                                  /* A cursor number */
  1.6819      SrcList *pSrcList;                         /* FROM clause */
  1.6820      struct SrcCount *pSrcCount;                /* Counting column references */
  1.6821 +    struct CCurHint *pCCurHint;                /* Used by codeCursorHint() */
  1.6822 +    int *aiCol;                                /* array of column indexes */
  1.6823    } u;
  1.6824  };
  1.6825  
  1.6826 @@ -12272,6 +13999,7 @@
  1.6827  SQLITE_PRIVATE int sqlite3WalkSelect(Walker*, Select*);
  1.6828  SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker*, Select*);
  1.6829  SQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker*, Select*);
  1.6830 +SQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker*, Expr*);
  1.6831  
  1.6832  /*
  1.6833  ** Return code from the parse-tree walking primitives and their
  1.6834 @@ -12292,10 +14020,21 @@
  1.6835      char *zName;                    /* Name of this CTE */
  1.6836      ExprList *pCols;                /* List of explicit column names, or NULL */
  1.6837      Select *pSelect;                /* The definition of this CTE */
  1.6838 -    const char *zErr;               /* Error message for circular references */
  1.6839 +    const char *zCteErr;            /* Error message for circular references */
  1.6840    } a[1];
  1.6841  };
  1.6842  
  1.6843 +#ifdef SQLITE_DEBUG
  1.6844 +/*
  1.6845 +** An instance of the TreeView object is used for printing the content of
  1.6846 +** data structures on sqlite3DebugPrintf() using a tree-like view.
  1.6847 +*/
  1.6848 +struct TreeView {
  1.6849 +  int iLevel;             /* Which level of the tree we are on */
  1.6850 +  u8  bLine[100];         /* Draw vertical in column i if bLine[i] is true */
  1.6851 +};
  1.6852 +#endif /* SQLITE_DEBUG */
  1.6853 +
  1.6854  /*
  1.6855  ** Assuming zIn points to the first byte of a UTF-8 character,
  1.6856  ** advance zIn to point to the first byte of the next UTF-8 character.
  1.6857 @@ -12320,14 +14059,21 @@
  1.6858  #define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__)
  1.6859  #define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__)
  1.6860  
  1.6861 +/*
  1.6862 +** FTS3 and FTS4 both require virtual table support
  1.6863 +*/
  1.6864 +#if defined(SQLITE_OMIT_VIRTUALTABLE)
  1.6865 +# undef SQLITE_ENABLE_FTS3
  1.6866 +# undef SQLITE_ENABLE_FTS4
  1.6867 +#endif
  1.6868  
  1.6869  /*
  1.6870  ** FTS4 is really an extension for FTS3.  It is enabled using the
  1.6871 -** SQLITE_ENABLE_FTS3 macro.  But to avoid confusion we also all
  1.6872 -** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3.
  1.6873 +** SQLITE_ENABLE_FTS3 macro.  But to avoid confusion we also call
  1.6874 +** the SQLITE_ENABLE_FTS4 macro to serve as an alias for SQLITE_ENABLE_FTS3.
  1.6875  */
  1.6876  #if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)
  1.6877 -# define SQLITE_ENABLE_FTS3
  1.6878 +# define SQLITE_ENABLE_FTS3 1
  1.6879  #endif
  1.6880  
  1.6881  /*
  1.6882 @@ -12361,6 +14107,9 @@
  1.6883  # define sqlite3Isxdigit(x)  isxdigit((unsigned char)(x))
  1.6884  # define sqlite3Tolower(x)   tolower((unsigned char)(x))
  1.6885  #endif
  1.6886 +#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
  1.6887 +SQLITE_PRIVATE int sqlite3IsIdChar(u8);
  1.6888 +#endif
  1.6889  
  1.6890  /*
  1.6891  ** Internal function prototypes
  1.6892 @@ -12371,15 +14120,16 @@
  1.6893  
  1.6894  SQLITE_PRIVATE int sqlite3MallocInit(void);
  1.6895  SQLITE_PRIVATE void sqlite3MallocEnd(void);
  1.6896 -SQLITE_PRIVATE void *sqlite3Malloc(int);
  1.6897 -SQLITE_PRIVATE void *sqlite3MallocZero(int);
  1.6898 -SQLITE_PRIVATE void *sqlite3DbMallocZero(sqlite3*, int);
  1.6899 -SQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3*, int);
  1.6900 +SQLITE_PRIVATE void *sqlite3Malloc(u64);
  1.6901 +SQLITE_PRIVATE void *sqlite3MallocZero(u64);
  1.6902 +SQLITE_PRIVATE void *sqlite3DbMallocZero(sqlite3*, u64);
  1.6903 +SQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3*, u64);
  1.6904 +SQLITE_PRIVATE void *sqlite3DbMallocRawNN(sqlite3*, u64);
  1.6905  SQLITE_PRIVATE char *sqlite3DbStrDup(sqlite3*,const char*);
  1.6906 -SQLITE_PRIVATE char *sqlite3DbStrNDup(sqlite3*,const char*, int);
  1.6907 -SQLITE_PRIVATE void *sqlite3Realloc(void*, int);
  1.6908 -SQLITE_PRIVATE void *sqlite3DbReallocOrFree(sqlite3 *, void *, int);
  1.6909 -SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *, void *, int);
  1.6910 +SQLITE_PRIVATE char *sqlite3DbStrNDup(sqlite3*,const char*, u64);
  1.6911 +SQLITE_PRIVATE void *sqlite3Realloc(void*, u64);
  1.6912 +SQLITE_PRIVATE void *sqlite3DbReallocOrFree(sqlite3 *, void *, u64);
  1.6913 +SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *, void *, u64);
  1.6914  SQLITE_PRIVATE void sqlite3DbFree(sqlite3*, void*);
  1.6915  SQLITE_PRIVATE int sqlite3MallocSize(void*);
  1.6916  SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3*, void*);
  1.6917 @@ -12388,7 +14138,9 @@
  1.6918  SQLITE_PRIVATE void *sqlite3PageMalloc(int);
  1.6919  SQLITE_PRIVATE void sqlite3PageFree(void*);
  1.6920  SQLITE_PRIVATE void sqlite3MemSetDefault(void);
  1.6921 +#ifndef SQLITE_OMIT_BUILTIN_TEST
  1.6922  SQLITE_PRIVATE void sqlite3BenignMallocHooks(void (*)(void), void (*)(void));
  1.6923 +#endif
  1.6924  SQLITE_PRIVATE int sqlite3HeapNearlyFull(void);
  1.6925  
  1.6926  /*
  1.6927 @@ -12424,10 +14176,20 @@
  1.6928  SQLITE_PRIVATE   int sqlite3MutexInit(void);
  1.6929  SQLITE_PRIVATE   int sqlite3MutexEnd(void);
  1.6930  #endif
  1.6931 -
  1.6932 -SQLITE_PRIVATE int sqlite3StatusValue(int);
  1.6933 -SQLITE_PRIVATE void sqlite3StatusAdd(int, int);
  1.6934 -SQLITE_PRIVATE void sqlite3StatusSet(int, int);
  1.6935 +#if !defined(SQLITE_MUTEX_OMIT) && !defined(SQLITE_MUTEX_NOOP)
  1.6936 +SQLITE_PRIVATE   void sqlite3MemoryBarrier(void);
  1.6937 +#else
  1.6938 +# define sqlite3MemoryBarrier()
  1.6939 +#endif
  1.6940 +
  1.6941 +SQLITE_PRIVATE sqlite3_int64 sqlite3StatusValue(int);
  1.6942 +SQLITE_PRIVATE void sqlite3StatusUp(int, int);
  1.6943 +SQLITE_PRIVATE void sqlite3StatusDown(int, int);
  1.6944 +SQLITE_PRIVATE void sqlite3StatusHighwater(int, int);
  1.6945 +
  1.6946 +/* Access to mutexes used by sqlite3_status() */
  1.6947 +SQLITE_PRIVATE sqlite3_mutex *sqlite3Pcache1Mutex(void);
  1.6948 +SQLITE_PRIVATE sqlite3_mutex *sqlite3MallocMutex(void);
  1.6949  
  1.6950  #ifndef SQLITE_OMIT_FLOATING_POINT
  1.6951  SQLITE_PRIVATE   int sqlite3IsNaN(double);
  1.6952 @@ -12445,45 +14207,29 @@
  1.6953    sqlite3_value **apArg;   /* The argument values */
  1.6954  };
  1.6955  
  1.6956 -#define SQLITE_PRINTF_INTERNAL 0x01
  1.6957 -#define SQLITE_PRINTF_SQLFUNC  0x02
  1.6958 -SQLITE_PRIVATE void sqlite3VXPrintf(StrAccum*, u32, const char*, va_list);
  1.6959 -SQLITE_PRIVATE void sqlite3XPrintf(StrAccum*, u32, const char*, ...);
  1.6960 +SQLITE_PRIVATE void sqlite3VXPrintf(StrAccum*, const char*, va_list);
  1.6961 +SQLITE_PRIVATE void sqlite3XPrintf(StrAccum*, const char*, ...);
  1.6962  SQLITE_PRIVATE char *sqlite3MPrintf(sqlite3*,const char*, ...);
  1.6963  SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
  1.6964 -SQLITE_PRIVATE char *sqlite3MAppendf(sqlite3*,char*,const char*,...);
  1.6965 -#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
  1.6966 +#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
  1.6967  SQLITE_PRIVATE   void sqlite3DebugPrintf(const char*, ...);
  1.6968  #endif
  1.6969  #if defined(SQLITE_TEST)
  1.6970  SQLITE_PRIVATE   void *sqlite3TestTextToPtr(const char*);
  1.6971  #endif
  1.6972  
  1.6973 -/* Output formatting for SQLITE_TESTCTRL_EXPLAIN */
  1.6974 -#if defined(SQLITE_ENABLE_TREE_EXPLAIN)
  1.6975 -SQLITE_PRIVATE   void sqlite3ExplainBegin(Vdbe*);
  1.6976 -SQLITE_PRIVATE   void sqlite3ExplainPrintf(Vdbe*, const char*, ...);
  1.6977 -SQLITE_PRIVATE   void sqlite3ExplainNL(Vdbe*);
  1.6978 -SQLITE_PRIVATE   void sqlite3ExplainPush(Vdbe*);
  1.6979 -SQLITE_PRIVATE   void sqlite3ExplainPop(Vdbe*);
  1.6980 -SQLITE_PRIVATE   void sqlite3ExplainFinish(Vdbe*);
  1.6981 -SQLITE_PRIVATE   void sqlite3ExplainSelect(Vdbe*, Select*);
  1.6982 -SQLITE_PRIVATE   void sqlite3ExplainExpr(Vdbe*, Expr*);
  1.6983 -SQLITE_PRIVATE   void sqlite3ExplainExprList(Vdbe*, ExprList*);
  1.6984 -SQLITE_PRIVATE   const char *sqlite3VdbeExplanation(Vdbe*);
  1.6985 -#else
  1.6986 -# define sqlite3ExplainBegin(X)
  1.6987 -# define sqlite3ExplainSelect(A,B)
  1.6988 -# define sqlite3ExplainExpr(A,B)
  1.6989 -# define sqlite3ExplainExprList(A,B)
  1.6990 -# define sqlite3ExplainFinish(X)
  1.6991 -# define sqlite3VdbeExplanation(X) 0
  1.6992 -#endif
  1.6993 -
  1.6994 -
  1.6995 -SQLITE_PRIVATE void sqlite3SetString(char **, sqlite3*, const char*, ...);
  1.6996 +#if defined(SQLITE_DEBUG)
  1.6997 +SQLITE_PRIVATE   void sqlite3TreeViewExpr(TreeView*, const Expr*, u8);
  1.6998 +SQLITE_PRIVATE   void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*);
  1.6999 +SQLITE_PRIVATE   void sqlite3TreeViewSelect(TreeView*, const Select*, u8);
  1.7000 +SQLITE_PRIVATE   void sqlite3TreeViewWith(TreeView*, const With*, u8);
  1.7001 +#endif
  1.7002 +
  1.7003 +
  1.7004 +SQLITE_PRIVATE void sqlite3SetString(char **, sqlite3*, const char*);
  1.7005  SQLITE_PRIVATE void sqlite3ErrorMsg(Parse*, const char*, ...);
  1.7006  SQLITE_PRIVATE int sqlite3Dequote(char*);
  1.7007 +SQLITE_PRIVATE void sqlite3TokenInit(Token*,char*);
  1.7008  SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char*, int);
  1.7009  SQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*, char **);
  1.7010  SQLITE_PRIVATE void sqlite3FinishCoding(Parse*);
  1.7011 @@ -12501,22 +14247,30 @@
  1.7012  SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*);
  1.7013  SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
  1.7014  SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
  1.7015 +SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int);
  1.7016  SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
  1.7017  SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan*);
  1.7018  SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);
  1.7019 +SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*);
  1.7020  SQLITE_PRIVATE int sqlite3Init(sqlite3*, char**);
  1.7021  SQLITE_PRIVATE int sqlite3InitCallback(void*, int, char**, char**);
  1.7022  SQLITE_PRIVATE void sqlite3Pragma(Parse*,Token*,Token*,Token*,int);
  1.7023  SQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3*);
  1.7024  SQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3*,int);
  1.7025  SQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*);
  1.7026 -SQLITE_PRIVATE void sqlite3BeginParse(Parse*,int);
  1.7027  SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*);
  1.7028 +SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*);
  1.7029 +SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);
  1.7030  SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*);
  1.7031  SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int);
  1.7032  SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*);
  1.7033  SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index*, i16);
  1.7034  SQLITE_PRIVATE void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);
  1.7035 +#if SQLITE_ENABLE_HIDDEN_COLUMNS
  1.7036 +SQLITE_PRIVATE   void sqlite3ColumnPropertiesFromName(Table*, Column*);
  1.7037 +#else
  1.7038 +# define sqlite3ColumnPropertiesFromName(T,C) /* no-op */
  1.7039 +#endif
  1.7040  SQLITE_PRIVATE void sqlite3AddColumn(Parse*,Token*);
  1.7041  SQLITE_PRIVATE void sqlite3AddNotNull(Parse*, int);
  1.7042  SQLITE_PRIVATE void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int);
  1.7043 @@ -12538,11 +14292,14 @@
  1.7044  
  1.7045  SQLITE_PRIVATE Bitvec *sqlite3BitvecCreate(u32);
  1.7046  SQLITE_PRIVATE int sqlite3BitvecTest(Bitvec*, u32);
  1.7047 +SQLITE_PRIVATE int sqlite3BitvecTestNotNull(Bitvec*, u32);
  1.7048  SQLITE_PRIVATE int sqlite3BitvecSet(Bitvec*, u32);
  1.7049  SQLITE_PRIVATE void sqlite3BitvecClear(Bitvec*, u32, void*);
  1.7050  SQLITE_PRIVATE void sqlite3BitvecDestroy(Bitvec*);
  1.7051  SQLITE_PRIVATE u32 sqlite3BitvecSize(Bitvec*);
  1.7052 +#ifndef SQLITE_OMIT_BUILTIN_TEST
  1.7053  SQLITE_PRIVATE int sqlite3BitvecBuiltinTest(int,int*);
  1.7054 +#endif
  1.7055  
  1.7056  SQLITE_PRIVATE RowSet *sqlite3RowSetInit(sqlite3*, void*, unsigned int);
  1.7057  SQLITE_PRIVATE void sqlite3RowSetClear(RowSet*);
  1.7058 @@ -12550,7 +14307,7 @@
  1.7059  SQLITE_PRIVATE int sqlite3RowSetTest(RowSet*, int iBatch, i64);
  1.7060  SQLITE_PRIVATE int sqlite3RowSetNext(RowSet*, i64*);
  1.7061  
  1.7062 -SQLITE_PRIVATE void sqlite3CreateView(Parse*,Token*,Token*,Token*,Select*,int,int);
  1.7063 +SQLITE_PRIVATE void sqlite3CreateView(Parse*,Token*,Token*,Token*,ExprList*,Select*,int,int);
  1.7064  
  1.7065  #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)
  1.7066  SQLITE_PRIVATE   int sqlite3ViewGetColumnNames(Parse*,Table*);
  1.7067 @@ -12580,6 +14337,7 @@
  1.7068  SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*,
  1.7069                                        Token*, Select*, Expr*, IdList*);
  1.7070  SQLITE_PRIVATE void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token *);
  1.7071 +SQLITE_PRIVATE void sqlite3SrcListFuncArgs(Parse*, SrcList*, ExprList*);
  1.7072  SQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *, struct SrcList_item *);
  1.7073  SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);
  1.7074  SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);
  1.7075 @@ -12610,7 +14368,12 @@
  1.7076  SQLITE_PRIVATE int sqlite3WhereContinueLabel(WhereInfo*);
  1.7077  SQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*);
  1.7078  SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*, int*);
  1.7079 +#define ONEPASS_OFF      0        /* Use of ONEPASS not allowed */
  1.7080 +#define ONEPASS_SINGLE   1        /* ONEPASS valid for a single row update */
  1.7081 +#define ONEPASS_MULTI    2        /* ONEPASS is valid for multiple rows */
  1.7082 +SQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn(Parse*, Index*, int, int, int);
  1.7083  SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8);
  1.7084 +SQLITE_PRIVATE void sqlite3ExprCodeGetColumnToReg(Parse*, Table*, int, int, int);
  1.7085  SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
  1.7086  SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);
  1.7087  SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse*, int, int, int);
  1.7088 @@ -12620,16 +14383,19 @@
  1.7089  SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse*);
  1.7090  SQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse*, int, int);
  1.7091  SQLITE_PRIVATE void sqlite3ExprCode(Parse*, Expr*, int);
  1.7092 +SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int);
  1.7093  SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
  1.7094  SQLITE_PRIVATE void sqlite3ExprCodeAtInit(Parse*, Expr*, int, u8);
  1.7095  SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
  1.7096  SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int);
  1.7097  SQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse*, Expr*, int);
  1.7098 -SQLITE_PRIVATE int sqlite3ExprCodeExprList(Parse*, ExprList*, int, u8);
  1.7099 +SQLITE_PRIVATE int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int, u8);
  1.7100  #define SQLITE_ECEL_DUP      0x01  /* Deep, not shallow copies */
  1.7101  #define SQLITE_ECEL_FACTOR   0x02  /* Factor out constant terms */
  1.7102 +#define SQLITE_ECEL_REF      0x04  /* Use ExprList.u.x.iOrderByCol */
  1.7103  SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse*, Expr*, int, int);
  1.7104  SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse*, Expr*, int, int);
  1.7105 +SQLITE_PRIVATE void sqlite3ExprIfFalseDup(Parse*, Expr*, int, int);
  1.7106  SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3*,const char*, const char*);
  1.7107  SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,int isView,const char*, const char*);
  1.7108  SQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,int isView,struct SrcList_item *);
  1.7109 @@ -12646,8 +14412,10 @@
  1.7110  SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
  1.7111  SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
  1.7112  SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
  1.7113 +#ifndef SQLITE_OMIT_BUILTIN_TEST
  1.7114  SQLITE_PRIVATE void sqlite3PrngSaveState(void);
  1.7115  SQLITE_PRIVATE void sqlite3PrngRestoreState(void);
  1.7116 +#endif
  1.7117  SQLITE_PRIVATE void sqlite3RollbackAll(sqlite3*,int);
  1.7118  SQLITE_PRIVATE void sqlite3CodeVerifySchema(Parse*, int);
  1.7119  SQLITE_PRIVATE void sqlite3CodeVerifyNamedSchema(Parse*, const char *zDb);
  1.7120 @@ -12659,19 +14427,24 @@
  1.7121  SQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3*);
  1.7122  SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr*);
  1.7123  SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr*);
  1.7124 -SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr*);
  1.7125 +SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr*, u8);
  1.7126 +SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr*,int);
  1.7127 +#ifdef SQLITE_ENABLE_CURSOR_HINTS
  1.7128 +SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr*);
  1.7129 +#endif
  1.7130  SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr*, int*);
  1.7131  SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*);
  1.7132  SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
  1.7133  SQLITE_PRIVATE int sqlite3IsRowid(const char*);
  1.7134 -SQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8);
  1.7135 -SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*);
  1.7136 +SQLITE_PRIVATE void sqlite3GenerateRowDelete(
  1.7137 +    Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int);
  1.7138 +SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);
  1.7139  SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int);
  1.7140  SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int);
  1.7141  SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,
  1.7142 -                                     u8,u8,int,int*);
  1.7143 +                                     u8,u8,int,int*,int*);
  1.7144  SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int);
  1.7145 -SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int, u8*, int*, int*);
  1.7146 +SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, u8, int, u8*, int*, int*);
  1.7147  SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
  1.7148  SQLITE_PRIVATE void sqlite3MultiWrite(Parse*);
  1.7149  SQLITE_PRIVATE void sqlite3MayAbort(Parse*);
  1.7150 @@ -12683,6 +14456,11 @@
  1.7151  SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);
  1.7152  SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*);
  1.7153  SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int);
  1.7154 +#if SELECTTRACE_ENABLED
  1.7155 +SQLITE_PRIVATE void sqlite3SelectSetName(Select*,const char*);
  1.7156 +#else
  1.7157 +# define sqlite3SelectSetName(A,B)
  1.7158 +#endif
  1.7159  SQLITE_PRIVATE void sqlite3FuncDefInsert(FuncDefHash*, FuncDef*);
  1.7160  SQLITE_PRIVATE FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,int,u8,u8);
  1.7161  SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(sqlite3*);
  1.7162 @@ -12718,6 +14496,7 @@
  1.7163  SQLITE_PRIVATE   void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
  1.7164  SQLITE_PRIVATE   u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);
  1.7165  # define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p))
  1.7166 +# define sqlite3IsToplevel(p) ((p)->pToplevel==0)
  1.7167  #else
  1.7168  # define sqlite3TriggersExist(B,C,D,E,F) 0
  1.7169  # define sqlite3DeleteTrigger(A,B)
  1.7170 @@ -12727,6 +14506,7 @@
  1.7171  # define sqlite3CodeRowTriggerDirect(A,B,C,D,E,F)
  1.7172  # define sqlite3TriggerList(X, Y) 0
  1.7173  # define sqlite3ParseToplevel(p) p
  1.7174 +# define sqlite3IsToplevel(p) 1
  1.7175  # define sqlite3TriggerColmask(A,B,C,D,E,F,G) 0
  1.7176  #endif
  1.7177  
  1.7178 @@ -12769,55 +14549,41 @@
  1.7179  /*
  1.7180  ** Routines to read and write variable-length integers.  These used to
  1.7181  ** be defined locally, but now we use the varint routines in the util.c
  1.7182 -** file.  Code should use the MACRO forms below, as the Varint32 versions
  1.7183 -** are coded to assume the single byte case is already handled (which 
  1.7184 -** the MACRO form does).
  1.7185 +** file.
  1.7186  */
  1.7187  SQLITE_PRIVATE int sqlite3PutVarint(unsigned char*, u64);
  1.7188 -SQLITE_PRIVATE int sqlite3PutVarint32(unsigned char*, u32);
  1.7189  SQLITE_PRIVATE u8 sqlite3GetVarint(const unsigned char *, u64 *);
  1.7190  SQLITE_PRIVATE u8 sqlite3GetVarint32(const unsigned char *, u32 *);
  1.7191  SQLITE_PRIVATE int sqlite3VarintLen(u64 v);
  1.7192  
  1.7193  /*
  1.7194 -** The header of a record consists of a sequence variable-length integers.
  1.7195 -** These integers are almost always small and are encoded as a single byte.
  1.7196 -** The following macros take advantage this fact to provide a fast encode
  1.7197 -** and decode of the integers in a record header.  It is faster for the common
  1.7198 -** case where the integer is a single byte.  It is a little slower when the
  1.7199 -** integer is two or more bytes.  But overall it is faster.
  1.7200 -**
  1.7201 -** The following expressions are equivalent:
  1.7202 -**
  1.7203 -**     x = sqlite3GetVarint32( A, &B );
  1.7204 -**     x = sqlite3PutVarint32( A, B );
  1.7205 -**
  1.7206 -**     x = getVarint32( A, B );
  1.7207 -**     x = putVarint32( A, B );
  1.7208 -**
  1.7209 +** The common case is for a varint to be a single byte.  They following
  1.7210 +** macros handle the common case without a procedure call, but then call
  1.7211 +** the procedure for larger varints.
  1.7212  */
  1.7213  #define getVarint32(A,B)  \
  1.7214    (u8)((*(A)<(u8)0x80)?((B)=(u32)*(A)),1:sqlite3GetVarint32((A),(u32 *)&(B)))
  1.7215  #define putVarint32(A,B)  \
  1.7216    (u8)(((u32)(B)<(u32)0x80)?(*(A)=(unsigned char)(B)),1:\
  1.7217 -  sqlite3PutVarint32((A),(B)))
  1.7218 +  sqlite3PutVarint((A),(B)))
  1.7219  #define getVarint    sqlite3GetVarint
  1.7220  #define putVarint    sqlite3PutVarint
  1.7221  
  1.7222  
  1.7223 -SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(Vdbe *, Index *);
  1.7224 +SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3*, Index*);
  1.7225  SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe*, Table*, int);
  1.7226  SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2);
  1.7227  SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity);
  1.7228  SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr);
  1.7229  SQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*, int, u8);
  1.7230  SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char*, i64*);
  1.7231 -SQLITE_PRIVATE void sqlite3Error(sqlite3*, int, const char*,...);
  1.7232 +SQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...);
  1.7233 +SQLITE_PRIVATE void sqlite3Error(sqlite3*,int);
  1.7234  SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n);
  1.7235  SQLITE_PRIVATE u8 sqlite3HexToInt(int h);
  1.7236  SQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);
  1.7237  
  1.7238 -#if defined(SQLITE_TEST) 
  1.7239 +#if defined(SQLITE_NEED_ERR_NAME)
  1.7240  SQLITE_PRIVATE const char *sqlite3ErrName(int);
  1.7241  #endif
  1.7242  
  1.7243 @@ -12826,7 +14592,7 @@
  1.7244  SQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int);
  1.7245  SQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName);
  1.7246  SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr);
  1.7247 -SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*);
  1.7248 +SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int);
  1.7249  SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);
  1.7250  SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);
  1.7251  SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);
  1.7252 @@ -12855,6 +14621,7 @@
  1.7253  SQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);
  1.7254  #ifndef SQLITE_AMALGAMATION
  1.7255  SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[];
  1.7256 +SQLITE_PRIVATE const char sqlite3StrBINARY[];
  1.7257  SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[];
  1.7258  SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[];
  1.7259  SQLITE_PRIVATE const Token sqlite3IntTokens[];
  1.7260 @@ -12873,8 +14640,10 @@
  1.7261  SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*);
  1.7262  SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *, Expr *, int, int);
  1.7263  SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
  1.7264 +SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);
  1.7265  SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
  1.7266  SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);
  1.7267 +SQLITE_PRIVATE int sqlite3ResolveExprListNames(NameContext*, ExprList*);
  1.7268  SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
  1.7269  SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
  1.7270  SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
  1.7271 @@ -12892,7 +14661,6 @@
  1.7272  SQLITE_PRIVATE void sqlite3DefaultRowEst(Index*);
  1.7273  SQLITE_PRIVATE void sqlite3RegisterLikeFunctions(sqlite3*, int);
  1.7274  SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);
  1.7275 -SQLITE_PRIVATE void sqlite3MinimumFileFormat(Parse*, int, int);
  1.7276  SQLITE_PRIVATE void sqlite3SchemaClear(void *);
  1.7277  SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *, Btree *);
  1.7278  SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
  1.7279 @@ -12908,13 +14676,15 @@
  1.7280    void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
  1.7281    FuncDestructor *pDestructor
  1.7282  );
  1.7283 +SQLITE_PRIVATE void sqlite3OomFault(sqlite3*);
  1.7284 +SQLITE_PRIVATE void sqlite3OomClear(sqlite3*);
  1.7285  SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int);
  1.7286  SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *);
  1.7287  
  1.7288 -SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, char*, int, int);
  1.7289 +SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int);
  1.7290  SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum*,const char*,int);
  1.7291  SQLITE_PRIVATE void sqlite3StrAccumAppendAll(StrAccum*,const char*);
  1.7292 -SQLITE_PRIVATE void sqlite3AppendSpace(StrAccum*,int);
  1.7293 +SQLITE_PRIVATE void sqlite3AppendChar(StrAccum*,int,char);
  1.7294  SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*);
  1.7295  SQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum*);
  1.7296  SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int);
  1.7297 @@ -12934,7 +14704,7 @@
  1.7298  /*
  1.7299  ** The interface to the LEMON-generated parser
  1.7300  */
  1.7301 -SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(size_t));
  1.7302 +SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(u64));
  1.7303  SQLITE_PRIVATE void sqlite3ParserFree(void*, void(*)(void*));
  1.7304  SQLITE_PRIVATE void sqlite3Parser(void*, int, Token, Parse*);
  1.7305  #ifdef YYTRACKMAXSTACKDEPTH
  1.7306 @@ -12983,6 +14753,8 @@
  1.7307  SQLITE_PRIVATE    VTable *sqlite3GetVTable(sqlite3*, Table*);
  1.7308  #  define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0)
  1.7309  #endif
  1.7310 +SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*);
  1.7311 +SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*);
  1.7312  SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*);
  1.7313  SQLITE_PRIVATE void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*, int);
  1.7314  SQLITE_PRIVATE void sqlite3VtabFinishParse(Parse*, Token*);
  1.7315 @@ -13095,12 +14867,11 @@
  1.7316  SQLITE_PRIVATE int sqlite3MemJournalSize(void);
  1.7317  SQLITE_PRIVATE int sqlite3IsMemJournal(sqlite3_file *);
  1.7318  
  1.7319 +SQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p);
  1.7320  #if SQLITE_MAX_EXPR_DEPTH>0
  1.7321 -SQLITE_PRIVATE   void sqlite3ExprSetHeight(Parse *pParse, Expr *p);
  1.7322  SQLITE_PRIVATE   int sqlite3SelectExprHeight(Select *);
  1.7323  SQLITE_PRIVATE   int sqlite3ExprCheckHeight(Parse*, int);
  1.7324  #else
  1.7325 -  #define sqlite3ExprSetHeight(x,y)
  1.7326    #define sqlite3SelectExprHeight(x) 0
  1.7327    #define sqlite3ExprCheckHeight(x,y)
  1.7328  #endif
  1.7329 @@ -13130,7 +14901,7 @@
  1.7330  #ifdef SQLITE_ENABLE_IOTRACE
  1.7331  # define IOTRACE(A)  if( sqlite3IoTrace ){ sqlite3IoTrace A; }
  1.7332  SQLITE_PRIVATE   void sqlite3VdbeIOTraceSql(Vdbe*);
  1.7333 -SQLITE_PRIVATE void (*sqlite3IoTrace)(const char*,...);
  1.7334 +SQLITE_API SQLITE_EXTERN void (SQLITE_CDECL *sqlite3IoTrace)(const char*,...);
  1.7335  #else
  1.7336  # define IOTRACE(A)
  1.7337  # define sqlite3VdbeIOTraceSql(X)
  1.7338 @@ -13174,10 +14945,21 @@
  1.7339  # define sqlite3MemdebugNoType(X,Y)   1
  1.7340  #endif
  1.7341  #define MEMTYPE_HEAP       0x01  /* General heap allocations */
  1.7342 -#define MEMTYPE_LOOKASIDE  0x02  /* Might have been lookaside memory */
  1.7343 +#define MEMTYPE_LOOKASIDE  0x02  /* Heap that might have been lookaside */
  1.7344  #define MEMTYPE_SCRATCH    0x04  /* Scratch allocations */
  1.7345  #define MEMTYPE_PCACHE     0x08  /* Page cache allocations */
  1.7346 -#define MEMTYPE_DB         0x10  /* Uses sqlite3DbMalloc, not sqlite_malloc */
  1.7347 +
  1.7348 +/*
  1.7349 +** Threading interface
  1.7350 +*/
  1.7351 +#if SQLITE_MAX_WORKER_THREADS>0
  1.7352 +SQLITE_PRIVATE int sqlite3ThreadCreate(SQLiteThread**,void*(*)(void*),void*);
  1.7353 +SQLITE_PRIVATE int sqlite3ThreadJoin(SQLiteThread*, void**);
  1.7354 +#endif
  1.7355 +
  1.7356 +#if defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)
  1.7357 +SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3*);
  1.7358 +#endif
  1.7359  
  1.7360  #endif /* _SQLITEINT_H_ */
  1.7361  
  1.7362 @@ -13195,8 +14977,9 @@
  1.7363  **
  1.7364  *************************************************************************
  1.7365  **
  1.7366 -** This file contains definitions of global variables and contants.
  1.7367 -*/
  1.7368 +** This file contains definitions of global variables and constants.
  1.7369 +*/
  1.7370 +/* #include "sqliteInt.h" */
  1.7371  
  1.7372  /* An array to map all upper-case characters into their corresponding
  1.7373  ** lower-case character. 
  1.7374 @@ -13230,16 +15013,16 @@
  1.7375       48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 3x */
  1.7376       64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 4x */
  1.7377       80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 5x */
  1.7378 -     96, 97, 66, 67, 68, 69, 70, 71, 72, 73,106,107,108,109,110,111, /* 6x */
  1.7379 -    112, 81, 82, 83, 84, 85, 86, 87, 88, 89,122,123,124,125,126,127, /* 7x */
  1.7380 +     96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 6x */
  1.7381 +    112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 7x */
  1.7382      128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, /* 8x */
  1.7383 -    144,145,146,147,148,149,150,151,152,153,154,155,156,157,156,159, /* 9x */
  1.7384 +    144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, /* 9x */
  1.7385      160,161,162,163,164,165,166,167,168,169,170,171,140,141,142,175, /* Ax */
  1.7386      176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, /* Bx */
  1.7387      192,129,130,131,132,133,134,135,136,137,202,203,204,205,206,207, /* Cx */
  1.7388      208,145,146,147,148,149,150,151,152,153,218,219,220,221,222,223, /* Dx */
  1.7389 -    224,225,162,163,164,165,166,167,168,169,232,203,204,205,206,207, /* Ex */
  1.7390 -    239,240,241,242,243,244,245,246,247,248,249,219,220,221,222,255, /* Fx */
  1.7391 +    224,225,162,163,164,165,166,167,168,169,234,235,236,237,238,239, /* Ex */
  1.7392 +    240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255, /* Fx */
  1.7393  #endif
  1.7394  };
  1.7395  
  1.7396 @@ -13313,14 +15096,36 @@
  1.7397  };
  1.7398  #endif
  1.7399  
  1.7400 +/* EVIDENCE-OF: R-02982-34736 In order to maintain full backwards
  1.7401 +** compatibility for legacy applications, the URI filename capability is
  1.7402 +** disabled by default.
  1.7403 +**
  1.7404 +** EVIDENCE-OF: R-38799-08373 URI filenames can be enabled or disabled
  1.7405 +** using the SQLITE_USE_URI=1 or SQLITE_USE_URI=0 compile-time options.
  1.7406 +**
  1.7407 +** EVIDENCE-OF: R-43642-56306 By default, URI handling is globally
  1.7408 +** disabled. The default value may be changed by compiling with the
  1.7409 +** SQLITE_USE_URI symbol defined.
  1.7410 +*/
  1.7411  #ifndef SQLITE_USE_URI
  1.7412  # define  SQLITE_USE_URI 0
  1.7413  #endif
  1.7414  
  1.7415 +/* EVIDENCE-OF: R-38720-18127 The default setting is determined by the
  1.7416 +** SQLITE_ALLOW_COVERING_INDEX_SCAN compile-time option, or is "on" if
  1.7417 +** that compile-time option is omitted.
  1.7418 +*/
  1.7419  #ifndef SQLITE_ALLOW_COVERING_INDEX_SCAN
  1.7420  # define SQLITE_ALLOW_COVERING_INDEX_SCAN 1
  1.7421  #endif
  1.7422  
  1.7423 +/* The minimum PMA size is set to this value multiplied by the database
  1.7424 +** page size in bytes.
  1.7425 +*/
  1.7426 +#ifndef SQLITE_SORTER_PMASZ
  1.7427 +# define SQLITE_SORTER_PMASZ 250
  1.7428 +#endif
  1.7429 +
  1.7430  /*
  1.7431  ** The following singleton contains the global configuration for
  1.7432  ** the SQLite library.
  1.7433 @@ -13348,9 +15153,10 @@
  1.7434     0,                         /* nScratch */
  1.7435     (void*)0,                  /* pPage */
  1.7436     0,                         /* szPage */
  1.7437 -   0,                         /* nPage */
  1.7438 +   SQLITE_DEFAULT_PCACHE_INITSZ, /* nPage */
  1.7439     0,                         /* mxParserStack */
  1.7440     0,                         /* sharedCacheEnabled */
  1.7441 +   SQLITE_SORTER_PMASZ,       /* szPma */
  1.7442     /* All the rest should always be initialized to zero */
  1.7443     0,                         /* isInit */
  1.7444     0,                         /* inProgress */
  1.7445 @@ -13406,13 +15212,14 @@
  1.7446  **
  1.7447  ** IMPORTANT:  Changing the pending byte to any value other than
  1.7448  ** 0x40000000 results in an incompatible database file format!
  1.7449 -** Changing the pending byte during operating results in undefined
  1.7450 -** and dileterious behavior.
  1.7451 +** Changing the pending byte during operation will result in undefined
  1.7452 +** and incorrect behavior.
  1.7453  */
  1.7454  #ifndef SQLITE_OMIT_WSD
  1.7455  SQLITE_PRIVATE int sqlite3PendingByte = 0x40000000;
  1.7456  #endif
  1.7457  
  1.7458 +/* #include "opcodes.h" */
  1.7459  /*
  1.7460  ** Properties of opcodes.  The OPFLG_INITIALIZER macro is
  1.7461  ** created by mkopcodeh.awk during compilation.  Data is obtained
  1.7462 @@ -13421,6 +15228,11 @@
  1.7463  */
  1.7464  SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER;
  1.7465  
  1.7466 +/*
  1.7467 +** Name of the default collating sequence
  1.7468 +*/
  1.7469 +SQLITE_PRIVATE const char sqlite3StrBINARY[] = "BINARY";
  1.7470 +
  1.7471  /************** End of global.c **********************************************/
  1.7472  /************** Begin file ctime.c *******************************************/
  1.7473  /*
  1.7474 @@ -13441,6 +15253,7 @@
  1.7475  
  1.7476  #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
  1.7477  
  1.7478 +/* #include "sqliteInt.h" */
  1.7479  
  1.7480  /*
  1.7481  ** An array of names of all compile-time options.  This array should 
  1.7482 @@ -13457,88 +15270,103 @@
  1.7483  #define CTIMEOPT_VAL_(opt) #opt
  1.7484  #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
  1.7485  
  1.7486 -#ifdef SQLITE_32BIT_ROWID
  1.7487 +#if SQLITE_32BIT_ROWID
  1.7488    "32BIT_ROWID",
  1.7489  #endif
  1.7490 -#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC
  1.7491 +#if SQLITE_4_BYTE_ALIGNED_MALLOC
  1.7492    "4_BYTE_ALIGNED_MALLOC",
  1.7493  #endif
  1.7494 -#ifdef SQLITE_CASE_SENSITIVE_LIKE
  1.7495 +#if SQLITE_CASE_SENSITIVE_LIKE
  1.7496    "CASE_SENSITIVE_LIKE",
  1.7497  #endif
  1.7498 -#ifdef SQLITE_CHECK_PAGES
  1.7499 +#if SQLITE_CHECK_PAGES
  1.7500    "CHECK_PAGES",
  1.7501  #endif
  1.7502 -#ifdef SQLITE_COVERAGE_TEST
  1.7503 +#if SQLITE_COVERAGE_TEST
  1.7504    "COVERAGE_TEST",
  1.7505  #endif
  1.7506 -#ifdef SQLITE_DEBUG
  1.7507 +#if SQLITE_DEBUG
  1.7508    "DEBUG",
  1.7509  #endif
  1.7510 -#ifdef SQLITE_DEFAULT_LOCKING_MODE
  1.7511 +#if SQLITE_DEFAULT_LOCKING_MODE
  1.7512    "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
  1.7513  #endif
  1.7514  #if defined(SQLITE_DEFAULT_MMAP_SIZE) && !defined(SQLITE_DEFAULT_MMAP_SIZE_xc)
  1.7515    "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
  1.7516  #endif
  1.7517 -#ifdef SQLITE_DISABLE_DIRSYNC
  1.7518 +#if SQLITE_DISABLE_DIRSYNC
  1.7519    "DISABLE_DIRSYNC",
  1.7520  #endif
  1.7521 -#ifdef SQLITE_DISABLE_LFS
  1.7522 +#if SQLITE_DISABLE_LFS
  1.7523    "DISABLE_LFS",
  1.7524  #endif
  1.7525 -#ifdef SQLITE_ENABLE_ATOMIC_WRITE
  1.7526 +#if SQLITE_ENABLE_8_3_NAMES
  1.7527 +  "ENABLE_8_3_NAMES",
  1.7528 +#endif
  1.7529 +#if SQLITE_ENABLE_API_ARMOR
  1.7530 +  "ENABLE_API_ARMOR",
  1.7531 +#endif
  1.7532 +#if SQLITE_ENABLE_ATOMIC_WRITE
  1.7533    "ENABLE_ATOMIC_WRITE",
  1.7534  #endif
  1.7535 -#ifdef SQLITE_ENABLE_CEROD
  1.7536 +#if SQLITE_ENABLE_CEROD
  1.7537    "ENABLE_CEROD",
  1.7538  #endif
  1.7539 -#ifdef SQLITE_ENABLE_COLUMN_METADATA
  1.7540 +#if SQLITE_ENABLE_COLUMN_METADATA
  1.7541    "ENABLE_COLUMN_METADATA",
  1.7542  #endif
  1.7543 -#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
  1.7544 +#if SQLITE_ENABLE_DBSTAT_VTAB
  1.7545 +  "ENABLE_DBSTAT_VTAB",
  1.7546 +#endif
  1.7547 +#if SQLITE_ENABLE_EXPENSIVE_ASSERT
  1.7548    "ENABLE_EXPENSIVE_ASSERT",
  1.7549  #endif
  1.7550 -#ifdef SQLITE_ENABLE_FTS1
  1.7551 +#if SQLITE_ENABLE_FTS1
  1.7552    "ENABLE_FTS1",
  1.7553  #endif
  1.7554 -#ifdef SQLITE_ENABLE_FTS2
  1.7555 +#if SQLITE_ENABLE_FTS2
  1.7556    "ENABLE_FTS2",
  1.7557  #endif
  1.7558 -#ifdef SQLITE_ENABLE_FTS3
  1.7559 +#if SQLITE_ENABLE_FTS3
  1.7560    "ENABLE_FTS3",
  1.7561  #endif
  1.7562 -#ifdef SQLITE_ENABLE_FTS3_PARENTHESIS
  1.7563 +#if SQLITE_ENABLE_FTS3_PARENTHESIS
  1.7564    "ENABLE_FTS3_PARENTHESIS",
  1.7565  #endif
  1.7566 -#ifdef SQLITE_ENABLE_FTS4
  1.7567 +#if SQLITE_ENABLE_FTS4
  1.7568    "ENABLE_FTS4",
  1.7569  #endif
  1.7570 -#ifdef SQLITE_ENABLE_ICU
  1.7571 +#if SQLITE_ENABLE_FTS5
  1.7572 +  "ENABLE_FTS5",
  1.7573 +#endif
  1.7574 +#if SQLITE_ENABLE_ICU
  1.7575    "ENABLE_ICU",
  1.7576  #endif
  1.7577 -#ifdef SQLITE_ENABLE_IOTRACE
  1.7578 +#if SQLITE_ENABLE_IOTRACE
  1.7579    "ENABLE_IOTRACE",
  1.7580  #endif
  1.7581 -#ifdef SQLITE_ENABLE_LOAD_EXTENSION
  1.7582 +#if SQLITE_ENABLE_JSON1
  1.7583 +  "ENABLE_JSON1",
  1.7584 +#endif
  1.7585 +#if SQLITE_ENABLE_LOAD_EXTENSION
  1.7586    "ENABLE_LOAD_EXTENSION",
  1.7587  #endif
  1.7588 -#ifdef SQLITE_ENABLE_LOCKING_STYLE
  1.7589 +#if SQLITE_ENABLE_LOCKING_STYLE
  1.7590    "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),
  1.7591  #endif
  1.7592 -#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
  1.7593 +#if SQLITE_ENABLE_MEMORY_MANAGEMENT
  1.7594    "ENABLE_MEMORY_MANAGEMENT",
  1.7595  #endif
  1.7596 -#ifdef SQLITE_ENABLE_MEMSYS3
  1.7597 +#if SQLITE_ENABLE_MEMSYS3
  1.7598    "ENABLE_MEMSYS3",
  1.7599  #endif
  1.7600 -#ifdef SQLITE_ENABLE_MEMSYS5
  1.7601 +#if SQLITE_ENABLE_MEMSYS5
  1.7602    "ENABLE_MEMSYS5",
  1.7603  #endif
  1.7604 -#ifdef SQLITE_ENABLE_OVERSIZE_CELL_CHECK
  1.7605 +#if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
  1.7606    "ENABLE_OVERSIZE_CELL_CHECK",
  1.7607  #endif
  1.7608 -#ifdef SQLITE_ENABLE_RTREE
  1.7609 +#if SQLITE_ENABLE_RTREE
  1.7610    "ENABLE_RTREE",
  1.7611  #endif
  1.7612  #if defined(SQLITE_ENABLE_STAT4)
  1.7613 @@ -13546,31 +15374,34 @@
  1.7614  #elif defined(SQLITE_ENABLE_STAT3)
  1.7615    "ENABLE_STAT3",
  1.7616  #endif
  1.7617 -#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
  1.7618 +#if SQLITE_ENABLE_UNLOCK_NOTIFY
  1.7619    "ENABLE_UNLOCK_NOTIFY",
  1.7620  #endif
  1.7621 -#ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
  1.7622 +#if SQLITE_ENABLE_UPDATE_DELETE_LIMIT
  1.7623    "ENABLE_UPDATE_DELETE_LIMIT",
  1.7624  #endif
  1.7625 -#ifdef SQLITE_HAS_CODEC
  1.7626 +#if SQLITE_HAS_CODEC
  1.7627    "HAS_CODEC",
  1.7628  #endif
  1.7629 -#ifdef SQLITE_HAVE_ISNAN
  1.7630 +#if HAVE_ISNAN || SQLITE_HAVE_ISNAN
  1.7631    "HAVE_ISNAN",
  1.7632  #endif
  1.7633 -#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX
  1.7634 +#if SQLITE_HOMEGROWN_RECURSIVE_MUTEX
  1.7635    "HOMEGROWN_RECURSIVE_MUTEX",
  1.7636  #endif
  1.7637 -#ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS
  1.7638 +#if SQLITE_IGNORE_AFP_LOCK_ERRORS
  1.7639    "IGNORE_AFP_LOCK_ERRORS",
  1.7640  #endif
  1.7641 -#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS
  1.7642 +#if SQLITE_IGNORE_FLOCK_LOCK_ERRORS
  1.7643    "IGNORE_FLOCK_LOCK_ERRORS",
  1.7644  #endif
  1.7645  #ifdef SQLITE_INT64_TYPE
  1.7646    "INT64_TYPE",
  1.7647  #endif
  1.7648 -#ifdef SQLITE_LOCK_TRACE
  1.7649 +#ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS
  1.7650 +  "LIKE_DOESNT_MATCH_BLOBS",
  1.7651 +#endif
  1.7652 +#if SQLITE_LOCK_TRACE
  1.7653    "LOCK_TRACE",
  1.7654  #endif
  1.7655  #if defined(SQLITE_MAX_MMAP_SIZE) && !defined(SQLITE_MAX_MMAP_SIZE_xc)
  1.7656 @@ -13579,223 +15410,226 @@
  1.7657  #ifdef SQLITE_MAX_SCHEMA_RETRY
  1.7658    "MAX_SCHEMA_RETRY=" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY),
  1.7659  #endif
  1.7660 -#ifdef SQLITE_MEMDEBUG
  1.7661 +#if SQLITE_MEMDEBUG
  1.7662    "MEMDEBUG",
  1.7663  #endif
  1.7664 -#ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT
  1.7665 +#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT
  1.7666    "MIXED_ENDIAN_64BIT_FLOAT",
  1.7667  #endif
  1.7668 -#ifdef SQLITE_NO_SYNC
  1.7669 +#if SQLITE_NO_SYNC
  1.7670    "NO_SYNC",
  1.7671  #endif
  1.7672 -#ifdef SQLITE_OMIT_ALTERTABLE
  1.7673 +#if SQLITE_OMIT_ALTERTABLE
  1.7674    "OMIT_ALTERTABLE",
  1.7675  #endif
  1.7676 -#ifdef SQLITE_OMIT_ANALYZE
  1.7677 +#if SQLITE_OMIT_ANALYZE
  1.7678    "OMIT_ANALYZE",
  1.7679  #endif
  1.7680 -#ifdef SQLITE_OMIT_ATTACH
  1.7681 +#if SQLITE_OMIT_ATTACH
  1.7682    "OMIT_ATTACH",
  1.7683  #endif
  1.7684 -#ifdef SQLITE_OMIT_AUTHORIZATION
  1.7685 +#if SQLITE_OMIT_AUTHORIZATION
  1.7686    "OMIT_AUTHORIZATION",
  1.7687  #endif
  1.7688 -#ifdef SQLITE_OMIT_AUTOINCREMENT
  1.7689 +#if SQLITE_OMIT_AUTOINCREMENT
  1.7690    "OMIT_AUTOINCREMENT",
  1.7691  #endif
  1.7692 -#ifdef SQLITE_OMIT_AUTOINIT
  1.7693 +#if SQLITE_OMIT_AUTOINIT
  1.7694    "OMIT_AUTOINIT",
  1.7695  #endif
  1.7696 -#ifdef SQLITE_OMIT_AUTOMATIC_INDEX
  1.7697 +#if SQLITE_OMIT_AUTOMATIC_INDEX
  1.7698    "OMIT_AUTOMATIC_INDEX",
  1.7699  #endif
  1.7700 -#ifdef SQLITE_OMIT_AUTORESET
  1.7701 +#if SQLITE_OMIT_AUTORESET
  1.7702    "OMIT_AUTORESET",
  1.7703  #endif
  1.7704 -#ifdef SQLITE_OMIT_AUTOVACUUM
  1.7705 +#if SQLITE_OMIT_AUTOVACUUM
  1.7706    "OMIT_AUTOVACUUM",
  1.7707  #endif
  1.7708 -#ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION
  1.7709 +#if SQLITE_OMIT_BETWEEN_OPTIMIZATION
  1.7710    "OMIT_BETWEEN_OPTIMIZATION",
  1.7711  #endif
  1.7712 -#ifdef SQLITE_OMIT_BLOB_LITERAL
  1.7713 +#if SQLITE_OMIT_BLOB_LITERAL
  1.7714    "OMIT_BLOB_LITERAL",
  1.7715  #endif
  1.7716 -#ifdef SQLITE_OMIT_BTREECOUNT
  1.7717 +#if SQLITE_OMIT_BTREECOUNT
  1.7718    "OMIT_BTREECOUNT",
  1.7719  #endif
  1.7720 -#ifdef SQLITE_OMIT_BUILTIN_TEST
  1.7721 +#if SQLITE_OMIT_BUILTIN_TEST
  1.7722    "OMIT_BUILTIN_TEST",
  1.7723  #endif
  1.7724 -#ifdef SQLITE_OMIT_CAST
  1.7725 +#if SQLITE_OMIT_CAST
  1.7726    "OMIT_CAST",
  1.7727  #endif
  1.7728 -#ifdef SQLITE_OMIT_CHECK
  1.7729 +#if SQLITE_OMIT_CHECK
  1.7730    "OMIT_CHECK",
  1.7731  #endif
  1.7732 -#ifdef SQLITE_OMIT_COMPLETE
  1.7733 +#if SQLITE_OMIT_COMPLETE
  1.7734    "OMIT_COMPLETE",
  1.7735  #endif
  1.7736 -#ifdef SQLITE_OMIT_COMPOUND_SELECT
  1.7737 +#if SQLITE_OMIT_COMPOUND_SELECT
  1.7738    "OMIT_COMPOUND_SELECT",
  1.7739  #endif
  1.7740 -#ifdef SQLITE_OMIT_CTE
  1.7741 +#if SQLITE_OMIT_CTE
  1.7742    "OMIT_CTE",
  1.7743  #endif
  1.7744 -#ifdef SQLITE_OMIT_DATETIME_FUNCS
  1.7745 +#if SQLITE_OMIT_DATETIME_FUNCS
  1.7746    "OMIT_DATETIME_FUNCS",
  1.7747  #endif
  1.7748 -#ifdef SQLITE_OMIT_DECLTYPE
  1.7749 +#if SQLITE_OMIT_DECLTYPE
  1.7750    "OMIT_DECLTYPE",
  1.7751  #endif
  1.7752 -#ifdef SQLITE_OMIT_DEPRECATED
  1.7753 +#if SQLITE_OMIT_DEPRECATED
  1.7754    "OMIT_DEPRECATED",
  1.7755  #endif
  1.7756 -#ifdef SQLITE_OMIT_DISKIO
  1.7757 +#if SQLITE_OMIT_DISKIO
  1.7758    "OMIT_DISKIO",
  1.7759  #endif
  1.7760 -#ifdef SQLITE_OMIT_EXPLAIN
  1.7761 +#if SQLITE_OMIT_EXPLAIN
  1.7762    "OMIT_EXPLAIN",
  1.7763  #endif
  1.7764 -#ifdef SQLITE_OMIT_FLAG_PRAGMAS
  1.7765 +#if SQLITE_OMIT_FLAG_PRAGMAS
  1.7766    "OMIT_FLAG_PRAGMAS",
  1.7767  #endif
  1.7768 -#ifdef SQLITE_OMIT_FLOATING_POINT
  1.7769 +#if SQLITE_OMIT_FLOATING_POINT
  1.7770    "OMIT_FLOATING_POINT",
  1.7771  #endif
  1.7772 -#ifdef SQLITE_OMIT_FOREIGN_KEY
  1.7773 +#if SQLITE_OMIT_FOREIGN_KEY
  1.7774    "OMIT_FOREIGN_KEY",
  1.7775  #endif
  1.7776 -#ifdef SQLITE_OMIT_GET_TABLE
  1.7777 +#if SQLITE_OMIT_GET_TABLE
  1.7778    "OMIT_GET_TABLE",
  1.7779  #endif
  1.7780 -#ifdef SQLITE_OMIT_INCRBLOB
  1.7781 +#if SQLITE_OMIT_INCRBLOB
  1.7782    "OMIT_INCRBLOB",
  1.7783  #endif
  1.7784 -#ifdef SQLITE_OMIT_INTEGRITY_CHECK
  1.7785 +#if SQLITE_OMIT_INTEGRITY_CHECK
  1.7786    "OMIT_INTEGRITY_CHECK",
  1.7787  #endif
  1.7788 -#ifdef SQLITE_OMIT_LIKE_OPTIMIZATION
  1.7789 +#if SQLITE_OMIT_LIKE_OPTIMIZATION
  1.7790    "OMIT_LIKE_OPTIMIZATION",
  1.7791  #endif
  1.7792 -#ifdef SQLITE_OMIT_LOAD_EXTENSION
  1.7793 +#if SQLITE_OMIT_LOAD_EXTENSION
  1.7794    "OMIT_LOAD_EXTENSION",
  1.7795  #endif
  1.7796 -#ifdef SQLITE_OMIT_LOCALTIME
  1.7797 +#if SQLITE_OMIT_LOCALTIME
  1.7798    "OMIT_LOCALTIME",
  1.7799  #endif
  1.7800 -#ifdef SQLITE_OMIT_LOOKASIDE
  1.7801 +#if SQLITE_OMIT_LOOKASIDE
  1.7802    "OMIT_LOOKASIDE",
  1.7803  #endif
  1.7804 -#ifdef SQLITE_OMIT_MEMORYDB
  1.7805 +#if SQLITE_OMIT_MEMORYDB
  1.7806    "OMIT_MEMORYDB",
  1.7807  #endif
  1.7808 -#ifdef SQLITE_OMIT_OR_OPTIMIZATION
  1.7809 +#if SQLITE_OMIT_OR_OPTIMIZATION
  1.7810    "OMIT_OR_OPTIMIZATION",
  1.7811  #endif
  1.7812 -#ifdef SQLITE_OMIT_PAGER_PRAGMAS
  1.7813 +#if SQLITE_OMIT_PAGER_PRAGMAS
  1.7814    "OMIT_PAGER_PRAGMAS",
  1.7815  #endif
  1.7816 -#ifdef SQLITE_OMIT_PRAGMA
  1.7817 +#if SQLITE_OMIT_PRAGMA
  1.7818    "OMIT_PRAGMA",
  1.7819  #endif
  1.7820 -#ifdef SQLITE_OMIT_PROGRESS_CALLBACK
  1.7821 +#if SQLITE_OMIT_PROGRESS_CALLBACK
  1.7822    "OMIT_PROGRESS_CALLBACK",
  1.7823  #endif
  1.7824 -#ifdef SQLITE_OMIT_QUICKBALANCE
  1.7825 +#if SQLITE_OMIT_QUICKBALANCE
  1.7826    "OMIT_QUICKBALANCE",
  1.7827  #endif
  1.7828 -#ifdef SQLITE_OMIT_REINDEX
  1.7829 +#if SQLITE_OMIT_REINDEX
  1.7830    "OMIT_REINDEX",
  1.7831  #endif
  1.7832 -#ifdef SQLITE_OMIT_SCHEMA_PRAGMAS
  1.7833 +#if SQLITE_OMIT_SCHEMA_PRAGMAS
  1.7834    "OMIT_SCHEMA_PRAGMAS",
  1.7835  #endif
  1.7836 -#ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
  1.7837 +#if SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
  1.7838    "OMIT_SCHEMA_VERSION_PRAGMAS",
  1.7839  #endif
  1.7840 -#ifdef SQLITE_OMIT_SHARED_CACHE
  1.7841 +#if SQLITE_OMIT_SHARED_CACHE
  1.7842    "OMIT_SHARED_CACHE",
  1.7843  #endif
  1.7844 -#ifdef SQLITE_OMIT_SUBQUERY
  1.7845 +#if SQLITE_OMIT_SUBQUERY
  1.7846    "OMIT_SUBQUERY",
  1.7847  #endif
  1.7848 -#ifdef SQLITE_OMIT_TCL_VARIABLE
  1.7849 +#if SQLITE_OMIT_TCL_VARIABLE
  1.7850    "OMIT_TCL_VARIABLE",
  1.7851  #endif
  1.7852 -#ifdef SQLITE_OMIT_TEMPDB
  1.7853 +#if SQLITE_OMIT_TEMPDB
  1.7854    "OMIT_TEMPDB",
  1.7855  #endif
  1.7856 -#ifdef SQLITE_OMIT_TRACE
  1.7857 +#if SQLITE_OMIT_TRACE