updated sqlite to latest release
authorEdouard Tisserant
Thu, 03 Mar 2016 13:09:12 +0100
changeset 491d32c60ada438
parent 490 a0cd914fb619
child 492 0c8bd44f2eb1
child 493 ebe4ed001a0c
updated sqlite to latest release
src/pgp_netpgp.c
src/sqlite3.c
src/sqlite3.h
     1.1 --- a/src/pgp_netpgp.c	Thu Mar 03 11:14:07 2016 +0100
     1.2 +++ b/src/pgp_netpgp.c	Thu Mar 03 13:09:12 2016 +0100
     1.3 @@ -243,7 +243,7 @@
     1.4      unsigned i;
     1.5      int	n;
     1.6      
     1.7 -    /* 4 char per short (hexes + space) + null */
     1.8 +    /* 4 hexes per short + null */
     1.9      *str = malloc((length / 2) * 4 + 1);
    1.10      
    1.11      if(*str == NULL)
     2.1 --- a/src/sqlite3.c	Thu Mar 03 11:14:07 2016 +0100
     2.2 +++ b/src/sqlite3.c	Thu Mar 03 13:09:12 2016 +0100
     2.3 @@ -1,6 +1,6 @@
     2.4  /******************************************************************************
     2.5  ** This file is an amalgamation of many separate C source files from SQLite
     2.6 -** version 3.8.6.  By combining all the individual C code files into this 
     2.7 +** version 3.11.0.  By combining all the individual C code files into this 
     2.8  ** single large file, the entire code can be compiled as a single translation
     2.9  ** unit.  This allows many compilers to do optimizations that would not be
    2.10  ** possible if the files were compiled separately.  Performance improvements
    2.11 @@ -22,9 +22,6 @@
    2.12  #ifndef SQLITE_PRIVATE
    2.13  # define SQLITE_PRIVATE static
    2.14  #endif
    2.15 -#ifndef SQLITE_API
    2.16 -# define SQLITE_API
    2.17 -#endif
    2.18  /************** Begin file sqliteInt.h ***************************************/
    2.19  /*
    2.20  ** 2001 September 15
    2.21 @@ -44,6 +41,95 @@
    2.22  #define _SQLITEINT_H_
    2.23  
    2.24  /*
    2.25 +** Include the header file used to customize the compiler options for MSVC.
    2.26 +** This should be done first so that it can successfully prevent spurious
    2.27 +** compiler warnings due to subsequent content in this file and other files
    2.28 +** that are included by this file.
    2.29 +*/
    2.30 +/************** Include msvc.h in the middle of sqliteInt.h ******************/
    2.31 +/************** Begin file msvc.h ********************************************/
    2.32 +/*
    2.33 +** 2015 January 12
    2.34 +**
    2.35 +** The author disclaims copyright to this source code.  In place of
    2.36 +** a legal notice, here is a blessing:
    2.37 +**
    2.38 +**    May you do good and not evil.
    2.39 +**    May you find forgiveness for yourself and forgive others.
    2.40 +**    May you share freely, never taking more than you give.
    2.41 +**
    2.42 +******************************************************************************
    2.43 +**
    2.44 +** This file contains code that is specific to MSVC.
    2.45 +*/
    2.46 +#ifndef _MSVC_H_
    2.47 +#define _MSVC_H_
    2.48 +
    2.49 +#if defined(_MSC_VER)
    2.50 +#pragma warning(disable : 4054)
    2.51 +#pragma warning(disable : 4055)
    2.52 +#pragma warning(disable : 4100)
    2.53 +#pragma warning(disable : 4127)
    2.54 +#pragma warning(disable : 4130)
    2.55 +#pragma warning(disable : 4152)
    2.56 +#pragma warning(disable : 4189)
    2.57 +#pragma warning(disable : 4206)
    2.58 +#pragma warning(disable : 4210)
    2.59 +#pragma warning(disable : 4232)
    2.60 +#pragma warning(disable : 4244)
    2.61 +#pragma warning(disable : 4305)
    2.62 +#pragma warning(disable : 4306)
    2.63 +#pragma warning(disable : 4702)
    2.64 +#pragma warning(disable : 4706)
    2.65 +#endif /* defined(_MSC_VER) */
    2.66 +
    2.67 +#endif /* _MSVC_H_ */
    2.68 +
    2.69 +/************** End of msvc.h ************************************************/
    2.70 +/************** Continuing where we left off in sqliteInt.h ******************/
    2.71 +
    2.72 +/*
    2.73 +** Special setup for VxWorks
    2.74 +*/
    2.75 +/************** Include vxworks.h in the middle of sqliteInt.h ***************/
    2.76 +/************** Begin file vxworks.h *****************************************/
    2.77 +/*
    2.78 +** 2015-03-02
    2.79 +**
    2.80 +** The author disclaims copyright to this source code.  In place of
    2.81 +** a legal notice, here is a blessing:
    2.82 +**
    2.83 +**    May you do good and not evil.
    2.84 +**    May you find forgiveness for yourself and forgive others.
    2.85 +**    May you share freely, never taking more than you give.
    2.86 +**
    2.87 +******************************************************************************
    2.88 +**
    2.89 +** This file contains code that is specific to Wind River's VxWorks
    2.90 +*/
    2.91 +#if defined(__RTP__) || defined(_WRS_KERNEL)
    2.92 +/* This is VxWorks.  Set up things specially for that OS
    2.93 +*/
    2.94 +#include <vxWorks.h>
    2.95 +#include <pthread.h>  /* amalgamator: dontcache */
    2.96 +#define OS_VXWORKS 1
    2.97 +#define SQLITE_OS_OTHER 0
    2.98 +#define SQLITE_HOMEGROWN_RECURSIVE_MUTEX 1
    2.99 +#define SQLITE_OMIT_LOAD_EXTENSION 1
   2.100 +#define SQLITE_ENABLE_LOCKING_STYLE 0
   2.101 +#define HAVE_UTIME 1
   2.102 +#else
   2.103 +/* This is not VxWorks. */
   2.104 +#define OS_VXWORKS 0
   2.105 +#define HAVE_FCHOWN 1
   2.106 +#define HAVE_READLINK 1
   2.107 +#define HAVE_LSTAT 1
   2.108 +#endif /* defined(_WRS_KERNEL) */
   2.109 +
   2.110 +/************** End of vxworks.h *********************************************/
   2.111 +/************** Continuing where we left off in sqliteInt.h ******************/
   2.112 +
   2.113 +/*
   2.114  ** These #defines should enable >2GB file support on POSIX if the
   2.115  ** underlying operating system supports it.  If the OS lacks
   2.116  ** large file support, or if the OS is windows, these should be no-ops.
   2.117 @@ -75,6 +161,22 @@
   2.118  # define _LARGEFILE_SOURCE 1
   2.119  #endif
   2.120  
   2.121 +/* What version of GCC is being used.  0 means GCC is not being used */
   2.122 +#ifdef __GNUC__
   2.123 +# define GCC_VERSION (__GNUC__*1000000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__)
   2.124 +#else
   2.125 +# define GCC_VERSION 0
   2.126 +#endif
   2.127 +
   2.128 +/* Needed for various definitions... */
   2.129 +#if defined(__GNUC__) && !defined(_GNU_SOURCE)
   2.130 +# define _GNU_SOURCE
   2.131 +#endif
   2.132 +
   2.133 +#if defined(__OpenBSD__) && !defined(_BSD_SOURCE)
   2.134 +# define _BSD_SOURCE
   2.135 +#endif
   2.136 +
   2.137  /*
   2.138  ** For MinGW, check to see if we can include the header file containing its
   2.139  ** version information, among other things.  Normally, this internal MinGW
   2.140 @@ -138,7 +240,7 @@
   2.141  **
   2.142  ** The official C-language API documentation for SQLite is derived
   2.143  ** from comments in this file.  This file is the authoritative source
   2.144 -** on how SQLite interfaces are suppose to operate.
   2.145 +** on how SQLite interfaces are supposed to operate.
   2.146  **
   2.147  ** The name of this file under configuration management is "sqlite.h.in".
   2.148  ** The makefile makes some minor changes to this file (such as inserting
   2.149 @@ -158,21 +260,25 @@
   2.150  
   2.151  
   2.152  /*
   2.153 -** Add the ability to override 'extern'
   2.154 +** Provide the ability to override linkage features of the interface.
   2.155  */
   2.156  #ifndef SQLITE_EXTERN
   2.157  # define SQLITE_EXTERN extern
   2.158  #endif
   2.159 -
   2.160  #ifndef SQLITE_API
   2.161  # define SQLITE_API
   2.162  #endif
   2.163 -
   2.164 +#ifndef SQLITE_CDECL
   2.165 +# define SQLITE_CDECL
   2.166 +#endif
   2.167 +#ifndef SQLITE_STDCALL
   2.168 +# define SQLITE_STDCALL
   2.169 +#endif
   2.170  
   2.171  /*
   2.172  ** These no-op macros are used in front of interfaces to mark those
   2.173  ** interfaces as either deprecated or experimental.  New applications
   2.174 -** should not use deprecated interfaces - they are support for backwards
   2.175 +** should not use deprecated interfaces - they are supported for backwards
   2.176  ** compatibility only.  Application writers should be aware that
   2.177  ** experimental interfaces are subject to change in point releases.
   2.178  **
   2.179 @@ -222,9 +328,9 @@
   2.180  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
   2.181  ** [sqlite_version()] and [sqlite_source_id()].
   2.182  */
   2.183 -#define SQLITE_VERSION        "3.8.6"
   2.184 -#define SQLITE_VERSION_NUMBER 3008006
   2.185 -#define SQLITE_SOURCE_ID      "2014-08-15 11:46:33 9491ba7d738528f168657adb43a198238abde19e"
   2.186 +#define SQLITE_VERSION        "3.11.0"
   2.187 +#define SQLITE_VERSION_NUMBER 3011000
   2.188 +#define SQLITE_SOURCE_ID      "2016-02-15 17:29:24 3d862f207e3adc00f78066799ac5a8c282430a5f"
   2.189  
   2.190  /*
   2.191  ** CAPI3REF: Run-Time Library Version Numbers
   2.192 @@ -235,7 +341,7 @@
   2.193  ** but are associated with the library instead of the header file.  ^(Cautious
   2.194  ** programmers might include assert() statements in their application to
   2.195  ** verify that values returned by these interfaces match the macros in
   2.196 -** the header, and thus insure that the application is
   2.197 +** the header, and thus ensure that the application is
   2.198  ** compiled with matching library and header files.
   2.199  **
   2.200  ** <blockquote><pre>
   2.201 @@ -257,9 +363,9 @@
   2.202  ** See also: [sqlite_version()] and [sqlite_source_id()].
   2.203  */
   2.204  SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
   2.205 -SQLITE_API const char *sqlite3_libversion(void);
   2.206 -SQLITE_API const char *sqlite3_sourceid(void);
   2.207 -SQLITE_API int sqlite3_libversion_number(void);
   2.208 +SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void);
   2.209 +SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void);
   2.210 +SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void);
   2.211  
   2.212  /*
   2.213  ** CAPI3REF: Run-Time Library Compilation Options Diagnostics
   2.214 @@ -284,8 +390,8 @@
   2.215  ** [sqlite_compileoption_get()] and the [compile_options pragma].
   2.216  */
   2.217  #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
   2.218 -SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
   2.219 -SQLITE_API const char *sqlite3_compileoption_get(int N);
   2.220 +SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName);
   2.221 +SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N);
   2.222  #endif
   2.223  
   2.224  /*
   2.225 @@ -316,7 +422,7 @@
   2.226  ** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
   2.227  ** can be fully or partially disabled using a call to [sqlite3_config()]
   2.228  ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
   2.229 -** or [SQLITE_CONFIG_MUTEX].  ^(The return value of the
   2.230 +** or [SQLITE_CONFIG_SERIALIZED].  ^(The return value of the
   2.231  ** sqlite3_threadsafe() function shows only the compile-time setting of
   2.232  ** thread safety, not any run-time changes to that setting made by
   2.233  ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
   2.234 @@ -324,7 +430,7 @@
   2.235  **
   2.236  ** See the [threading mode] documentation for additional information.
   2.237  */
   2.238 -SQLITE_API int sqlite3_threadsafe(void);
   2.239 +SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void);
   2.240  
   2.241  /*
   2.242  ** CAPI3REF: Database Connection Handle
   2.243 @@ -381,6 +487,7 @@
   2.244  
   2.245  /*
   2.246  ** CAPI3REF: Closing A Database Connection
   2.247 +** DESTRUCTOR: sqlite3
   2.248  **
   2.249  ** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors
   2.250  ** for the [sqlite3] object.
   2.251 @@ -420,8 +527,8 @@
   2.252  ** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
   2.253  ** argument is a harmless no-op.
   2.254  */
   2.255 -SQLITE_API int sqlite3_close(sqlite3*);
   2.256 -SQLITE_API int sqlite3_close_v2(sqlite3*);
   2.257 +SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3*);
   2.258 +SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3*);
   2.259  
   2.260  /*
   2.261  ** The type for a callback function.
   2.262 @@ -432,6 +539,7 @@
   2.263  
   2.264  /*
   2.265  ** CAPI3REF: One-Step Query Execution Interface
   2.266 +** METHOD: sqlite3
   2.267  **
   2.268  ** The sqlite3_exec() interface is a convenience wrapper around
   2.269  ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
   2.270 @@ -456,7 +564,7 @@
   2.271  ** from [sqlite3_malloc()] and passed back through the 5th parameter.
   2.272  ** To avoid memory leaks, the application should invoke [sqlite3_free()]
   2.273  ** on error message strings returned through the 5th parameter of
   2.274 -** of sqlite3_exec() after the error message string is no longer needed.
   2.275 +** sqlite3_exec() after the error message string is no longer needed.
   2.276  ** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors
   2.277  ** occur, then sqlite3_exec() sets the pointer in its 5th parameter to
   2.278  ** NULL before returning.
   2.279 @@ -483,7 +591,7 @@
   2.280  ** Restrictions:
   2.281  **
   2.282  ** <ul>
   2.283 -** <li> The application must insure that the 1st parameter to sqlite3_exec()
   2.284 +** <li> The application must ensure that the 1st parameter to sqlite3_exec()
   2.285  **      is a valid and open [database connection].
   2.286  ** <li> The application must not close the [database connection] specified by
   2.287  **      the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
   2.288 @@ -491,7 +599,7 @@
   2.289  **      the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
   2.290  ** </ul>
   2.291  */
   2.292 -SQLITE_API int sqlite3_exec(
   2.293 +SQLITE_API int SQLITE_STDCALL sqlite3_exec(
   2.294    sqlite3*,                                  /* An open database */
   2.295    const char *sql,                           /* SQL to be evaluated */
   2.296    int (*callback)(void*,int,char**,char**),  /* Callback function */
   2.297 @@ -586,6 +694,8 @@
   2.298  #define SQLITE_IOERR_MMAP              (SQLITE_IOERR | (24<<8))
   2.299  #define SQLITE_IOERR_GETTEMPPATH       (SQLITE_IOERR | (25<<8))
   2.300  #define SQLITE_IOERR_CONVPATH          (SQLITE_IOERR | (26<<8))
   2.301 +#define SQLITE_IOERR_VNODE             (SQLITE_IOERR | (27<<8))
   2.302 +#define SQLITE_IOERR_AUTH              (SQLITE_IOERR | (28<<8))
   2.303  #define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))
   2.304  #define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))
   2.305  #define SQLITE_BUSY_SNAPSHOT           (SQLITE_BUSY   |  (2<<8))
   2.306 @@ -612,6 +722,7 @@
   2.307  #define SQLITE_NOTICE_RECOVER_WAL      (SQLITE_NOTICE | (1<<8))
   2.308  #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
   2.309  #define SQLITE_WARNING_AUTOINDEX       (SQLITE_WARNING | (1<<8))
   2.310 +#define SQLITE_AUTH_USER               (SQLITE_AUTH | (1<<8))
   2.311  
   2.312  /*
   2.313  ** CAPI3REF: Flags For File Open Operations
   2.314 @@ -870,14 +981,16 @@
   2.315  ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
   2.316  ** interface.
   2.317  **
   2.318 +** <ul>
   2.319 +** <li>[[SQLITE_FCNTL_LOCKSTATE]]
   2.320  ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging.  This
   2.321  ** opcode causes the xFileControl method to write the current state of
   2.322  ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
   2.323  ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
   2.324  ** into an integer that the pArg argument points to. This capability
   2.325 -** is used during testing and only needs to be supported when SQLITE_TEST
   2.326 -** is defined.
   2.327 -** <ul>
   2.328 +** is used during testing and is only available when the SQLITE_TEST
   2.329 +** compile-time option is used.
   2.330 +**
   2.331  ** <li>[[SQLITE_FCNTL_SIZE_HINT]]
   2.332  ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
   2.333  ** layer a hint of how large the database file will grow to be during the
   2.334 @@ -898,8 +1011,13 @@
   2.335  ** <li>[[SQLITE_FCNTL_FILE_POINTER]]
   2.336  ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer
   2.337  ** to the [sqlite3_file] object associated with a particular database
   2.338 -** connection.  See the [sqlite3_file_control()] documentation for
   2.339 -** additional information.
   2.340 +** connection.  See also [SQLITE_FCNTL_JOURNAL_POINTER].
   2.341 +**
   2.342 +** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]]
   2.343 +** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer
   2.344 +** to the [sqlite3_file] object associated with the journal file (either
   2.345 +** the [rollback journal] or the [write-ahead log]) for a particular database
   2.346 +** connection.  See also [SQLITE_FCNTL_FILE_POINTER].
   2.347  **
   2.348  ** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]
   2.349  ** No longer in use.
   2.350 @@ -986,6 +1104,15 @@
   2.351  ** pointer in case this file-control is not implemented.  This file-control
   2.352  ** is intended for diagnostic use only.
   2.353  **
   2.354 +** <li>[[SQLITE_FCNTL_VFS_POINTER]]
   2.355 +** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level
   2.356 +** [VFSes] currently in use.  ^(The argument X in
   2.357 +** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be
   2.358 +** of type "[sqlite3_vfs] **".  This opcodes will set *X
   2.359 +** to a pointer to the top-level VFS.)^
   2.360 +** ^When there are multiple VFS shims in the stack, this opcode finds the
   2.361 +** upper-most shim only.
   2.362 +**
   2.363  ** <li>[[SQLITE_FCNTL_PRAGMA]]
   2.364  ** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] 
   2.365  ** file control is sent to the open [sqlite3_file] object corresponding
   2.366 @@ -1002,7 +1129,9 @@
   2.367  ** [PRAGMA] processing continues.  ^If the [SQLITE_FCNTL_PRAGMA]
   2.368  ** file control returns [SQLITE_OK], then the parser assumes that the
   2.369  ** VFS has handled the PRAGMA itself and the parser generates a no-op
   2.370 -** prepared statement.  ^If the [SQLITE_FCNTL_PRAGMA] file control returns
   2.371 +** prepared statement if result string is NULL, or that returns a copy
   2.372 +** of the result string if the string is non-NULL.
   2.373 +** ^If the [SQLITE_FCNTL_PRAGMA] file control returns
   2.374  ** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
   2.375  ** that the VFS encountered an error while handling the [PRAGMA] and the
   2.376  ** compilation of the PRAGMA fails with an error.  ^The [SQLITE_FCNTL_PRAGMA]
   2.377 @@ -1060,12 +1189,27 @@
   2.378  ** pointed to by the pArg argument.  This capability is used during testing
   2.379  ** and only needs to be supported when SQLITE_TEST is defined.
   2.380  **
   2.381 +** <li>[[SQLITE_FCNTL_WAL_BLOCK]]
   2.382 +** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might
   2.383 +** be advantageous to block on the next WAL lock if the lock is not immediately
   2.384 +** available.  The WAL subsystem issues this signal during rare
   2.385 +** circumstances in order to fix a problem with priority inversion.
   2.386 +** Applications should <em>not</em> use this file-control.
   2.387 +**
   2.388 +** <li>[[SQLITE_FCNTL_ZIPVFS]]
   2.389 +** The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other
   2.390 +** VFS should return SQLITE_NOTFOUND for this opcode.
   2.391 +**
   2.392 +** <li>[[SQLITE_FCNTL_RBU]]
   2.393 +** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by
   2.394 +** the RBU extension only.  All other VFS should return SQLITE_NOTFOUND for
   2.395 +** this opcode.  
   2.396  ** </ul>
   2.397  */
   2.398  #define SQLITE_FCNTL_LOCKSTATE               1
   2.399 -#define SQLITE_GET_LOCKPROXYFILE             2
   2.400 -#define SQLITE_SET_LOCKPROXYFILE             3
   2.401 -#define SQLITE_LAST_ERRNO                    4
   2.402 +#define SQLITE_FCNTL_GET_LOCKPROXYFILE       2
   2.403 +#define SQLITE_FCNTL_SET_LOCKPROXYFILE       3
   2.404 +#define SQLITE_FCNTL_LAST_ERRNO              4
   2.405  #define SQLITE_FCNTL_SIZE_HINT               5
   2.406  #define SQLITE_FCNTL_CHUNK_SIZE              6
   2.407  #define SQLITE_FCNTL_FILE_POINTER            7
   2.408 @@ -1084,6 +1228,17 @@
   2.409  #define SQLITE_FCNTL_SYNC                   21
   2.410  #define SQLITE_FCNTL_COMMIT_PHASETWO        22
   2.411  #define SQLITE_FCNTL_WIN32_SET_HANDLE       23
   2.412 +#define SQLITE_FCNTL_WAL_BLOCK              24
   2.413 +#define SQLITE_FCNTL_ZIPVFS                 25
   2.414 +#define SQLITE_FCNTL_RBU                    26
   2.415 +#define SQLITE_FCNTL_VFS_POINTER            27
   2.416 +#define SQLITE_FCNTL_JOURNAL_POINTER        28
   2.417 +
   2.418 +/* deprecated names */
   2.419 +#define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE
   2.420 +#define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE
   2.421 +#define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO
   2.422 +
   2.423  
   2.424  /*
   2.425  ** CAPI3REF: Mutex Handle
   2.426 @@ -1335,7 +1490,7 @@
   2.427  ** </ul>
   2.428  **
   2.429  ** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as
   2.430 -** was given no the corresponding lock.  
   2.431 +** was given on the corresponding lock.  
   2.432  **
   2.433  ** The xShmLock method can transition between unlocked and SHARED or
   2.434  ** between unlocked and EXCLUSIVE.  It cannot transition between SHARED
   2.435 @@ -1432,10 +1587,10 @@
   2.436  ** must return [SQLITE_OK] on success and some other [error code] upon
   2.437  ** failure.
   2.438  */
   2.439 -SQLITE_API int sqlite3_initialize(void);
   2.440 -SQLITE_API int sqlite3_shutdown(void);
   2.441 -SQLITE_API int sqlite3_os_init(void);
   2.442 -SQLITE_API int sqlite3_os_end(void);
   2.443 +SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void);
   2.444 +SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void);
   2.445 +SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void);
   2.446 +SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void);
   2.447  
   2.448  /*
   2.449  ** CAPI3REF: Configuring The SQLite Library
   2.450 @@ -1446,9 +1601,11 @@
   2.451  ** applications and so this routine is usually not necessary.  It is
   2.452  ** provided to support rare applications with unusual needs.
   2.453  **
   2.454 -** The sqlite3_config() interface is not threadsafe.  The application
   2.455 -** must insure that no other SQLite interfaces are invoked by other
   2.456 -** threads while sqlite3_config() is running.  Furthermore, sqlite3_config()
   2.457 +** <b>The sqlite3_config() interface is not threadsafe. The application
   2.458 +** must ensure that no other SQLite interfaces are invoked by other
   2.459 +** threads while sqlite3_config() is running.</b>
   2.460 +**
   2.461 +** The sqlite3_config() interface
   2.462  ** may only be invoked prior to library initialization using
   2.463  ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
   2.464  ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
   2.465 @@ -1466,10 +1623,11 @@
   2.466  ** ^If the option is unknown or SQLite is unable to set the option
   2.467  ** then this routine returns a non-zero [error code].
   2.468  */
   2.469 -SQLITE_API int sqlite3_config(int, ...);
   2.470 +SQLITE_API int SQLITE_CDECL sqlite3_config(int, ...);
   2.471  
   2.472  /*
   2.473  ** CAPI3REF: Configure database connections
   2.474 +** METHOD: sqlite3
   2.475  **
   2.476  ** The sqlite3_db_config() interface is used to make configuration
   2.477  ** changes to a [database connection].  The interface is similar to
   2.478 @@ -1484,7 +1642,7 @@
   2.479  ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
   2.480  ** the call is considered successful.
   2.481  */
   2.482 -SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
   2.483 +SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3*, int op, ...);
   2.484  
   2.485  /*
   2.486  ** CAPI3REF: Memory Allocation Routines
   2.487 @@ -1618,31 +1776,33 @@
   2.488  ** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
   2.489  **
   2.490  ** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>
   2.491 -** <dd> ^(This option takes a single argument which is a pointer to an
   2.492 -** instance of the [sqlite3_mem_methods] structure.  The argument specifies
   2.493 +** <dd> ^(The SQLITE_CONFIG_MALLOC option takes a single argument which is 
   2.494 +** a pointer to an instance of the [sqlite3_mem_methods] structure.
   2.495 +** The argument specifies
   2.496  ** alternative low-level memory allocation routines to be used in place of
   2.497  ** the memory allocation routines built into SQLite.)^ ^SQLite makes
   2.498  ** its own private copy of the content of the [sqlite3_mem_methods] structure
   2.499  ** before the [sqlite3_config()] call returns.</dd>
   2.500  **
   2.501  ** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>
   2.502 -** <dd> ^(This option takes a single argument which is a pointer to an
   2.503 -** instance of the [sqlite3_mem_methods] structure.  The [sqlite3_mem_methods]
   2.504 +** <dd> ^(The SQLITE_CONFIG_GETMALLOC option takes a single argument which
   2.505 +** is a pointer to an instance of the [sqlite3_mem_methods] structure.
   2.506 +** The [sqlite3_mem_methods]
   2.507  ** structure is filled with the currently defined memory allocation routines.)^
   2.508  ** This option can be used to overload the default memory allocation
   2.509  ** routines with a wrapper that simulations memory allocation failure or
   2.510  ** tracks memory usage, for example. </dd>
   2.511  **
   2.512  ** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>
   2.513 -** <dd> ^This option takes single argument of type int, interpreted as a 
   2.514 -** boolean, which enables or disables the collection of memory allocation 
   2.515 -** statistics. ^(When memory allocation statistics are disabled, the 
   2.516 -** following SQLite interfaces become non-operational:
   2.517 +** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,
   2.518 +** interpreted as a boolean, which enables or disables the collection of
   2.519 +** memory allocation statistics. ^(When memory allocation statistics are
   2.520 +** disabled, the following SQLite interfaces become non-operational:
   2.521  **   <ul>
   2.522  **   <li> [sqlite3_memory_used()]
   2.523  **   <li> [sqlite3_memory_highwater()]
   2.524  **   <li> [sqlite3_soft_heap_limit64()]
   2.525 -**   <li> [sqlite3_status()]
   2.526 +**   <li> [sqlite3_status64()]
   2.527  **   </ul>)^
   2.528  ** ^Memory allocation statistics are enabled by default unless SQLite is
   2.529  ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
   2.530 @@ -1650,53 +1810,72 @@
   2.531  ** </dd>
   2.532  **
   2.533  ** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt>
   2.534 -** <dd> ^This option specifies a static memory buffer that SQLite can use for
   2.535 -** scratch memory.  There are three arguments:  A pointer an 8-byte
   2.536 +** <dd> ^The SQLITE_CONFIG_SCRATCH option specifies a static memory buffer
   2.537 +** that SQLite can use for scratch memory.  ^(There are three arguments
   2.538 +** to SQLITE_CONFIG_SCRATCH:  A pointer an 8-byte
   2.539  ** aligned memory buffer from which the scratch allocations will be
   2.540  ** drawn, the size of each scratch allocation (sz),
   2.541 -** and the maximum number of scratch allocations (N).  The sz
   2.542 -** argument must be a multiple of 16.
   2.543 +** and the maximum number of scratch allocations (N).)^
   2.544  ** The first argument must be a pointer to an 8-byte aligned buffer
   2.545  ** of at least sz*N bytes of memory.
   2.546 -** ^SQLite will use no more than two scratch buffers per thread.  So
   2.547 -** N should be set to twice the expected maximum number of threads.
   2.548 -** ^SQLite will never require a scratch buffer that is more than 6
   2.549 -** times the database page size. ^If SQLite needs needs additional
   2.550 +** ^SQLite will not use more than one scratch buffers per thread.
   2.551 +** ^SQLite will never request a scratch buffer that is more than 6
   2.552 +** times the database page size.
   2.553 +** ^If SQLite needs needs additional
   2.554  ** scratch memory beyond what is provided by this configuration option, then 
   2.555 -** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
   2.556 +** [sqlite3_malloc()] will be used to obtain the memory needed.<p>
   2.557 +** ^When the application provides any amount of scratch memory using
   2.558 +** SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary large
   2.559 +** [sqlite3_malloc|heap allocations].
   2.560 +** This can help [Robson proof|prevent memory allocation failures] due to heap
   2.561 +** fragmentation in low-memory embedded systems.
   2.562 +** </dd>
   2.563  **
   2.564  ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
   2.565 -** <dd> ^This option specifies a static memory buffer that SQLite can use for
   2.566 -** the database page cache with the default page cache implementation.  
   2.567 -** This configuration should not be used if an application-define page
   2.568 -** cache implementation is loaded using the SQLITE_CONFIG_PCACHE2 option.
   2.569 -** There are three arguments to this option: A pointer to 8-byte aligned
   2.570 -** memory, the size of each page buffer (sz), and the number of pages (N).
   2.571 +** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool
   2.572 +** that SQLite can use for the database page cache with the default page
   2.573 +** cache implementation.  
   2.574 +** This configuration option is a no-op if an application-define page
   2.575 +** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2].
   2.576 +** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to
   2.577 +** 8-byte aligned memory (pMem), the size of each page cache line (sz),
   2.578 +** and the number of cache lines (N).
   2.579  ** The sz argument should be the size of the largest database page
   2.580 -** (a power of two between 512 and 32768) plus a little extra for each
   2.581 -** page header.  ^The page header size is 20 to 40 bytes depending on
   2.582 -** the host architecture.  ^It is harmless, apart from the wasted memory,
   2.583 -** to make sz a little too large.  The first
   2.584 -** argument should point to an allocation of at least sz*N bytes of memory.
   2.585 -** ^SQLite will use the memory provided by the first argument to satisfy its
   2.586 -** memory needs for the first N pages that it adds to cache.  ^If additional
   2.587 -** page cache memory is needed beyond what is provided by this option, then
   2.588 -** SQLite goes to [sqlite3_malloc()] for the additional storage space.
   2.589 -** The pointer in the first argument must
   2.590 -** be aligned to an 8-byte boundary or subsequent behavior of SQLite
   2.591 -** will be undefined.</dd>
   2.592 +** (a power of two between 512 and 65536) plus some extra bytes for each
   2.593 +** page header.  ^The number of extra bytes needed by the page header
   2.594 +** can be determined using [SQLITE_CONFIG_PCACHE_HDRSZ].
   2.595 +** ^It is harmless, apart from the wasted memory,
   2.596 +** for the sz parameter to be larger than necessary.  The pMem
   2.597 +** argument must be either a NULL pointer or a pointer to an 8-byte
   2.598 +** aligned block of memory of at least sz*N bytes, otherwise
   2.599 +** subsequent behavior is undefined.
   2.600 +** ^When pMem is not NULL, SQLite will strive to use the memory provided
   2.601 +** to satisfy page cache needs, falling back to [sqlite3_malloc()] if
   2.602 +** a page cache line is larger than sz bytes or if all of the pMem buffer
   2.603 +** is exhausted.
   2.604 +** ^If pMem is NULL and N is non-zero, then each database connection
   2.605 +** does an initial bulk allocation for page cache memory
   2.606 +** from [sqlite3_malloc()] sufficient for N cache lines if N is positive or
   2.607 +** of -1024*N bytes if N is negative, . ^If additional
   2.608 +** page cache memory is needed beyond what is provided by the initial
   2.609 +** allocation, then SQLite goes to [sqlite3_malloc()] separately for each
   2.610 +** additional cache line. </dd>
   2.611  **
   2.612  ** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>
   2.613 -** <dd> ^This option specifies a static memory buffer that SQLite will use
   2.614 -** for all of its dynamic memory allocation needs beyond those provided
   2.615 -** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
   2.616 -** There are three arguments: An 8-byte aligned pointer to the memory,
   2.617 +** <dd> ^The SQLITE_CONFIG_HEAP option specifies a static memory buffer 
   2.618 +** that SQLite will use for all of its dynamic memory allocation needs
   2.619 +** beyond those provided for by [SQLITE_CONFIG_SCRATCH] and
   2.620 +** [SQLITE_CONFIG_PAGECACHE].
   2.621 +** ^The SQLITE_CONFIG_HEAP option is only available if SQLite is compiled
   2.622 +** with either [SQLITE_ENABLE_MEMSYS3] or [SQLITE_ENABLE_MEMSYS5] and returns
   2.623 +** [SQLITE_ERROR] if invoked otherwise.
   2.624 +** ^There are three arguments to SQLITE_CONFIG_HEAP:
   2.625 +** An 8-byte aligned pointer to the memory,
   2.626  ** the number of bytes in the memory buffer, and the minimum allocation size.
   2.627  ** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts
   2.628  ** to using its default memory allocator (the system malloc() implementation),
   2.629  ** undoing any prior invocation of [SQLITE_CONFIG_MALLOC].  ^If the
   2.630 -** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or
   2.631 -** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
   2.632 +** memory pointer is not NULL then the alternative memory
   2.633  ** allocator is engaged to handle all of SQLites memory allocation needs.
   2.634  ** The first pointer (the memory pointer) must be aligned to an 8-byte
   2.635  ** boundary or subsequent behavior of SQLite will be undefined.
   2.636 @@ -1704,11 +1883,11 @@
   2.637  ** for the minimum allocation size are 2**5 through 2**8.</dd>
   2.638  **
   2.639  ** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>
   2.640 -** <dd> ^(This option takes a single argument which is a pointer to an
   2.641 -** instance of the [sqlite3_mutex_methods] structure.  The argument specifies
   2.642 -** alternative low-level mutex routines to be used in place
   2.643 -** the mutex routines built into SQLite.)^  ^SQLite makes a copy of the
   2.644 -** content of the [sqlite3_mutex_methods] structure before the call to
   2.645 +** <dd> ^(The SQLITE_CONFIG_MUTEX option takes a single argument which is a
   2.646 +** pointer to an instance of the [sqlite3_mutex_methods] structure.
   2.647 +** The argument specifies alternative low-level mutex routines to be used
   2.648 +** in place the mutex routines built into SQLite.)^  ^SQLite makes a copy of
   2.649 +** the content of the [sqlite3_mutex_methods] structure before the call to
   2.650  ** [sqlite3_config()] returns. ^If SQLite is compiled with
   2.651  ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
   2.652  ** the entire mutexing subsystem is omitted from the build and hence calls to
   2.653 @@ -1716,8 +1895,8 @@
   2.654  ** return [SQLITE_ERROR].</dd>
   2.655  **
   2.656  ** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt>
   2.657 -** <dd> ^(This option takes a single argument which is a pointer to an
   2.658 -** instance of the [sqlite3_mutex_methods] structure.  The
   2.659 +** <dd> ^(The SQLITE_CONFIG_GETMUTEX option takes a single argument which
   2.660 +** is a pointer to an instance of the [sqlite3_mutex_methods] structure.  The
   2.661  ** [sqlite3_mutex_methods]
   2.662  ** structure is filled with the currently defined mutex routines.)^
   2.663  ** This option can be used to overload the default mutex allocation
   2.664 @@ -1729,25 +1908,25 @@
   2.665  ** return [SQLITE_ERROR].</dd>
   2.666  **
   2.667  ** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>
   2.668 -** <dd> ^(This option takes two arguments that determine the default
   2.669 -** memory allocation for the lookaside memory allocator on each
   2.670 -** [database connection].  The first argument is the
   2.671 +** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine
   2.672 +** the default size of lookaside memory on each [database connection].
   2.673 +** The first argument is the
   2.674  ** size of each lookaside buffer slot and the second is the number of
   2.675 -** slots allocated to each database connection.)^  ^(This option sets the
   2.676 -** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
   2.677 -** verb to [sqlite3_db_config()] can be used to change the lookaside
   2.678 +** slots allocated to each database connection.)^  ^(SQLITE_CONFIG_LOOKASIDE
   2.679 +** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
   2.680 +** option to [sqlite3_db_config()] can be used to change the lookaside
   2.681  ** configuration on individual connections.)^ </dd>
   2.682  **
   2.683  ** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>
   2.684 -** <dd> ^(This option takes a single argument which is a pointer to
   2.685 -** an [sqlite3_pcache_methods2] object.  This object specifies the interface
   2.686 -** to a custom page cache implementation.)^  ^SQLite makes a copy of the
   2.687 -** object and uses it for page cache memory allocations.</dd>
   2.688 +** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is 
   2.689 +** a pointer to an [sqlite3_pcache_methods2] object.  This object specifies
   2.690 +** the interface to a custom page cache implementation.)^
   2.691 +** ^SQLite makes a copy of the [sqlite3_pcache_methods2] object.</dd>
   2.692  **
   2.693  ** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>
   2.694 -** <dd> ^(This option takes a single argument which is a pointer to an
   2.695 -** [sqlite3_pcache_methods2] object.  SQLite copies of the current
   2.696 -** page cache implementation into that object.)^ </dd>
   2.697 +** <dd> ^(The SQLITE_CONFIG_GETPCACHE2 option takes a single argument which
   2.698 +** is a pointer to an [sqlite3_pcache_methods2] object.  SQLite copies of
   2.699 +** the current page cache implementation into that object.)^ </dd>
   2.700  **
   2.701  ** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>
   2.702  ** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite
   2.703 @@ -1770,10 +1949,11 @@
   2.704  ** function must be threadsafe. </dd>
   2.705  **
   2.706  ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
   2.707 -** <dd>^(This option takes a single argument of type int. If non-zero, then
   2.708 -** URI handling is globally enabled. If the parameter is zero, then URI handling
   2.709 -** is globally disabled.)^ ^If URI handling is globally enabled, all filenames
   2.710 -** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
   2.711 +** <dd>^(The SQLITE_CONFIG_URI option takes a single argument of type int.
   2.712 +** If non-zero, then URI handling is globally enabled. If the parameter is zero,
   2.713 +** then URI handling is globally disabled.)^ ^If URI handling is globally
   2.714 +** enabled, all filenames passed to [sqlite3_open()], [sqlite3_open_v2()],
   2.715 +** [sqlite3_open16()] or
   2.716  ** specified as part of [ATTACH] commands are interpreted as URIs, regardless
   2.717  ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
   2.718  ** connection is opened. ^If it is globally disabled, filenames are
   2.719 @@ -1783,9 +1963,10 @@
   2.720  ** [SQLITE_USE_URI] symbol defined.)^
   2.721  **
   2.722  ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
   2.723 -** <dd>^This option takes a single integer argument which is interpreted as
   2.724 -** a boolean in order to enable or disable the use of covering indices for
   2.725 -** full table scans in the query optimizer.  ^The default setting is determined
   2.726 +** <dd>^The SQLITE_CONFIG_COVERING_INDEX_SCAN option takes a single integer
   2.727 +** argument which is interpreted as a boolean in order to enable or disable
   2.728 +** the use of covering indices for full table scans in the query optimizer.
   2.729 +** ^The default setting is determined
   2.730  ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
   2.731  ** if that compile-time option is omitted.
   2.732  ** The ability to disable the use of covering indices for full table scans
   2.733 @@ -1825,18 +2006,37 @@
   2.734  ** ^The default setting can be overridden by each database connection using
   2.735  ** either the [PRAGMA mmap_size] command, or by using the
   2.736  ** [SQLITE_FCNTL_MMAP_SIZE] file control.  ^(The maximum allowed mmap size
   2.737 -** cannot be changed at run-time.  Nor may the maximum allowed mmap size
   2.738 -** exceed the compile-time maximum mmap size set by the
   2.739 +** will be silently truncated if necessary so that it does not exceed the
   2.740 +** compile-time maximum mmap size set by the
   2.741  ** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
   2.742  ** ^If either argument to this option is negative, then that argument is
   2.743  ** changed to its compile-time default.
   2.744  **
   2.745  ** [[SQLITE_CONFIG_WIN32_HEAPSIZE]]
   2.746  ** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
   2.747 -** <dd>^This option is only available if SQLite is compiled for Windows
   2.748 -** with the [SQLITE_WIN32_MALLOC] pre-processor macro defined.
   2.749 -** SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
   2.750 +** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is
   2.751 +** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro
   2.752 +** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
   2.753  ** that specifies the maximum size of the created heap.
   2.754 +**
   2.755 +** [[SQLITE_CONFIG_PCACHE_HDRSZ]]
   2.756 +** <dt>SQLITE_CONFIG_PCACHE_HDRSZ
   2.757 +** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which
   2.758 +** is a pointer to an integer and writes into that integer the number of extra
   2.759 +** bytes per page required for each page in [SQLITE_CONFIG_PAGECACHE].
   2.760 +** The amount of extra space required can change depending on the compiler,
   2.761 +** target platform, and SQLite version.
   2.762 +**
   2.763 +** [[SQLITE_CONFIG_PMASZ]]
   2.764 +** <dt>SQLITE_CONFIG_PMASZ
   2.765 +** <dd>^The SQLITE_CONFIG_PMASZ option takes a single parameter which
   2.766 +** is an unsigned integer and sets the "Minimum PMA Size" for the multithreaded
   2.767 +** sorter to that integer.  The default minimum PMA Size is set by the
   2.768 +** [SQLITE_SORTER_PMASZ] compile-time option.  New threads are launched
   2.769 +** to help with sort operations when multithreaded sorting
   2.770 +** is enabled (using the [PRAGMA threads] command) and the amount of content
   2.771 +** to be sorted exceeds the page size times the minimum of the
   2.772 +** [PRAGMA cache_size] setting and this value.
   2.773  ** </dl>
   2.774  */
   2.775  #define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */
   2.776 @@ -1862,6 +2062,8 @@
   2.777  #define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */
   2.778  #define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */
   2.779  #define SQLITE_CONFIG_WIN32_HEAPSIZE      23  /* int nByte */
   2.780 +#define SQLITE_CONFIG_PCACHE_HDRSZ        24  /* int *psz */
   2.781 +#define SQLITE_CONFIG_PMASZ               25  /* unsigned int szPma */
   2.782  
   2.783  /*
   2.784  ** CAPI3REF: Database Connection Configuration Options
   2.785 @@ -1928,15 +2130,17 @@
   2.786  
   2.787  /*
   2.788  ** CAPI3REF: Enable Or Disable Extended Result Codes
   2.789 +** METHOD: sqlite3
   2.790  **
   2.791  ** ^The sqlite3_extended_result_codes() routine enables or disables the
   2.792  ** [extended result codes] feature of SQLite. ^The extended result
   2.793  ** codes are disabled by default for historical compatibility.
   2.794  */
   2.795 -SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
   2.796 +SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3*, int onoff);
   2.797  
   2.798  /*
   2.799  ** CAPI3REF: Last Insert Rowid
   2.800 +** METHOD: sqlite3
   2.801  **
   2.802  ** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
   2.803  ** has a unique 64-bit signed
   2.804 @@ -1984,52 +2188,51 @@
   2.805  ** unpredictable and might not equal either the old or the new
   2.806  ** last insert [rowid].
   2.807  */
   2.808 -SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
   2.809 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3*);
   2.810  
   2.811  /*
   2.812  ** CAPI3REF: Count The Number Of Rows Modified
   2.813 -**
   2.814 -** ^This function returns the number of database rows that were changed
   2.815 -** or inserted or deleted by the most recently completed SQL statement
   2.816 -** on the [database connection] specified by the first parameter.
   2.817 -** ^(Only changes that are directly specified by the [INSERT], [UPDATE],
   2.818 -** or [DELETE] statement are counted.  Auxiliary changes caused by
   2.819 -** triggers or [foreign key actions] are not counted.)^ Use the
   2.820 -** [sqlite3_total_changes()] function to find the total number of changes
   2.821 -** including changes caused by triggers and foreign key actions.
   2.822 -**
   2.823 -** ^Changes to a view that are simulated by an [INSTEAD OF trigger]
   2.824 -** are not counted.  Only real table changes are counted.
   2.825 -**
   2.826 -** ^(A "row change" is a change to a single row of a single table
   2.827 -** caused by an INSERT, DELETE, or UPDATE statement.  Rows that
   2.828 -** are changed as side effects of [REPLACE] constraint resolution,
   2.829 -** rollback, ABORT processing, [DROP TABLE], or by any other
   2.830 -** mechanisms do not count as direct row changes.)^
   2.831 -**
   2.832 -** A "trigger context" is a scope of execution that begins and
   2.833 -** ends with the script of a [CREATE TRIGGER | trigger]. 
   2.834 -** Most SQL statements are
   2.835 -** evaluated outside of any trigger.  This is the "top level"
   2.836 -** trigger context.  If a trigger fires from the top level, a
   2.837 -** new trigger context is entered for the duration of that one
   2.838 -** trigger.  Subtriggers create subcontexts for their duration.
   2.839 -**
   2.840 -** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
   2.841 -** not create a new trigger context.
   2.842 -**
   2.843 -** ^This function returns the number of direct row changes in the
   2.844 -** most recent INSERT, UPDATE, or DELETE statement within the same
   2.845 -** trigger context.
   2.846 -**
   2.847 -** ^Thus, when called from the top level, this function returns the
   2.848 -** number of changes in the most recent INSERT, UPDATE, or DELETE
   2.849 -** that also occurred at the top level.  ^(Within the body of a trigger,
   2.850 -** the sqlite3_changes() interface can be called to find the number of
   2.851 -** changes in the most recently completed INSERT, UPDATE, or DELETE
   2.852 -** statement within the body of the same trigger.
   2.853 -** However, the number returned does not include changes
   2.854 -** caused by subtriggers since those have their own context.)^
   2.855 +** METHOD: sqlite3
   2.856 +**
   2.857 +** ^This function returns the number of rows modified, inserted or
   2.858 +** deleted by the most recently completed INSERT, UPDATE or DELETE
   2.859 +** statement on the database connection specified by the only parameter.
   2.860 +** ^Executing any other type of SQL statement does not modify the value
   2.861 +** returned by this function.
   2.862 +**
   2.863 +** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are
   2.864 +** considered - auxiliary changes caused by [CREATE TRIGGER | triggers], 
   2.865 +** [foreign key actions] or [REPLACE] constraint resolution are not counted.
   2.866 +** 
   2.867 +** Changes to a view that are intercepted by 
   2.868 +** [INSTEAD OF trigger | INSTEAD OF triggers] are not counted. ^The value 
   2.869 +** returned by sqlite3_changes() immediately after an INSERT, UPDATE or 
   2.870 +** DELETE statement run on a view is always zero. Only changes made to real 
   2.871 +** tables are counted.
   2.872 +**
   2.873 +** Things are more complicated if the sqlite3_changes() function is
   2.874 +** executed while a trigger program is running. This may happen if the
   2.875 +** program uses the [changes() SQL function], or if some other callback
   2.876 +** function invokes sqlite3_changes() directly. Essentially:
   2.877 +** 
   2.878 +** <ul>
   2.879 +**   <li> ^(Before entering a trigger program the value returned by
   2.880 +**        sqlite3_changes() function is saved. After the trigger program 
   2.881 +**        has finished, the original value is restored.)^
   2.882 +** 
   2.883 +**   <li> ^(Within a trigger program each INSERT, UPDATE and DELETE 
   2.884 +**        statement sets the value returned by sqlite3_changes() 
   2.885 +**        upon completion as normal. Of course, this value will not include 
   2.886 +**        any changes performed by sub-triggers, as the sqlite3_changes() 
   2.887 +**        value will be saved and restored after each sub-trigger has run.)^
   2.888 +** </ul>
   2.889 +** 
   2.890 +** ^This means that if the changes() SQL function (or similar) is used
   2.891 +** by the first INSERT, UPDATE or DELETE statement within a trigger, it 
   2.892 +** returns the value as set when the calling statement began executing.
   2.893 +** ^If it is used by the second or subsequent such statement within a trigger 
   2.894 +** program, the value returned reflects the number of rows modified by the 
   2.895 +** previous INSERT, UPDATE or DELETE statement within the same trigger.
   2.896  **
   2.897  ** See also the [sqlite3_total_changes()] interface, the
   2.898  ** [count_changes pragma], and the [changes() SQL function].
   2.899 @@ -2038,25 +2241,23 @@
   2.900  ** while [sqlite3_changes()] is running then the value returned
   2.901  ** is unpredictable and not meaningful.
   2.902  */
   2.903 -SQLITE_API int sqlite3_changes(sqlite3*);
   2.904 +SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3*);
   2.905  
   2.906  /*
   2.907  ** CAPI3REF: Total Number Of Rows Modified
   2.908 -**
   2.909 -** ^This function returns the number of row changes caused by [INSERT],
   2.910 -** [UPDATE] or [DELETE] statements since the [database connection] was opened.
   2.911 -** ^(The count returned by sqlite3_total_changes() includes all changes
   2.912 -** from all [CREATE TRIGGER | trigger] contexts and changes made by
   2.913 -** [foreign key actions]. However,
   2.914 -** the count does not include changes used to implement [REPLACE] constraints,
   2.915 -** do rollbacks or ABORT processing, or [DROP TABLE] processing.  The
   2.916 -** count does not include rows of views that fire an [INSTEAD OF trigger],
   2.917 -** though if the INSTEAD OF trigger makes changes of its own, those changes 
   2.918 -** are counted.)^
   2.919 -** ^The sqlite3_total_changes() function counts the changes as soon as
   2.920 -** the statement that makes them is completed (when the statement handle
   2.921 -** is passed to [sqlite3_reset()] or [sqlite3_finalize()]).
   2.922 -**
   2.923 +** METHOD: sqlite3
   2.924 +**
   2.925 +** ^This function returns the total number of rows inserted, modified or
   2.926 +** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
   2.927 +** since the database connection was opened, including those executed as
   2.928 +** part of trigger programs. ^Executing any other type of SQL statement
   2.929 +** does not affect the value returned by sqlite3_total_changes().
   2.930 +** 
   2.931 +** ^Changes made as part of [foreign key actions] are included in the
   2.932 +** count, but those made as part of REPLACE constraint resolution are
   2.933 +** not. ^Changes to a view that are intercepted by INSTEAD OF triggers 
   2.934 +** are not counted.
   2.935 +** 
   2.936  ** See also the [sqlite3_changes()] interface, the
   2.937  ** [count_changes pragma], and the [total_changes() SQL function].
   2.938  **
   2.939 @@ -2064,10 +2265,11 @@
   2.940  ** while [sqlite3_total_changes()] is running then the value
   2.941  ** returned is unpredictable and not meaningful.
   2.942  */
   2.943 -SQLITE_API int sqlite3_total_changes(sqlite3*);
   2.944 +SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3*);
   2.945  
   2.946  /*
   2.947  ** CAPI3REF: Interrupt A Long-Running Query
   2.948 +** METHOD: sqlite3
   2.949  **
   2.950  ** ^This function causes any pending database operation to abort and
   2.951  ** return at its earliest opportunity. This routine is typically
   2.952 @@ -2103,7 +2305,7 @@
   2.953  ** If the database connection closes while [sqlite3_interrupt()]
   2.954  ** is running then bad things will likely happen.
   2.955  */
   2.956 -SQLITE_API void sqlite3_interrupt(sqlite3*);
   2.957 +SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3*);
   2.958  
   2.959  /*
   2.960  ** CAPI3REF: Determine If An SQL Statement Is Complete
   2.961 @@ -2138,11 +2340,13 @@
   2.962  ** The input to [sqlite3_complete16()] must be a zero-terminated
   2.963  ** UTF-16 string in native byte order.
   2.964  */
   2.965 -SQLITE_API int sqlite3_complete(const char *sql);
   2.966 -SQLITE_API int sqlite3_complete16(const void *sql);
   2.967 +SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *sql);
   2.968 +SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *sql);
   2.969  
   2.970  /*
   2.971  ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
   2.972 +** KEYWORDS: {busy-handler callback} {busy handler}
   2.973 +** METHOD: sqlite3
   2.974  **
   2.975  ** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X
   2.976  ** that might be invoked with argument P whenever
   2.977 @@ -2159,7 +2363,7 @@
   2.978  ** ^The first argument to the busy handler is a copy of the void* pointer which
   2.979  ** is the third argument to sqlite3_busy_handler().  ^The second argument to
   2.980  ** the busy handler callback is the number of times that the busy handler has
   2.981 -** been invoked for the same locking event.  ^If the
   2.982 +** been invoked previously for the same locking event.  ^If the
   2.983  ** busy callback returns 0, then no additional attempts are made to
   2.984  ** access the database and [SQLITE_BUSY] is returned
   2.985  ** to the application.
   2.986 @@ -2198,10 +2402,11 @@
   2.987  ** A busy handler must not close the database connection
   2.988  ** or [prepared statement] that invoked the busy handler.
   2.989  */
   2.990 -SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
   2.991 +SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
   2.992  
   2.993  /*
   2.994  ** CAPI3REF: Set A Busy Timeout
   2.995 +** METHOD: sqlite3
   2.996  **
   2.997  ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
   2.998  ** for a specified amount of time when a table is locked.  ^The handler
   2.999 @@ -2214,16 +2419,17 @@
  2.1000  ** turns off all busy handlers.
  2.1001  **
  2.1002  ** ^(There can only be a single busy handler for a particular
  2.1003 -** [database connection] any any given moment.  If another busy handler
  2.1004 +** [database connection] at any given moment.  If another busy handler
  2.1005  ** was defined  (using [sqlite3_busy_handler()]) prior to calling
  2.1006  ** this routine, that other busy handler is cleared.)^
  2.1007  **
  2.1008  ** See also:  [PRAGMA busy_timeout]
  2.1009  */
  2.1010 -SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
  2.1011 +SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3*, int ms);
  2.1012  
  2.1013  /*
  2.1014  ** CAPI3REF: Convenience Routines For Running Queries
  2.1015 +** METHOD: sqlite3
  2.1016  **
  2.1017  ** This is a legacy interface that is preserved for backwards compatibility.
  2.1018  ** Use of this interface is not recommended.
  2.1019 @@ -2294,7 +2500,7 @@
  2.1020  ** reflected in subsequent calls to [sqlite3_errcode()] or
  2.1021  ** [sqlite3_errmsg()].
  2.1022  */
  2.1023 -SQLITE_API int sqlite3_get_table(
  2.1024 +SQLITE_API int SQLITE_STDCALL sqlite3_get_table(
  2.1025    sqlite3 *db,          /* An open database */
  2.1026    const char *zSql,     /* SQL to be evaluated */
  2.1027    char ***pazResult,    /* Results of the query */
  2.1028 @@ -2302,13 +2508,17 @@
  2.1029    int *pnColumn,        /* Number of result columns written here */
  2.1030    char **pzErrmsg       /* Error msg written here */
  2.1031  );
  2.1032 -SQLITE_API void sqlite3_free_table(char **result);
  2.1033 +SQLITE_API void SQLITE_STDCALL sqlite3_free_table(char **result);
  2.1034  
  2.1035  /*
  2.1036  ** CAPI3REF: Formatted String Printing Functions
  2.1037  **
  2.1038  ** These routines are work-alikes of the "printf()" family of functions
  2.1039  ** from the standard C library.
  2.1040 +** These routines understand most of the common K&R formatting options,
  2.1041 +** plus some additional non-standard formats, detailed below.
  2.1042 +** Note that some of the more obscure formatting options from recent
  2.1043 +** C-library standards are omitted from this implementation.
  2.1044  **
  2.1045  ** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
  2.1046  ** results into memory obtained from [sqlite3_malloc()].
  2.1047 @@ -2341,7 +2551,7 @@
  2.1048  ** These routines all implement some additional formatting
  2.1049  ** options that are useful for constructing SQL statements.
  2.1050  ** All of the usual printf() formatting options apply.  In addition, there
  2.1051 -** is are "%q", "%Q", and "%z" options.
  2.1052 +** is are "%q", "%Q", "%w" and "%z" options.
  2.1053  **
  2.1054  ** ^(The %q option works like %s in that it substitutes a nul-terminated
  2.1055  ** string from the argument list.  But %q also doubles every '\'' character.
  2.1056 @@ -2394,14 +2604,20 @@
  2.1057  ** The code above will render a correct SQL statement in the zSQL
  2.1058  ** variable even if the zText variable is a NULL pointer.
  2.1059  **
  2.1060 +** ^(The "%w" formatting option is like "%q" except that it expects to
  2.1061 +** be contained within double-quotes instead of single quotes, and it
  2.1062 +** escapes the double-quote character instead of the single-quote
  2.1063 +** character.)^  The "%w" formatting option is intended for safely inserting
  2.1064 +** table and column names into a constructed SQL statement.
  2.1065 +**
  2.1066  ** ^(The "%z" formatting option works like "%s" but with the
  2.1067  ** addition that after the string has been read and copied into
  2.1068  ** the result, [sqlite3_free()] is called on the input string.)^
  2.1069  */
  2.1070 -SQLITE_API char *sqlite3_mprintf(const char*,...);
  2.1071 -SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
  2.1072 -SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
  2.1073 -SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
  2.1074 +SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char*,...);
  2.1075 +SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char*, va_list);
  2.1076 +SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int,char*,const char*, ...);
  2.1077 +SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int,char*,const char*, va_list);
  2.1078  
  2.1079  /*
  2.1080  ** CAPI3REF: Memory Allocation Subsystem
  2.1081 @@ -2418,6 +2634,10 @@
  2.1082  ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns
  2.1083  ** a NULL pointer.
  2.1084  **
  2.1085 +** ^The sqlite3_malloc64(N) routine works just like
  2.1086 +** sqlite3_malloc(N) except that N is an unsigned 64-bit integer instead
  2.1087 +** of a signed 32-bit integer.
  2.1088 +**
  2.1089  ** ^Calling sqlite3_free() with a pointer previously returned
  2.1090  ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so
  2.1091  ** that it might be reused.  ^The sqlite3_free() routine is
  2.1092 @@ -2429,24 +2649,38 @@
  2.1093  ** might result if sqlite3_free() is called with a non-NULL pointer that
  2.1094  ** was not obtained from sqlite3_malloc() or sqlite3_realloc().
  2.1095  **
  2.1096 -** ^(The sqlite3_realloc() interface attempts to resize a
  2.1097 -** prior memory allocation to be at least N bytes, where N is the
  2.1098 -** second parameter.  The memory allocation to be resized is the first
  2.1099 -** parameter.)^ ^ If the first parameter to sqlite3_realloc()
  2.1100 +** ^The sqlite3_realloc(X,N) interface attempts to resize a
  2.1101 +** prior memory allocation X to be at least N bytes.
  2.1102 +** ^If the X parameter to sqlite3_realloc(X,N)
  2.1103  ** is a NULL pointer then its behavior is identical to calling
  2.1104 -** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc().
  2.1105 -** ^If the second parameter to sqlite3_realloc() is zero or
  2.1106 +** sqlite3_malloc(N).
  2.1107 +** ^If the N parameter to sqlite3_realloc(X,N) is zero or
  2.1108  ** negative then the behavior is exactly the same as calling
  2.1109 -** sqlite3_free(P) where P is the first parameter to sqlite3_realloc().
  2.1110 -** ^sqlite3_realloc() returns a pointer to a memory allocation
  2.1111 -** of at least N bytes in size or NULL if sufficient memory is unavailable.
  2.1112 +** sqlite3_free(X).
  2.1113 +** ^sqlite3_realloc(X,N) returns a pointer to a memory allocation
  2.1114 +** of at least N bytes in size or NULL if insufficient memory is available.
  2.1115  ** ^If M is the size of the prior allocation, then min(N,M) bytes
  2.1116  ** of the prior allocation are copied into the beginning of buffer returned
  2.1117 -** by sqlite3_realloc() and the prior allocation is freed.
  2.1118 -** ^If sqlite3_realloc() returns NULL, then the prior allocation
  2.1119 -** is not freed.
  2.1120 -**
  2.1121 -** ^The memory returned by sqlite3_malloc() and sqlite3_realloc()
  2.1122 +** by sqlite3_realloc(X,N) and the prior allocation is freed.
  2.1123 +** ^If sqlite3_realloc(X,N) returns NULL and N is positive, then the
  2.1124 +** prior allocation is not freed.
  2.1125 +**
  2.1126 +** ^The sqlite3_realloc64(X,N) interfaces works the same as
  2.1127 +** sqlite3_realloc(X,N) except that N is a 64-bit unsigned integer instead
  2.1128 +** of a 32-bit signed integer.
  2.1129 +**
  2.1130 +** ^If X is a memory allocation previously obtained from sqlite3_malloc(),
  2.1131 +** sqlite3_malloc64(), sqlite3_realloc(), or sqlite3_realloc64(), then
  2.1132 +** sqlite3_msize(X) returns the size of that memory allocation in bytes.
  2.1133 +** ^The value returned by sqlite3_msize(X) might be larger than the number
  2.1134 +** of bytes requested when X was allocated.  ^If X is a NULL pointer then
  2.1135 +** sqlite3_msize(X) returns zero.  If X points to something that is not
  2.1136 +** the beginning of memory allocation, or if it points to a formerly
  2.1137 +** valid memory allocation that has now been freed, then the behavior
  2.1138 +** of sqlite3_msize(X) is undefined and possibly harmful.
  2.1139 +**
  2.1140 +** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(),
  2.1141 +** sqlite3_malloc64(), and sqlite3_realloc64()
  2.1142  ** is always aligned to at least an 8 byte boundary, or to a
  2.1143  ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time
  2.1144  ** option is used.
  2.1145 @@ -2473,9 +2707,12 @@
  2.1146  ** a block of memory after it has been released using
  2.1147  ** [sqlite3_free()] or [sqlite3_realloc()].
  2.1148  */
  2.1149 -SQLITE_API void *sqlite3_malloc(int);
  2.1150 -SQLITE_API void *sqlite3_realloc(void*, int);
  2.1151 -SQLITE_API void sqlite3_free(void*);
  2.1152 +SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int);
  2.1153 +SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64);
  2.1154 +SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void*, int);
  2.1155 +SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void*, sqlite3_uint64);
  2.1156 +SQLITE_API void SQLITE_STDCALL sqlite3_free(void*);
  2.1157 +SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void*);
  2.1158  
  2.1159  /*
  2.1160  ** CAPI3REF: Memory Allocator Statistics
  2.1161 @@ -2500,8 +2737,8 @@
  2.1162  ** by [sqlite3_memory_highwater(1)] is the high-water mark
  2.1163  ** prior to the reset.
  2.1164  */
  2.1165 -SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
  2.1166 -SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
  2.1167 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void);
  2.1168 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag);
  2.1169  
  2.1170  /*
  2.1171  ** CAPI3REF: Pseudo-Random Number Generator
  2.1172 @@ -2513,20 +2750,22 @@
  2.1173  ** applications to access the same PRNG for other purposes.
  2.1174  **
  2.1175  ** ^A call to this routine stores N bytes of randomness into buffer P.
  2.1176 -** ^If N is less than one, then P can be a NULL pointer.
  2.1177 +** ^The P parameter can be a NULL pointer.
  2.1178  **
  2.1179  ** ^If this routine has not been previously called or if the previous
  2.1180 -** call had N less than one, then the PRNG is seeded using randomness
  2.1181 -** obtained from the xRandomness method of the default [sqlite3_vfs] object.
  2.1182 -** ^If the previous call to this routine had an N of 1 or more then
  2.1183 -** the pseudo-randomness is generated
  2.1184 +** call had N less than one or a NULL pointer for P, then the PRNG is
  2.1185 +** seeded using randomness obtained from the xRandomness method of
  2.1186 +** the default [sqlite3_vfs] object.
  2.1187 +** ^If the previous call to this routine had an N of 1 or more and a
  2.1188 +** non-NULL P then the pseudo-randomness is generated
  2.1189  ** internally and without recourse to the [sqlite3_vfs] xRandomness
  2.1190  ** method.
  2.1191  */
  2.1192 -SQLITE_API void sqlite3_randomness(int N, void *P);
  2.1193 +SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *P);
  2.1194  
  2.1195  /*
  2.1196  ** CAPI3REF: Compile-Time Authorization Callbacks
  2.1197 +** METHOD: sqlite3
  2.1198  **
  2.1199  ** ^This routine registers an authorizer callback with a particular
  2.1200  ** [database connection], supplied in the first argument.
  2.1201 @@ -2605,7 +2844,7 @@
  2.1202  ** as stated in the previous paragraph, sqlite3_step() invokes
  2.1203  ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
  2.1204  */
  2.1205 -SQLITE_API int sqlite3_set_authorizer(
  2.1206 +SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
  2.1207    sqlite3*,
  2.1208    int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
  2.1209    void *pUserData
  2.1210 @@ -2683,6 +2922,7 @@
  2.1211  
  2.1212  /*
  2.1213  ** CAPI3REF: Tracing And Profiling Functions
  2.1214 +** METHOD: sqlite3
  2.1215  **
  2.1216  ** These routines register callback functions that can be used for
  2.1217  ** tracing and profiling the execution of SQL statements.
  2.1218 @@ -2709,12 +2949,13 @@
  2.1219  ** sqlite3_profile() function is considered experimental and is
  2.1220  ** subject to change in future versions of SQLite.
  2.1221  */
  2.1222 -SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
  2.1223 -SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
  2.1224 +SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
  2.1225 +SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
  2.1226     void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
  2.1227  
  2.1228  /*
  2.1229  ** CAPI3REF: Query Progress Callbacks
  2.1230 +** METHOD: sqlite3
  2.1231  **
  2.1232  ** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback
  2.1233  ** function X to be invoked periodically during long running calls to
  2.1234 @@ -2744,10 +2985,11 @@
  2.1235  ** database connections for the meaning of "modify" in this paragraph.
  2.1236  **
  2.1237  */
  2.1238 -SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
  2.1239 +SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
  2.1240  
  2.1241  /*
  2.1242  ** CAPI3REF: Opening A New Database Connection
  2.1243 +** CONSTRUCTOR: sqlite3
  2.1244  **
  2.1245  ** ^These routines open an SQLite database file as specified by the 
  2.1246  ** filename argument. ^The filename argument is interpreted as UTF-8 for
  2.1247 @@ -2762,9 +3004,9 @@
  2.1248  ** an English language description of the error following a failure of any
  2.1249  ** of the sqlite3_open() routines.
  2.1250  **
  2.1251 -** ^The default encoding for the database will be UTF-8 if
  2.1252 -** sqlite3_open() or sqlite3_open_v2() is called and
  2.1253 -** UTF-16 in the native byte order if sqlite3_open16() is used.
  2.1254 +** ^The default encoding will be UTF-8 for databases created using
  2.1255 +** sqlite3_open() or sqlite3_open_v2().  ^The default encoding for databases
  2.1256 +** created using sqlite3_open16() will be UTF-16 in the native byte order.
  2.1257  **
  2.1258  ** Whether or not an error occurs when it is opened, resources
  2.1259  ** associated with the [database connection] handle should be released by
  2.1260 @@ -2852,13 +3094,14 @@
  2.1261  ** then it is interpreted as an absolute path. ^If the path does not begin 
  2.1262  ** with a '/' (meaning that the authority section is omitted from the URI)
  2.1263  ** then the path is interpreted as a relative path. 
  2.1264 -** ^On windows, the first component of an absolute path 
  2.1265 -** is a drive specification (e.g. "C:").
  2.1266 +** ^(On windows, the first component of an absolute path 
  2.1267 +** is a drive specification (e.g. "C:").)^
  2.1268  **
  2.1269  ** [[core URI query parameters]]
  2.1270  ** The query component of a URI may contain parameters that are interpreted
  2.1271  ** either by SQLite itself, or by a [VFS | custom VFS implementation].
  2.1272 -** SQLite interprets the following three query parameters:
  2.1273 +** SQLite and its built-in [VFSes] interpret the
  2.1274 +** following query parameters:
  2.1275  **
  2.1276  ** <ul>
  2.1277  **   <li> <b>vfs</b>: ^The "vfs" parameter may be used to specify the name of
  2.1278 @@ -2893,11 +3136,9 @@
  2.1279  **     a URI filename, its value overrides any behavior requested by setting
  2.1280  **     SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag.
  2.1281  **
  2.1282 -**  <li> <b>psow</b>: ^The psow parameter may be "true" (or "on" or "yes" or
  2.1283 -**     "1") or "false" (or "off" or "no" or "0") to indicate that the
  2.1284 +**  <li> <b>psow</b>: ^The psow parameter indicates whether or not the
  2.1285  **     [powersafe overwrite] property does or does not apply to the
  2.1286 -**     storage media on which the database file resides.  ^The psow query
  2.1287 -**     parameter only works for the built-in unix and Windows VFSes.
  2.1288 +**     storage media on which the database file resides.
  2.1289  **
  2.1290  **  <li> <b>nolock</b>: ^The nolock parameter is a boolean query parameter
  2.1291  **     which if set disables file locking in rollback journal modes.  This
  2.1292 @@ -2973,15 +3214,15 @@
  2.1293  **
  2.1294  ** See also: [sqlite3_temp_directory]
  2.1295  */
  2.1296 -SQLITE_API int sqlite3_open(
  2.1297 +SQLITE_API int SQLITE_STDCALL sqlite3_open(
  2.1298    const char *filename,   /* Database filename (UTF-8) */
  2.1299    sqlite3 **ppDb          /* OUT: SQLite db handle */
  2.1300  );
  2.1301 -SQLITE_API int sqlite3_open16(
  2.1302 +SQLITE_API int SQLITE_STDCALL sqlite3_open16(
  2.1303    const void *filename,   /* Database filename (UTF-16) */
  2.1304    sqlite3 **ppDb          /* OUT: SQLite db handle */
  2.1305  );
  2.1306 -SQLITE_API int sqlite3_open_v2(
  2.1307 +SQLITE_API int SQLITE_STDCALL sqlite3_open_v2(
  2.1308    const char *filename,   /* Database filename (UTF-8) */
  2.1309    sqlite3 **ppDb,         /* OUT: SQLite db handle */
  2.1310    int flags,              /* Flags */
  2.1311 @@ -3027,19 +3268,22 @@
  2.1312  ** VFS method, then the behavior of this routine is undefined and probably
  2.1313  ** undesirable.
  2.1314  */
  2.1315 -SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
  2.1316 -SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
  2.1317 -SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
  2.1318 +SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam);
  2.1319 +SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
  2.1320 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
  2.1321  
  2.1322  
  2.1323  /*
  2.1324  ** CAPI3REF: Error Codes And Messages
  2.1325 -**
  2.1326 -** ^The sqlite3_errcode() interface returns the numeric [result code] or
  2.1327 -** [extended result code] for the most recent failed sqlite3_* API call
  2.1328 -** associated with a [database connection]. If a prior API call failed
  2.1329 -** but the most recent API call succeeded, the return value from
  2.1330 -** sqlite3_errcode() is undefined.  ^The sqlite3_extended_errcode()
  2.1331 +** METHOD: sqlite3
  2.1332 +**
  2.1333 +** ^If the most recent sqlite3_* API call associated with 
  2.1334 +** [database connection] D failed, then the sqlite3_errcode(D) interface
  2.1335 +** returns the numeric [result code] or [extended result code] for that
  2.1336 +** API call.
  2.1337 +** If the most recent API call was successful,
  2.1338 +** then the return value from sqlite3_errcode() is undefined.
  2.1339 +** ^The sqlite3_extended_errcode()
  2.1340  ** interface is the same except that it always returns the 
  2.1341  ** [extended result code] even when extended result codes are
  2.1342  ** disabled.
  2.1343 @@ -3070,40 +3314,41 @@
  2.1344  ** was invoked incorrectly by the application.  In that case, the
  2.1345  ** error code and message may or may not be set.
  2.1346  */
  2.1347 -SQLITE_API int sqlite3_errcode(sqlite3 *db);
  2.1348 -SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
  2.1349 -SQLITE_API const char *sqlite3_errmsg(sqlite3*);
  2.1350 -SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
  2.1351 -SQLITE_API const char *sqlite3_errstr(int);
  2.1352 -
  2.1353 -/*
  2.1354 -** CAPI3REF: SQL Statement Object
  2.1355 +SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db);
  2.1356 +SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db);
  2.1357 +SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3*);
  2.1358 +SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3*);
  2.1359 +SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int);
  2.1360 +
  2.1361 +/*
  2.1362 +** CAPI3REF: Prepared Statement Object
  2.1363  ** KEYWORDS: {prepared statement} {prepared statements}
  2.1364  **
  2.1365 -** An instance of this object represents a single SQL statement.
  2.1366 -** This object is variously known as a "prepared statement" or a
  2.1367 -** "compiled SQL statement" or simply as a "statement".
  2.1368 -**
  2.1369 -** The life of a statement object goes something like this:
  2.1370 +** An instance of this object represents a single SQL statement that
  2.1371 +** has been compiled into binary form and is ready to be evaluated.
  2.1372 +**
  2.1373 +** Think of each SQL statement as a separate computer program.  The
  2.1374 +** original SQL text is source code.  A prepared statement object 
  2.1375 +** is the compiled object code.  All SQL must be converted into a
  2.1376 +** prepared statement before it can be run.
  2.1377 +**
  2.1378 +** The life-cycle of a prepared statement object usually goes like this:
  2.1379  **
  2.1380  ** <ol>
  2.1381 -** <li> Create the object using [sqlite3_prepare_v2()] or a related
  2.1382 -**      function.
  2.1383 -** <li> Bind values to [host parameters] using the sqlite3_bind_*()
  2.1384 +** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
  2.1385 +** <li> Bind values to [parameters] using the sqlite3_bind_*()
  2.1386  **      interfaces.
  2.1387  ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
  2.1388 -** <li> Reset the statement using [sqlite3_reset()] then go back
  2.1389 +** <li> Reset the prepared statement using [sqlite3_reset()] then go back
  2.1390  **      to step 2.  Do this zero or more times.
  2.1391  ** <li> Destroy the object using [sqlite3_finalize()].
  2.1392  ** </ol>
  2.1393 -**
  2.1394 -** Refer to documentation on individual methods above for additional
  2.1395 -** information.
  2.1396  */
  2.1397  typedef struct sqlite3_stmt sqlite3_stmt;
  2.1398  
  2.1399  /*
  2.1400  ** CAPI3REF: Run-time Limits
  2.1401 +** METHOD: sqlite3
  2.1402  **
  2.1403  ** ^(This interface allows the size of various constructs to be limited
  2.1404  ** on a connection by connection basis.  The first parameter is the
  2.1405 @@ -3141,7 +3386,7 @@
  2.1406  **
  2.1407  ** New run-time limit categories may be added in future releases.
  2.1408  */
  2.1409 -SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
  2.1410 +SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3*, int id, int newVal);
  2.1411  
  2.1412  /*
  2.1413  ** CAPI3REF: Run-Time Limit Categories
  2.1414 @@ -3193,6 +3438,10 @@
  2.1415  **
  2.1416  ** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
  2.1417  ** <dd>The maximum depth of recursion for triggers.</dd>)^
  2.1418 +**
  2.1419 +** [[SQLITE_LIMIT_WORKER_THREADS]] ^(<dt>SQLITE_LIMIT_WORKER_THREADS</dt>
  2.1420 +** <dd>The maximum number of auxiliary worker threads that a single
  2.1421 +** [prepared statement] may start.</dd>)^
  2.1422  ** </dl>
  2.1423  */
  2.1424  #define SQLITE_LIMIT_LENGTH                    0
  2.1425 @@ -3206,10 +3455,13 @@
  2.1426  #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH       8
  2.1427  #define SQLITE_LIMIT_VARIABLE_NUMBER           9
  2.1428  #define SQLITE_LIMIT_TRIGGER_DEPTH            10
  2.1429 +#define SQLITE_LIMIT_WORKER_THREADS           11
  2.1430  
  2.1431  /*
  2.1432  ** CAPI3REF: Compiling An SQL Statement
  2.1433  ** KEYWORDS: {SQL statement compiler}
  2.1434 +** METHOD: sqlite3
  2.1435 +** CONSTRUCTOR: sqlite3_stmt
  2.1436  **
  2.1437  ** To execute an SQL query, it must first be compiled into a byte-code
  2.1438  ** program using one of these routines.
  2.1439 @@ -3223,16 +3475,14 @@
  2.1440  ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
  2.1441  ** use UTF-16.
  2.1442  **
  2.1443 -** ^If the nByte argument is less than zero, then zSql is read up to the
  2.1444 -** first zero terminator. ^If nByte is non-negative, then it is the maximum
  2.1445 -** number of  bytes read from zSql.  ^When nByte is non-negative, the
  2.1446 -** zSql string ends at either the first '\000' or '\u0000' character or
  2.1447 -** the nByte-th byte, whichever comes first. If the caller knows
  2.1448 -** that the supplied string is nul-terminated, then there is a small
  2.1449 -** performance advantage to be gained by passing an nByte parameter that
  2.1450 -** is equal to the number of bytes in the input string <i>including</i>
  2.1451 -** the nul-terminator bytes as this saves SQLite from having to
  2.1452 -** make a copy of the input string.
  2.1453 +** ^If the nByte argument is negative, then zSql is read up to the
  2.1454 +** first zero terminator. ^If nByte is positive, then it is the
  2.1455 +** number of bytes read from zSql.  ^If nByte is zero, then no prepared
  2.1456 +** statement is generated.
  2.1457 +** If the caller knows that the supplied string is nul-terminated, then
  2.1458 +** there is a small performance advantage to passing an nByte parameter that
  2.1459 +** is the number of bytes in the input string <i>including</i>
  2.1460 +** the nul-terminator.
  2.1461  **
  2.1462  ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
  2.1463  ** past the end of the first SQL statement in zSql.  These routines only
  2.1464 @@ -3288,28 +3538,28 @@
  2.1465  ** </li>
  2.1466  ** </ol>
  2.1467  */
  2.1468 -SQLITE_API int sqlite3_prepare(
  2.1469 +SQLITE_API int SQLITE_STDCALL sqlite3_prepare(
  2.1470    sqlite3 *db,            /* Database handle */
  2.1471    const char *zSql,       /* SQL statement, UTF-8 encoded */
  2.1472    int nByte,              /* Maximum length of zSql in bytes. */
  2.1473    sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  2.1474    const char **pzTail     /* OUT: Pointer to unused portion of zSql */
  2.1475  );
  2.1476 -SQLITE_API int sqlite3_prepare_v2(
  2.1477 +SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2(
  2.1478    sqlite3 *db,            /* Database handle */
  2.1479    const char *zSql,       /* SQL statement, UTF-8 encoded */
  2.1480    int nByte,              /* Maximum length of zSql in bytes. */
  2.1481    sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  2.1482    const char **pzTail     /* OUT: Pointer to unused portion of zSql */
  2.1483  );
  2.1484 -SQLITE_API int sqlite3_prepare16(
  2.1485 +SQLITE_API int SQLITE_STDCALL sqlite3_prepare16(
  2.1486    sqlite3 *db,            /* Database handle */
  2.1487    const void *zSql,       /* SQL statement, UTF-16 encoded */
  2.1488    int nByte,              /* Maximum length of zSql in bytes. */
  2.1489    sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  2.1490    const void **pzTail     /* OUT: Pointer to unused portion of zSql */
  2.1491  );
  2.1492 -SQLITE_API int sqlite3_prepare16_v2(
  2.1493 +SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
  2.1494    sqlite3 *db,            /* Database handle */
  2.1495    const void *zSql,       /* SQL statement, UTF-16 encoded */
  2.1496    int nByte,              /* Maximum length of zSql in bytes. */
  2.1497 @@ -3319,15 +3569,17 @@
  2.1498  
  2.1499  /*
  2.1500  ** CAPI3REF: Retrieving Statement SQL
  2.1501 +** METHOD: sqlite3_stmt
  2.1502  **
  2.1503  ** ^This interface can be used to retrieve a saved copy of the original
  2.1504  ** SQL text used to create a [prepared statement] if that statement was
  2.1505  ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
  2.1506  */
  2.1507 -SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
  2.1508 +SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
  2.1509  
  2.1510  /*
  2.1511  ** CAPI3REF: Determine If An SQL Statement Writes The Database
  2.1512 +** METHOD: sqlite3_stmt
  2.1513  **
  2.1514  ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
  2.1515  ** and only if the [prepared statement] X makes no direct changes to
  2.1516 @@ -3355,14 +3607,16 @@
  2.1517  ** change the configuration of a database connection, they do not make 
  2.1518  ** changes to the content of the database files on disk.
  2.1519  */
  2.1520 -SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
  2.1521 +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
  2.1522  
  2.1523  /*
  2.1524  ** CAPI3REF: Determine If A Prepared Statement Has Been Reset
  2.1525 +** METHOD: sqlite3_stmt
  2.1526  **
  2.1527  ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
  2.1528  ** [prepared statement] S has been stepped at least once using 
  2.1529 -** [sqlite3_step(S)] but has not run to completion and/or has not 
  2.1530 +** [sqlite3_step(S)] but has neither run to completion (returned
  2.1531 +** [SQLITE_DONE] from [sqlite3_step(S)]) nor
  2.1532  ** been reset using [sqlite3_reset(S)].  ^The sqlite3_stmt_busy(S)
  2.1533  ** interface returns false if S is a NULL pointer.  If S is not a 
  2.1534  ** NULL pointer and is not a pointer to a valid [prepared statement]
  2.1535 @@ -3374,7 +3628,7 @@
  2.1536  ** for example, in diagnostic routines to search for prepared 
  2.1537  ** statements that are holding a transaction open.
  2.1538  */
  2.1539 -SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
  2.1540 +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt*);
  2.1541  
  2.1542  /*
  2.1543  ** CAPI3REF: Dynamically Typed Value Object
  2.1544 @@ -3389,7 +3643,9 @@
  2.1545  ** Some interfaces require a protected sqlite3_value.  Other interfaces
  2.1546  ** will accept either a protected or an unprotected sqlite3_value.
  2.1547  ** Every interface that accepts sqlite3_value arguments specifies
  2.1548 -** whether or not it requires a protected sqlite3_value.
  2.1549 +** whether or not it requires a protected sqlite3_value.  The
  2.1550 +** [sqlite3_value_dup()] interface can be used to construct a new 
  2.1551 +** protected sqlite3_value from an unprotected sqlite3_value.
  2.1552  **
  2.1553  ** The terms "protected" and "unprotected" refer to whether or not
  2.1554  ** a mutex is held.  An internal mutex is held for a protected
  2.1555 @@ -3433,6 +3689,7 @@
  2.1556  ** CAPI3REF: Binding Values To Prepared Statements
  2.1557  ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
  2.1558  ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
  2.1559 +** METHOD: sqlite3_stmt
  2.1560  **
  2.1561  ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
  2.1562  ** literals may be replaced by a [parameter] that matches one of following
  2.1563 @@ -3479,18 +3736,18 @@
  2.1564  ** If the fourth parameter to sqlite3_bind_blob() is negative, then
  2.1565  ** the behavior is undefined.
  2.1566  ** If a non-negative fourth parameter is provided to sqlite3_bind_text()
  2.1567 -** or sqlite3_bind_text16() then that parameter must be the byte offset
  2.1568 +** or sqlite3_bind_text16() or sqlite3_bind_text64() then
  2.1569 +** that parameter must be the byte offset
  2.1570  ** where the NUL terminator would occur assuming the string were NUL
  2.1571  ** terminated.  If any NUL characters occur at byte offsets less than 
  2.1572  ** the value of the fourth parameter then the resulting string value will
  2.1573  ** contain embedded NULs.  The result of expressions involving strings
  2.1574  ** with embedded NULs is undefined.
  2.1575  **
  2.1576 -** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
  2.1577 -** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
  2.1578 +** ^The fifth argument to the BLOB and string binding interfaces
  2.1579 +** is a destructor used to dispose of the BLOB or
  2.1580  ** string after SQLite has finished with it.  ^The destructor is called
  2.1581 -** to dispose of the BLOB or string even if the call to sqlite3_bind_blob(),
  2.1582 -** sqlite3_bind_text(), or sqlite3_bind_text16() fails.  
  2.1583 +** to dispose of the BLOB or string even if the call to bind API fails.
  2.1584  ** ^If the fifth argument is
  2.1585  ** the special value [SQLITE_STATIC], then SQLite assumes that the
  2.1586  ** information is in static, unmanaged space and does not need to be freed.
  2.1587 @@ -3498,6 +3755,14 @@
  2.1588  ** SQLite makes its own private copy of the data immediately, before
  2.1589  ** the sqlite3_bind_*() routine returns.
  2.1590  **
  2.1591 +** ^The sixth argument to sqlite3_bind_text64() must be one of
  2.1592 +** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]
  2.1593 +** to specify the encoding of the text in the third parameter.  If
  2.1594 +** the sixth argument to sqlite3_bind_text64() is not one of the
  2.1595 +** allowed values shown above, or if the text encoding is different
  2.1596 +** from the encoding specified by the sixth parameter, then the behavior
  2.1597 +** is undefined.
  2.1598 +**
  2.1599  ** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
  2.1600  ** is filled with zeroes.  ^A zeroblob uses a fixed amount of memory
  2.1601  ** (just an integer to hold its size) while it is being processed.
  2.1602 @@ -3518,24 +3783,33 @@
  2.1603  **
  2.1604  ** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an
  2.1605  ** [error code] if anything goes wrong.
  2.1606 +** ^[SQLITE_TOOBIG] might be returned if the size of a string or BLOB
  2.1607 +** exceeds limits imposed by [sqlite3_limit]([SQLITE_LIMIT_LENGTH]) or
  2.1608 +** [SQLITE_MAX_LENGTH].
  2.1609  ** ^[SQLITE_RANGE] is returned if the parameter
  2.1610  ** index is out of range.  ^[SQLITE_NOMEM] is returned if malloc() fails.
  2.1611  **
  2.1612  ** See also: [sqlite3_bind_parameter_count()],
  2.1613  ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
  2.1614  */
  2.1615 -SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
  2.1616 -SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
  2.1617 -SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
  2.1618 -SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
  2.1619 -SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
  2.1620 -SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));
  2.1621 -SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
  2.1622 -SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
  2.1623 -SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
  2.1624 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
  2.1625 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
  2.1626 +                        void(*)(void*));
  2.1627 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt*, int, double);
  2.1628 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt*, int, int);
  2.1629 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
  2.1630 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt*, int);
  2.1631 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
  2.1632 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
  2.1633 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
  2.1634 +                         void(*)(void*), unsigned char encoding);
  2.1635 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
  2.1636 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
  2.1637 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
  2.1638  
  2.1639  /*
  2.1640  ** CAPI3REF: Number Of SQL Parameters
  2.1641 +** METHOD: sqlite3_stmt
  2.1642  **
  2.1643  ** ^This routine can be used to find the number of [SQL parameters]
  2.1644  ** in a [prepared statement].  SQL parameters are tokens of the
  2.1645 @@ -3552,10 +3826,11 @@
  2.1646  ** [sqlite3_bind_parameter_name()], and
  2.1647  ** [sqlite3_bind_parameter_index()].
  2.1648  */
  2.1649 -SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
  2.1650 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt*);
  2.1651  
  2.1652  /*
  2.1653  ** CAPI3REF: Name Of A Host Parameter
  2.1654 +** METHOD: sqlite3_stmt
  2.1655  **
  2.1656  ** ^The sqlite3_bind_parameter_name(P,N) interface returns
  2.1657  ** the name of the N-th [SQL parameter] in the [prepared statement] P.
  2.1658 @@ -3579,10 +3854,11 @@
  2.1659  ** [sqlite3_bind_parameter_count()], and
  2.1660  ** [sqlite3_bind_parameter_index()].
  2.1661  */
  2.1662 -SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
  2.1663 +SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt*, int);
  2.1664  
  2.1665  /*
  2.1666  ** CAPI3REF: Index Of A Parameter With A Given Name
  2.1667 +** METHOD: sqlite3_stmt
  2.1668  **
  2.1669  ** ^Return the index of an SQL parameter given its name.  ^The
  2.1670  ** index value returned is suitable for use as the second
  2.1671 @@ -3593,21 +3869,23 @@
  2.1672  **
  2.1673  ** See also: [sqlite3_bind_blob|sqlite3_bind()],
  2.1674  ** [sqlite3_bind_parameter_count()], and
  2.1675 -** [sqlite3_bind_parameter_index()].
  2.1676 -*/
  2.1677 -SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
  2.1678 +** [sqlite3_bind_parameter_name()].
  2.1679 +*/
  2.1680 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
  2.1681  
  2.1682  /*
  2.1683  ** CAPI3REF: Reset All Bindings On A Prepared Statement
  2.1684 +** METHOD: sqlite3_stmt
  2.1685  **
  2.1686  ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
  2.1687  ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
  2.1688  ** ^Use this routine to reset all host parameters to NULL.
  2.1689  */
  2.1690 -SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
  2.1691 +SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt*);
  2.1692  
  2.1693  /*
  2.1694  ** CAPI3REF: Number Of Columns In A Result Set
  2.1695 +** METHOD: sqlite3_stmt
  2.1696  **
  2.1697  ** ^Return the number of columns in the result set returned by the
  2.1698  ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
  2.1699 @@ -3615,10 +3893,11 @@
  2.1700  **
  2.1701  ** See also: [sqlite3_data_count()]
  2.1702  */
  2.1703 -SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
  2.1704 +SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt);
  2.1705  
  2.1706  /*
  2.1707  ** CAPI3REF: Column Names In A Result Set
  2.1708 +** METHOD: sqlite3_stmt
  2.1709  **
  2.1710  ** ^These routines return the name assigned to a particular column
  2.1711  ** in the result set of a [SELECT] statement.  ^The sqlite3_column_name()
  2.1712 @@ -3643,11 +3922,12 @@
  2.1713  ** then the name of the column is unspecified and may change from
  2.1714  ** one release of SQLite to the next.
  2.1715  */
  2.1716 -SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
  2.1717 -SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
  2.1718 +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt*, int N);
  2.1719 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt*, int N);
  2.1720  
  2.1721  /*
  2.1722  ** CAPI3REF: Source Of Data In A Query Result
  2.1723 +** METHOD: sqlite3_stmt
  2.1724  **
  2.1725  ** ^These routines provide a means to determine the database, table, and
  2.1726  ** table column that is the origin of a particular result column in
  2.1727 @@ -3691,15 +3971,16 @@
  2.1728  ** for the same [prepared statement] and result column
  2.1729  ** at the same time then the results are undefined.
  2.1730  */
  2.1731 -SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);
  2.1732 -SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
  2.1733 -SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);
  2.1734 -SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
  2.1735 -SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
  2.1736 -SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
  2.1737 +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt*,int);
  2.1738 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt*,int);
  2.1739 +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt*,int);
  2.1740 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt*,int);
  2.1741 +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt*,int);
  2.1742 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt*,int);
  2.1743  
  2.1744  /*
  2.1745  ** CAPI3REF: Declared Datatype Of A Query Result
  2.1746 +** METHOD: sqlite3_stmt
  2.1747  **
  2.1748  ** ^(The first parameter is a [prepared statement].
  2.1749  ** If this statement is a [SELECT] statement and the Nth column of the
  2.1750 @@ -3727,11 +4008,12 @@
  2.1751  ** is associated with individual values, not with the containers
  2.1752  ** used to hold those values.
  2.1753  */
  2.1754 -SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
  2.1755 -SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
  2.1756 +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt*,int);
  2.1757 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt*,int);
  2.1758  
  2.1759  /*
  2.1760  ** CAPI3REF: Evaluate An SQL Statement
  2.1761 +** METHOD: sqlite3_stmt
  2.1762  **
  2.1763  ** After a [prepared statement] has been prepared using either
  2.1764  ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
  2.1765 @@ -3807,10 +4089,11 @@
  2.1766  ** then the more specific [error codes] are returned directly
  2.1767  ** by sqlite3_step().  The use of the "v2" interface is recommended.
  2.1768  */
  2.1769 -SQLITE_API int sqlite3_step(sqlite3_stmt*);
  2.1770 +SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt*);
  2.1771  
  2.1772  /*
  2.1773  ** CAPI3REF: Number of columns in a result set
  2.1774 +** METHOD: sqlite3_stmt
  2.1775  **
  2.1776  ** ^The sqlite3_data_count(P) interface returns the number of columns in the
  2.1777  ** current row of the result set of [prepared statement] P.
  2.1778 @@ -3827,7 +4110,7 @@
  2.1779  **
  2.1780  ** See also: [sqlite3_column_count()]
  2.1781  */
  2.1782 -SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
  2.1783 +SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt);
  2.1784  
  2.1785  /*
  2.1786  ** CAPI3REF: Fundamental Datatypes
  2.1787 @@ -3864,8 +4147,7 @@
  2.1788  /*
  2.1789  ** CAPI3REF: Result Values From A Query
  2.1790  ** KEYWORDS: {column access functions}
  2.1791 -**
  2.1792 -** These routines form the "result set" interface.
  2.1793 +** METHOD: sqlite3_stmt
  2.1794  **
  2.1795  ** ^These routines return information about a single column of the current
  2.1796  ** result row of a query.  ^In every case the first argument is a pointer
  2.1797 @@ -3926,13 +4208,14 @@
  2.1798  ** even empty strings, are always zero-terminated.  ^The return
  2.1799  ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
  2.1800  **
  2.1801 -** ^The object returned by [sqlite3_column_value()] is an
  2.1802 -** [unprotected sqlite3_value] object.  An unprotected sqlite3_value object
  2.1803 -** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
  2.1804 +** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
  2.1805 +** [unprotected sqlite3_value] object.  In a multithreaded environment,
  2.1806 +** an unprotected sqlite3_value object may only be used safely with
  2.1807 +** [sqlite3_bind_value()] and [sqlite3_result_value()].
  2.1808  ** If the [unprotected sqlite3_value] object returned by
  2.1809  ** [sqlite3_column_value()] is used in any other way, including calls
  2.1810  ** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
  2.1811 -** or [sqlite3_value_bytes()], then the behavior is undefined.
  2.1812 +** or [sqlite3_value_bytes()], the behavior is not threadsafe.
  2.1813  **
  2.1814  ** These routines attempt to convert the value where appropriate.  ^For
  2.1815  ** example, if the internal representation is FLOAT and a text result
  2.1816 @@ -3963,12 +4246,6 @@
  2.1817  ** </table>
  2.1818  ** </blockquote>)^
  2.1819  **
  2.1820 -** The table above makes reference to standard C library functions atoi()
  2.1821 -** and atof().  SQLite does not really use these functions.  It has its
  2.1822 -** own equivalent internal routines.  The atoi() and atof() names are
  2.1823 -** used in the table for brevity and because they are familiar to most
  2.1824 -** C programmers.
  2.1825 -**
  2.1826  ** Note that when type conversions occur, pointers returned by prior
  2.1827  ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
  2.1828  ** sqlite3_column_text16() may be invalidated.
  2.1829 @@ -3993,7 +4270,7 @@
  2.1830  ** of conversion are done in place when it is possible, but sometimes they
  2.1831  ** are not possible and in those cases prior pointers are invalidated.
  2.1832  **
  2.1833 -** The safest and easiest to remember policy is to invoke these routines
  2.1834 +** The safest policy is to invoke these routines
  2.1835  ** in one of the following ways:
  2.1836  **
  2.1837  ** <ul>
  2.1838 @@ -4013,7 +4290,7 @@
  2.1839  ** ^The pointers returned are valid until a type conversion occurs as
  2.1840  ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
  2.1841  ** [sqlite3_finalize()] is called.  ^The memory space used to hold strings
  2.1842 -** and BLOBs is freed automatically.  Do <b>not</b> pass the pointers returned
  2.1843 +** and BLOBs is freed automatically.  Do <em>not</em> pass the pointers returned
  2.1844  ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
  2.1845  ** [sqlite3_free()].
  2.1846  **
  2.1847 @@ -4023,19 +4300,20 @@
  2.1848  ** pointer.  Subsequent calls to [sqlite3_errcode()] will return
  2.1849  ** [SQLITE_NOMEM].)^
  2.1850  */
  2.1851 -SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
  2.1852 -SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
  2.1853 -SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
  2.1854 -SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
  2.1855 -SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
  2.1856 -SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
  2.1857 -SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
  2.1858 -SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
  2.1859 -SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
  2.1860 -SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
  2.1861 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt*, int iCol);
  2.1862 +SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt*, int iCol);
  2.1863 +SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
  2.1864 +SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt*, int iCol);
  2.1865 +SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt*, int iCol);
  2.1866 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt*, int iCol);
  2.1867 +SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt*, int iCol);
  2.1868 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt*, int iCol);
  2.1869 +SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt*, int iCol);
  2.1870 +SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt*, int iCol);
  2.1871  
  2.1872  /*
  2.1873  ** CAPI3REF: Destroy A Prepared Statement Object
  2.1874 +** DESTRUCTOR: sqlite3_stmt
  2.1875  **
  2.1876  ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
  2.1877  ** ^If the most recent evaluation of the statement encountered no errors
  2.1878 @@ -4059,10 +4337,11 @@
  2.1879  ** statement after it has been finalized can result in undefined and
  2.1880  ** undesirable behavior such as segfaults and heap corruption.
  2.1881  */
  2.1882 -SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
  2.1883 +SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt);
  2.1884  
  2.1885  /*
  2.1886  ** CAPI3REF: Reset A Prepared Statement Object
  2.1887 +** METHOD: sqlite3_stmt
  2.1888  **
  2.1889  ** The sqlite3_reset() function is called to reset a [prepared statement]
  2.1890  ** object back to its initial state, ready to be re-executed.
  2.1891 @@ -4085,13 +4364,14 @@
  2.1892  ** ^The [sqlite3_reset(S)] interface does not change the values
  2.1893  ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
  2.1894  */
  2.1895 -SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
  2.1896 +SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt);
  2.1897  
  2.1898  /*
  2.1899  ** CAPI3REF: Create Or Redefine SQL Functions
  2.1900  ** KEYWORDS: {function creation routines}
  2.1901  ** KEYWORDS: {application-defined SQL function}
  2.1902  ** KEYWORDS: {application-defined SQL functions}
  2.1903 +** METHOD: sqlite3
  2.1904  **
  2.1905  ** ^These functions (collectively known as "function creation routines")
  2.1906  ** are used to add SQL functions or aggregates or to redefine the behavior
  2.1907 @@ -4184,7 +4464,7 @@
  2.1908  ** close the database connection nor finalize or reset the prepared
  2.1909  ** statement in which the function is running.
  2.1910  */
  2.1911 -SQLITE_API int sqlite3_create_function(
  2.1912 +SQLITE_API int SQLITE_STDCALL sqlite3_create_function(
  2.1913    sqlite3 *db,
  2.1914    const char *zFunctionName,
  2.1915    int nArg,
  2.1916 @@ -4194,7 +4474,7 @@
  2.1917    void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  2.1918    void (*xFinal)(sqlite3_context*)
  2.1919  );
  2.1920 -SQLITE_API int sqlite3_create_function16(
  2.1921 +SQLITE_API int SQLITE_STDCALL sqlite3_create_function16(
  2.1922    sqlite3 *db,
  2.1923    const void *zFunctionName,
  2.1924    int nArg,
  2.1925 @@ -4204,7 +4484,7 @@
  2.1926    void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  2.1927    void (*xFinal)(sqlite3_context*)
  2.1928  );
  2.1929 -SQLITE_API int sqlite3_create_function_v2(
  2.1930 +SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2(
  2.1931    sqlite3 *db,
  2.1932    const char *zFunctionName,
  2.1933    int nArg,
  2.1934 @@ -4222,9 +4502,9 @@
  2.1935  ** These constant define integer codes that represent the various
  2.1936  ** text encodings supported by SQLite.
  2.1937  */
  2.1938 -#define SQLITE_UTF8           1
  2.1939 -#define SQLITE_UTF16LE        2
  2.1940 -#define SQLITE_UTF16BE        3
  2.1941 +#define SQLITE_UTF8           1    /* IMP: R-37514-35566 */
  2.1942 +#define SQLITE_UTF16LE        2    /* IMP: R-03371-37637 */
  2.1943 +#define SQLITE_UTF16BE        3    /* IMP: R-51971-34154 */
  2.1944  #define SQLITE_UTF16          4    /* Use native byte order */
  2.1945  #define SQLITE_ANY            5    /* Deprecated */
  2.1946  #define SQLITE_UTF16_ALIGNED  8    /* sqlite3_create_collation only */
  2.1947 @@ -4246,25 +4526,26 @@
  2.1948  ** These functions are [deprecated].  In order to maintain
  2.1949  ** backwards compatibility with older code, these functions continue 
  2.1950  ** to be supported.  However, new applications should avoid
  2.1951 -** the use of these functions.  To help encourage people to avoid
  2.1952 -** using these functions, we are not going to tell you what they do.
  2.1953 +** the use of these functions.  To encourage programmers to avoid
  2.1954 +** these functions, we will not explain what they do.
  2.1955  */
  2.1956  #ifndef SQLITE_OMIT_DEPRECATED
  2.1957 -SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
  2.1958 -SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
  2.1959 -SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
  2.1960 -SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
  2.1961 -SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
  2.1962 -SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
  2.1963 +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context*);
  2.1964 +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt*);
  2.1965 +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
  2.1966 +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_global_recover(void);
  2.1967 +SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_thread_cleanup(void);
  2.1968 +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
  2.1969                        void*,sqlite3_int64);
  2.1970  #endif
  2.1971  
  2.1972  /*
  2.1973 -** CAPI3REF: Obtaining SQL Function Parameter Values
  2.1974 +** CAPI3REF: Obtaining SQL Values
  2.1975 +** METHOD: sqlite3_value
  2.1976  **
  2.1977  ** The C-language implementation of SQL functions and aggregates uses
  2.1978  ** this set of interface routines to access the parameter values on
  2.1979 -** the function or aggregate.
  2.1980 +** the function or aggregate.  
  2.1981  **
  2.1982  ** The xFunc (for scalar functions) or xStep (for aggregates) parameters
  2.1983  ** to [sqlite3_create_function()] and [sqlite3_create_function16()]
  2.1984 @@ -4279,7 +4560,7 @@
  2.1985  ** object results in undefined behavior.
  2.1986  **
  2.1987  ** ^These routines work just like the corresponding [column access functions]
  2.1988 -** except that  these routines take a single [protected sqlite3_value] object
  2.1989 +** except that these routines take a single [protected sqlite3_value] object
  2.1990  ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
  2.1991  **
  2.1992  ** ^The sqlite3_value_text16() interface extracts a UTF-16 string
  2.1993 @@ -4304,21 +4585,55 @@
  2.1994  ** These routines must be called from the same thread as
  2.1995  ** the SQL function that supplied the [sqlite3_value*] parameters.
  2.1996  */
  2.1997 -SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
  2.1998 -SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
  2.1999 -SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
  2.2000 -SQLITE_API double sqlite3_value_double(sqlite3_value*);
  2.2001 -SQLITE_API int sqlite3_value_int(sqlite3_value*);
  2.2002 -SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
  2.2003 -SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
  2.2004 -SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
  2.2005 -SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
  2.2006 -SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
  2.2007 -SQLITE_API int sqlite3_value_type(sqlite3_value*);
  2.2008 -SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
  2.2009 +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value*);
  2.2010 +SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value*);
  2.2011 +SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value*);
  2.2012 +SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value*);
  2.2013 +SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value*);
  2.2014 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value*);
  2.2015 +SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value*);
  2.2016 +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value*);
  2.2017 +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value*);
  2.2018 +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value*);
  2.2019 +SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value*);
  2.2020 +SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value*);
  2.2021 +
  2.2022 +/*
  2.2023 +** CAPI3REF: Finding The Subtype Of SQL Values
  2.2024 +** METHOD: sqlite3_value
  2.2025 +**
  2.2026 +** The sqlite3_value_subtype(V) function returns the subtype for
  2.2027 +** an [application-defined SQL function] argument V.  The subtype
  2.2028 +** information can be used to pass a limited amount of context from
  2.2029 +** one SQL function to another.  Use the [sqlite3_result_subtype()]
  2.2030 +** routine to set the subtype for the return value of an SQL function.
  2.2031 +**
  2.2032 +** SQLite makes no use of subtype itself.  It merely passes the subtype
  2.2033 +** from the result of one [application-defined SQL function] into the
  2.2034 +** input of another.
  2.2035 +*/
  2.2036 +SQLITE_API unsigned int SQLITE_STDCALL sqlite3_value_subtype(sqlite3_value*);
  2.2037 +
  2.2038 +/*
  2.2039 +** CAPI3REF: Copy And Free SQL Values
  2.2040 +** METHOD: sqlite3_value
  2.2041 +**
  2.2042 +** ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value]
  2.2043 +** object D and returns a pointer to that copy.  ^The [sqlite3_value] returned
  2.2044 +** is a [protected sqlite3_value] object even if the input is not.
  2.2045 +** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a
  2.2046 +** memory allocation fails.
  2.2047 +**
  2.2048 +** ^The sqlite3_value_free(V) interface frees an [sqlite3_value] object
  2.2049 +** previously obtained from [sqlite3_value_dup()].  ^If V is a NULL pointer
  2.2050 +** then sqlite3_value_free(V) is a harmless no-op.
  2.2051 +*/
  2.2052 +SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_value_dup(const sqlite3_value*);
  2.2053 +SQLITE_API void SQLITE_STDCALL sqlite3_value_free(sqlite3_value*);
  2.2054  
  2.2055  /*
  2.2056  ** CAPI3REF: Obtain Aggregate Function Context
  2.2057 +** METHOD: sqlite3_context
  2.2058  **
  2.2059  ** Implementations of aggregate SQL functions use this
  2.2060  ** routine to allocate memory for storing their state.
  2.2061 @@ -4359,10 +4674,11 @@
  2.2062  ** This routine must be called from the same thread in which
  2.2063  ** the aggregate SQL function is running.
  2.2064  */
  2.2065 -SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
  2.2066 +SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context*, int nBytes);
  2.2067  
  2.2068  /*
  2.2069  ** CAPI3REF: User Data For Functions
  2.2070 +** METHOD: sqlite3_context
  2.2071  **
  2.2072  ** ^The sqlite3_user_data() interface returns a copy of
  2.2073  ** the pointer that was the pUserData parameter (the 5th parameter)
  2.2074 @@ -4373,10 +4689,11 @@
  2.2075  ** This routine must be called from the same thread in which
  2.2076  ** the application-defined function is running.
  2.2077  */
  2.2078 -SQLITE_API void *sqlite3_user_data(sqlite3_context*);
  2.2079 +SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context*);
  2.2080  
  2.2081  /*
  2.2082  ** CAPI3REF: Database Connection For Functions
  2.2083 +** METHOD: sqlite3_context
  2.2084  **
  2.2085  ** ^The sqlite3_context_db_handle() interface returns a copy of
  2.2086  ** the pointer to the [database connection] (the 1st parameter)
  2.2087 @@ -4384,10 +4701,11 @@
  2.2088  ** and [sqlite3_create_function16()] routines that originally
  2.2089  ** registered the application defined function.
  2.2090  */
  2.2091 -SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
  2.2092 +SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context*);
  2.2093  
  2.2094  /*
  2.2095  ** CAPI3REF: Function Auxiliary Data
  2.2096 +** METHOD: sqlite3_context
  2.2097  **
  2.2098  ** These functions may be used by (non-aggregate) SQL functions to
  2.2099  ** associate metadata with argument values. If the same value is passed to
  2.2100 @@ -4436,8 +4754,8 @@
  2.2101  ** These routines must be called from the same thread in which
  2.2102  ** the SQL function is running.
  2.2103  */
  2.2104 -SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
  2.2105 -SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
  2.2106 +SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context*, int N);
  2.2107 +SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
  2.2108  
  2.2109  
  2.2110  /*
  2.2111 @@ -4460,6 +4778,7 @@
  2.2112  
  2.2113  /*
  2.2114  ** CAPI3REF: Setting The Result Of An SQL Function
  2.2115 +** METHOD: sqlite3_context
  2.2116  **
  2.2117  ** These routines are used by the xFunc or xFinal callbacks that
  2.2118  ** implement SQL functions and aggregates.  See
  2.2119 @@ -4475,9 +4794,9 @@
  2.2120  ** to by the second parameter and which is N bytes long where N is the
  2.2121  ** third parameter.
  2.2122  **
  2.2123 -** ^The sqlite3_result_zeroblob() interfaces set the result of
  2.2124 -** the application-defined function to be a BLOB containing all zero
  2.2125 -** bytes and N bytes in size, where N is the value of the 2nd parameter.
  2.2126 +** ^The sqlite3_result_zeroblob(C,N) and sqlite3_result_zeroblob64(C,N)
  2.2127 +** interfaces set the result of the application-defined function to be
  2.2128 +** a BLOB containing all zero bytes and N bytes in size.
  2.2129  **
  2.2130  ** ^The sqlite3_result_double() interface sets the result from
  2.2131  ** an application-defined function to be a floating point value specified
  2.2132 @@ -4526,6 +4845,10 @@
  2.2133  ** set the return value of the application-defined function to be
  2.2134  ** a text string which is represented as UTF-8, UTF-16 native byte order,
  2.2135  ** UTF-16 little endian, or UTF-16 big endian, respectively.
  2.2136 +** ^The sqlite3_result_text64() interface sets the return value of an
  2.2137 +** application-defined function to be a text string in an encoding
  2.2138 +** specified by the fifth (and last) parameter, which must be one
  2.2139 +** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].
  2.2140  ** ^SQLite takes the text result from the application from
  2.2141  ** the 2nd parameter of the sqlite3_result_text* interfaces.
  2.2142  ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
  2.2143 @@ -4555,7 +4878,7 @@
  2.2144  ** from [sqlite3_malloc()] before it returns.
  2.2145  **
  2.2146  ** ^The sqlite3_result_value() interface sets the result of
  2.2147 -** the application-defined function to be a copy the
  2.2148 +** the application-defined function to be a copy of the
  2.2149  ** [unprotected sqlite3_value] object specified by the 2nd parameter.  ^The
  2.2150  ** sqlite3_result_value() interface makes a copy of the [sqlite3_value]
  2.2151  ** so that the [sqlite3_value] specified in the parameter may change or
  2.2152 @@ -4568,25 +4891,46 @@
  2.2153  ** than the one containing the application-defined function that received
  2.2154  ** the [sqlite3_context] pointer, the results are undefined.
  2.2155  */
  2.2156 -SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
  2.2157 -SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
  2.2158 -SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
  2.2159 -SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
  2.2160 -SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);
  2.2161 -SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);
  2.2162 -SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);
  2.2163 -SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
  2.2164 -SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
  2.2165 -SQLITE_API void sqlite3_result_null(sqlite3_context*);
  2.2166 -SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
  2.2167 -SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
  2.2168 -SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
  2.2169 -SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
  2.2170 -SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
  2.2171 -SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
  2.2172 +SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
  2.2173 +SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(sqlite3_context*,const void*,
  2.2174 +                           sqlite3_uint64,void(*)(void*));
  2.2175 +SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context*, double);
  2.2176 +SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context*, const char*, int);
  2.2177 +SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context*, const void*, int);
  2.2178 +SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context*);
  2.2179 +SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context*);
  2.2180 +SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context*, int);
  2.2181 +SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context*, int);
  2.2182 +SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
  2.2183 +SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context*);
  2.2184 +SQLITE_API void SQLITE_STDCALL sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
  2.2185 +SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
  2.2186 +                           void(*)(void*), unsigned char encoding);
  2.2187 +SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
  2.2188 +SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
  2.2189 +SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
  2.2190 +SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context*, sqlite3_value*);
  2.2191 +SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context*, int n);
  2.2192 +SQLITE_API int SQLITE_STDCALL sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
  2.2193 +
  2.2194 +
  2.2195 +/*
  2.2196 +** CAPI3REF: Setting The Subtype Of An SQL Function
  2.2197 +** METHOD: sqlite3_context
  2.2198 +**
  2.2199 +** The sqlite3_result_subtype(C,T) function causes the subtype of
  2.2200 +** the result from the [application-defined SQL function] with 
  2.2201 +** [sqlite3_context] C to be the value T.  Only the lower 8 bits 
  2.2202 +** of the subtype T are preserved in current versions of SQLite;
  2.2203 +** higher order bits are discarded.
  2.2204 +** The number of subtype bytes preserved by SQLite might increase
  2.2205 +** in future releases of SQLite.
  2.2206 +*/
  2.2207 +SQLITE_API void SQLITE_STDCALL sqlite3_result_subtype(sqlite3_context*,unsigned int);
  2.2208  
  2.2209  /*
  2.2210  ** CAPI3REF: Define New Collating Sequences
  2.2211 +** METHOD: sqlite3
  2.2212  **
  2.2213  ** ^These functions add, remove, or modify a [collation] associated
  2.2214  ** with the [database connection] specified as the first argument.
  2.2215 @@ -4664,14 +5008,14 @@
  2.2216  **
  2.2217  ** See also:  [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
  2.2218  */
  2.2219 -SQLITE_API int sqlite3_create_collation(
  2.2220 +SQLITE_API int SQLITE_STDCALL sqlite3_create_collation(
  2.2221    sqlite3*, 
  2.2222    const char *zName, 
  2.2223    int eTextRep, 
  2.2224    void *pArg,
  2.2225    int(*xCompare)(void*,int,const void*,int,const void*)
  2.2226  );
  2.2227 -SQLITE_API int sqlite3_create_collation_v2(
  2.2228 +SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2(
  2.2229    sqlite3*, 
  2.2230    const char *zName, 
  2.2231    int eTextRep, 
  2.2232 @@ -4679,7 +5023,7 @@
  2.2233    int(*xCompare)(void*,int,const void*,int,const void*),
  2.2234    void(*xDestroy)(void*)
  2.2235  );
  2.2236 -SQLITE_API int sqlite3_create_collation16(
  2.2237 +SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16(
  2.2238    sqlite3*, 
  2.2239    const void *zName,
  2.2240    int eTextRep, 
  2.2241 @@ -4689,6 +5033,7 @@
  2.2242  
  2.2243  /*
  2.2244  ** CAPI3REF: Collation Needed Callbacks
  2.2245 +** METHOD: sqlite3
  2.2246  **
  2.2247  ** ^To avoid having to register all collation sequences before a database
  2.2248  ** can be used, a single callback function may be registered with the
  2.2249 @@ -4713,12 +5058,12 @@
  2.2250  ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
  2.2251  ** [sqlite3_create_collation_v2()].
  2.2252  */
  2.2253 -SQLITE_API int sqlite3_collation_needed(
  2.2254 +SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed(
  2.2255    sqlite3*, 
  2.2256    void*, 
  2.2257    void(*)(void*,sqlite3*,int eTextRep,const char*)
  2.2258  );
  2.2259 -SQLITE_API int sqlite3_collation_needed16(
  2.2260 +SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16(
  2.2261    sqlite3*, 
  2.2262    void*,
  2.2263    void(*)(void*,sqlite3*,int eTextRep,const void*)
  2.2264 @@ -4732,11 +5077,11 @@
  2.2265  ** The code to implement this API is not available in the public release
  2.2266  ** of SQLite.
  2.2267  */
  2.2268 -SQLITE_API int sqlite3_key(
  2.2269 +SQLITE_API int SQLITE_STDCALL sqlite3_key(
  2.2270    sqlite3 *db,                   /* Database to be rekeyed */
  2.2271    const void *pKey, int nKey     /* The key */
  2.2272  );
  2.2273 -SQLITE_API int sqlite3_key_v2(
  2.2274 +SQLITE_API int SQLITE_STDCALL sqlite3_key_v2(
  2.2275    sqlite3 *db,                   /* Database to be rekeyed */
  2.2276    const char *zDbName,           /* Name of the database */
  2.2277    const void *pKey, int nKey     /* The key */
  2.2278 @@ -4750,11 +5095,11 @@
  2.2279  ** The code to implement this API is not available in the public release
  2.2280  ** of SQLite.
  2.2281  */
  2.2282 -SQLITE_API int sqlite3_rekey(
  2.2283 +SQLITE_API int SQLITE_STDCALL sqlite3_rekey(
  2.2284    sqlite3 *db,                   /* Database to be rekeyed */
  2.2285    const void *pKey, int nKey     /* The new key */
  2.2286  );
  2.2287 -SQLITE_API int sqlite3_rekey_v2(
  2.2288 +SQLITE_API int SQLITE_STDCALL sqlite3_rekey_v2(
  2.2289    sqlite3 *db,                   /* Database to be rekeyed */
  2.2290    const char *zDbName,           /* Name of the database */
  2.2291    const void *pKey, int nKey     /* The new key */
  2.2292 @@ -4764,7 +5109,7 @@
  2.2293  ** Specify the activation key for a SEE database.  Unless 
  2.2294  ** activated, none of the SEE routines will work.
  2.2295  */
  2.2296 -SQLITE_API void sqlite3_activate_see(
  2.2297 +SQLITE_API void SQLITE_STDCALL sqlite3_activate_see(
  2.2298    const char *zPassPhrase        /* Activation phrase */
  2.2299  );
  2.2300  #endif
  2.2301 @@ -4774,7 +5119,7 @@
  2.2302  ** Specify the activation key for a CEROD database.  Unless 
  2.2303  ** activated, none of the CEROD routines will work.
  2.2304  */
  2.2305 -SQLITE_API void sqlite3_activate_cerod(
  2.2306 +SQLITE_API void SQLITE_STDCALL sqlite3_activate_cerod(
  2.2307    const char *zPassPhrase        /* Activation phrase */
  2.2308  );
  2.2309  #endif
  2.2310 @@ -4796,7 +5141,7 @@
  2.2311  ** all, then the behavior of sqlite3_sleep() may deviate from the description
  2.2312  ** in the previous paragraphs.
  2.2313  */
  2.2314 -SQLITE_API int sqlite3_sleep(int);
  2.2315 +SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int);
  2.2316  
  2.2317  /*
  2.2318  ** CAPI3REF: Name Of The Folder Holding Temporary Files
  2.2319 @@ -4896,6 +5241,7 @@
  2.2320  /*
  2.2321  ** CAPI3REF: Test For Auto-Commit Mode
  2.2322  ** KEYWORDS: {autocommit mode}
  2.2323 +** METHOD: sqlite3
  2.2324  **
  2.2325  ** ^The sqlite3_get_autocommit() interface returns non-zero or
  2.2326  ** zero if the given database connection is or is not in autocommit mode,
  2.2327 @@ -4914,10 +5260,11 @@
  2.2328  ** connection while this routine is running, then the return value
  2.2329  ** is undefined.
  2.2330  */
  2.2331 -SQLITE_API int sqlite3_get_autocommit(sqlite3*);
  2.2332 +SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3*);
  2.2333  
  2.2334  /*
  2.2335  ** CAPI3REF: Find The Database Handle Of A Prepared Statement
  2.2336 +** METHOD: sqlite3_stmt
  2.2337  **
  2.2338  ** ^The sqlite3_db_handle interface returns the [database connection] handle
  2.2339  ** to which a [prepared statement] belongs.  ^The [database connection]
  2.2340 @@ -4926,10 +5273,11 @@
  2.2341  ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
  2.2342  ** create the statement in the first place.
  2.2343  */
  2.2344 -SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
  2.2345 +SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt*);
  2.2346  
  2.2347  /*
  2.2348  ** CAPI3REF: Return The Filename For A Database Connection
  2.2349 +** METHOD: sqlite3
  2.2350  **
  2.2351  ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
  2.2352  ** associated with database N of connection D.  ^The main database file
  2.2353 @@ -4942,19 +5290,21 @@
  2.2354  ** will be an absolute pathname, even if the filename used
  2.2355  ** to open the database originally was a URI or relative pathname.
  2.2356  */
  2.2357 -SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
  2.2358 +SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName);
  2.2359  
  2.2360  /*
  2.2361  ** CAPI3REF: Determine if a database is read-only
  2.2362 +** METHOD: sqlite3
  2.2363  **
  2.2364  ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
  2.2365  ** of connection D is read-only, 0 if it is read/write, or -1 if N is not
  2.2366  ** the name of a database on connection D.
  2.2367  */
  2.2368 -SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
  2.2369 +SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
  2.2370  
  2.2371  /*
  2.2372  ** CAPI3REF: Find the next prepared statement
  2.2373 +** METHOD: sqlite3
  2.2374  **
  2.2375  ** ^This interface returns a pointer to the next [prepared statement] after
  2.2376  ** pStmt associated with the [database connection] pDb.  ^If pStmt is NULL
  2.2377 @@ -4966,10 +5316,11 @@
  2.2378  ** [sqlite3_next_stmt(D,S)] must refer to an open database
  2.2379  ** connection and in particular must not be a NULL pointer.
  2.2380  */
  2.2381 -SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
  2.2382 +SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
  2.2383  
  2.2384  /*
  2.2385  ** CAPI3REF: Commit And Rollback Notification Callbacks
  2.2386 +** METHOD: sqlite3
  2.2387  **
  2.2388  ** ^The sqlite3_commit_hook() interface registers a callback
  2.2389  ** function to be invoked whenever a transaction is [COMMIT | committed].
  2.2390 @@ -5014,11 +5365,12 @@
  2.2391  **
  2.2392  ** See also the [sqlite3_update_hook()] interface.
  2.2393  */
  2.2394 -SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
  2.2395 -SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
  2.2396 +SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
  2.2397 +SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
  2.2398  
  2.2399  /*
  2.2400  ** CAPI3REF: Data Change Notification Callbacks
  2.2401 +** METHOD: sqlite3
  2.2402  **
  2.2403  ** ^The sqlite3_update_hook() interface registers a callback function
  2.2404  ** with the [database connection] identified by the first argument
  2.2405 @@ -5065,7 +5417,7 @@
  2.2406  ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
  2.2407  ** interfaces.
  2.2408  */
  2.2409 -SQLITE_API void *sqlite3_update_hook(
  2.2410 +SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
  2.2411    sqlite3*, 
  2.2412    void(*)(void *,int ,char const *,char const *,sqlite3_int64),
  2.2413    void*
  2.2414 @@ -5095,12 +5447,17 @@
  2.2415  ** future releases of SQLite.  Applications that care about shared
  2.2416  ** cache setting should set it explicitly.
  2.2417  **
  2.2418 +** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0
  2.2419 +** and will always return SQLITE_MISUSE. On those systems, 
  2.2420 +** shared cache mode should be enabled per-database connection via 
  2.2421 +** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE].
  2.2422 +**
  2.2423  ** This interface is threadsafe on processors where writing a
  2.2424  ** 32-bit integer is atomic.
  2.2425  **
  2.2426  ** See Also:  [SQLite Shared-Cache Mode]
  2.2427  */
  2.2428 -SQLITE_API int sqlite3_enable_shared_cache(int);
  2.2429 +SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int);
  2.2430  
  2.2431  /*
  2.2432  ** CAPI3REF: Attempt To Free Heap Memory
  2.2433 @@ -5116,10 +5473,11 @@
  2.2434  **
  2.2435  ** See also: [sqlite3_db_release_memory()]
  2.2436  */
  2.2437 -SQLITE_API int sqlite3_release_memory(int);
  2.2438 +SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int);
  2.2439  
  2.2440  /*
  2.2441  ** CAPI3REF: Free Memory Used By A Database Connection
  2.2442 +** METHOD: sqlite3
  2.2443  **
  2.2444  ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
  2.2445  ** memory as possible from database connection D. Unlike the
  2.2446 @@ -5129,7 +5487,7 @@
  2.2447  **
  2.2448  ** See also: [sqlite3_release_memory()]
  2.2449  */
  2.2450 -SQLITE_API int sqlite3_db_release_memory(sqlite3*);
  2.2451 +SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3*);
  2.2452  
  2.2453  /*
  2.2454  ** CAPI3REF: Impose A Limit On Heap Size
  2.2455 @@ -5181,7 +5539,7 @@
  2.2456  ** The circumstances under which SQLite will enforce the soft heap limit may
  2.2457  ** changes in future releases of SQLite.
  2.2458  */
  2.2459 -SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
  2.2460 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 N);
  2.2461  
  2.2462  /*
  2.2463  ** CAPI3REF: Deprecated Soft Heap Limit Interface
  2.2464 @@ -5192,26 +5550,34 @@
  2.2465  ** only.  All new applications should use the
  2.2466  ** [sqlite3_soft_heap_limit64()] interface rather than this one.
  2.2467  */
  2.2468 -SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
  2.2469 +SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_soft_heap_limit(int N);
  2.2470  
  2.2471  
  2.2472  /*
  2.2473  ** CAPI3REF: Extract Metadata About A Column Of A Table
  2.2474 -**
  2.2475 -** ^This routine returns metadata about a specific column of a specific
  2.2476 -** database table accessible using the [database connection] handle
  2.2477 -** passed as the first function argument.
  2.2478 +** METHOD: sqlite3
  2.2479 +**
  2.2480 +** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
  2.2481 +** information about column C of table T in database D
  2.2482 +** on [database connection] X.)^  ^The sqlite3_table_column_metadata()
  2.2483 +** interface returns SQLITE_OK and fills in the non-NULL pointers in
  2.2484 +** the final five arguments with appropriate values if the specified
  2.2485 +** column exists.  ^The sqlite3_table_column_metadata() interface returns
  2.2486 +** SQLITE_ERROR and if the specified column does not exist.
  2.2487 +** ^If the column-name parameter to sqlite3_table_column_metadata() is a
  2.2488 +** NULL pointer, then this routine simply checks for the existance of the
  2.2489 +** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
  2.2490 +** does not.
  2.2491  **
  2.2492  ** ^The column is identified by the second, third and fourth parameters to
  2.2493 -** this function. ^The second parameter is either the name of the database
  2.2494 +** this function. ^(The second parameter is either the name of the database
  2.2495  ** (i.e. "main", "temp", or an attached database) containing the specified
  2.2496 -** table or NULL. ^If it is NULL, then all attached databases are searched
  2.2497 +** table or NULL.)^ ^If it is NULL, then all attached databases are searched
  2.2498  ** for the table using the same algorithm used by the database engine to
  2.2499  ** resolve unqualified table references.
  2.2500  **
  2.2501  ** ^The third and fourth parameters to this function are the table and column
  2.2502 -** name of the desired column, respectively. Neither of these parameters
  2.2503 -** may be NULL.
  2.2504 +** name of the desired column, respectively.
  2.2505  **
  2.2506  ** ^Metadata is returned by writing to the memory locations passed as the 5th
  2.2507  ** and subsequent parameters to this function. ^Any of these arguments may be
  2.2508 @@ -5230,16 +5596,17 @@
  2.2509  ** </blockquote>)^
  2.2510  **
  2.2511  ** ^The memory pointed to by the character pointers returned for the
  2.2512 -** declaration type and collation sequence is valid only until the next
  2.2513 +** declaration type and collation sequence is valid until the next
  2.2514  ** call to any SQLite API function.
  2.2515  **
  2.2516  ** ^If the specified table is actually a view, an [error code] is returned.
  2.2517  **
  2.2518 -** ^If the specified column is "rowid", "oid" or "_rowid_" and an
  2.2519 +** ^If the specified column is "rowid", "oid" or "_rowid_" and the table 
  2.2520 +** is not a [WITHOUT ROWID] table and an
  2.2521  ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
  2.2522  ** parameters are set for the explicitly declared column. ^(If there is no
  2.2523 -** explicitly declared [INTEGER PRIMARY KEY] column, then the output
  2.2524 -** parameters are set as follows:
  2.2525 +** [INTEGER PRIMARY KEY] column, then the outputs
  2.2526 +** for the [rowid] are set as follows:
  2.2527  **
  2.2528  ** <pre>
  2.2529  **     data type: "INTEGER"
  2.2530 @@ -5249,15 +5616,11 @@
  2.2531  **     auto increment: 0
  2.2532  ** </pre>)^
  2.2533  **
  2.2534 -** ^(This function may load one or more schemas from database files. If an
  2.2535 -** error occurs during this process, or if the requested table or column
  2.2536 -** cannot be found, an [error code] is returned and an error message left
  2.2537 -** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
  2.2538 -**
  2.2539 -** ^This API is only available if the library was compiled with the
  2.2540 -** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
  2.2541 -*/
  2.2542 -SQLITE_API int sqlite3_table_column_metadata(
  2.2543 +** ^This function causes all database schemas to be read from disk and
  2.2544 +** parsed, if that has not already been done, and returns an error if
  2.2545 +** any errors are encountered while loading the schema.
  2.2546 +*/
  2.2547 +SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
  2.2548    sqlite3 *db,                /* Connection handle */
  2.2549    const char *zDbName,        /* Database name or NULL */
  2.2550    const char *zTableName,     /* Table name */
  2.2551 @@ -5271,6 +5634,7 @@
  2.2552  
  2.2553  /*
  2.2554  ** CAPI3REF: Load An Extension
  2.2555 +** METHOD: sqlite3
  2.2556  **
  2.2557  ** ^This interface loads an SQLite extension library from the named file.
  2.2558  **
  2.2559 @@ -5303,7 +5667,7 @@
  2.2560  **
  2.2561  ** See also the [load_extension() SQL function].
  2.2562  */
  2.2563 -SQLITE_API int sqlite3_load_extension(
  2.2564 +SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
  2.2565    sqlite3 *db,          /* Load the extension into this database connection */
  2.2566    const char *zFile,    /* Name of the shared library containing extension */
  2.2567    const char *zProc,    /* Entry point.  Derived from zFile if 0 */
  2.2568 @@ -5312,6 +5676,7 @@
  2.2569  
  2.2570  /*
  2.2571  ** CAPI3REF: Enable Or Disable Extension Loading
  2.2572 +** METHOD: sqlite3
  2.2573  **
  2.2574  ** ^So as not to open security holes in older applications that are
  2.2575  ** unprepared to deal with [extension loading], and as a means of disabling
  2.2576 @@ -5323,7 +5688,7 @@
  2.2577  ** to turn extension loading on and call it with onoff==0 to turn
  2.2578  ** it back off again.
  2.2579  */
  2.2580 -SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
  2.2581 +SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff);
  2.2582  
  2.2583  /*
  2.2584  ** CAPI3REF: Automatically Load Statically Linked Extensions
  2.2585 @@ -5361,7 +5726,7 @@
  2.2586  ** See also: [sqlite3_reset_auto_extension()]
  2.2587  ** and [sqlite3_cancel_auto_extension()]
  2.2588  */
  2.2589 -SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
  2.2590 +SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
  2.2591  
  2.2592  /*
  2.2593  ** CAPI3REF: Cancel Automatic Extension Loading
  2.2594 @@ -5373,7 +5738,7 @@
  2.2595  ** unregistered and it returns 0 if X was not on the list of initialization
  2.2596  ** routines.
  2.2597  */
  2.2598 -SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
  2.2599 +SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
  2.2600  
  2.2601  /*
  2.2602  ** CAPI3REF: Reset Automatic Extension Loading
  2.2603 @@ -5381,7 +5746,7 @@
  2.2604  ** ^This interface disables all automatic extensions previously
  2.2605  ** registered using [sqlite3_auto_extension()].
  2.2606  */
  2.2607 -SQLITE_API void sqlite3_reset_auto_extension(void);
  2.2608 +SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void);
  2.2609  
  2.2610  /*
  2.2611  ** The interface to the virtual-table mechanism is currently considered
  2.2612 @@ -5483,6 +5848,17 @@
  2.2613  ** ^Information about the ORDER BY clause is stored in aOrderBy[].
  2.2614  ** ^Each term of aOrderBy records a column of the ORDER BY clause.
  2.2615  **
  2.2616 +** The colUsed field indicates which columns of the virtual table may be
  2.2617 +** required by the current scan. Virtual table columns are numbered from
  2.2618 +** zero in the order in which they appear within the CREATE TABLE statement
  2.2619 +** passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62),
  2.2620 +** the corresponding bit is set within the colUsed mask if the column may be
  2.2621 +** required by SQLite. If the table has at least 64 columns and any column
  2.2622 +** to the right of the first 63 is required, then bit 63 of colUsed is also
  2.2623 +** set. In other words, column iCol may be required if the expression
  2.2624 +** (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to 
  2.2625 +** non-zero.
  2.2626 +**
  2.2627  ** The [xBestIndex] method must fill aConstraintUsage[] with information
  2.2628  ** about what parameters to pass to xFilter.  ^If argvIndex>0 then
  2.2629  ** the right-hand side of the corresponding aConstraint[] is evaluated
  2.2630 @@ -5508,19 +5884,37 @@
  2.2631  ** ^The estimatedRows value is an estimate of the number of rows that
  2.2632  ** will be returned by the strategy.
  2.2633  **
  2.2634 +** The xBestIndex method may optionally populate the idxFlags field with a 
  2.2635 +** mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag -
  2.2636 +** SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite
  2.2637 +** assumes that the strategy may visit at most one row. 
  2.2638 +**
  2.2639 +** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then
  2.2640 +** SQLite also assumes that if a call to the xUpdate() method is made as
  2.2641 +** part of the same statement to delete or update a virtual table row and the
  2.2642 +** implementation returns SQLITE_CONSTRAINT, then there is no need to rollback
  2.2643 +** any database changes. In other words, if the xUpdate() returns
  2.2644 +** SQLITE_CONSTRAINT, the database contents must be exactly as they were
  2.2645 +** before xUpdate was called. By contrast, if SQLITE_INDEX_SCAN_UNIQUE is not
  2.2646 +** set and xUpdate returns SQLITE_CONSTRAINT, any database changes made by
  2.2647 +** the xUpdate method are automatically rolled back by SQLite.
  2.2648 +**
  2.2649  ** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info
  2.2650  ** structure for SQLite version 3.8.2. If a virtual table extension is
  2.2651  ** used with an SQLite version earlier than 3.8.2, the results of attempting 
  2.2652  ** to read or write the estimatedRows field are undefined (but are likely 
  2.2653  ** to included crashing the application). The estimatedRows field should
  2.2654  ** therefore only be used if [sqlite3_libversion_number()] returns a
  2.2655 -** value greater than or equal to 3008002.
  2.2656 +** value greater than or equal to 3008002. Similarly, the idxFlags field
  2.2657 +** was added for version 3.9.0. It may therefore only be used if
  2.2658 +** sqlite3_libversion_number() returns a value greater than or equal to
  2.2659 +** 3009000.
  2.2660  */
  2.2661  struct sqlite3_index_info {
  2.2662    /* Inputs */
  2.2663    int nConstraint;           /* Number of entries in aConstraint */
  2.2664    struct sqlite3_index_constraint {
  2.2665 -     int iColumn;              /* Column on left-hand side of constraint */
  2.2666 +     int iColumn;              /* Column constrained.  -1 for ROWID */
  2.2667       unsigned char op;         /* Constraint operator */
  2.2668       unsigned char usable;     /* True if this constraint is usable */
  2.2669       int iTermOffset;          /* Used internally - xBestIndex should ignore */
  2.2670 @@ -5542,7 +5936,16 @@
  2.2671    double estimatedCost;           /* Estimated cost of using this index */
  2.2672    /* Fields below are only available in SQLite 3.8.2 and later */
  2.2673    sqlite3_int64 estimatedRows;    /* Estimated number of rows returned */
  2.2674 -};
  2.2675 +  /* Fields below are only available in SQLite 3.9.0 and later */
  2.2676 +  int idxFlags;              /* Mask of SQLITE_INDEX_SCAN_* flags */
  2.2677 +  /* Fields below are only available in SQLite 3.10.0 and later */
  2.2678 +  sqlite3_uint64 colUsed;    /* Input: Mask of columns used by statement */
  2.2679 +};
  2.2680 +
  2.2681 +/*
  2.2682 +** CAPI3REF: Virtual Table Scan Flags
  2.2683 +*/
  2.2684 +#define SQLITE_INDEX_SCAN_UNIQUE      1     /* Scan visits at most 1 row */
  2.2685  
  2.2686  /*
  2.2687  ** CAPI3REF: Virtual Table Constraint Operator Codes
  2.2688 @@ -5552,15 +5955,19 @@
  2.2689  ** an operator that is part of a constraint term in the wHERE clause of
  2.2690  ** a query that uses a [virtual table].
  2.2691  */
  2.2692 -#define SQLITE_INDEX_CONSTRAINT_EQ    2
  2.2693 -#define SQLITE_INDEX_CONSTRAINT_GT    4
  2.2694 -#define SQLITE_INDEX_CONSTRAINT_LE    8
  2.2695 -#define SQLITE_INDEX_CONSTRAINT_LT    16
  2.2696 -#define SQLITE_INDEX_CONSTRAINT_GE    32
  2.2697 -#define SQLITE_INDEX_CONSTRAINT_MATCH 64
  2.2698 +#define SQLITE_INDEX_CONSTRAINT_EQ      2
  2.2699 +#define SQLITE_INDEX_CONSTRAINT_GT      4
  2.2700 +#define SQLITE_INDEX_CONSTRAINT_LE      8
  2.2701 +#define SQLITE_INDEX_CONSTRAINT_LT     16
  2.2702 +#define SQLITE_INDEX_CONSTRAINT_GE     32
  2.2703 +#define SQLITE_INDEX_CONSTRAINT_MATCH  64
  2.2704 +#define SQLITE_INDEX_CONSTRAINT_LIKE   65
  2.2705 +#define SQLITE_INDEX_CONSTRAINT_GLOB   66
  2.2706 +#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
  2.2707  
  2.2708  /*
  2.2709  ** CAPI3REF: Register A Virtual Table Implementation
  2.2710 +** METHOD: sqlite3
  2.2711  **
  2.2712  ** ^These routines are used to register a new [virtual table module] name.
  2.2713  ** ^Module names must be registered before
  2.2714 @@ -5584,13 +5991,13 @@
  2.2715  ** interface is equivalent to sqlite3_create_module_v2() with a NULL
  2.2716  ** destructor.
  2.2717  */
  2.2718 -SQLITE_API int sqlite3_create_module(
  2.2719 +SQLITE_API int SQLITE_STDCALL sqlite3_create_module(
  2.2720    sqlite3 *db,               /* SQLite connection to register module with */
  2.2721    const char *zName,         /* Name of the module */
  2.2722    const sqlite3_module *p,   /* Methods for the module */
  2.2723    void *pClientData          /* Client data for xCreate/xConnect */
  2.2724  );
  2.2725 -SQLITE_API int sqlite3_create_module_v2(
  2.2726 +SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2(
  2.2727    sqlite3 *db,               /* SQLite connection to register module with */
  2.2728    const char *zName,         /* Name of the module */
  2.2729    const sqlite3_module *p,   /* Methods for the module */
  2.2730 @@ -5618,7 +6025,7 @@
  2.2731  */
  2.2732  struct sqlite3_vtab {
  2.2733    const sqlite3_module *pModule;  /* The module for this virtual table */
  2.2734 -  int nRef;                       /* NO LONGER USED */
  2.2735 +  int nRef;                       /* Number of open cursors */
  2.2736    char *zErrMsg;                  /* Error message from sqlite3_mprintf() */
  2.2737    /* Virtual table implementations will typically add additional fields */
  2.2738  };
  2.2739 @@ -5653,10 +6060,11 @@
  2.2740  ** to declare the format (the names and datatypes of the columns) of
  2.2741  ** the virtual tables they implement.
  2.2742  */
  2.2743 -SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
  2.2744 +SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3*, const char *zSQL);
  2.2745  
  2.2746  /*
  2.2747  ** CAPI3REF: Overload A Function For A Virtual Table
  2.2748 +** METHOD: sqlite3
  2.2749  **
  2.2750  ** ^(Virtual tables can provide alternative implementations of functions
  2.2751  ** using the [xFindFunction] method of the [virtual table module].  
  2.2752 @@ -5671,7 +6079,7 @@
  2.2753  ** purpose is to be a placeholder function that can be overloaded
  2.2754  ** by a [virtual table].
  2.2755  */
  2.2756 -SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
  2.2757 +SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
  2.2758  
  2.2759  /*
  2.2760  ** The interface to the virtual-table mechanism defined above (back up
  2.2761 @@ -5699,6 +6107,8 @@
  2.2762  
  2.2763  /*
  2.2764  ** CAPI3REF: Open A BLOB For Incremental I/O
  2.2765 +** METHOD: sqlite3
  2.2766 +** CONSTRUCTOR: sqlite3_blob
  2.2767  **
  2.2768  ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located
  2.2769  ** in row iRow, column zColumn, table zTable in database zDb;
  2.2770 @@ -5708,26 +6118,42 @@
  2.2771  **     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
  2.2772  ** </pre>)^
  2.2773  **
  2.2774 +** ^(Parameter zDb is not the filename that contains the database, but 
  2.2775 +** rather the symbolic name of the database. For attached databases, this is
  2.2776 +** the name that appears after the AS keyword in the [ATTACH] statement.
  2.2777 +** For the main database file, the database name is "main". For TEMP
  2.2778 +** tables, the database name is "temp".)^
  2.2779 +**
  2.2780  ** ^If the flags parameter is non-zero, then the BLOB is opened for read
  2.2781 -** and write access. ^If it is zero, the BLOB is opened for read access.
  2.2782 -** ^It is not possible to open a column that is part of an index or primary 
  2.2783 -** key for writing. ^If [foreign key constraints] are enabled, it is 
  2.2784 -** not possible to open a column that is part of a [child key] for writing.
  2.2785 -**
  2.2786 -** ^Note that the database name is not the filename that contains
  2.2787 -** the database but rather the symbolic name of the database that
  2.2788 -** appears after the AS keyword when the database is connected using [ATTACH].
  2.2789 -** ^For the main database file, the database name is "main".
  2.2790 -** ^For TEMP tables, the database name is "temp".
  2.2791 -**
  2.2792 -** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written
  2.2793 -** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set
  2.2794 -** to be a null pointer.)^
  2.2795 -** ^This function sets the [database connection] error code and message
  2.2796 -** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related
  2.2797 -** functions. ^Note that the *ppBlob variable is always initialized in a
  2.2798 -** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob
  2.2799 -** regardless of the success or failure of this routine.
  2.2800 +** and write access. ^If the flags parameter is zero, the BLOB is opened for
  2.2801 +** read-only access.
  2.2802 +**
  2.2803 +** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is stored
  2.2804 +** in *ppBlob. Otherwise an [error code] is returned and, unless the error
  2.2805 +** code is SQLITE_MISUSE, *ppBlob is set to NULL.)^ ^This means that, provided
  2.2806 +** the API is not misused, it is always safe to call [sqlite3_blob_close()] 
  2.2807 +** on *ppBlob after this function it returns.
  2.2808 +**
  2.2809 +** This function fails with SQLITE_ERROR if any of the following are true:
  2.2810 +** <ul>
  2.2811 +**   <li> ^(Database zDb does not exist)^, 
  2.2812 +**   <li> ^(Table zTable does not exist within database zDb)^, 
  2.2813 +**   <li> ^(Table zTable is a WITHOUT ROWID table)^, 
  2.2814 +**   <li> ^(Column zColumn does not exist)^,
  2.2815 +**   <li> ^(Row iRow is not present in the table)^,
  2.2816 +**   <li> ^(The specified column of row iRow contains a value that is not
  2.2817 +**         a TEXT or BLOB value)^,
  2.2818 +**   <li> ^(Column zColumn is part of an index, PRIMARY KEY or UNIQUE 
  2.2819 +**         constraint and the blob is being opened for read/write access)^,
  2.2820 +**   <li> ^([foreign key constraints | Foreign key constraints] are enabled, 
  2.2821 +**         column zColumn is part of a [child key] definition and the blob is
  2.2822 +**         being opened for read/write access)^.
  2.2823 +** </ul>
  2.2824 +**
  2.2825 +** ^Unless it returns SQLITE_MISUSE, this function sets the 
  2.2826 +** [database connection] error code and message accessible via 
  2.2827 +** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. 
  2.2828 +**
  2.2829  **
  2.2830  ** ^(If the row that a BLOB handle points to is modified by an
  2.2831  ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects
  2.2832 @@ -5745,18 +6171,14 @@
  2.2833  ** interface.  Use the [UPDATE] SQL command to change the size of a
  2.2834  ** blob.
  2.2835  **
  2.2836 -** ^The [sqlite3_blob_open()] interface will fail for a [WITHOUT ROWID]
  2.2837 -** table.  Incremental BLOB I/O is not possible on [WITHOUT ROWID] tables.
  2.2838 -**
  2.2839  ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
  2.2840 -** and the built-in [zeroblob] SQL function can be used, if desired,
  2.2841 -** to create an empty, zero-filled blob in which to read or write using
  2.2842 -** this interface.
  2.2843 +** and the built-in [zeroblob] SQL function may be used to create a 
  2.2844 +** zero-filled blob to read or write using the incremental-blob interface.
  2.2845  **
  2.2846  ** To avoid a resource leak, every open [BLOB handle] should eventually
  2.2847  ** be released by a call to [sqlite3_blob_close()].
  2.2848  */
  2.2849 -SQLITE_API int sqlite3_blob_open(
  2.2850 +SQLITE_API int SQLITE_STDCALL sqlite3_blob_open(
  2.2851    sqlite3*,
  2.2852    const char *zDb,
  2.2853    const char *zTable,
  2.2854 @@ -5768,6 +6190,7 @@
  2.2855  
  2.2856  /*
  2.2857  ** CAPI3REF: Move a BLOB Handle to a New Row
  2.2858 +** METHOD: sqlite3_blob
  2.2859  **
  2.2860  ** ^This function is used to move an existing blob handle so that it points
  2.2861  ** to a different row of the same database table. ^The new row is identified
  2.2862 @@ -5788,34 +6211,34 @@
  2.2863  **
  2.2864  ** ^This function sets the database handle error code and message.
  2.2865  */
  2.2866 -SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
  2.2867 +SQLITE_API int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
  2.2868  
  2.2869  /*
  2.2870  ** CAPI3REF: Close A BLOB Handle
  2.2871 -**
  2.2872 -** ^Closes an open [BLOB handle].
  2.2873 -**
  2.2874 -** ^Closing a BLOB shall cause the current transaction to commit
  2.2875 -** if there are no other BLOBs, no pending prepared statements, and the
  2.2876 -** database connection is in [autocommit mode].
  2.2877 -** ^If any writes were made to the BLOB, they might be held in cache
  2.2878 -** until the close operation if they will fit.
  2.2879 -**
  2.2880 -** ^(Closing the BLOB often forces the changes
  2.2881 -** out to disk and so if any I/O errors occur, they will likely occur
  2.2882 -** at the time when the BLOB is closed.  Any errors that occur during
  2.2883 -** closing are reported as a non-zero return value.)^
  2.2884 -**
  2.2885 -** ^(The BLOB is closed unconditionally.  Even if this routine returns
  2.2886 -** an error code, the BLOB is still closed.)^
  2.2887 -**
  2.2888 -** ^Calling this routine with a null pointer (such as would be returned
  2.2889 -** by a failed call to [sqlite3_blob_open()]) is a harmless no-op.
  2.2890 -*/
  2.2891 -SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
  2.2892 +** DESTRUCTOR: sqlite3_blob
  2.2893 +**
  2.2894 +** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed
  2.2895 +** unconditionally.  Even if this routine returns an error code, the 
  2.2896 +** handle is still closed.)^
  2.2897 +**
  2.2898 +** ^If the blob handle being closed was opened for read-write access, and if
  2.2899 +** the database is in auto-commit mode and there are no other open read-write
  2.2900 +** blob handles or active write statements, the current transaction is
  2.2901 +** committed. ^If an error occurs while committing the transaction, an error
  2.2902 +** code is returned and the transaction rolled back.
  2.2903 +**
  2.2904 +** Calling this function with an argument that is not a NULL pointer or an
  2.2905 +** open blob handle results in undefined behaviour. ^Calling this routine 
  2.2906 +** with a null pointer (such as would be returned by a failed call to 
  2.2907 +** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
  2.2908 +** is passed a valid open blob handle, the values returned by the 
  2.2909 +** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
  2.2910 +*/
  2.2911 +SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *);
  2.2912  
  2.2913  /*
  2.2914  ** CAPI3REF: Return The Size Of An Open BLOB
  2.2915 +** METHOD: sqlite3_blob
  2.2916  **
  2.2917  ** ^Returns the size in bytes of the BLOB accessible via the 
  2.2918  ** successfully opened [BLOB handle] in its only argument.  ^The
  2.2919 @@ -5827,10 +6250,11 @@
  2.2920  ** been closed by [sqlite3_blob_close()].  Passing any other pointer in
  2.2921  ** to this routine results in undefined and probably undesirable behavior.
  2.2922  */
  2.2923 -SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
  2.2924 +SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *);
  2.2925  
  2.2926  /*
  2.2927  ** CAPI3REF: Read Data From A BLOB Incrementally
  2.2928 +** METHOD: sqlite3_blob
  2.2929  **
  2.2930  ** ^(This function is used to read data from an open [BLOB handle] into a
  2.2931  ** caller-supplied buffer. N bytes of data are copied into buffer Z
  2.2932 @@ -5855,26 +6279,33 @@
  2.2933  **
  2.2934  ** See also: [sqlite3_blob_write()].
  2.2935  */
  2.2936 -SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
  2.2937 +SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
  2.2938  
  2.2939  /*
  2.2940  ** CAPI3REF: Write Data Into A BLOB Incrementally
  2.2941 -**
  2.2942 -** ^This function is used to write data into an open [BLOB handle] from a
  2.2943 -** caller-supplied buffer. ^N bytes of data are copied from the buffer Z
  2.2944 -** into the open BLOB, starting at offset iOffset.
  2.2945 +** METHOD: sqlite3_blob
  2.2946 +**
  2.2947 +** ^(This function is used to write data into an open [BLOB handle] from a
  2.2948 +** caller-supplied buffer. N bytes of data are copied from the buffer Z
  2.2949 +** into the open BLOB, starting at offset iOffset.)^
  2.2950 +**
  2.2951 +** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
  2.2952 +** Otherwise, an  [error code] or an [extended error code] is returned.)^
  2.2953 +** ^Unless SQLITE_MISUSE is returned, this function sets the 
  2.2954 +** [database connection] error code and message accessible via 
  2.2955 +** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. 
  2.2956  **
  2.2957  ** ^If the [BLOB handle] passed as the first argument was not opened for
  2.2958  ** writing (the flags parameter to [sqlite3_blob_open()] was zero),
  2.2959  ** this function returns [SQLITE_READONLY].
  2.2960  **
  2.2961 -** ^This function may only modify the contents of the BLOB; it is
  2.2962 +** This function may only modify the contents of the BLOB; it is
  2.2963  ** not possible to increase the size of a BLOB using this API.
  2.2964  ** ^If offset iOffset is less than N bytes from the end of the BLOB,
  2.2965 -** [SQLITE_ERROR] is returned and no data is written.  ^If N is
  2.2966 -** less than zero [SQLITE_ERROR] is returned and no data is written.
  2.2967 -** The size of the BLOB (and hence the maximum value of N+iOffset)
  2.2968 -** can be determined using the [sqlite3_blob_bytes()] interface.
  2.2969 +** [SQLITE_ERROR] is returned and no data is written. The size of the 
  2.2970 +** BLOB (and hence the maximum value of N+iOffset) can be determined 
  2.2971 +** using the [sqlite3_blob_bytes()] interface. ^If N or iOffset are less 
  2.2972 +** than zero [SQLITE_ERROR] is returned and no data is written.
  2.2973  **
  2.2974  ** ^An attempt to write to an expired [BLOB handle] fails with an
  2.2975  ** error code of [SQLITE_ABORT].  ^Writes to the BLOB that occurred
  2.2976 @@ -5883,9 +6314,6 @@
  2.2977  ** have been overwritten by the statement that expired the BLOB handle
  2.2978  ** or by other independent statements.
  2.2979  **
  2.2980 -** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
  2.2981 -** Otherwise, an  [error code] or an [extended error code] is returned.)^
  2.2982 -**
  2.2983  ** This routine only works on a [BLOB handle] which has been created
  2.2984  ** by a prior successful call to [sqlite3_blob_open()] and which has not
  2.2985  ** been closed by [sqlite3_blob_close()].  Passing any other pointer in
  2.2986 @@ -5893,7 +6321,7 @@
  2.2987  **
  2.2988  ** See also: [sqlite3_blob_read()].
  2.2989  */
  2.2990 -SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
  2.2991 +SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
  2.2992  
  2.2993  /*
  2.2994  ** CAPI3REF: Virtual File System Objects
  2.2995 @@ -5924,9 +6352,9 @@
  2.2996  ** ^(If the default VFS is unregistered, another VFS is chosen as
  2.2997  ** the default.  The choice for the new VFS is arbitrary.)^
  2.2998  */
  2.2999 -SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
  2.3000 -SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
  2.3001 -SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
  2.3002 +SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfsName);
  2.3003 +SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
  2.3004 +SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs*);
  2.3005  
  2.3006  /*
  2.3007  ** CAPI3REF: Mutexes
  2.3008 @@ -5938,34 +6366,34 @@
  2.3009  **
  2.3010  ** The SQLite source code contains multiple implementations
  2.3011  ** of these mutex routines.  An appropriate implementation
  2.3012 -** is selected automatically at compile-time.  ^(The following
  2.3013 +** is selected automatically at compile-time.  The following
  2.3014  ** implementations are available in the SQLite core:
  2.3015  **
  2.3016  ** <ul>
  2.3017  ** <li>   SQLITE_MUTEX_PTHREADS
  2.3018  ** <li>   SQLITE_MUTEX_W32
  2.3019  ** <li>   SQLITE_MUTEX_NOOP
  2.3020 -** </ul>)^
  2.3021 -**
  2.3022 -** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
  2.3023 +** </ul>
  2.3024 +**
  2.3025 +** The SQLITE_MUTEX_NOOP implementation is a set of routines
  2.3026  ** that does no real locking and is appropriate for use in
  2.3027 -** a single-threaded application.  ^The SQLITE_MUTEX_PTHREADS and
  2.3028 +** a single-threaded application.  The SQLITE_MUTEX_PTHREADS and
  2.3029  ** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix
  2.3030  ** and Windows.
  2.3031  **
  2.3032 -** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
  2.3033 +** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
  2.3034  ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
  2.3035  ** implementation is included with the library. In this case the
  2.3036  ** application must supply a custom mutex implementation using the
  2.3037  ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function
  2.3038  ** before calling sqlite3_initialize() or any other public sqlite3_
  2.3039 -** function that calls sqlite3_initialize().)^
  2.3040 +** function that calls sqlite3_initialize().
  2.3041  **
  2.3042  ** ^The sqlite3_mutex_alloc() routine allocates a new
  2.3043 -** mutex and returns a pointer to it. ^If it returns NULL
  2.3044 -** that means that a mutex could not be allocated.  ^SQLite
  2.3045 -** will unwind its stack and return an error.  ^(The argument
  2.3046 -** to sqlite3_mutex_alloc() is one of these integer constants:
  2.3047 +** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()
  2.3048 +** routine returns NULL if it is unable to allocate the requested
  2.3049 +** mutex.  The argument to sqlite3_mutex_alloc() must one of these
  2.3050 +** integer constants:
  2.3051  **
  2.3052  ** <ul>
  2.3053  ** <li>  SQLITE_MUTEX_FAST
  2.3054 @@ -5978,7 +6406,11 @@
  2.3055  ** <li>  SQLITE_MUTEX_STATIC_PMEM
  2.3056  ** <li>  SQLITE_MUTEX_STATIC_APP1
  2.3057  ** <li>  SQLITE_MUTEX_STATIC_APP2
  2.3058 -** </ul>)^
  2.3059 +** <li>  SQLITE_MUTEX_STATIC_APP3
  2.3060 +** <li>  SQLITE_MUTEX_STATIC_VFS1
  2.3061 +** <li>  SQLITE_MUTEX_STATIC_VFS2
  2.3062 +** <li>  SQLITE_MUTEX_STATIC_VFS3
  2.3063 +** </ul>
  2.3064  **
  2.3065  ** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)
  2.3066  ** cause sqlite3_mutex_alloc() to create
  2.3067 @@ -5986,14 +6418,14 @@
  2.3068  ** is used but not necessarily so when SQLITE_MUTEX_FAST is used.
  2.3069  ** The mutex implementation does not need to make a distinction
  2.3070  ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
  2.3071 -** not want to.  ^SQLite will only request a recursive mutex in
  2.3072 -** cases where it really needs one.  ^If a faster non-recursive mutex
  2.3073 +** not want to.  SQLite will only request a recursive mutex in
  2.3074 +** cases where it really needs one.  If a faster non-recursive mutex
  2.3075  ** implementation is available on the host platform, the mutex subsystem
  2.3076  ** might return such a mutex in response to SQLITE_MUTEX_FAST.
  2.3077  **
  2.3078  ** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other
  2.3079  ** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return
  2.3080 -** a pointer to a static preexisting mutex.  ^Six static mutexes are
  2.3081 +** a pointer to a static preexisting mutex.  ^Nine static mutexes are
  2.3082  ** used by the current version of SQLite.  Future versions of SQLite
  2.3083  ** may add additional static mutexes.  Static mutexes are for internal
  2.3084  ** use by SQLite only.  Applications that use SQLite mutexes should
  2.3085 @@ -6002,16 +6434,13 @@
  2.3086  **
  2.3087  ** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
  2.3088  ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()
  2.3089 -** returns a different mutex on every call.  ^But for the static
  2.3090 +** returns a different mutex on every call.  ^For the static
  2.3091  ** mutex types, the same mutex is returned on every call that has
  2.3092  ** the same type number.
  2.3093  **
  2.3094  ** ^The sqlite3_mutex_free() routine deallocates a previously
  2.3095 -** allocated dynamic mutex.  ^SQLite is careful to deallocate every
  2.3096 -** dynamic mutex that it allocates.  The dynamic mutexes must not be in
  2.3097 -** use when they are deallocated.  Attempting to deallocate a static
  2.3098 -** mutex results in undefined behavior.  ^SQLite never deallocates
  2.3099 -** a static mutex.
  2.3100 +** allocated dynamic mutex.  Attempting to deallocate a static
  2.3101 +** mutex results in undefined behavior.
  2.3102  **
  2.3103  ** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
  2.3104  ** to enter a mutex.  ^If another thread is already within the mutex,
  2.3105 @@ -6019,23 +6448,21 @@
  2.3106  ** SQLITE_BUSY.  ^The sqlite3_mutex_try() interface returns [SQLITE_OK]
  2.3107  ** upon successful entry.  ^(Mutexes created using
  2.3108  ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.
  2.3109 -** In such cases the,
  2.3110 +** In such cases, the
  2.3111  ** mutex must be exited an equal number of times before another thread
  2.3112 -** can enter.)^  ^(If the same thread tries to enter any other
  2.3113 -** kind of mutex more than once, the behavior is undefined.
  2.3114 -** SQLite will never exhibit
  2.3115 -** such behavior in its own use of mutexes.)^
  2.3116 +** can enter.)^  If the same thread tries to enter any mutex other
  2.3117 +** than an SQLITE_MUTEX_RECURSIVE more than once, the behavior is undefined.
  2.3118  **
  2.3119  ** ^(Some systems (for example, Windows 95) do not support the operation
  2.3120  ** implemented by sqlite3_mutex_try().  On those systems, sqlite3_mutex_try()
  2.3121 -** will always return SQLITE_BUSY.  The SQLite core only ever uses
  2.3122 -** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^
  2.3123 +** will always return SQLITE_BUSY. The SQLite core only ever uses
  2.3124 +** sqlite3_mutex_try() as an optimization so this is acceptable 
  2.3125 +** behavior.)^
  2.3126  **
  2.3127  ** ^The sqlite3_mutex_leave() routine exits a mutex that was
  2.3128 -** previously entered by the same thread.   ^(The behavior
  2.3129 +** previously entered by the same thread.   The behavior
  2.3130  ** is undefined if the mutex is not currently entered by the
  2.3131 -** calling thread or is not currently allocated.  SQLite will
  2.3132 -** never do either.)^
  2.3133 +** calling thread or is not currently allocated.
  2.3134  **
  2.3135  ** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
  2.3136  ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
  2.3137 @@ -6043,11 +6470,11 @@
  2.3138  **
  2.3139  ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
  2.3140  */
  2.3141 -SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);
  2.3142 -SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);
  2.3143 -SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
  2.3144 -SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
  2.3145 -SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
  2.3146 +SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int);
  2.3147 +SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex*);
  2.3148 +SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex*);
  2.3149 +SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex*);
  2.3150 +SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex*);
  2.3151  
  2.3152  /*
  2.3153  ** CAPI3REF: Mutex Methods Object
  2.3154 @@ -6056,9 +6483,9 @@
  2.3155  ** used to allocate and use mutexes.
  2.3156  **
  2.3157  ** Usually, the default mutex implementations provided by SQLite are
  2.3158 -** sufficient, however the user has the option of substituting a custom
  2.3159 +** sufficient, however the application has the option of substituting a custom
  2.3160  ** implementation for specialized deployments or systems for which SQLite
  2.3161 -** does not provide a suitable implementation. In this case, the user
  2.3162 +** does not provide a suitable implementation. In this case, the application
  2.3163  ** creates and populates an instance of this structure to pass
  2.3164  ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.
  2.3165  ** Additionally, an instance of this structure can be used as an
  2.3166 @@ -6099,13 +6526,13 @@
  2.3167  ** (i.e. it is acceptable to provide an implementation that segfaults if
  2.3168  ** it is passed a NULL pointer).
  2.3169  **
  2.3170 -** The xMutexInit() method must be threadsafe.  ^It must be harmless to
  2.3171 +** The xMutexInit() method must be threadsafe.  It must be harmless to
  2.3172  ** invoke xMutexInit() multiple times within the same process and without
  2.3173  ** intervening calls to xMutexEnd().  Second and subsequent calls to
  2.3174  ** xMutexInit() must be no-ops.
  2.3175  **
  2.3176 -** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
  2.3177 -** and its associates).  ^Similarly, xMutexAlloc() must not use SQLite memory
  2.3178 +** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
  2.3179 +** and its associates).  Similarly, xMutexAlloc() must not use SQLite memory
  2.3180  ** allocation for a static mutex.  ^However xMutexAlloc() may use SQLite
  2.3181  ** memory allocation for a fast or recursive mutex.
  2.3182  **
  2.3183 @@ -6131,34 +6558,34 @@
  2.3184  ** CAPI3REF: Mutex Verification Routines
  2.3185  **
  2.3186  ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines
  2.3187 -** are intended for use inside assert() statements.  ^The SQLite core
  2.3188 +** are intended for use inside assert() statements.  The SQLite core
  2.3189  ** never uses these routines except inside an assert() and applications
  2.3190 -** are advised to follow the lead of the core.  ^The SQLite core only
  2.3191 +** are advised to follow the lead of the core.  The SQLite core only
  2.3192  ** provides implementations for these routines when it is compiled
  2.3193 -** with the SQLITE_DEBUG flag.  ^External mutex implementations
  2.3194 +** with the SQLITE_DEBUG flag.  External mutex implementations
  2.3195  ** are only required to provide these routines if SQLITE_DEBUG is
  2.3196  ** defined and if NDEBUG is not defined.
  2.3197  **
  2.3198 -** ^These routines should return true if the mutex in their argument
  2.3199 +** These routines should return true if the mutex in their argument
  2.3200  ** is held or not held, respectively, by the calling thread.
  2.3201  **
  2.3202 -** ^The implementation is not required to provide versions of these
  2.3203 +** The implementation is not required to provide versions of these
  2.3204  ** routines that actually work. If the implementation does not provide working
  2.3205  ** versions of these routines, it should at least provide stubs that always
  2.3206  ** return true so that one does not get spurious assertion failures.
  2.3207  **
  2.3208 -** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
  2.3209 +** If the argument to sqlite3_mutex_held() is a NULL pointer then
  2.3210  ** the routine should return 1.   This seems counter-intuitive since
  2.3211  ** clearly the mutex cannot be held if it does not exist.  But
  2.3212  ** the reason the mutex does not exist is because the build is not
  2.3213  ** using mutexes.  And we do not want the assert() containing the
  2.3214  ** call to sqlite3_mutex_held() to fail, so a non-zero return is
  2.3215 -** the appropriate thing to do.  ^The sqlite3_mutex_notheld()
  2.3216 +** the appropriate thing to do.  The sqlite3_mutex_notheld()
  2.3217  ** interface should also return 1 when given a NULL pointer.
  2.3218  */
  2.3219  #ifndef NDEBUG
  2.3220 -SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
  2.3221 -SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
  2.3222 +SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex*);
  2.3223 +SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex*);
  2.3224  #endif
  2.3225  
  2.3226  /*
  2.3227 @@ -6184,9 +6611,13 @@
  2.3228  #define SQLITE_MUTEX_STATIC_APP1      8  /* For use by application */
  2.3229  #define SQLITE_MUTEX_STATIC_APP2      9  /* For use by application */
  2.3230  #define SQLITE_MUTEX_STATIC_APP3     10  /* For use by application */
  2.3231 +#define SQLITE_MUTEX_STATIC_VFS1     11  /* For use by built-in VFS */
  2.3232 +#define SQLITE_MUTEX_STATIC_VFS2     12  /* For use by extension VFS */
  2.3233 +#define SQLITE_MUTEX_STATIC_VFS3     13  /* For use by application VFS */
  2.3234  
  2.3235  /*
  2.3236  ** CAPI3REF: Retrieve the mutex for a database connection
  2.3237 +** METHOD: sqlite3
  2.3238  **
  2.3239  ** ^This interface returns a pointer the [sqlite3_mutex] object that 
  2.3240  ** serializes access to the [database connection] given in the argument
  2.3241 @@ -6194,10 +6625,11 @@
  2.3242  ** ^If the [threading mode] is Single-thread or Multi-thread then this
  2.3243  ** routine returns a NULL pointer.
  2.3244  */
  2.3245 -SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
  2.3246 +SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3*);
  2.3247  
  2.3248  /*
  2.3249  ** CAPI3REF: Low-Level Control Of Database Files
  2.3250 +** METHOD: sqlite3
  2.3251  **
  2.3252  ** ^The [sqlite3_file_control()] interface makes a direct call to the
  2.3253  ** xFileControl method for the [sqlite3_io_methods] object associated
  2.3254 @@ -6228,7 +6660,7 @@
  2.3255  **
  2.3256  ** See also: [SQLITE_FCNTL_LOCKSTATE]
  2.3257  */
  2.3258 -SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
  2.3259 +SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
  2.3260  
  2.3261  /*
  2.3262  ** CAPI3REF: Testing Interface
  2.3263 @@ -6247,7 +6679,7 @@
  2.3264  ** Unlike most of the SQLite API, this function is not guaranteed to
  2.3265  ** operate consistently from one release to the next.
  2.3266  */
  2.3267 -SQLITE_API int sqlite3_test_control(int op, ...);
  2.3268 +SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...);
  2.3269  
  2.3270  /*
  2.3271  ** CAPI3REF: Testing Interface Operation Codes
  2.3272 @@ -6275,17 +6707,19 @@
  2.3273  #define SQLITE_TESTCTRL_ISKEYWORD               16
  2.3274  #define SQLITE_TESTCTRL_SCRATCHMALLOC           17
  2.3275  #define SQLITE_TESTCTRL_LOCALTIME_FAULT         18
  2.3276 -#define SQLITE_TESTCTRL_EXPLAIN_STMT            19
  2.3277 +#define SQLITE_TESTCTRL_EXPLAIN_STMT            19  /* NOT USED */
  2.3278  #define SQLITE_TESTCTRL_NEVER_CORRUPT           20
  2.3279  #define SQLITE_TESTCTRL_VDBE_COVERAGE           21
  2.3280  #define SQLITE_TESTCTRL_BYTEORDER               22
  2.3281  #define SQLITE_TESTCTRL_ISINIT                  23
  2.3282 -#define SQLITE_TESTCTRL_LAST                    23
  2.3283 +#define SQLITE_TESTCTRL_SORTER_MMAP             24
  2.3284 +#define SQLITE_TESTCTRL_IMPOSTER                25
  2.3285 +#define SQLITE_TESTCTRL_LAST                    25
  2.3286  
  2.3287  /*
  2.3288  ** CAPI3REF: SQLite Runtime Status
  2.3289  **
  2.3290 -** ^This interface is used to retrieve runtime status information
  2.3291 +** ^These interfaces are used to retrieve runtime status information
  2.3292  ** about the performance of SQLite, and optionally to reset various
  2.3293  ** highwater marks.  ^The first argument is an integer code for
  2.3294  ** the specific parameter to measure.  ^(Recognized integer codes
  2.3295 @@ -6299,19 +6733,22 @@
  2.3296  ** ^(Other parameters record only the highwater mark and not the current
  2.3297  ** value.  For these latter parameters nothing is written into *pCurrent.)^
  2.3298  **
  2.3299 -** ^The sqlite3_status() routine returns SQLITE_OK on success and a
  2.3300 -** non-zero [error code] on failure.
  2.3301 -**
  2.3302 -** This routine is threadsafe but is not atomic.  This routine can be
  2.3303 -** called while other threads are running the same or different SQLite
  2.3304 -** interfaces.  However the values returned in *pCurrent and
  2.3305 -** *pHighwater reflect the status of SQLite at different points in time
  2.3306 -** and it is possible that another thread might change the parameter
  2.3307 -** in between the times when *pCurrent and *pHighwater are written.
  2.3308 +** ^The sqlite3_status() and sqlite3_status64() routines return
  2.3309 +** SQLITE_OK on success and a non-zero [error code] on failure.
  2.3310 +**
  2.3311 +** If either the current value or the highwater mark is too large to
  2.3312 +** be represented by a 32-bit integer, then the values returned by
  2.3313 +** sqlite3_status() are undefined.
  2.3314  **
  2.3315  ** See also: [sqlite3_db_status()]
  2.3316  */
  2.3317 -SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
  2.3318 +SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
  2.3319 +SQLITE_API int SQLITE_STDCALL sqlite3_status64(
  2.3320 +  int op,
  2.3321 +  sqlite3_int64 *pCurrent,
  2.3322 +  sqlite3_int64 *pHighwater,
  2.3323 +  int resetFlag
  2.3324 +);
  2.3325  
  2.3326  
  2.3327  /*
  2.3328 @@ -6390,7 +6827,8 @@
  2.3329  ** The value written into the *pCurrent parameter is undefined.</dd>)^
  2.3330  **
  2.3331  ** [[SQLITE_STATUS_PARSER_STACK]] ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>
  2.3332 -** <dd>This parameter records the deepest parser stack.  It is only
  2.3333 +** <dd>The *pHighwater parameter records the deepest parser stack. 
  2.3334 +** The *pCurrent value is undefined.  The *pHighwater value is only
  2.3335  ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^
  2.3336  ** </dl>
  2.3337  **
  2.3338 @@ -6409,6 +6847,7 @@
  2.3339  
  2.3340  /*
  2.3341  ** CAPI3REF: Database Connection Status
  2.3342 +** METHOD: sqlite3
  2.3343  **
  2.3344  ** ^This interface is used to retrieve runtime status information 
  2.3345  ** about a single [database connection].  ^The first argument is the
  2.3346 @@ -6429,7 +6868,7 @@
  2.3347  **
  2.3348  ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
  2.3349  */
  2.3350 -SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
  2.3351 +SQLITE_API int SQLITE_STDCALL sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
  2.3352  
  2.3353  /*
  2.3354  ** CAPI3REF: Status Parameters for database connections
  2.3355 @@ -6471,12 +6910,12 @@
  2.3356  ** the current value is always zero.)^
  2.3357  **
  2.3358  ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
  2.3359 -** <dd>This parameter returns the approximate number of of bytes of heap
  2.3360 +** <dd>This parameter returns the approximate number of bytes of heap
  2.3361  ** memory used by all pager caches associated with the database connection.)^
  2.3362  ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
  2.3363  **
  2.3364  ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
  2.3365 -** <dd>This parameter returns the approximate number of of bytes of heap
  2.3366 +** <dd>This parameter returns the approximate number of bytes of heap
  2.3367  ** memory used to store the schema for all databases associated
  2.3368  ** with the connection - main, temp, and any [ATTACH]-ed databases.)^ 
  2.3369  ** ^The full amount of memory used by the schemas is reported, even if the
  2.3370 @@ -6485,7 +6924,7 @@
  2.3371  ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.
  2.3372  **
  2.3373  ** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>
  2.3374 -** <dd>This parameter returns the approximate number of of bytes of heap
  2.3375 +** <dd>This parameter returns the approximate number of bytes of heap
  2.3376  ** and lookaside memory used by all prepared statements associated with
  2.3377  ** the database connection.)^
  2.3378  ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0.
  2.3379 @@ -6537,6 +6976,7 @@
  2.3380  
  2.3381  /*
  2.3382  ** CAPI3REF: Prepared Statement Status
  2.3383 +** METHOD: sqlite3_stmt
  2.3384  **
  2.3385  ** ^(Each prepared statement maintains various
  2.3386  ** [SQLITE_STMTSTATUS counters] that measure the number
  2.3387 @@ -6558,7 +6998,7 @@
  2.3388  **
  2.3389  ** See also: [sqlite3_status()] and [sqlite3_db_status()].
  2.3390  */
  2.3391 -SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
  2.3392 +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
  2.3393  
  2.3394  /*
  2.3395  ** CAPI3REF: Status Parameters for prepared statements
  2.3396 @@ -6885,6 +7325,10 @@
  2.3397  ** must be different or else sqlite3_backup_init(D,N,S,M) will fail with
  2.3398  ** an error.
  2.3399  **
  2.3400 +** ^A call to sqlite3_backup_init() will fail, returning SQLITE_ERROR, if 
  2.3401 +** there is already a read or read-write transaction open on the 
  2.3402 +** destination database.
  2.3403 +**
  2.3404  ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is
  2.3405  ** returned and an error code and error message are stored in the
  2.3406  ** destination [database connection] D.
  2.3407 @@ -6977,20 +7421,20 @@
  2.3408  ** is not a permanent error and does not affect the return value of
  2.3409  ** sqlite3_backup_finish().
  2.3410  **
  2.3411 -** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]]
  2.3412 +** [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]]
  2.3413  ** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>
  2.3414  **
  2.3415 -** ^Each call to sqlite3_backup_step() sets two values inside
  2.3416 -** the [sqlite3_backup] object: the number of pages still to be backed
  2.3417 -** up and the total number of pages in the source database file.
  2.3418 -** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces
  2.3419 -** retrieve these two values, respectively.
  2.3420 -**
  2.3421 -** ^The values returned by these functions are only updated by
  2.3422 -** sqlite3_backup_step(). ^If the source database is modified during a backup
  2.3423 -** operation, then the values are not updated to account for any extra
  2.3424 -** pages that need to be updated or the size of the source database file
  2.3425 -** changing.
  2.3426 +** ^The sqlite3_backup_remaining() routine returns the number of pages still
  2.3427 +** to be backed up at the conclusion of the most recent sqlite3_backup_step().
  2.3428 +** ^The sqlite3_backup_pagecount() routine returns the total number of pages
  2.3429 +** in the source database at the conclusion of the most recent
  2.3430 +** sqlite3_backup_step().
  2.3431 +** ^(The values returned by these functions are only updated by
  2.3432 +** sqlite3_backup_step(). If the source database is modified in a way that
  2.3433 +** changes the size of the source database or the number of pages remaining,
  2.3434 +** those changes are not reflected in the output of sqlite3_backup_pagecount()
  2.3435 +** and sqlite3_backup_remaining() until after the next
  2.3436 +** sqlite3_backup_step().)^
  2.3437  **
  2.3438  ** <b>Concurrent Usage of Database Handles</b>
  2.3439  **
  2.3440 @@ -7023,19 +7467,20 @@
  2.3441  ** same time as another thread is invoking sqlite3_backup_step() it is
  2.3442  ** possible that they return invalid values.
  2.3443  */
  2.3444 -SQLITE_API sqlite3_backup *sqlite3_backup_init(
  2.3445 +SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init(
  2.3446    sqlite3 *pDest,                        /* Destination database handle */
  2.3447    const char *zDestName,                 /* Destination database name */
  2.3448    sqlite3 *pSource,                      /* Source database handle */
  2.3449    const char *zSourceName                /* Source database name */
  2.3450  );
  2.3451 -SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);
  2.3452 -SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);
  2.3453 -SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);
  2.3454 -SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
  2.3455 +SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage);
  2.3456 +SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p);
  2.3457 +SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p);
  2.3458 +SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p);
  2.3459  
  2.3460  /*
  2.3461  ** CAPI3REF: Unlock Notification
  2.3462 +** METHOD: sqlite3
  2.3463  **
  2.3464  ** ^When running in shared-cache mode, a database operation may fail with
  2.3465  ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
  2.3466 @@ -7148,7 +7593,7 @@
  2.3467  ** the special "DROP TABLE/INDEX" case, the extended error code is just 
  2.3468  ** SQLITE_LOCKED.)^
  2.3469  */
  2.3470 -SQLITE_API int sqlite3_unlock_notify(
  2.3471 +SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify(
  2.3472    sqlite3 *pBlocked,                          /* Waiting connection */
  2.3473    void (*xNotify)(void **apArg, int nArg),    /* Callback function to invoke */
  2.3474    void *pNotifyArg                            /* Argument to pass to xNotify */
  2.3475 @@ -7163,23 +7608,48 @@
  2.3476  ** strings in a case-independent fashion, using the same definition of "case
  2.3477  ** independence" that SQLite uses internally when comparing identifiers.
  2.3478  */
  2.3479 -SQLITE_API int sqlite3_stricmp(const char *, const char *);
  2.3480 -SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
  2.3481 +SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *, const char *);
  2.3482 +SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *, const char *, int);
  2.3483  
  2.3484  /*
  2.3485  ** CAPI3REF: String Globbing
  2.3486  *
  2.3487 -** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches
  2.3488 -** the glob pattern P, and it returns non-zero if string X does not match
  2.3489 -** the glob pattern P.  ^The definition of glob pattern matching used in
  2.3490 +** ^The [sqlite3_strglob(P,X)] interface returns zero if and only if
  2.3491 +** string X matches the [GLOB] pattern P.
  2.3492 +** ^The definition of [GLOB] pattern matching used in
  2.3493  ** [sqlite3_strglob(P,X)] is the same as for the "X GLOB P" operator in the
  2.3494 -** SQL dialect used by SQLite.  ^The sqlite3_strglob(P,X) function is case
  2.3495 -** sensitive.
  2.3496 +** SQL dialect understood by SQLite.  ^The [sqlite3_strglob(P,X)] function
  2.3497 +** is case sensitive.
  2.3498  **
  2.3499  ** Note that this routine returns zero on a match and non-zero if the strings
  2.3500  ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
  2.3501 -*/
  2.3502 -SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);
  2.3503 +**
  2.3504 +** See also: [sqlite3_strlike()].
  2.3505 +*/
  2.3506 +SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlob, const char *zStr);
  2.3507 +
  2.3508 +/*
  2.3509 +** CAPI3REF: String LIKE Matching
  2.3510 +*
  2.3511 +** ^The [sqlite3_strlike(P,X,E)] interface returns zero if and only if
  2.3512 +** string X matches the [LIKE] pattern P with escape character E.
  2.3513 +** ^The definition of [LIKE] pattern matching used in
  2.3514 +** [sqlite3_strlike(P,X,E)] is the same as for the "X LIKE P ESCAPE E"
  2.3515 +** operator in the SQL dialect understood by SQLite.  ^For "X LIKE P" without
  2.3516 +** the ESCAPE clause, set the E parameter of [sqlite3_strlike(P,X,E)] to 0.
  2.3517 +** ^As with the LIKE operator, the [sqlite3_strlike(P,X,E)] function is case
  2.3518 +** insensitive - equivalent upper and lower case ASCII characters match
  2.3519 +** one another.
  2.3520 +**
  2.3521 +** ^The [sqlite3_strlike(P,X,E)] function matches Unicode characters, though
  2.3522 +** only ASCII characters are case folded.
  2.3523 +**
  2.3524 +** Note that this routine returns zero on a match and non-zero if the strings
  2.3525 +** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
  2.3526 +**
  2.3527 +** See also: [sqlite3_strglob()].
  2.3528 +*/
  2.3529 +SQLITE_API int SQLITE_STDCALL sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc);
  2.3530  
  2.3531  /*
  2.3532  ** CAPI3REF: Error Logging Interface
  2.3533 @@ -7202,18 +7672,17 @@
  2.3534  ** a few hundred characters, it will be truncated to the length of the
  2.3535  ** buffer.
  2.3536  */
  2.3537 -SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
  2.3538 +SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...);
  2.3539  
  2.3540  /*
  2.3541  ** CAPI3REF: Write-Ahead Log Commit Hook
  2.3542 +** METHOD: sqlite3
  2.3543  **
  2.3544  ** ^The [sqlite3_wal_hook()] function is used to register a callback that
  2.3545 -** will be invoked each time a database connection commits data to a
  2.3546 -** [write-ahead log] (i.e. whenever a transaction is committed in
  2.3547 -** [journal_mode | journal_mode=WAL mode]). 
  2.3548 -**
  2.3549 -** ^The callback is invoked by SQLite after the commit has taken place and 
  2.3550 -** the associated write-lock on the database released, so the implementation 
  2.3551 +** is invoked each time data is committed to a database in wal mode.
  2.3552 +**
  2.3553 +** ^(The callback is invoked by SQLite after the commit has taken place and 
  2.3554 +** the associated write-lock on the database released)^, so the implementation 
  2.3555  ** may read, write or [checkpoint] the database as required.
  2.3556  **
  2.3557  ** ^The first parameter passed to the callback function when it is invoked
  2.3558 @@ -7239,7 +7708,7 @@
  2.3559  ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
  2.3560  ** those overwrite any prior [sqlite3_wal_hook()] settings.
  2.3561  */
  2.3562 -SQLITE_API void *sqlite3_wal_hook(
  2.3563 +SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
  2.3564    sqlite3*, 
  2.3565    int(*)(void *,sqlite3*,const char*,int),
  2.3566    void*
  2.3567 @@ -7247,6 +7716,7 @@
  2.3568  
  2.3569  /*
  2.3570  ** CAPI3REF: Configure an auto-checkpoint
  2.3571 +** METHOD: sqlite3
  2.3572  **
  2.3573  ** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around
  2.3574  ** [sqlite3_wal_hook()] that causes any database on [database connection] D
  2.3575 @@ -7273,104 +7743,123 @@
  2.3576  ** is only necessary if the default setting is found to be suboptimal
  2.3577  ** for a particular application.
  2.3578  */
  2.3579 -SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
  2.3580 +SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
  2.3581  
  2.3582  /*
  2.3583  ** CAPI3REF: Checkpoint a database
  2.3584 -**
  2.3585 -** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X
  2.3586 -** on [database connection] D to be [checkpointed].  ^If X is NULL or an
  2.3587 -** empty string, then a checkpoint is run on all databases of
  2.3588 -** connection D.  ^If the database connection D is not in
  2.3589 -** [WAL | write-ahead log mode] then this interface is a harmless no-op.
  2.3590 -** ^The [sqlite3_wal_checkpoint(D,X)] interface initiates a
  2.3591 -** [sqlite3_wal_checkpoint_v2|PASSIVE] checkpoint.
  2.3592 -** Use the [sqlite3_wal_checkpoint_v2()] interface to get a FULL
  2.3593 -** or RESET checkpoint.
  2.3594 -**
  2.3595 -** ^The [wal_checkpoint pragma] can be used to invoke this interface
  2.3596 -** from SQL.  ^The [sqlite3_wal_autocheckpoint()] interface and the
  2.3597 -** [wal_autocheckpoint pragma] can be used to cause this interface to be
  2.3598 -** run whenever the WAL reaches a certain size threshold.
  2.3599 -**
  2.3600 -** See also: [sqlite3_wal_checkpoint_v2()]
  2.3601 -*/
  2.3602 -SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
  2.3603 +** METHOD: sqlite3
  2.3604 +**
  2.3605 +** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
  2.3606 +** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^
  2.3607 +**
  2.3608 +** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the 
  2.3609 +** [write-ahead log] for database X on [database connection] D to be
  2.3610 +** transferred into the database file and for the write-ahead log to
  2.3611 +** be reset.  See the [checkpointing] documentation for addition
  2.3612 +** information.
  2.3613 +**
  2.3614 +** This interface used to be the only way to cause a checkpoint to
  2.3615 +** occur.  But then the newer and more powerful [sqlite3_wal_checkpoint_v2()]
  2.3616 +** interface was added.  This interface is retained for backwards
  2.3617 +** compatibility and as a convenience for applications that need to manually
  2.3618 +** start a callback but which do not need the full power (and corresponding
  2.3619 +** complication) of [sqlite3_wal_checkpoint_v2()].
  2.3620 +*/
  2.3621 +SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
  2.3622  
  2.3623  /*
  2.3624  ** CAPI3REF: Checkpoint a database
  2.3625 -**
  2.3626 -** Run a checkpoint operation on WAL database zDb attached to database 
  2.3627 -** handle db. The specific operation is determined by the value of the 
  2.3628 -** eMode parameter:
  2.3629 +** METHOD: sqlite3
  2.3630 +**
  2.3631 +** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
  2.3632 +** operation on database X of [database connection] D in mode M.  Status
  2.3633 +** information is written back into integers pointed to by L and C.)^
  2.3634 +** ^(The M parameter must be a valid [checkpoint mode]:)^
  2.3635  **
  2.3636  ** <dl>
  2.3637  ** <dt>SQLITE_CHECKPOINT_PASSIVE<dd>
  2.3638 -**   Checkpoint as many frames as possible without waiting for any database 
  2.3639 -**   readers or writers to finish. Sync the db file if all frames in the log
  2.3640 -**   are checkpointed. This mode is the same as calling 
  2.3641 -**   sqlite3_wal_checkpoint(). The [sqlite3_busy_handler|busy-handler callback]
  2.3642 -**   is never invoked.
  2.3643 +**   ^Checkpoint as many frames as possible without waiting for any database 
  2.3644 +**   readers or writers to finish, then sync the database file if all frames 
  2.3645 +**   in the log were checkpointed. ^The [busy-handler callback]
  2.3646 +**   is never invoked in the SQLITE_CHECKPOINT_PASSIVE mode.  
  2.3647 +**   ^On the other hand, passive mode might leave the checkpoint unfinished
  2.3648 +**   if there are concurrent readers or writers.
  2.3649  **
  2.3650  ** <dt>SQLITE_CHECKPOINT_FULL<dd>
  2.3651 -**   This mode blocks (it invokes the
  2.3652 +**   ^This mode blocks (it invokes the
  2.3653  **   [sqlite3_busy_handler|busy-handler callback]) until there is no
  2.3654  **   database writer and all readers are reading from the most recent database
  2.3655 -**   snapshot. It then checkpoints all frames in the log file and syncs the
  2.3656 -**   database file. This call blocks database writers while it is running,
  2.3657 -**   but not database readers.
  2.3658 +**   snapshot. ^It then checkpoints all frames in the log file and syncs the
  2.3659 +**   database file. ^This mode blocks new database writers while it is pending,
  2.3660 +**   but new database readers are allowed to continue unimpeded.
  2.3661  **
  2.3662  ** <dt>SQLITE_CHECKPOINT_RESTART<dd>
  2.3663 -**   This mode works the same way as SQLITE_CHECKPOINT_FULL, except after 
  2.3664 -**   checkpointing the log file it blocks (calls the 
  2.3665 -**   [sqlite3_busy_handler|busy-handler callback])
  2.3666 -**   until all readers are reading from the database file only. This ensures 
  2.3667 -**   that the next client to write to the database file restarts the log file 
  2.3668 -**   from the beginning. This call blocks database writers while it is running,
  2.3669 -**   but not database readers.
  2.3670 +**   ^This mode works the same way as SQLITE_CHECKPOINT_FULL with the addition
  2.3671 +**   that after checkpointing the log file it blocks (calls the 
  2.3672 +**   [busy-handler callback])
  2.3673 +**   until all readers are reading from the database file only. ^This ensures 
  2.3674 +**   that the next writer will restart the log file from the beginning.
  2.3675 +**   ^Like SQLITE_CHECKPOINT_FULL, this mode blocks new
  2.3676 +**   database writer attempts while it is pending, but does not impede readers.
  2.3677 +**
  2.3678 +** <dt>SQLITE_CHECKPOINT_TRUNCATE<dd>
  2.3679 +**   ^This mode works the same way as SQLITE_CHECKPOINT_RESTART with the
  2.3680 +**   addition that it also truncates the log file to zero bytes just prior
  2.3681 +**   to a successful return.
  2.3682  ** </dl>
  2.3683  **
  2.3684 -** If pnLog is not NULL, then *pnLog is set to the total number of frames in
  2.3685 -** the log file before returning. If pnCkpt is not NULL, then *pnCkpt is set to
  2.3686 -** the total number of checkpointed frames (including any that were already
  2.3687 -** checkpointed when this function is called). *pnLog and *pnCkpt may be
  2.3688 -** populated even if sqlite3_wal_checkpoint_v2() returns other than SQLITE_OK.
  2.3689 -** If no values are available because of an error, they are both set to -1
  2.3690 -** before returning to communicate this to the caller.
  2.3691 -**
  2.3692 -** All calls obtain an exclusive "checkpoint" lock on the database file. If
  2.3693 +** ^If pnLog is not NULL, then *pnLog is set to the total number of frames in
  2.3694 +** the log file or to -1 if the checkpoint could not run because
  2.3695 +** of an error or because the database is not in [WAL mode]. ^If pnCkpt is not
  2.3696 +** NULL,then *pnCkpt is set to the total number of checkpointed frames in the
  2.3697 +** log file (including any that were already checkpointed before the function
  2.3698 +** was called) or to -1 if the checkpoint could not run due to an error or
  2.3699 +** because the database is not in WAL mode. ^Note that upon successful
  2.3700 +** completion of an SQLITE_CHECKPOINT_TRUNCATE, the log file will have been
  2.3701 +** truncated to zero bytes and so both *pnLog and *pnCkpt will be set to zero.
  2.3702 +**
  2.3703 +** ^All calls obtain an exclusive "checkpoint" lock on the database file. ^If
  2.3704  ** any other process is running a checkpoint operation at the same time, the 
  2.3705 -** lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a 
  2.3706 +** lock cannot be obtained and SQLITE_BUSY is returned. ^Even if there is a 
  2.3707  ** busy-handler configured, it will not be invoked in this case.
  2.3708  **
  2.3709 -** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive 
  2.3710 -** "writer" lock on the database file. If the writer lock cannot be obtained
  2.3711 -** immediately, and a busy-handler is configured, it is invoked and the writer
  2.3712 -** lock retried until either the busy-handler returns 0 or the lock is
  2.3713 -** successfully obtained. The busy-handler is also invoked while waiting for
  2.3714 -** database readers as described above. If the busy-handler returns 0 before
  2.3715 +** ^The SQLITE_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the 
  2.3716 +** exclusive "writer" lock on the database file. ^If the writer lock cannot be
  2.3717 +** obtained immediately, and a busy-handler is configured, it is invoked and
  2.3718 +** the writer lock retried until either the busy-handler returns 0 or the lock
  2.3719 +** is successfully obtained. ^The busy-handler is also invoked while waiting for
  2.3720 +** database readers as described above. ^If the busy-handler returns 0 before
  2.3721  ** the writer lock is obtained or while waiting for database readers, the
  2.3722  ** checkpoint operation proceeds from that point in the same way as 
  2.3723  ** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible 
  2.3724 -** without blocking any further. SQLITE_BUSY is returned in this case.
  2.3725 -**
  2.3726 -** If parameter zDb is NULL or points to a zero length string, then the
  2.3727 -** specified operation is attempted on all WAL databases. In this case the
  2.3728 -** values written to output parameters *pnLog and *pnCkpt are undefined. If 
  2.3729 +** without blocking any further. ^SQLITE_BUSY is returned in this case.
  2.3730 +**
  2.3731 +** ^If parameter zDb is NULL or points to a zero length string, then the
  2.3732 +** specified operation is attempted on all WAL databases [attached] to 
  2.3733 +** [database connection] db.  In this case the
  2.3734 +** values written to output parameters *pnLog and *pnCkpt are undefined. ^If 
  2.3735  ** an SQLITE_BUSY error is encountered when processing one or more of the 
  2.3736  ** attached WAL databases, the operation is still attempted on any remaining 
  2.3737 -** attached databases and SQLITE_BUSY is returned to the caller. If any other 
  2.3738 +** attached databases and SQLITE_BUSY is returned at the end. ^If any other 
  2.3739  ** error occurs while processing an attached database, processing is abandoned 
  2.3740 -** and the error code returned to the caller immediately. If no error 
  2.3741 +** and the error code is returned to the caller immediately. ^If no error 
  2.3742  ** (SQLITE_BUSY or otherwise) is encountered while processing the attached 
  2.3743  ** databases, SQLITE_OK is returned.
  2.3744  **
  2.3745 -** If database zDb is the name of an attached database that is not in WAL
  2.3746 -** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. If
  2.3747 +** ^If database zDb is the name of an attached database that is not in WAL
  2.3748 +** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. ^If
  2.3749  ** zDb is not NULL (or a zero length string) and is not the name of any
  2.3750  ** attached database, SQLITE_ERROR is returned to the caller.
  2.3751 -*/
  2.3752 -SQLITE_API int sqlite3_wal_checkpoint_v2(
  2.3753 +**
  2.3754 +** ^Unless it returns SQLITE_MISUSE,
  2.3755 +** the sqlite3_wal_checkpoint_v2() interface
  2.3756 +** sets the error information that is queried by
  2.3757 +** [sqlite3_errcode()] and [sqlite3_errmsg()].
  2.3758 +**
  2.3759 +** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
  2.3760 +** from SQL.
  2.3761 +*/
  2.3762 +SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
  2.3763    sqlite3 *db,                    /* Database handle */
  2.3764    const char *zDb,                /* Name of attached database (or NULL) */
  2.3765    int eMode,                      /* SQLITE_CHECKPOINT_* value */
  2.3766 @@ -7379,16 +7868,18 @@
  2.3767  );
  2.3768  
  2.3769  /*
  2.3770 -** CAPI3REF: Checkpoint operation parameters
  2.3771 -**
  2.3772 -** These constants can be used as the 3rd parameter to
  2.3773 -** [sqlite3_wal_checkpoint_v2()].  See the [sqlite3_wal_checkpoint_v2()]
  2.3774 -** documentation for additional information about the meaning and use of
  2.3775 -** each of these values.
  2.3776 -*/
  2.3777 -#define SQLITE_CHECKPOINT_PASSIVE 0
  2.3778 -#define SQLITE_CHECKPOINT_FULL    1
  2.3779 -#define SQLITE_CHECKPOINT_RESTART 2
  2.3780 +** CAPI3REF: Checkpoint Mode Values
  2.3781 +** KEYWORDS: {checkpoint mode}
  2.3782 +**
  2.3783 +** These constants define all valid values for the "checkpoint mode" passed
  2.3784 +** as the third parameter to the [sqlite3_wal_checkpoint_v2()] interface.
  2.3785 +** See the [sqlite3_wal_checkpoint_v2()] documentation for details on the
  2.3786 +** meaning of each of these checkpoint modes.
  2.3787 +*/
  2.3788 +#define SQLITE_CHECKPOINT_PASSIVE  0  /* Do as much as possible w/o blocking */
  2.3789 +#define SQLITE_CHECKPOINT_FULL     1  /* Wait for writers, then checkpoint */
  2.3790 +#define SQLITE_CHECKPOINT_RESTART  2  /* Like FULL but wait for for readers */
  2.3791 +#define SQLITE_CHECKPOINT_TRUNCATE 3  /* Like RESTART but also truncate WAL */
  2.3792  
  2.3793  /*
  2.3794  ** CAPI3REF: Virtual Table Interface Configuration
  2.3795 @@ -7404,7 +7895,7 @@
  2.3796  ** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].)  Further options
  2.3797  ** may be added in the future.
  2.3798  */
  2.3799 -SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
  2.3800 +SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3*, int op, ...);
  2.3801  
  2.3802  /*
  2.3803  ** CAPI3REF: Virtual Table Configuration Options
  2.3804 @@ -7457,7 +7948,7 @@
  2.3805  ** of the SQL statement that triggered the call to the [xUpdate] method of the
  2.3806  ** [virtual table].
  2.3807  */
  2.3808 -SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
  2.3809 +SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *);
  2.3810  
  2.3811  /*
  2.3812  ** CAPI3REF: Conflict resolution modes
  2.3813 @@ -7477,7 +7968,232 @@
  2.3814  /* #define SQLITE_ABORT 4  // Also an error code */
  2.3815  #define SQLITE_REPLACE  5
  2.3816  
  2.3817 -
  2.3818 +/*
  2.3819 +** CAPI3REF: Prepared Statement Scan Status Opcodes
  2.3820 +** KEYWORDS: {scanstatus options}
  2.3821 +**
  2.3822 +** The following constants can be used for the T parameter to the
  2.3823 +** [sqlite3_stmt_scanstatus(S,X,T,V)] interface.  Each constant designates a
  2.3824 +** different metric for sqlite3_stmt_scanstatus() to return.
  2.3825 +**
  2.3826 +** When the value returned to V is a string, space to hold that string is
  2.3827 +** managed by the prepared statement S and will be automatically freed when
  2.3828 +** S is finalized.
  2.3829 +**
  2.3830 +** <dl>
  2.3831 +** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>
  2.3832 +** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be
  2.3833 +** set to the total number of times that the X-th loop has run.</dd>
  2.3834 +**
  2.3835 +** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt>
  2.3836 +** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set
  2.3837 +** to the total number of rows examined by all iterations of the X-th loop.</dd>
  2.3838 +**
  2.3839 +** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>
  2.3840 +** <dd>^The "double" variable pointed to by the T parameter will be set to the
  2.3841 +** query planner's estimate for the average number of rows output from each
  2.3842 +** iteration of the X-th loop.  If the query planner's estimates was accurate,
  2.3843 +** then this value will approximate the quotient NVISIT/NLOOP and the
  2.3844 +** product of this value for all prior loops with the same SELECTID will
  2.3845 +** be the NLOOP value for the current loop.
  2.3846 +**
  2.3847 +** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>
  2.3848 +** <dd>^The "const char *" variable pointed to by the T parameter will be set
  2.3849 +** to a zero-terminated UTF-8 string containing the name of the index or table
  2.3850 +** used for the X-th loop.
  2.3851 +**
  2.3852 +** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>
  2.3853 +** <dd>^The "const char *" variable pointed to by the T parameter will be set
  2.3854 +** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]
  2.3855 +** description for the X-th loop.
  2.3856 +**
  2.3857 +** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt>
  2.3858 +** <dd>^The "int" variable pointed to by the T parameter will be set to the
  2.3859 +** "select-id" for the X-th loop.  The select-id identifies which query or
  2.3860 +** subquery the loop is part of.  The main query has a select-id of zero.
  2.3861 +** The select-id is the same value as is output in the first column
  2.3862 +** of an [EXPLAIN QUERY PLAN] query.
  2.3863 +** </dl>
  2.3864 +*/
  2.3865 +#define SQLITE_SCANSTAT_NLOOP    0
  2.3866 +#define SQLITE_SCANSTAT_NVISIT   1
  2.3867 +#define SQLITE_SCANSTAT_EST      2
  2.3868 +#define SQLITE_SCANSTAT_NAME     3
  2.3869 +#define SQLITE_SCANSTAT_EXPLAIN  4
  2.3870 +#define SQLITE_SCANSTAT_SELECTID 5
  2.3871 +
  2.3872 +/*
  2.3873 +** CAPI3REF: Prepared Statement Scan Status
  2.3874 +** METHOD: sqlite3_stmt
  2.3875 +**
  2.3876 +** This interface returns information about the predicted and measured
  2.3877 +** performance for pStmt.  Advanced applications can use this
  2.3878 +** interface to compare the predicted and the measured performance and
  2.3879 +** issue warnings and/or rerun [ANALYZE] if discrepancies are found.
  2.3880 +**
  2.3881 +** Since this interface is expected to be rarely used, it is only
  2.3882 +** available if SQLite is compiled using the [SQLITE_ENABLE_STMT_SCANSTATUS]
  2.3883 +** compile-time option.
  2.3884 +**
  2.3885 +** The "iScanStatusOp" parameter determines which status information to return.
  2.3886 +** The "iScanStatusOp" must be one of the [scanstatus options] or the behavior
  2.3887 +** of this interface is undefined.
  2.3888 +** ^The requested measurement is written into a variable pointed to by
  2.3889 +** the "pOut" parameter.
  2.3890 +** Parameter "idx" identifies the specific loop to retrieve statistics for.
  2.3891 +** Loops are numbered starting from zero. ^If idx is out of range - less than
  2.3892 +** zero or greater than or equal to the total number of loops used to implement
  2.3893 +** the statement - a non-zero value is returned and the variable that pOut
  2.3894 +** points to is unchanged.
  2.3895 +**
  2.3896 +** ^Statistics might not be available for all loops in all statements. ^In cases
  2.3897 +** where there exist loops with no available statistics, this function behaves
  2.3898 +** as if the loop did not exist - it returns non-zero and leave the variable
  2.3899 +** that pOut points to unchanged.
  2.3900 +**
  2.3901 +** See also: [sqlite3_stmt_scanstatus_reset()]
  2.3902 +*/
  2.3903 +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_scanstatus(
  2.3904 +  sqlite3_stmt *pStmt,      /* Prepared statement for which info desired */
  2.3905 +  int idx,                  /* Index of loop to report on */
  2.3906 +  int iScanStatusOp,        /* Information desired.  SQLITE_SCANSTAT_* */
  2.3907 +  void *pOut                /* Result written here */
  2.3908 +);     
  2.3909 +
  2.3910 +/*
  2.3911 +** CAPI3REF: Zero Scan-Status Counters
  2.3912 +** METHOD: sqlite3_stmt
  2.3913 +**
  2.3914 +** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.
  2.3915 +**
  2.3916 +** This API is only available if the library is built with pre-processor
  2.3917 +** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.
  2.3918 +*/
  2.3919 +SQLITE_API void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
  2.3920 +
  2.3921 +/*
  2.3922 +** CAPI3REF: Flush caches to disk mid-transaction
  2.3923 +**
  2.3924 +** ^If a write-transaction is open on [database connection] D when the
  2.3925 +** [sqlite3_db_cacheflush(D)] interface invoked, any dirty
  2.3926 +** pages in the pager-cache that are not currently in use are written out 
  2.3927 +** to disk. A dirty page may be in use if a database cursor created by an
  2.3928 +** active SQL statement is reading from it, or if it is page 1 of a database
  2.3929 +** file (page 1 is always "in use").  ^The [sqlite3_db_cacheflush(D)]
  2.3930 +** interface flushes caches for all schemas - "main", "temp", and
  2.3931 +** any [attached] databases.
  2.3932 +**
  2.3933 +** ^If this function needs to obtain extra database locks before dirty pages 
  2.3934 +** can be flushed to disk, it does so. ^If those locks cannot be obtained 
  2.3935 +** immediately and there is a busy-handler callback configured, it is invoked
  2.3936 +** in the usual manner. ^If the required lock still cannot be obtained, then
  2.3937 +** the database is skipped and an attempt made to flush any dirty pages
  2.3938 +** belonging to the next (if any) database. ^If any databases are skipped
  2.3939 +** because locks cannot be obtained, but no other error occurs, this
  2.3940 +** function returns SQLITE_BUSY.
  2.3941 +**
  2.3942 +** ^If any other error occurs while flushing dirty pages to disk (for
  2.3943 +** example an IO error or out-of-memory condition), then processing is
  2.3944 +** abandoned and an SQLite [error code] is returned to the caller immediately.
  2.3945 +**
  2.3946 +** ^Otherwise, if no error occurs, [sqlite3_db_cacheflush()] returns SQLITE_OK.
  2.3947 +**
  2.3948 +** ^This function does not set the database handle error code or message
  2.3949 +** returned by the [sqlite3_errcode()] and [sqlite3_errmsg()] functions.
  2.3950 +*/
  2.3951 +SQLITE_API int SQLITE_STDCALL sqlite3_db_cacheflush(sqlite3*);
  2.3952 +
  2.3953 +/*
  2.3954 +** CAPI3REF: Database Snapshot
  2.3955 +** KEYWORDS: {snapshot}
  2.3956 +** EXPERIMENTAL
  2.3957 +**
  2.3958 +** An instance of the snapshot object records the state of a [WAL mode]
  2.3959 +** database for some specific point in history.
  2.3960 +**
  2.3961 +** In [WAL mode], multiple [database connections] that are open on the
  2.3962 +** same database file can each be reading a different historical version
  2.3963 +** of the database file.  When a [database connection] begins a read
  2.3964 +** transaction, that connection sees an unchanging copy of the database
  2.3965 +** as it existed for the point in time when the transaction first started.
  2.3966 +** Subsequent changes to the database from other connections are not seen
  2.3967 +** by the reader until a new read transaction is started.
  2.3968 +**
  2.3969 +** The sqlite3_snapshot object records state information about an historical
  2.3970 +** version of the database file so that it is possible to later open a new read
  2.3971 +** transaction that sees that historical version of the database rather than
  2.3972 +** the most recent version.
  2.3973 +**
  2.3974 +** The constructor for this object is [sqlite3_snapshot_get()].  The
  2.3975 +** [sqlite3_snapshot_open()] method causes a fresh read transaction to refer
  2.3976 +** to an historical snapshot (if possible).  The destructor for 
  2.3977 +** sqlite3_snapshot objects is [sqlite3_snapshot_free()].
  2.3978 +*/
  2.3979 +typedef struct sqlite3_snapshot sqlite3_snapshot;
  2.3980 +
  2.3981 +/*
  2.3982 +** CAPI3REF: Record A Database Snapshot
  2.3983 +** EXPERIMENTAL
  2.3984 +**
  2.3985 +** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a
  2.3986 +** new [sqlite3_snapshot] object that records the current state of
  2.3987 +** schema S in database connection D.  ^On success, the
  2.3988 +** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
  2.3989 +** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.
  2.3990 +** ^If schema S of [database connection] D is not a [WAL mode] database
  2.3991 +** that is in a read transaction, then [sqlite3_snapshot_get(D,S,P)]
  2.3992 +** leaves the *P value unchanged and returns an appropriate [error code].
  2.3993 +**
  2.3994 +** The [sqlite3_snapshot] object returned from a successful call to
  2.3995 +** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()]
  2.3996 +** to avoid a memory leak.
  2.3997 +**
  2.3998 +** The [sqlite3_snapshot_get()] interface is only available when the
  2.3999 +** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
  2.4000 +*/
  2.4001 +SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_snapshot_get(
  2.4002 +  sqlite3 *db,
  2.4003 +  const char *zSchema,
  2.4004 +  sqlite3_snapshot **ppSnapshot
  2.4005 +);
  2.4006 +
  2.4007 +/*
  2.4008 +** CAPI3REF: Start a read transaction on an historical snapshot
  2.4009 +** EXPERIMENTAL
  2.4010 +**
  2.4011 +** ^The [sqlite3_snapshot_open(D,S,P)] interface attempts to move the
  2.4012 +** read transaction that is currently open on schema S of
  2.4013 +** [database connection] D so that it refers to historical [snapshot] P.
  2.4014 +** ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK on success
  2.4015 +** or an appropriate [error code] if it fails.
  2.4016 +**
  2.4017 +** ^In order to succeed, a call to [sqlite3_snapshot_open(D,S,P)] must be
  2.4018 +** the first operation, apart from other sqlite3_snapshot_open() calls,
  2.4019 +** following the [BEGIN] that starts a new read transaction.
  2.4020 +** ^A [snapshot] will fail to open if it has been overwritten by a 
  2.4021 +** [checkpoint].  
  2.4022 +**
  2.4023 +** The [sqlite3_snapshot_open()] interface is only available when the
  2.4024 +** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
  2.4025 +*/
  2.4026 +SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_snapshot_open(
  2.4027 +  sqlite3 *db,
  2.4028 +  const char *zSchema,
  2.4029 +  sqlite3_snapshot *pSnapshot
  2.4030 +);
  2.4031 +
  2.4032 +/*
  2.4033 +** CAPI3REF: Destroy a snapshot
  2.4034 +** EXPERIMENTAL
  2.4035 +**
  2.4036 +** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.
  2.4037 +** The application must eventually free every [sqlite3_snapshot] object
  2.4038 +** using this routine to avoid a memory leak.
  2.4039 +**
  2.4040 +** The [sqlite3_snapshot_free()] interface is only available when the
  2.4041 +** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
  2.4042 +*/
  2.4043 +SQLITE_API SQLITE_EXPERIMENTAL void SQLITE_STDCALL sqlite3_snapshot_free(sqlite3_snapshot*);
  2.4044  
  2.4045  /*
  2.4046  ** Undo the hack that converts floating point types to integer for
  2.4047 @@ -7531,7 +8247,7 @@
  2.4048  **
  2.4049  **   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
  2.4050  */
  2.4051 -SQLITE_API int sqlite3_rtree_geometry_callback(
  2.4052 +SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback(
  2.4053    sqlite3 *db,
  2.4054    const char *zGeom,
  2.4055    int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),
  2.4056 @@ -7557,7 +8273,7 @@
  2.4057  **
  2.4058  **   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)
  2.4059  */
  2.4060 -SQLITE_API int sqlite3_rtree_query_callback(
  2.4061 +SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback(
  2.4062    sqlite3 *db,
  2.4063    const char *zQueryFunc,
  2.4064    int (*xQueryFunc)(sqlite3_rtree_query_info*),
  2.4065 @@ -7591,6 +8307,8 @@
  2.4066    int eParentWithin;                /* Visibility of parent node */
  2.4067    int eWithin;                      /* OUT: Visiblity */
  2.4068    sqlite3_rtree_dbl rScore;         /* OUT: Write the score here */
  2.4069 +  /* The following fields are only available in 3.8.11 and later */
  2.4070 +  sqlite3_value **apSqlParam;       /* Original SQL values of parameters */
  2.4071  };
  2.4072  
  2.4073  /*
  2.4074 @@ -7607,6 +8325,584 @@
  2.4075  
  2.4076  #endif  /* ifndef _SQLITE3RTREE_H_ */
  2.4077  
  2.4078 +/*
  2.4079 +** 2014 May 31
  2.4080 +**
  2.4081 +** The author disclaims copyright to this source code.  In place of
  2.4082 +** a legal notice, here is a blessing:
  2.4083 +**
  2.4084 +**    May you do good and not evil.
  2.4085 +**    May you find forgiveness for yourself and forgive others.
  2.4086 +**    May you share freely, never taking more than you give.
  2.4087 +**
  2.4088 +******************************************************************************
  2.4089 +**
  2.4090 +** Interfaces to extend FTS5. Using the interfaces defined in this file, 
  2.4091 +** FTS5 may be extended with:
  2.4092 +**
  2.4093 +**     * custom tokenizers, and
  2.4094 +**     * custom auxiliary functions.
  2.4095 +*/
  2.4096 +
  2.4097 +
  2.4098 +#ifndef _FTS5_H
  2.4099 +#define _FTS5_H
  2.4100 +
  2.4101 +
  2.4102 +#if 0
  2.4103 +extern "C" {
  2.4104 +#endif
  2.4105 +
  2.4106 +/*************************************************************************
  2.4107 +** CUSTOM AUXILIARY FUNCTIONS
  2.4108 +**
  2.4109 +** Virtual table implementations may overload SQL functions by implementing
  2.4110 +** the sqlite3_module.xFindFunction() method.
  2.4111 +*/
  2.4112 +
  2.4113 +typedef struct Fts5ExtensionApi Fts5ExtensionApi;
  2.4114 +typedef struct Fts5Context Fts5Context;
  2.4115 +typedef struct Fts5PhraseIter Fts5PhraseIter;
  2.4116 +
  2.4117 +typedef void (*fts5_extension_function)(
  2.4118 +  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */
  2.4119 +  Fts5Context *pFts,              /* First arg to pass to pApi functions */
  2.4120 +  sqlite3_context *pCtx,          /* Context for returning result/error */
  2.4121 +  int nVal,                       /* Number of values in apVal[] array */
  2.4122 +  sqlite3_value **apVal           /* Array of trailing arguments */
  2.4123 +);
  2.4124 +
  2.4125 +struct Fts5PhraseIter {
  2.4126 +  const unsigned char *a;
  2.4127 +  const unsigned char *b;
  2.4128 +};
  2.4129 +
  2.4130 +/*
  2.4131 +** EXTENSION API FUNCTIONS
  2.4132 +**
  2.4133 +** xUserData(pFts):
  2.4134 +**   Return a copy of the context pointer the extension function was 
  2.4135 +**   registered with.
  2.4136 +**
  2.4137 +** xColumnTotalSize(pFts, iCol, pnToken):
  2.4138 +**   If parameter iCol is less than zero, set output variable *pnToken
  2.4139 +**   to the total number of tokens in the FTS5 table. Or, if iCol is
  2.4140 +**   non-negative but less than the number of columns in the table, return
  2.4141 +**   the total number of tokens in column iCol, considering all rows in 
  2.4142 +**   the FTS5 table.
  2.4143 +**
  2.4144 +**   If parameter iCol is greater than or equal to the number of columns
  2.4145 +**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
  2.4146 +**   an OOM condition or IO error), an appropriate SQLite error code is 
  2.4147 +**   returned.
  2.4148 +**
  2.4149 +** xColumnCount(pFts):
  2.4150 +**   Return the number of columns in the table.
  2.4151 +**
  2.4152 +** xColumnSize(pFts, iCol, pnToken):
  2.4153 +**   If parameter iCol is less than zero, set output variable *pnToken
  2.4154 +**   to the total number of tokens in the current row. Or, if iCol is
  2.4155 +**   non-negative but less than the number of columns in the table, set
  2.4156 +**   *pnToken to the number of tokens in column iCol of the current row.
  2.4157 +**
  2.4158 +**   If parameter iCol is greater than or equal to the number of columns
  2.4159 +**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
  2.4160 +**   an OOM condition or IO error), an appropriate SQLite error code is 
  2.4161 +**   returned.
  2.4162 +**
  2.4163 +**   This function may be quite inefficient if used with an FTS5 table
  2.4164 +**   created with the "columnsize=0" option.
  2.4165 +**
  2.4166 +** xColumnText:
  2.4167 +**   This function attempts to retrieve the text of column iCol of the
  2.4168 +**   current document. If successful, (*pz) is set to point to a buffer
  2.4169 +**   containing the text in utf-8 encoding, (*pn) is set to the size in bytes
  2.4170 +**   (not characters) of the buffer and SQLITE_OK is returned. Otherwise,
  2.4171 +**   if an error occurs, an SQLite error code is returned and the final values
  2.4172 +**   of (*pz) and (*pn) are undefined.
  2.4173 +**
  2.4174 +** xPhraseCount:
  2.4175 +**   Returns the number of phrases in the current query expression.
  2.4176 +**
  2.4177 +** xPhraseSize:
  2.4178 +**   Returns the number of tokens in phrase iPhrase of the query. Phrases
  2.4179 +**   are numbered starting from zero.
  2.4180 +**
  2.4181 +** xInstCount:
  2.4182 +**   Set *pnInst to the total number of occurrences of all phrases within
  2.4183 +**   the query within the current row. Return SQLITE_OK if successful, or
  2.4184 +**   an error code (i.e. SQLITE_NOMEM) if an error occurs.
  2.4185 +**
  2.4186 +**   This API can be quite slow if used with an FTS5 table created with the
  2.4187 +**   "detail=none" or "detail=column" option. If the FTS5 table is created 
  2.4188 +**   with either "detail=none" or "detail=column" and "content=" option 
  2.4189 +**   (i.e. if it is a contentless table), then this API always returns 0.
  2.4190 +**
  2.4191 +** xInst:
  2.4192 +**   Query for the details of phrase match iIdx within the current row.
  2.4193 +**   Phrase matches are numbered starting from zero, so the iIdx argument
  2.4194 +**   should be greater than or equal to zero and smaller than the value
  2.4195 +**   output by xInstCount().
  2.4196 +**
  2.4197 +**   Usually, output parameter *piPhrase is set to the phrase number, *piCol
  2.4198 +**   to the column in which it occurs and *piOff the token offset of the
  2.4199 +**   first token of the phrase. The exception is if the table was created
  2.4200 +**   with the offsets=0 option specified. In this case *piOff is always
  2.4201 +**   set to -1.
  2.4202 +**
  2.4203 +**   Returns SQLITE_OK if successful, or an error code (i.e. SQLITE_NOMEM) 
  2.4204 +**   if an error occurs.
  2.4205 +**
  2.4206 +**   This API can be quite slow if used with an FTS5 table created with the
  2.4207 +**   "detail=none" or "detail=column" option. 
  2.4208 +**
  2.4209 +** xRowid:
  2.4210 +**   Returns the rowid of the current row.
  2.4211 +**
  2.4212 +** xTokenize:
  2.4213 +**   Tokenize text using the tokenizer belonging to the FTS5 table.
  2.4214 +**
  2.4215 +** xQueryPhrase(pFts5, iPhrase, pUserData, xCallback):
  2.4216 +**   This API function is used to query the FTS table for phrase iPhrase
  2.4217 +**   of the current query. Specifically, a query equivalent to:
  2.4218 +**
  2.4219 +**       ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid
  2.4220 +**
  2.4221 +**   with $p set to a phrase equivalent to the phrase iPhrase of the
  2.4222 +**   current query is executed. For each row visited, the callback function
  2.4223 +**   passed as the fourth argument is invoked. The context and API objects 
  2.4224 +**   passed to the callback function may be used to access the properties of
  2.4225 +**   each matched row. Invoking Api.xUserData() returns a copy of the pointer
  2.4226 +**   passed as the third argument to pUserData.
  2.4227 +**
  2.4228 +**   If the callback function returns any value other than SQLITE_OK, the
  2.4229 +**   query is abandoned and the xQueryPhrase function returns immediately.
  2.4230 +**   If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK.
  2.4231 +**   Otherwise, the error code is propagated upwards.
  2.4232 +**
  2.4233 +**   If the query runs to completion without incident, SQLITE_OK is returned.
  2.4234 +**   Or, if some error occurs before the query completes or is aborted by
  2.4235 +**   the callback, an SQLite error code is returned.
  2.4236 +**
  2.4237 +**
  2.4238 +** xSetAuxdata(pFts5, pAux, xDelete)
  2.4239 +**
  2.4240 +**   Save the pointer passed as the second argument as the extension functions 
  2.4241 +**   "auxiliary data". The pointer may then be retrieved by the current or any
  2.4242 +**   future invocation of the same fts5 extension function made as part of
  2.4243 +**   of the same MATCH query using the xGetAuxdata() API.
  2.4244 +**
  2.4245 +**   Each extension function is allocated a single auxiliary data slot for
  2.4246 +**   each FTS query (MATCH expression). If the extension function is invoked 
  2.4247 +**   more than once for a single FTS query, then all invocations share a 
  2.4248 +**   single auxiliary data context.
  2.4249 +**
  2.4250 +**   If there is already an auxiliary data pointer when this function is
  2.4251 +**   invoked, then it is replaced by the new pointer. If an xDelete callback
  2.4252 +**   was specified along with the original pointer, it is invoked at this
  2.4253 +**   point.
  2.4254 +**
  2.4255 +**   The xDelete callback, if one is specified, is also invoked on the
  2.4256 +**   auxiliary data pointer after the FTS5 query has finished.
  2.4257 +**
  2.4258 +**   If an error (e.g. an OOM condition) occurs within this function, an
  2.4259 +**   the auxiliary data is set to NULL and an error code returned. If the
  2.4260 +**   xDelete parameter was not NULL, it is invoked on the auxiliary data
  2.4261 +**   pointer before returning.
  2.4262 +**
  2.4263 +**
  2.4264 +** xGetAuxdata(pFts5, bClear)
  2.4265 +**
  2.4266 +**   Returns the current auxiliary data pointer for the fts5 extension 
  2.4267 +**   function. See the xSetAuxdata() method for details.
  2.4268 +**
  2.4269 +**   If the bClear argument is non-zero, then the auxiliary data is cleared
  2.4270 +**   (set to NULL) before this function returns. In this case the xDelete,
  2.4271 +**   if any, is not invoked.
  2.4272 +**
  2.4273 +**
  2.4274 +** xRowCount(pFts5, pnRow)
  2.4275 +**
  2.4276 +**   This function is used to retrieve the total number of rows in the table.
  2.4277 +**   In other words, the same value that would be returned by:
  2.4278 +**
  2.4279 +**        SELECT count(*) FROM ftstable;
  2.4280 +**
  2.4281 +** xPhraseFirst()
  2.4282 +**   This function is used, along with type Fts5PhraseIter and the xPhraseNext
  2.4283 +**   method, to iterate through all instances of a single query phrase within
  2.4284 +**   the current row. This is the same information as is accessible via the
  2.4285 +**   xInstCount/xInst APIs. While the xInstCount/xInst APIs are more convenient
  2.4286 +**   to use, this API may be faster under some circumstances. To iterate 
  2.4287 +**   through instances of phrase iPhrase, use the following code:
  2.4288 +**
  2.4289 +**       Fts5PhraseIter iter;
  2.4290 +**       int iCol, iOff;
  2.4291 +**       for(pApi->xPhraseFirst(pFts, iPhrase, &iter, &iCol, &iOff);
  2.4292 +**           iCol>=0;
  2.4293 +**           pApi->xPhraseNext(pFts, &iter, &iCol, &iOff)
  2.4294 +**       ){
  2.4295 +**         // An instance of phrase iPhrase at offset iOff of column iCol
  2.4296 +**       }
  2.4297 +**
  2.4298 +**   The Fts5PhraseIter structure is defined above. Applications should not
  2.4299 +**   modify this structure directly - it should only be used as shown above
  2.4300 +**   with the xPhraseFirst() and xPhraseNext() API methods (and by
  2.4301 +**   xPhraseFirstColumn() and xPhraseNextColumn() as illustrated below).
  2.4302 +**
  2.4303 +**   This API can be quite slow if used with an FTS5 table created with the
  2.4304 +**   "detail=none" or "detail=column" option. If the FTS5 table is created 
  2.4305 +**   with either "detail=none" or "detail=column" and "content=" option 
  2.4306 +**   (i.e. if it is a contentless table), then this API always iterates
  2.4307 +**   through an empty set (all calls to xPhraseFirst() set iCol to -1).
  2.4308 +**
  2.4309 +** xPhraseNext()
  2.4310 +**   See xPhraseFirst above.
  2.4311 +**
  2.4312 +** xPhraseFirstColumn()
  2.4313 +**   This function and xPhraseNextColumn() are similar to the xPhraseFirst()
  2.4314 +**   and xPhraseNext() APIs described above. The difference is that instead
  2.4315 +**   of iterating through all instances of a phrase in the current row, these
  2.4316 +**   APIs are used to iterate through the set of columns in the current row
  2.4317 +**   that contain one or more instances of a specified phrase. For example:
  2.4318 +**
  2.4319 +**       Fts5PhraseIter iter;
  2.4320 +**       int iCol;
  2.4321 +**       for(pApi->xPhraseFirstColumn(pFts, iPhrase, &iter, &iCol);
  2.4322 +**           iCol>=0;
  2.4323 +**           pApi->xPhraseNextColumn(pFts, &iter, &iCol)
  2.4324 +**       ){
  2.4325 +**         // Column iCol contains at least one instance of phrase iPhrase
  2.4326 +**       }
  2.4327 +**
  2.4328 +**   This API can be quite slow if used with an FTS5 table created with the
  2.4329 +**   "detail=none" option. If the FTS5 table is created with either 
  2.4330 +**   "detail=none" "content=" option (i.e. if it is a contentless table), 
  2.4331 +**   then this API always iterates through an empty set (all calls to 
  2.4332 +**   xPhraseFirstColumn() set iCol to -1).
  2.4333 +**
  2.4334 +**   The information accessed using this API and its companion
  2.4335 +**   xPhraseFirstColumn() may also be obtained using xPhraseFirst/xPhraseNext
  2.4336 +**   (or xInst/xInstCount). The chief advantage of this API is that it is
  2.4337 +**   significantly more efficient than those alternatives when used with
  2.4338 +**   "detail=column" tables.  
  2.4339 +**
  2.4340 +** xPhraseNextColumn()
  2.4341 +**   See xPhraseFirstColumn above.
  2.4342 +*/
  2.4343 +struct Fts5ExtensionApi {
  2.4344 +  int iVersion;                   /* Currently always set to 3 */
  2.4345 +
  2.4346 +  void *(*xUserData)(Fts5Context*);
  2.4347 +
  2.4348 +  int (*xColumnCount)(Fts5Context*);
  2.4349 +  int (*xRowCount)(Fts5Context*, sqlite3_int64 *pnRow);
  2.4350 +  int (*xColumnTotalSize)(Fts5Context*, int iCol, sqlite3_int64 *pnToken);
  2.4351 +
  2.4352 +  int (*xTokenize)(Fts5Context*, 
  2.4353 +    const char *pText, int nText, /* Text to tokenize */
  2.4354 +    void *pCtx,                   /* Context passed to xToken() */
  2.4355 +    int (*xToken)(void*, int, const char*, int, int, int)       /* Callback */
  2.4356 +  );
  2.4357 +
  2.4358 +  int (*xPhraseCount)(Fts5Context*);
  2.4359 +  int (*xPhraseSize)(Fts5Context*, int iPhrase);
  2.4360 +
  2.4361 +  int (*xInstCount)(Fts5Context*, int *pnInst);
  2.4362 +  int (*xInst)(Fts5Context*, int iIdx, int *piPhrase, int *piCol, int *piOff);
  2.4363 +
  2.4364 +  sqlite3_int64 (*xRowid)(Fts5Context*);
  2.4365 +  int (*xColumnText)(Fts5Context*, int iCol, const char **pz, int *pn);
  2.4366 +  int (*xColumnSize)(Fts5Context*, int iCol, int *pnToken);
  2.4367 +
  2.4368 +  int (*xQueryPhrase)(Fts5Context*, int iPhrase, void *pUserData,
  2.4369 +    int(*)(const Fts5ExtensionApi*,Fts5Context*,void*)
  2.4370 +  );
  2.4371 +  int (*xSetAuxdata)(Fts5Context*, void *pAux, void(*xDelete)(void*));
  2.4372 +  void *(*xGetAuxdata)(Fts5Context*, int bClear);
  2.4373 +
  2.4374 +  int (*xPhraseFirst)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*, int*);
  2.4375 +  void (*xPhraseNext)(Fts5Context*, Fts5PhraseIter*, int *piCol, int *piOff);
  2.4376 +
  2.4377 +  int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*);
  2.4378 +  void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol);
  2.4379 +};
  2.4380 +
  2.4381 +/* 
  2.4382 +** CUSTOM AUXILIARY FUNCTIONS
  2.4383 +*************************************************************************/
  2.4384 +
  2.4385 +/*************************************************************************
  2.4386 +** CUSTOM TOKENIZERS
  2.4387 +**
  2.4388 +** Applications may also register custom tokenizer types. A tokenizer 
  2.4389 +** is registered by providing fts5 with a populated instance of the 
  2.4390 +** following structure. All structure methods must be defined, setting
  2.4391 +** any member of the fts5_tokenizer struct to NULL leads to undefined
  2.4392 +** behaviour. The structure methods are expected to function as follows:
  2.4393 +**
  2.4394 +** xCreate:
  2.4395 +**   This function is used to allocate and inititalize a tokenizer instance.
  2.4396 +**   A tokenizer instance is required to actually tokenize text.
  2.4397 +**
  2.4398 +**   The first argument passed to this function is a copy of the (void*)
  2.4399 +**   pointer provided by the application when the fts5_tokenizer object
  2.4400 +**   was registered with FTS5 (the third argument to xCreateTokenizer()). 
  2.4401 +**   The second and third arguments are an array of nul-terminated strings
  2.4402 +**   containing the tokenizer arguments, if any, specified following the
  2.4403 +**   tokenizer name as part of the CREATE VIRTUAL TABLE statement used
  2.4404 +**   to create the FTS5 table.
  2.4405 +**
  2.4406 +**   The final argument is an output variable. If successful, (*ppOut) 
  2.4407 +**   should be set to point to the new tokenizer handle and SQLITE_OK
  2.4408 +**   returned. If an error occurs, some value other than SQLITE_OK should
  2.4409 +**   be returned. In this case, fts5 assumes that the final value of *ppOut 
  2.4410 +**   is undefined.
  2.4411 +**
  2.4412 +** xDelete:
  2.4413 +**   This function is invoked to delete a tokenizer handle previously
  2.4414 +**   allocated using xCreate(). Fts5 guarantees that this function will
  2.4415 +**   be invoked exactly once for each successful call to xCreate().
  2.4416 +**
  2.4417 +** xTokenize:
  2.4418 +**   This function is expected to tokenize the nText byte string indicated 
  2.4419 +**   by argument pText. pText may or may not be nul-terminated. The first
  2.4420 +**   argument passed to this function is a pointer to an Fts5Tokenizer object
  2.4421 +**   returned by an earlier call to xCreate().
  2.4422 +**
  2.4423 +**   The second argument indicates the reason that FTS5 is requesting
  2.4424 +**   tokenization of the supplied text. This is always one of the following
  2.4425 +**   four values:
  2.4426 +**
  2.4427 +**   <ul><li> <b>FTS5_TOKENIZE_DOCUMENT</b> - A document is being inserted into
  2.4428 +**            or removed from the FTS table. The tokenizer is being invoked to
  2.4429 +**            determine the set of tokens to add to (or delete from) the
  2.4430 +**            FTS index.
  2.4431 +**
  2.4432 +**       <li> <b>FTS5_TOKENIZE_QUERY</b> - A MATCH query is being executed 
  2.4433 +**            against the FTS index. The tokenizer is being called to tokenize 
  2.4434 +**            a bareword or quoted string specified as part of the query.
  2.4435 +**
  2.4436 +**       <li> <b>(FTS5_TOKENIZE_QUERY | FTS5_TOKENIZE_PREFIX)</b> - Same as
  2.4437 +**            FTS5_TOKENIZE_QUERY, except that the bareword or quoted string is
  2.4438 +**            followed by a "*" character, indicating that the last token
  2.4439 +**            returned by the tokenizer will be treated as a token prefix.
  2.4440 +**
  2.4441 +**       <li> <b>FTS5_TOKENIZE_AUX</b> - The tokenizer is being invoked to 
  2.4442 +**            satisfy an fts5_api.xTokenize() request made by an auxiliary
  2.4443 +**            function. Or an fts5_api.xColumnSize() request made by the same
  2.4444 +**            on a columnsize=0 database.  
  2.4445 +**   </ul>
  2.4446 +**
  2.4447 +**   For each token in the input string, the supplied callback xToken() must
  2.4448 +**   be invoked. The first argument to it should be a copy of the pointer
  2.4449 +**   passed as the second argument to xTokenize(). The third and fourth
  2.4450 +**   arguments are a pointer to a buffer containing the token text, and the
  2.4451 +**   size of the token in bytes. The 4th and 5th arguments are the byte offsets
  2.4452 +**   of the first byte of and first byte immediately following the text from
  2.4453 +**   which the token is derived within the input.
  2.4454 +**
  2.4455 +**   The second argument passed to the xToken() callback ("tflags") should
  2.4456 +**   normally be set to 0. The exception is if the tokenizer supports 
  2.4457 +**   synonyms. In this case see the discussion below for details.
  2.4458 +**
  2.4459 +**   FTS5 assumes the xToken() callback is invoked for each token in the 
  2.4460 +**   order that they occur within the input text.
  2.4461 +**
  2.4462 +**   If an xToken() callback returns any value other than SQLITE_OK, then
  2.4463 +**   the tokenization should be abandoned and the xTokenize() method should
  2.4464 +**   immediately return a copy of the xToken() return value. Or, if the
  2.4465 +**   input buffer is exhausted, xTokenize() should return SQLITE_OK. Finally,
  2.4466 +**   if an error occurs with the xTokenize() implementation itself, it
  2.4467 +**   may abandon the tokenization and return any error code other than
  2.4468 +**   SQLITE_OK or SQLITE_DONE.
  2.4469 +**
  2.4470 +** SYNONYM SUPPORT
  2.4471 +**
  2.4472 +**   Custom tokenizers may also support synonyms. Consider a case in which a
  2.4473 +**   user wishes to query for a phrase such as "first place". Using the 
  2.4474 +**   built-in tokenizers, the FTS5 query 'first + place' will match instances
  2.4475 +**   of "first place" within the document set, but not alternative forms
  2.4476 +**   such as "1st place". In some applications, it would be better to match
  2.4477 +**   all instances of "first place" or "1st place" regardless of which form
  2.4478 +**   the user specified in the MATCH query text.
  2.4479 +**
  2.4480 +**   There are several ways to approach this in FTS5:
  2.4481 +**
  2.4482 +**   <ol><li> By mapping all synonyms to a single token. In this case, the 
  2.4483 +**            In the above example, this means that the tokenizer returns the
  2.4484 +**            same token for inputs "first" and "1st". Say that token is in
  2.4485 +**            fact "first", so that when the user inserts the document "I won
  2.4486 +**            1st place" entries are added to the index for tokens "i", "won",
  2.4487 +**            "first" and "place". If the user then queries for '1st + place',
  2.4488 +**            the tokenizer substitutes "first" for "1st" and the query works
  2.4489 +**            as expected.
  2.4490 +**
  2.4491 +**       <li> By adding multiple synonyms for a single term to the FTS index.
  2.4492 +**            In this case, when tokenizing query text, the tokenizer may 
  2.4493 +**            provide multiple synonyms for a single term within the document.
  2.4494 +**            FTS5 then queries the index for each synonym individually. For
  2.4495 +**            example, faced with the query:
  2.4496 +**
  2.4497 +**   <codeblock>
  2.4498 +**     ... MATCH 'first place'</codeblock>
  2.4499 +**
  2.4500 +**            the tokenizer offers both "1st" and "first" as synonyms for the
  2.4501 +**            first token in the MATCH query and FTS5 effectively runs a query 
  2.4502 +**            similar to:
  2.4503 +**
  2.4504 +**   <codeblock>
  2.4505 +**     ... MATCH '(first OR 1st) place'</codeblock>
  2.4506 +**
  2.4507 +**            except that, for the purposes of auxiliary functions, the query
  2.4508 +**            still appears to contain just two phrases - "(first OR 1st)" 
  2.4509 +**            being treated as a single phrase.
  2.4510 +**
  2.4511 +**       <li> By adding multiple synonyms for a single term to the FTS index.
  2.4512 +**            Using this method, when tokenizing document text, the tokenizer
  2.4513 +**            provides multiple synonyms for each token. So that when a 
  2.4514 +**            document such as "I won first place" is tokenized, entries are
  2.4515 +**            added to the FTS index for "i", "won", "first", "1st" and
  2.4516 +**            "place".
  2.4517 +**
  2.4518 +**            This way, even if the tokenizer does not provide synonyms
  2.4519 +**            when tokenizing query text (it should not - to do would be
  2.4520 +**            inefficient), it doesn't matter if the user queries for 
  2.4521 +**            'first + place' or '1st + place', as there are entires in the
  2.4522 +**            FTS index corresponding to both forms of the first token.
  2.4523 +**   </ol>
  2.4524 +**
  2.4525 +**   Whether it is parsing document or query text, any call to xToken that
  2.4526 +**   specifies a <i>tflags</i> argument with the FTS5_TOKEN_COLOCATED bit
  2.4527 +**   is considered to supply a synonym for the previous token. For example,
  2.4528 +**   when parsing the document "I won first place", a tokenizer that supports
  2.4529 +**   synonyms would call xToken() 5 times, as follows:
  2.4530 +**
  2.4531 +**   <codeblock>
  2.4532 +**       xToken(pCtx, 0, "i",                      1,  0,  1);
  2.4533 +**       xToken(pCtx, 0, "won",                    3,  2,  5);
  2.4534 +**       xToken(pCtx, 0, "first",                  5,  6, 11);
  2.4535 +**       xToken(pCtx, FTS5_TOKEN_COLOCATED, "1st", 3,  6, 11);
  2.4536 +**       xToken(pCtx, 0, "place",                  5, 12, 17);
  2.4537 +**</codeblock>
  2.4538 +**
  2.4539 +**   It is an error to specify the FTS5_TOKEN_COLOCATED flag the first time
  2.4540 +**   xToken() is called. Multiple synonyms may be specified for a single token
  2.4541 +**   by making multiple calls to xToken(FTS5_TOKEN_COLOCATED) in sequence. 
  2.4542 +**   There is no limit to the number of synonyms that may be provided for a
  2.4543 +**   single token.
  2.4544 +**
  2.4545 +**   In many cases, method (1) above is the best approach. It does not add 
  2.4546 +**   extra data to the FTS index or require FTS5 to query for multiple terms,
  2.4547 +**   so it is efficient in terms of disk space and query speed. However, it
  2.4548 +**   does not support prefix queries very well. If, as suggested above, the
  2.4549 +**   token "first" is subsituted for "1st" by the tokenizer, then the query:
  2.4550 +**
  2.4551 +**   <codeblock>
  2.4552 +**     ... MATCH '1s*'</codeblock>
  2.4553 +**
  2.4554 +**   will not match documents that contain the token "1st" (as the tokenizer
  2.4555 +**   will probably not map "1s" to any prefix of "first").
  2.4556 +**
  2.4557 +**   For full prefix support, method (3) may be preferred. In this case, 
  2.4558 +**   because the index contains entries for both "first" and "1st", prefix
  2.4559 +**   queries such as 'fi*' or '1s*' will match correctly. However, because
  2.4560 +**   extra entries are added to the FTS index, this method uses more space
  2.4561 +**   within the database.
  2.4562 +**
  2.4563 +**   Method (2) offers a midpoint between (1) and (3). Using this method,
  2.4564 +**   a query such as '1s*' will match documents that contain the literal 
  2.4565 +**   token "1st", but not "first" (assuming the tokenizer is not able to
  2.4566 +**   provide synonyms for prefixes). However, a non-prefix query like '1st'
  2.4567 +**   will match against "1st" and "first". This method does not require
  2.4568 +**   extra disk space, as no extra entries are added to the FTS index. 
  2.4569 +**   On the other hand, it may require more CPU cycles to run MATCH queries,
  2.4570 +**   as separate queries of the FTS index are required for each synonym.
  2.4571 +**
  2.4572 +**   When using methods (2) or (3), it is important that the tokenizer only
  2.4573 +**   provide synonyms when tokenizing document text (method (2)) or query
  2.4574 +**   text (method (3)), not both. Doing so will not cause any errors, but is
  2.4575 +**   inefficient.
  2.4576 +*/
  2.4577 +typedef struct Fts5Tokenizer Fts5Tokenizer;
  2.4578 +typedef struct fts5_tokenizer fts5_tokenizer;
  2.4579 +struct fts5_tokenizer {
  2.4580 +  int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut);
  2.4581 +  void (*xDelete)(Fts5Tokenizer*);
  2.4582 +  int (*xTokenize)(Fts5Tokenizer*, 
  2.4583 +      void *pCtx,
  2.4584 +      int flags,            /* Mask of FTS5_TOKENIZE_* flags */
  2.4585 +      const char *pText, int nText, 
  2.4586 +      int (*xToken)(
  2.4587 +        void *pCtx,         /* Copy of 2nd argument to xTokenize() */
  2.4588 +        int tflags,         /* Mask of FTS5_TOKEN_* flags */
  2.4589 +        const char *pToken, /* Pointer to buffer containing token */
  2.4590 +        int nToken,         /* Size of token in bytes */
  2.4591 +        int iStart,         /* Byte offset of token within input text */
  2.4592 +        int iEnd            /* Byte offset of end of token within input text */
  2.4593 +      )
  2.4594 +  );
  2.4595 +};
  2.4596 +
  2.4597 +/* Flags that may be passed as the third argument to xTokenize() */
  2.4598 +#define FTS5_TOKENIZE_QUERY     0x0001
  2.4599 +#define FTS5_TOKENIZE_PREFIX    0x0002
  2.4600 +#define FTS5_TOKENIZE_DOCUMENT  0x0004
  2.4601 +#define FTS5_TOKENIZE_AUX       0x0008
  2.4602 +
  2.4603 +/* Flags that may be passed by the tokenizer implementation back to FTS5
  2.4604 +** as the third argument to the supplied xToken callback. */
  2.4605 +#define FTS5_TOKEN_COLOCATED    0x0001      /* Same position as prev. token */
  2.4606 +
  2.4607 +/*
  2.4608 +** END OF CUSTOM TOKENIZERS
  2.4609 +*************************************************************************/
  2.4610 +
  2.4611 +/*************************************************************************
  2.4612 +** FTS5 EXTENSION REGISTRATION API
  2.4613 +*/
  2.4614 +typedef struct fts5_api fts5_api;
  2.4615 +struct fts5_api {
  2.4616 +  int iVersion;                   /* Currently always set to 2 */
  2.4617 +
  2.4618 +  /* Create a new tokenizer */
  2.4619 +  int (*xCreateTokenizer)(
  2.4620 +    fts5_api *pApi,
  2.4621 +    const char *zName,
  2.4622 +    void *pContext,
  2.4623 +    fts5_tokenizer *pTokenizer,
  2.4624 +    void (*xDestroy)(void*)
  2.4625 +  );
  2.4626 +
  2.4627 +  /* Find an existing tokenizer */
  2.4628 +  int (*xFindTokenizer)(
  2.4629 +    fts5_api *pApi,
  2.4630 +    const char *zName,
  2.4631 +    void **ppContext,
  2.4632 +    fts5_tokenizer *pTokenizer
  2.4633 +  );
  2.4634 +
  2.4635 +  /* Create a new auxiliary function */
  2.4636 +  int (*xCreateFunction)(
  2.4637 +    fts5_api *pApi,
  2.4638 +    const char *zName,
  2.4639 +    void *pContext,
  2.4640 +    fts5_extension_function xFunction,
  2.4641 +    void (*xDestroy)(void*)
  2.4642 +  );
  2.4643 +};
  2.4644 +
  2.4645 +/*
  2.4646 +** END OF REGISTRATION API
  2.4647 +*************************************************************************/
  2.4648 +
  2.4649 +#if 0
  2.4650 +}  /* end of the 'extern "C"' block */
  2.4651 +#endif
  2.4652 +
  2.4653 +#endif /* _FTS5_H */
  2.4654 +
  2.4655 +
  2.4656  
  2.4657  /************** End of sqlite3.h *********************************************/
  2.4658  /************** Continuing where we left off in sqliteInt.h ******************/
  2.4659 @@ -7721,15 +9017,17 @@
  2.4660  #endif
  2.4661  
  2.4662  /*
  2.4663 -** The maximum number of in-memory pages to use for the main database
  2.4664 -** table and for temporary tables.  The SQLITE_DEFAULT_CACHE_SIZE
  2.4665 +** The suggested maximum number of in-memory pages to use for
  2.4666 +** the main database table and for temporary tables.
  2.4667 +**
  2.4668 +** IMPLEMENTATION-OF: R-31093-59126 The default suggested cache size
  2.4669 +** is 2000 pages.
  2.4670 +** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be
  2.4671 +** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options.
  2.4672  */
  2.4673  #ifndef SQLITE_DEFAULT_CACHE_SIZE
  2.4674  # define SQLITE_DEFAULT_CACHE_SIZE  2000
  2.4675  #endif
  2.4676 -#ifndef SQLITE_DEFAULT_TEMP_CACHE_SIZE
  2.4677 -# define SQLITE_DEFAULT_TEMP_CACHE_SIZE  500
  2.4678 -#endif
  2.4679  
  2.4680  /*
  2.4681  ** The default number of frames to accumulate in the log file before
  2.4682 @@ -7842,15 +9140,6 @@
  2.4683  #pragma warn -spa /* Suspicious pointer arithmetic */
  2.4684  #endif
  2.4685  
  2.4686 -/* Needed for various definitions... */
  2.4687 -#ifndef _GNU_SOURCE
  2.4688 -# define _GNU_SOURCE
  2.4689 -#endif
  2.4690 -
  2.4691 -#if defined(__OpenBSD__) && !defined(_BSD_SOURCE)
  2.4692 -# define _BSD_SOURCE
  2.4693 -#endif
  2.4694 -
  2.4695  /*
  2.4696  ** Include standard header files as necessary
  2.4697  */
  2.4698 @@ -7892,6 +9181,51 @@
  2.4699  #endif
  2.4700  
  2.4701  /*
  2.4702 +** The SQLITE_WITHIN(P,S,E) macro checks to see if pointer P points to
  2.4703 +** something between S (inclusive) and E (exclusive).
  2.4704 +**
  2.4705 +** In other words, S is a buffer and E is a pointer to the first byte after
  2.4706 +** the end of buffer S.  This macro returns true if P points to something
  2.4707 +** contained within the buffer S.
  2.4708 +*/
  2.4709 +#if defined(HAVE_STDINT_H)
  2.4710 +# define SQLITE_WITHIN(P,S,E) \
  2.4711 +    ((uintptr_t)(P)>=(uintptr_t)(S) && (uintptr_t)(P)<(uintptr_t)(E))
  2.4712 +#else
  2.4713 +# define SQLITE_WITHIN(P,S,E) ((P)>=(S) && (P)<(E))
  2.4714 +#endif
  2.4715 +
  2.4716 +/*
  2.4717 +** A macro to hint to the compiler that a function should not be
  2.4718 +** inlined.
  2.4719 +*/
  2.4720 +#if defined(__GNUC__)
  2.4721 +#  define SQLITE_NOINLINE  __attribute__((noinline))
  2.4722 +#elif defined(_MSC_VER) && _MSC_VER>=1310
  2.4723 +#  define SQLITE_NOINLINE  __declspec(noinline)
  2.4724 +#else
  2.4725 +#  define SQLITE_NOINLINE
  2.4726 +#endif
  2.4727 +
  2.4728 +/*
  2.4729 +** Make sure that the compiler intrinsics we desire are enabled when
  2.4730 +** compiling with an appropriate version of MSVC unless prevented by
  2.4731 +** the SQLITE_DISABLE_INTRINSIC define.
  2.4732 +*/
  2.4733 +#if !defined(SQLITE_DISABLE_INTRINSIC)
  2.4734 +#  if defined(_MSC_VER) && _MSC_VER>=1300
  2.4735 +#    if !defined(_WIN32_WCE)
  2.4736 +#      include <intrin.h>
  2.4737 +#      pragma intrinsic(_byteswap_ushort)
  2.4738 +#      pragma intrinsic(_byteswap_ulong)
  2.4739 +#      pragma intrinsic(_ReadWriteBarrier)
  2.4740 +#    else
  2.4741 +#      include <cmnintrin.h>
  2.4742 +#    endif
  2.4743 +#  endif
  2.4744 +#endif
  2.4745 +
  2.4746 +/*
  2.4747  ** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2.
  2.4748  ** 0 means mutexes are permanently disable and the library is never
  2.4749  ** threadsafe.  1 means the library is serialized which is the highest
  2.4750 @@ -7919,10 +9253,9 @@
  2.4751  #endif
  2.4752  
  2.4753  /*
  2.4754 -** The SQLITE_DEFAULT_MEMSTATUS macro must be defined as either 0 or 1.
  2.4755 -** It determines whether or not the features related to 
  2.4756 -** SQLITE_CONFIG_MEMSTATUS are available by default or not. This value can
  2.4757 -** be overridden at runtime using the sqlite3_config() API.
  2.4758 +** EVIDENCE-OF: R-25715-37072 Memory allocation statistics are enabled by
  2.4759 +** default unless SQLite is compiled with SQLITE_DEFAULT_MEMSTATUS=0 in
  2.4760 +** which case memory allocation statistics are disabled by default.
  2.4761  */
  2.4762  #if !defined(SQLITE_DEFAULT_MEMSTATUS)
  2.4763  # define SQLITE_DEFAULT_MEMSTATUS 1
  2.4764 @@ -8077,7 +9410,48 @@
  2.4765  #endif
  2.4766  
  2.4767  /*
  2.4768 -** Return true (non-zero) if the input is a integer that is too large
  2.4769 +** Some malloc failures are only possible if SQLITE_TEST_REALLOC_STRESS is
  2.4770 +** defined.  We need to defend against those failures when testing with
  2.4771 +** SQLITE_TEST_REALLOC_STRESS, but we don't want the unreachable branches
  2.4772 +** during a normal build.  The following macro can be used to disable tests
  2.4773 +** that are always false except when SQLITE_TEST_REALLOC_STRESS is set.
  2.4774 +*/
  2.4775 +#if defined(SQLITE_TEST_REALLOC_STRESS)
  2.4776 +# define ONLY_IF_REALLOC_STRESS(X)  (X)
  2.4777 +#elif !defined(NDEBUG)
  2.4778 +# define ONLY_IF_REALLOC_STRESS(X)  ((X)?(assert(0),1):0)
  2.4779 +#else
  2.4780 +# define ONLY_IF_REALLOC_STRESS(X)  (0)
  2.4781 +#endif
  2.4782 +
  2.4783 +/*
  2.4784 +** Declarations used for tracing the operating system interfaces.
  2.4785 +*/
  2.4786 +#if defined(SQLITE_FORCE_OS_TRACE) || defined(SQLITE_TEST) || \
  2.4787 +    (defined(SQLITE_DEBUG) && SQLITE_OS_WIN)
  2.4788 +  extern int sqlite3OSTrace;
  2.4789 +# define OSTRACE(X)          if( sqlite3OSTrace ) sqlite3DebugPrintf X
  2.4790 +# define SQLITE_HAVE_OS_TRACE
  2.4791 +#else
  2.4792 +# define OSTRACE(X)
  2.4793 +# undef  SQLITE_HAVE_OS_TRACE
  2.4794 +#endif
  2.4795 +
  2.4796 +/*
  2.4797 +** Is the sqlite3ErrName() function needed in the build?  Currently,
  2.4798 +** it is needed by "mutex_w32.c" (when debugging), "os_win.c" (when
  2.4799 +** OSTRACE is enabled), and by several "test*.c" files (which are
  2.4800 +** compiled using SQLITE_TEST).
  2.4801 +*/
  2.4802 +#if defined(SQLITE_HAVE_OS_TRACE) || defined(SQLITE_TEST) || \
  2.4803 +    (defined(SQLITE_DEBUG) && SQLITE_OS_WIN)
  2.4804 +# define SQLITE_NEED_ERR_NAME
  2.4805 +#else
  2.4806 +# undef  SQLITE_NEED_ERR_NAME
  2.4807 +#endif
  2.4808 +
  2.4809 +/*
  2.4810 +** Return true (non-zero) if the input is an integer that is too large
  2.4811  ** to fit in 32-bits.  This macro is used inside of various testcase()
  2.4812  ** macros to verify that we have tested SQLite for large-file support.
  2.4813  */
  2.4814 @@ -8156,15 +9530,15 @@
  2.4815  struct HashElem {
  2.4816    HashElem *next, *prev;       /* Next and previous elements in the table */
  2.4817    void *data;                  /* Data associated with this element */
  2.4818 -  const char *pKey; int nKey;  /* Key associated with this element */
  2.4819 +  const char *pKey;            /* Key associated with this element */
  2.4820  };
  2.4821  
  2.4822  /*
  2.4823  ** Access routines.  To delete, insert a NULL pointer.
  2.4824  */
  2.4825  SQLITE_PRIVATE void sqlite3HashInit(Hash*);
  2.4826 -SQLITE_PRIVATE void *sqlite3HashInsert(Hash*, const char *pKey, int nKey, void *pData);
  2.4827 -SQLITE_PRIVATE void *sqlite3HashFind(const Hash*, const char *pKey, int nKey);
  2.4828 +SQLITE_PRIVATE void *sqlite3HashInsert(Hash*, const char *pKey, void *pData);
  2.4829 +SQLITE_PRIVATE void *sqlite3HashFind(const Hash*, const char *pKey);
  2.4830  SQLITE_PRIVATE void sqlite3HashClear(Hash*);
  2.4831  
  2.4832  /*
  2.4833 @@ -8345,16 +9719,24 @@
  2.4834  #define TK_TO_REAL                        147
  2.4835  #define TK_ISNOT                          148
  2.4836  #define TK_END_OF_FILE                    149
  2.4837 -#define TK_ILLEGAL                        150
  2.4838 -#define TK_SPACE                          151
  2.4839 -#define TK_UNCLOSED_STRING                152
  2.4840 -#define TK_FUNCTION                       153
  2.4841 -#define TK_COLUMN                         154
  2.4842 -#define TK_AGG_FUNCTION                   155
  2.4843 -#define TK_AGG_COLUMN                     156
  2.4844 -#define TK_UMINUS                         157
  2.4845 -#define TK_UPLUS                          158
  2.4846 -#define TK_REGISTER                       159
  2.4847 +#define TK_UNCLOSED_STRING                150
  2.4848 +#define TK_FUNCTION                       151
  2.4849 +#define TK_COLUMN                         152
  2.4850 +#define TK_AGG_FUNCTION                   153
  2.4851 +#define TK_AGG_COLUMN                     154
  2.4852 +#define TK_UMINUS                         155
  2.4853 +#define TK_UPLUS                          156
  2.4854 +#define TK_REGISTER                       157
  2.4855 +#define TK_ASTERISK                       158
  2.4856 +#define TK_SPACE                          159
  2.4857 +#define TK_ILLEGAL                        160
  2.4858 +
  2.4859 +/* The token codes above must all fit in 8 bits */
  2.4860 +#define TKFLG_MASK           0xff  
  2.4861 +
  2.4862 +/* Flags that can be added to a token code when it is not
  2.4863 +** being stored in a u8: */
  2.4864 +#define TKFLG_DONTFOLD       0x100  /* Omit constant folding optimizations */
  2.4865  
  2.4866  /************** End of parse.h ***********************************************/
  2.4867  /************** Continuing where we left off in sqliteInt.h ******************/
  2.4868 @@ -8424,6 +9806,36 @@
  2.4869  #endif
  2.4870  
  2.4871  /*
  2.4872 +** If no value has been provided for SQLITE_MAX_WORKER_THREADS, or if
  2.4873 +** SQLITE_TEMP_STORE is set to 3 (never use temporary files), set it 
  2.4874 +** to zero.
  2.4875 +*/
  2.4876 +#if SQLITE_TEMP_STORE==3 || SQLITE_THREADSAFE==0
  2.4877 +# undef SQLITE_MAX_WORKER_THREADS
  2.4878 +# define SQLITE_MAX_WORKER_THREADS 0
  2.4879 +#endif
  2.4880 +#ifndef SQLITE_MAX_WORKER_THREADS
  2.4881 +# define SQLITE_MAX_WORKER_THREADS 8
  2.4882 +#endif
  2.4883 +#ifndef SQLITE_DEFAULT_WORKER_THREADS
  2.4884 +# define SQLITE_DEFAULT_WORKER_THREADS 0
  2.4885 +#endif
  2.4886 +#if SQLITE_DEFAULT_WORKER_THREADS>SQLITE_MAX_WORKER_THREADS
  2.4887 +# undef SQLITE_MAX_WORKER_THREADS
  2.4888 +# define SQLITE_MAX_WORKER_THREADS SQLITE_DEFAULT_WORKER_THREADS
  2.4889 +#endif
  2.4890 +
  2.4891 +/*
  2.4892 +** The default initial allocation for the pagecache when using separate
  2.4893 +** pagecaches for each database connection.  A positive number is the
  2.4894 +** number of pages.  A negative number N translations means that a buffer
  2.4895 +** of -1024*N bytes is allocated and used for as many pages as it will hold.
  2.4896 +*/
  2.4897 +#ifndef SQLITE_DEFAULT_PCACHE_INITSZ
  2.4898 +# define SQLITE_DEFAULT_PCACHE_INITSZ 100
  2.4899 +#endif
  2.4900 +
  2.4901 +/*
  2.4902  ** GCC does not define the offsetof() macro so we'll have to do it
  2.4903  ** ourselves.
  2.4904  */
  2.4905 @@ -8438,6 +9850,11 @@
  2.4906  #define MAX(A,B) ((A)>(B)?(A):(B))
  2.4907  
  2.4908  /*
  2.4909 +** Swap two objects of type TYPE.
  2.4910 +*/
  2.4911 +#define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;}
  2.4912 +
  2.4913 +/*
  2.4914  ** Check to see if this machine uses EBCDIC.  (Yes, believe it or
  2.4915  ** not, there are still machines out there that use EBCDIC.)
  2.4916  */
  2.4917 @@ -8526,7 +9943,7 @@
  2.4918  ** gives a possible range of values of approximately 1.0e986 to 1e-986.
  2.4919  ** But the allowed values are "grainy".  Not every value is representable.
  2.4920  ** For example, quantities 16 and 17 are both represented by a LogEst
  2.4921 -** of 40.  However, since LogEst quantaties are suppose to be estimates,
  2.4922 +** of 40.  However, since LogEst quantities are suppose to be estimates,
  2.4923  ** not exact values, this imprecision is not a problem.
  2.4924  **
  2.4925  ** "LogEst" is short for "Logarithmic Estimate".
  2.4926 @@ -8546,6 +9963,20 @@
  2.4927  typedef INT16_TYPE LogEst;
  2.4928  
  2.4929  /*
  2.4930 +** Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer
  2.4931 +*/
  2.4932 +#ifndef SQLITE_PTRSIZE
  2.4933 +# if defined(__SIZEOF_POINTER__)
  2.4934 +#   define SQLITE_PTRSIZE __SIZEOF_POINTER__
  2.4935 +# elif defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \
  2.4936 +       defined(_M_ARM)   || defined(__arm__)    || defined(__x86)
  2.4937 +#   define SQLITE_PTRSIZE 4
  2.4938 +# else
  2.4939 +#   define SQLITE_PTRSIZE 8
  2.4940 +# endif
  2.4941 +#endif
  2.4942 +
  2.4943 +/*
  2.4944  ** Macros to determine whether the machine is big or little endian,
  2.4945  ** and whether or not that determination is run-time or compile-time.
  2.4946  **
  2.4947 @@ -8554,11 +9985,6 @@
  2.4948  ** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined
  2.4949  ** at run-time.
  2.4950  */
  2.4951 -#ifdef SQLITE_AMALGAMATION
  2.4952 -SQLITE_PRIVATE const int sqlite3one = 1;
  2.4953 -#else
  2.4954 -SQLITE_PRIVATE const int sqlite3one;
  2.4955 -#endif
  2.4956  #if (defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \
  2.4957       defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)  ||    \
  2.4958       defined(_M_AMD64) || defined(_M_ARM)     || defined(__x86)   ||    \
  2.4959 @@ -8576,6 +10002,11 @@
  2.4960  # define SQLITE_UTF16NATIVE  SQLITE_UTF16BE
  2.4961  #endif
  2.4962  #if !defined(SQLITE_BYTEORDER)
  2.4963 +# ifdef SQLITE_AMALGAMATION
  2.4964 +  const int sqlite3one = 1;
  2.4965 +# else
  2.4966 +  extern const int sqlite3one;
  2.4967 +# endif
  2.4968  # define SQLITE_BYTEORDER    0     /* 0 means "unknown at compile-time" */
  2.4969  # define SQLITE_BIGENDIAN    (*(char *)(&sqlite3one)==0)
  2.4970  # define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1)
  2.4971 @@ -8607,7 +10038,7 @@
  2.4972  ** all alignment restrictions correct.
  2.4973  **
  2.4974  ** Except, if SQLITE_4_BYTE_ALIGNED_MALLOC is defined, then the
  2.4975 -** underlying malloc() implemention might return us 4-byte aligned
  2.4976 +** underlying malloc() implementation might return us 4-byte aligned
  2.4977  ** pointers.  In that case, only verify 4-byte alignment.
  2.4978  */
  2.4979  #ifdef SQLITE_4_BYTE_ALIGNED_MALLOC
  2.4980 @@ -8629,16 +10060,14 @@
  2.4981  */
  2.4982  #ifdef __APPLE__
  2.4983  # include <TargetConditionals.h>
  2.4984 -# if TARGET_OS_IPHONE
  2.4985 -#   undef SQLITE_MAX_MMAP_SIZE
  2.4986 -#   define SQLITE_MAX_MMAP_SIZE 0
  2.4987 -# endif
  2.4988  #endif
  2.4989  #ifndef SQLITE_MAX_MMAP_SIZE
  2.4990  # if defined(__linux__) \
  2.4991    || defined(_WIN32) \
  2.4992    || (defined(__APPLE__) && defined(__MACH__)) \
  2.4993 -  || defined(__sun)
  2.4994 +  || defined(__sun) \
  2.4995 +  || defined(__FreeBSD__) \
  2.4996 +  || defined(__DragonFly__)
  2.4997  #   define SQLITE_MAX_MMAP_SIZE 0x7fff0000  /* 2147418112 */
  2.4998  # else
  2.4999  #   define SQLITE_MAX_MMAP_SIZE 0
  2.5000 @@ -8675,6 +10104,16 @@
  2.5001  #endif
  2.5002  
  2.5003  /*
  2.5004 +** SELECTTRACE_ENABLED will be either 1 or 0 depending on whether or not
  2.5005 +** the Select query generator tracing logic is turned on.
  2.5006 +*/
  2.5007 +#if defined(SQLITE_DEBUG) || defined(SQLITE_ENABLE_SELECTTRACE)
  2.5008 +# define SELECTTRACE_ENABLED 1
  2.5009 +#else
  2.5010 +# define SELECTTRACE_ENABLED 0
  2.5011 +#endif
  2.5012 +
  2.5013 +/*
  2.5014  ** An instance of the following structure is used to store the busy-handler
  2.5015  ** callback for a given sqlite handle. 
  2.5016  **
  2.5017 @@ -8747,8 +10186,8 @@
  2.5018    #define SQLITE_WSD const
  2.5019    #define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v)))
  2.5020    #define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config)
  2.5021 -SQLITE_API   int sqlite3_wsd_init(int N, int J);
  2.5022 -SQLITE_API   void *sqlite3_wsd_find(void *K, int L);
  2.5023 +SQLITE_API int SQLITE_STDCALL sqlite3_wsd_init(int N, int J);
  2.5024 +SQLITE_API void *SQLITE_STDCALL sqlite3_wsd_find(void *K, int L);
  2.5025  #else
  2.5026    #define SQLITE_WSD 
  2.5027    #define GLOBAL(t,v) v
  2.5028 @@ -8806,12 +10245,14 @@
  2.5029  typedef struct RowSet RowSet;
  2.5030  typedef struct Savepoint Savepoint;
  2.5031  typedef struct Select Select;
  2.5032 +typedef struct SQLiteThread SQLiteThread;
  2.5033  typedef struct SelectDest SelectDest;
  2.5034  typedef struct SrcList SrcList;
  2.5035  typedef struct StrAccum StrAccum;
  2.5036  typedef struct Table Table;
  2.5037  typedef struct TableLock TableLock;
  2.5038  typedef struct Token Token;
  2.5039 +typedef struct TreeView TreeView;
  2.5040  typedef struct Trigger Trigger;
  2.5041  typedef struct TriggerPrg TriggerPrg;
  2.5042  typedef struct TriggerStep TriggerStep;
  2.5043 @@ -8850,7 +10291,7 @@
  2.5044  /* TODO: This definition is just included so other modules compile. It
  2.5045  ** needs to be revisited.
  2.5046  */
  2.5047 -#define SQLITE_N_BTREE_META 10
  2.5048 +#define SQLITE_N_BTREE_META 16
  2.5049  
  2.5050  /*
  2.5051  ** If defined as non-zero, auto-vacuum is enabled by default. Otherwise
  2.5052 @@ -8894,6 +10335,7 @@
  2.5053  
  2.5054  SQLITE_PRIVATE int sqlite3BtreeClose(Btree*);
  2.5055  SQLITE_PRIVATE int sqlite3BtreeSetCacheSize(Btree*,int);
  2.5056 +SQLITE_PRIVATE int sqlite3BtreeSetSpillSize(Btree*,int);
  2.5057  #if SQLITE_MAX_MMAP_SIZE>0
  2.5058  SQLITE_PRIVATE   int sqlite3BtreeSetMmapLimit(Btree*,sqlite3_int64);
  2.5059  #endif
  2.5060 @@ -8904,17 +10346,15 @@
  2.5061  SQLITE_PRIVATE int sqlite3BtreeMaxPageCount(Btree*,int);
  2.5062  SQLITE_PRIVATE u32 sqlite3BtreeLastPage(Btree*);
  2.5063  SQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree*,int);
  2.5064 -SQLITE_PRIVATE int sqlite3BtreeGetReserve(Btree*);
  2.5065 -#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_DEBUG)
  2.5066 +SQLITE_PRIVATE int sqlite3BtreeGetOptimalReserve(Btree*);
  2.5067  SQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p);
  2.5068 -#endif
  2.5069  SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *, int);
  2.5070  SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *);
  2.5071  SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree*,int);
  2.5072  SQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);
  2.5073  SQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree*, int);
  2.5074  SQLITE_PRIVATE int sqlite3BtreeCommit(Btree*);
  2.5075 -SQLITE_PRIVATE int sqlite3BtreeRollback(Btree*,int);
  2.5076 +SQLITE_PRIVATE int sqlite3BtreeRollback(Btree*,int,int);
  2.5077  SQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree*,int);
  2.5078  SQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree*, int*, int flags);
  2.5079  SQLITE_PRIVATE int sqlite3BtreeIsInTrans(Btree*);
  2.5080 @@ -8947,7 +10387,7 @@
  2.5081  SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree*, int, int*);
  2.5082  SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree*, int, int*);
  2.5083  SQLITE_PRIVATE int sqlite3BtreeClearTableOfCursor(BtCursor*);
  2.5084 -SQLITE_PRIVATE void sqlite3BtreeTripAllCursors(Btree*, int);
  2.5085 +SQLITE_PRIVATE int sqlite3BtreeTripAllCursors(Btree*, int, int);
  2.5086  
  2.5087  SQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue);
  2.5088  SQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
  2.5089 @@ -8965,6 +10405,11 @@
  2.5090  ** For example, the free-page-count field is located at byte offset 36 of
  2.5091  ** the database file header. The incr-vacuum-flag field is located at
  2.5092  ** byte offset 64 (== 36+4*7).
  2.5093 +**
  2.5094 +** The BTREE_DATA_VERSION value is not really a value stored in the header.
  2.5095 +** It is a read-only number computed by the pager.  But we merge it with
  2.5096 +** the header value access routines since its access pattern is the same.
  2.5097 +** Call it a "virtual meta value".
  2.5098  */
  2.5099  #define BTREE_FREE_PAGE_COUNT     0
  2.5100  #define BTREE_SCHEMA_VERSION      1
  2.5101 @@ -8975,12 +10420,78 @@
  2.5102  #define BTREE_USER_VERSION        6
  2.5103  #define BTREE_INCR_VACUUM         7
  2.5104  #define BTREE_APPLICATION_ID      8
  2.5105 -
  2.5106 -/*
  2.5107 -** Values that may be OR'd together to form the second argument of an
  2.5108 -** sqlite3BtreeCursorHints() call.
  2.5109 -*/
  2.5110 -#define BTREE_BULKLOAD 0x00000001
  2.5111 +#define BTREE_DATA_VERSION        15  /* A virtual meta-value */
  2.5112 +
  2.5113 +/*
  2.5114 +** Kinds of hints that can be passed into the sqlite3BtreeCursorHint()
  2.5115 +** interface.
  2.5116 +**
  2.5117 +** BTREE_HINT_RANGE  (arguments: Expr*, Mem*)
  2.5118 +**
  2.5119 +**     The first argument is an Expr* (which is guaranteed to be constant for
  2.5120 +**     the lifetime of the cursor) that defines constraints on which rows
  2.5121 +**     might be fetched with this cursor.  The Expr* tree may contain
  2.5122 +**     TK_REGISTER nodes that refer to values stored in the array of registers
  2.5123 +**     passed as the second parameter.  In other words, if Expr.op==TK_REGISTER
  2.5124 +**     then the value of the node is the value in Mem[pExpr.iTable].  Any
  2.5125 +**     TK_COLUMN node in the expression tree refers to the Expr.iColumn-th
  2.5126 +**     column of the b-tree of the cursor.  The Expr tree will not contain
  2.5127 +**     any function calls nor subqueries nor references to b-trees other than
  2.5128 +**     the cursor being hinted.
  2.5129 +**
  2.5130 +**     The design of the _RANGE hint is aid b-tree implementations that try
  2.5131 +**     to prefetch content from remote machines - to provide those
  2.5132 +**     implementations with limits on what needs to be prefetched and thereby
  2.5133 +**     reduce network bandwidth.
  2.5134 +**
  2.5135 +** Note that BTREE_HINT_FLAGS with BTREE_BULKLOAD is the only hint used by
  2.5136 +** standard SQLite.  The other hints are provided for extentions that use
  2.5137 +** the SQLite parser and code generator but substitute their own storage
  2.5138 +** engine.
  2.5139 +*/
  2.5140 +#define BTREE_HINT_RANGE 0       /* Range constraints on queries */
  2.5141 +
  2.5142 +/*
  2.5143 +** Values that may be OR'd together to form the argument to the
  2.5144 +** BTREE_HINT_FLAGS hint for sqlite3BtreeCursorHint():
  2.5145 +**
  2.5146 +** The BTREE_BULKLOAD flag is set on index cursors when the index is going
  2.5147 +** to be filled with content that is already in sorted order.
  2.5148 +**
  2.5149 +** The BTREE_SEEK_EQ flag is set on cursors that will get OP_SeekGE or
  2.5150 +** OP_SeekLE opcodes for a range search, but where the range of entries
  2.5151 +** selected will all have the same key.  In other words, the cursor will
  2.5152 +** be used only for equality key searches.
  2.5153 +**
  2.5154 +*/
  2.5155 +#define BTREE_BULKLOAD 0x00000001  /* Used to full index in sorted order */
  2.5156 +#define BTREE_SEEK_EQ  0x00000002  /* EQ seeks only - no range seeks */
  2.5157 +
  2.5158 +/* 
  2.5159 +** Flags passed as the third argument to sqlite3BtreeCursor().
  2.5160 +**
  2.5161 +** For read-only cursors the wrFlag argument is always zero. For read-write
  2.5162 +** cursors it may be set to either (BTREE_WRCSR|BTREE_FORDELETE) or just
  2.5163 +** (BTREE_WRCSR). If the BTREE_FORDELETE bit is set, then the cursor will
  2.5164 +** only be used by SQLite for the following:
  2.5165 +**
  2.5166 +**   * to seek to and then delete specific entries, and/or
  2.5167 +**
  2.5168 +**   * to read values that will be used to create keys that other
  2.5169 +**     BTREE_FORDELETE cursors will seek to and delete.
  2.5170 +**
  2.5171 +** The BTREE_FORDELETE flag is an optimization hint.  It is not used by
  2.5172 +** by this, the native b-tree engine of SQLite, but it is available to
  2.5173 +** alternative storage engines that might be substituted in place of this
  2.5174 +** b-tree system.  For alternative storage engines in which a delete of
  2.5175 +** the main table row automatically deletes corresponding index rows,
  2.5176 +** the FORDELETE flag hint allows those alternative storage engines to
  2.5177 +** skip a lot of work.  Namely:  FORDELETE cursors may treat all SEEK
  2.5178 +** and DELETE operations as no-ops, and any READ operation against a
  2.5179 +** FORDELETE cursor may return a null row: 0x01 0x00.
  2.5180 +*/
  2.5181 +#define BTREE_WRCSR     0x00000004     /* read-write cursor */
  2.5182 +#define BTREE_FORDELETE 0x00000008     /* Cursor is for seek/delete only */
  2.5183  
  2.5184  SQLITE_PRIVATE int sqlite3BtreeCursor(
  2.5185    Btree*,                              /* BTree containing table to open */
  2.5186 @@ -8991,6 +10502,10 @@
  2.5187  );
  2.5188  SQLITE_PRIVATE int sqlite3BtreeCursorSize(void);
  2.5189  SQLITE_PRIVATE void sqlite3BtreeCursorZero(BtCursor*);
  2.5190 +SQLITE_PRIVATE void sqlite3BtreeCursorHintFlags(BtCursor*, unsigned);
  2.5191 +#ifdef SQLITE_ENABLE_CURSOR_HINTS
  2.5192 +SQLITE_PRIVATE void sqlite3BtreeCursorHint(BtCursor*, int, ...);
  2.5193 +#endif
  2.5194  
  2.5195  SQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor*);
  2.5196  SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked(
  2.5197 @@ -9000,8 +10515,14 @@
  2.5198    int bias,
  2.5199    int *pRes
  2.5200  );
  2.5201 -SQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor*, int*);
  2.5202 -SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor*);
  2.5203 +SQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor*);
  2.5204 +SQLITE_PRIVATE int sqlite3BtreeCursorRestore(BtCursor*, int*);
  2.5205 +SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor*, u8 flags);
  2.5206 +
  2.5207 +/* Allowed flags for the 2nd argument to sqlite3BtreeDelete() */
  2.5208 +#define BTREE_SAVEPOSITION 0x02  /* Leave cursor pointing at NEXT or PREV */
  2.5209 +#define BTREE_AUXDELETE    0x04  /* not the primary delete operation */
  2.5210 +
  2.5211  SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey,
  2.5212                                    const void *pData, int nData,
  2.5213                                    int nZero, int bias, int seekResult);
  2.5214 @@ -9024,8 +10545,9 @@
  2.5215  SQLITE_PRIVATE void sqlite3BtreeIncrblobCursor(BtCursor *);
  2.5216  SQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *);
  2.5217  SQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBt, int iVersion);
  2.5218 -SQLITE_PRIVATE void sqlite3BtreeCursorHints(BtCursor *, unsigned int mask);
  2.5219 +SQLITE_PRIVATE int sqlite3BtreeCursorHasHint(BtCursor*, unsigned int mask);
  2.5220  SQLITE_PRIVATE int sqlite3BtreeIsReadonly(Btree *pBt);
  2.5221 +SQLITE_PRIVATE int sqlite3HeaderSizeBtree(void);
  2.5222  
  2.5223  #ifndef NDEBUG
  2.5224  SQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor*);
  2.5225 @@ -9052,15 +10574,17 @@
  2.5226  #ifndef SQLITE_OMIT_SHARED_CACHE
  2.5227  SQLITE_PRIVATE   void sqlite3BtreeEnter(Btree*);
  2.5228  SQLITE_PRIVATE   void sqlite3BtreeEnterAll(sqlite3*);
  2.5229 +SQLITE_PRIVATE   int sqlite3BtreeSharable(Btree*);
  2.5230 +SQLITE_PRIVATE   void sqlite3BtreeEnterCursor(BtCursor*);
  2.5231  #else
  2.5232  # define sqlite3BtreeEnter(X) 
  2.5233  # define sqlite3BtreeEnterAll(X)
  2.5234 +# define sqlite3BtreeSharable(X) 0
  2.5235 +# define sqlite3BtreeEnterCursor(X)
  2.5236  #endif
  2.5237  
  2.5238  #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE
  2.5239 -SQLITE_PRIVATE   int sqlite3BtreeSharable(Btree*);
  2.5240  SQLITE_PRIVATE   void sqlite3BtreeLeave(Btree*);
  2.5241 -SQLITE_PRIVATE   void sqlite3BtreeEnterCursor(BtCursor*);
  2.5242  SQLITE_PRIVATE   void sqlite3BtreeLeaveCursor(BtCursor*);
  2.5243  SQLITE_PRIVATE   void sqlite3BtreeLeaveAll(sqlite3*);
  2.5244  #ifndef NDEBUG
  2.5245 @@ -9071,9 +10595,7 @@
  2.5246  #endif
  2.5247  #else
  2.5248  
  2.5249 -# define sqlite3BtreeSharable(X) 0
  2.5250  # define sqlite3BtreeLeave(X)
  2.5251 -# define sqlite3BtreeEnterCursor(X)
  2.5252  # define sqlite3BtreeLeaveCursor(X)
  2.5253  # define sqlite3BtreeLeaveAll(X)
  2.5254  
  2.5255 @@ -9137,19 +10659,23 @@
  2.5256    int p1;             /* First operand */
  2.5257    int p2;             /* Second parameter (often the jump destination) */
  2.5258    int p3;             /* The third parameter */
  2.5259 -  union {             /* fourth parameter */
  2.5260 +  union p4union {     /* fourth parameter */
  2.5261      int i;                 /* Integer value if p4type==P4_INT32 */
  2.5262      void *p;               /* Generic pointer */
  2.5263      char *z;               /* Pointer to data for string (char array) types */
  2.5264      i64 *pI64;             /* Used when p4type is P4_INT64 */
  2.5265      double *pReal;         /* Used when p4type is P4_REAL */
  2.5266      FuncDef *pFunc;        /* Used when p4type is P4_FUNCDEF */
  2.5267 +    sqlite3_context *pCtx; /* Used when p4type is P4_FUNCCTX */
  2.5268      CollSeq *pColl;        /* Used when p4type is P4_COLLSEQ */
  2.5269      Mem *pMem;             /* Used when p4type is P4_MEM */
  2.5270      VTable *pVtab;         /* Used when p4type is P4_VTAB */
  2.5271      KeyInfo *pKeyInfo;     /* Used when p4type is P4_KEYINFO */
  2.5272      int *ai;               /* Used when p4type is P4_INTARRAY */
  2.5273      SubProgram *pProgram;  /* Used when p4type is P4_SUBPROGRAM */
  2.5274 +#ifdef SQLITE_ENABLE_CURSOR_HINTS
  2.5275 +    Expr *pExpr;           /* Used when p4type is P4_EXPR */
  2.5276 +#endif
  2.5277      int (*xAdvance)(BtCursor *, int *);
  2.5278    } p4;
  2.5279  #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
  2.5280 @@ -9200,6 +10726,7 @@
  2.5281  #define P4_COLLSEQ  (-4)  /* P4 is a pointer to a CollSeq structure */
  2.5282  #define P4_FUNCDEF  (-5)  /* P4 is a pointer to a FuncDef structure */
  2.5283  #define P4_KEYINFO  (-6)  /* P4 is a pointer to a KeyInfo structure */
  2.5284 +#define P4_EXPR     (-7)  /* P4 is a pointer to an Expr tree */
  2.5285  #define P4_MEM      (-8)  /* P4 is a pointer to a Mem*    structure */
  2.5286  #define P4_TRANSIENT  0   /* P4 is a pointer to a transient string */
  2.5287  #define P4_VTAB     (-10) /* P4 is a pointer to an sqlite3_vtab structure */
  2.5288 @@ -9210,6 +10737,7 @@
  2.5289  #define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */
  2.5290  #define P4_SUBPROGRAM  (-18) /* P4 is a pointer to a SubProgram structure */
  2.5291  #define P4_ADVANCE  (-19) /* P4 is a pointer to BtreeNext() or BtreePrev() */
  2.5292 +#define P4_FUNCCTX  (-20) /* P4 is a pointer to an sqlite3_context object */
  2.5293  
  2.5294  /* Error message codes for OP_Halt */
  2.5295  #define P5_ConstraintNotNull 1
  2.5296 @@ -9251,82 +10779,83 @@
  2.5297  /************** Include opcodes.h in the middle of vdbe.h ********************/
  2.5298  /************** Begin file opcodes.h *****************************************/
  2.5299  /* Automatically generated.  Do not edit */
  2.5300 -/* See the mkopcodeh.awk script for details */
  2.5301 -#define OP_Function        1 /* synopsis: r[P3]=func(r[P2@P5])             */
  2.5302 -#define OP_Savepoint       2
  2.5303 -#define OP_AutoCommit      3
  2.5304 -#define OP_Transaction     4
  2.5305 -#define OP_SorterNext      5
  2.5306 -#define OP_PrevIfOpen      6
  2.5307 -#define OP_NextIfOpen      7
  2.5308 -#define OP_Prev            8
  2.5309 -#define OP_Next            9
  2.5310 -#define OP_AggStep        10 /* synopsis: accum=r[P3] step(r[P2@P5])       */
  2.5311 -#define OP_Checkpoint     11
  2.5312 -#define OP_JournalMode    12
  2.5313 -#define OP_Vacuum         13
  2.5314 -#define OP_VFilter        14 /* synopsis: iplan=r[P3] zplan='P4'           */
  2.5315 -#define OP_VUpdate        15 /* synopsis: data=r[P3@P2]                    */
  2.5316 -#define OP_Goto           16
  2.5317 -#define OP_Gosub          17
  2.5318 -#define OP_Return         18
  2.5319 +/* See the tool/mkopcodeh.tcl script for details */
  2.5320 +#define OP_Savepoint       0
  2.5321 +#define OP_AutoCommit      1
  2.5322 +#define OP_Transaction     2
  2.5323 +#define OP_SorterNext      3
  2.5324 +#define OP_PrevIfOpen      4
  2.5325 +#define OP_NextIfOpen      5
  2.5326 +#define OP_Prev            6
  2.5327 +#define OP_Next            7
  2.5328 +#define OP_Checkpoint      8
  2.5329 +#define OP_JournalMode     9
  2.5330 +#define OP_Vacuum         10
  2.5331 +#define OP_VFilter        11 /* synopsis: iplan=r[P3] zplan='P4'           */
  2.5332 +#define OP_VUpdate        12 /* synopsis: data=r[P3@P2]                    */
  2.5333 +#define OP_Goto           13
  2.5334 +#define OP_Gosub          14
  2.5335 +#define OP_Return         15
  2.5336 +#define OP_InitCoroutine  16
  2.5337 +#define OP_EndCoroutine   17
  2.5338 +#define OP_Yield          18
  2.5339  #define OP_Not            19 /* same as TK_NOT, synopsis: r[P2]= !r[P1]    */
  2.5340 -#define OP_InitCoroutine  20
  2.5341 -#define OP_EndCoroutine   21
  2.5342 -#define OP_Yield          22
  2.5343 -#define OP_HaltIfNull     23 /* synopsis: if r[P3]=null halt               */
  2.5344 -#define OP_Halt           24
  2.5345 -#define OP_Integer        25 /* synopsis: r[P2]=P1                         */
  2.5346 -#define OP_Int64          26 /* synopsis: r[P2]=P4                         */
  2.5347 -#define OP_String         27 /* synopsis: r[P2]='P4' (len=P1)              */
  2.5348 -#define OP_Null           28 /* synopsis: r[P2..P3]=NULL                   */
  2.5349 -#define OP_SoftNull       29 /* synopsis: r[P1]=NULL                       */
  2.5350 -#define OP_Blob           30 /* synopsis: r[P2]=P4 (len=P1)                */
  2.5351 -#define OP_Variable       31 /* synopsis: r[P2]=parameter(P1,P4)           */
  2.5352 -#define OP_Move           32 /* synopsis: r[P2@P3]=r[P1@P3]                */
  2.5353 -#define OP_Copy           33 /* synopsis: r[P2@P3+1]=r[P1@P3+1]            */
  2.5354 -#define OP_SCopy          34 /* synopsis: r[P2]=r[P1]                      */
  2.5355 -#define OP_ResultRow      35 /* synopsis: output=r[P1@P2]                  */
  2.5356 -#define OP_CollSeq        36
  2.5357 +#define OP_HaltIfNull     20 /* synopsis: if r[P3]=null halt               */
  2.5358 +#define OP_Halt           21
  2.5359 +#define OP_Integer        22 /* synopsis: r[P2]=P1                         */
  2.5360 +#define OP_Int64          23 /* synopsis: r[P2]=P4                         */
  2.5361 +#define OP_String         24 /* synopsis: r[P2]='P4' (len=P1)              */
  2.5362 +#define OP_Null           25 /* synopsis: r[P2..P3]=NULL                   */
  2.5363 +#define OP_SoftNull       26 /* synopsis: r[P1]=NULL                       */
  2.5364 +#define OP_Blob           27 /* synopsis: r[P2]=P4 (len=P1)                */
  2.5365 +#define OP_Variable       28 /* synopsis: r[P2]=parameter(P1,P4)           */
  2.5366 +#define OP_Move           29 /* synopsis: r[P2@P3]=r[P1@P3]                */
  2.5367 +#define OP_Copy           30 /* synopsis: r[P2@P3+1]=r[P1@P3+1]            */
  2.5368 +#define OP_SCopy          31 /* synopsis: r[P2]=r[P1]                      */
  2.5369 +#define OP_IntCopy        32 /* synopsis: r[P2]=r[P1]                      */
  2.5370 +#define OP_ResultRow      33 /* synopsis: output=r[P1@P2]                  */
  2.5371 +#define OP_CollSeq        34
  2.5372 +#define OP_Function0      35 /* synopsis: r[P3]=func(r[P2@P5])             */
  2.5373 +#define OP_Function       36 /* synopsis: r[P3]=func(r[P2@P5])             */
  2.5374  #define OP_AddImm         37 /* synopsis: r[P1]=r[P1]+P2                   */
  2.5375  #define OP_MustBeInt      38
  2.5376  #define OP_RealAffinity   39
  2.5377 -#define OP_Permutation    40
  2.5378 -#define OP_Compare        41 /* synopsis: r[P1@P3] <-> r[P2@P3]            */
  2.5379 -#define OP_Jump           42
  2.5380 -#define OP_Once           43
  2.5381 -#define OP_If             44
  2.5382 -#define OP_IfNot          45
  2.5383 -#define OP_Column         46 /* synopsis: r[P3]=PX                         */
  2.5384 -#define OP_Affinity       47 /* synopsis: affinity(r[P1@P2])               */
  2.5385 -#define OP_MakeRecord     48 /* synopsis: r[P3]=mkrec(r[P1@P2])            */
  2.5386 -#define OP_Count          49 /* synopsis: r[P2]=count()                    */
  2.5387 -#define OP_ReadCookie     50
  2.5388 -#define OP_SetCookie      51
  2.5389 -#define OP_ReopenIdx      52 /* synopsis: root=P2 iDb=P3                   */
  2.5390 -#define OP_OpenRead       53 /* synopsis: root=P2 iDb=P3                   */
  2.5391 -#define OP_OpenWrite      54 /* synopsis: root=P2 iDb=P3                   */
  2.5392 -#define OP_OpenAutoindex  55 /* synopsis: nColumn=P2                       */
  2.5393 -#define OP_OpenEphemeral  56 /* synopsis: nColumn=P2                       */
  2.5394 -#define OP_SorterOpen     57
  2.5395 -#define OP_OpenPseudo     58 /* synopsis: P3 columns in r[P2]              */
  2.5396 -#define OP_Close          59
  2.5397 -#define OP_SeekLT         60 /* synopsis: key=r[P3@P4]                     */
  2.5398 -#define OP_SeekLE         61 /* synopsis: key=r[P3@P4]                     */
  2.5399 -#define OP_SeekGE         62 /* synopsis: key=r[P3@P4]                     */
  2.5400 -#define OP_SeekGT         63 /* synopsis: key=r[P3@P4]                     */
  2.5401 -#define OP_Seek           64 /* synopsis: intkey=r[P2]                     */
  2.5402 -#define OP_NoConflict     65 /* synopsis: key=r[P3@P4]                     */
  2.5403 -#define OP_NotFound       66 /* synopsis: key=r[P3@P4]                     */
  2.5404 -#define OP_Found          67 /* synopsis: key=r[P3@P4]                     */
  2.5405 -#define OP_NotExists      68 /* synopsis: intkey=r[P3]                     */
  2.5406 -#define OP_Sequence       69 /* synopsis: r[P2]=cursor[P1].ctr++           */
  2.5407 -#define OP_NewRowid       70 /* synopsis: r[P2]=rowid                      */
  2.5408 +#define OP_Cast           40 /* synopsis: affinity(r[P1])                  */
  2.5409 +#define OP_Permutation    41
  2.5410 +#define OP_Compare        42 /* synopsis: r[P1@P3] <-> r[P2@P3]            */
  2.5411 +#define OP_Jump           43
  2.5412 +#define OP_Once           44
  2.5413 +#define OP_If             45
  2.5414 +#define OP_IfNot          46
  2.5415 +#define OP_Column         47 /* synopsis: r[P3]=PX                         */
  2.5416 +#define OP_Affinity       48 /* synopsis: affinity(r[P1@P2])               */
  2.5417 +#define OP_MakeRecord     49 /* synopsis: r[P3]=mkrec(r[P1@P2])            */
  2.5418 +#define OP_Count          50 /* synopsis: r[P2]=count()                    */
  2.5419 +#define OP_ReadCookie     51
  2.5420 +#define OP_SetCookie      52
  2.5421 +#define OP_ReopenIdx      53 /* synopsis: root=P2 iDb=P3                   */
  2.5422 +#define OP_OpenRead       54 /* synopsis: root=P2 iDb=P3                   */
  2.5423 +#define OP_OpenWrite      55 /* synopsis: root=P2 iDb=P3                   */
  2.5424 +#define OP_OpenAutoindex  56 /* synopsis: nColumn=P2                       */
  2.5425 +#define OP_OpenEphemeral  57 /* synopsis: nColumn=P2                       */
  2.5426 +#define OP_SorterOpen     58
  2.5427 +#define OP_SequenceTest   59 /* synopsis: if( cursor[P1].ctr++ ) pc = P2   */
  2.5428 +#define OP_OpenPseudo     60 /* synopsis: P3 columns in r[P2]              */
  2.5429 +#define OP_Close          61
  2.5430 +#define OP_ColumnsUsed    62
  2.5431 +#define OP_SeekLT         63 /* synopsis: key=r[P3@P4]                     */
  2.5432 +#define OP_SeekLE         64 /* synopsis: key=r[P3@P4]                     */
  2.5433 +#define OP_SeekGE         65 /* synopsis: key=r[P3@P4]                     */
  2.5434 +#define OP_SeekGT         66 /* synopsis: key=r[P3@P4]                     */
  2.5435 +#define OP_NoConflict     67 /* synopsis: key=r[P3@P4]                     */
  2.5436 +#define OP_NotFound       68 /* synopsis: key=r[P3@P4]                     */
  2.5437 +#define OP_Found          69 /* synopsis: key=r[P3@P4]                     */
  2.5438 +#define OP_NotExists      70 /* synopsis: intkey=r[P3]                     */
  2.5439  #define OP_Or             71 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
  2.5440  #define OP_And            72 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
  2.5441 -#define OP_Insert         73 /* synopsis: intkey=r[P3] data=r[P2]          */
  2.5442 -#define OP_InsertInt      74 /* synopsis: intkey=P3 data=r[P2]             */
  2.5443 -#define OP_Delete         75
  2.5444 +#define OP_Sequence       73 /* synopsis: r[P2]=cursor[P1].ctr++           */
  2.5445 +#define OP_NewRowid       74 /* synopsis: r[P2]=rowid                      */
  2.5446 +#define OP_Insert         75 /* synopsis: intkey=r[P3] data=r[P2]          */
  2.5447  #define OP_IsNull         76 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
  2.5448  #define OP_NotNull        77 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
  2.5449  #define OP_Ne             78 /* same as TK_NE, synopsis: if r[P1]!=r[P3] goto P2 */
  2.5450 @@ -9335,7 +10864,7 @@
  2.5451  #define OP_Le             81 /* same as TK_LE, synopsis: if r[P1]<=r[P3] goto P2 */
  2.5452  #define OP_Lt             82 /* same as TK_LT, synopsis: if r[P1]<r[P3] goto P2 */
  2.5453  #define OP_Ge             83 /* same as TK_GE, synopsis: if r[P1]>=r[P3] goto P2 */
  2.5454 -#define OP_ResetCount     84
  2.5455 +#define OP_InsertInt      84 /* synopsis: intkey=P3 data=r[P2]             */
  2.5456  #define OP_BitAnd         85 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
  2.5457  #define OP_BitOr          86 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
  2.5458  #define OP_ShiftLeft      87 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
  2.5459 @@ -9346,104 +10875,106 @@
  2.5460  #define OP_Divide         92 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
  2.5461  #define OP_Remainder      93 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
  2.5462  #define OP_Concat         94 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
  2.5463 -#define OP_SorterCompare  95 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
  2.5464 +#define OP_Delete         95
  2.5465  #define OP_BitNot         96 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
  2.5466  #define OP_String8        97 /* same as TK_STRING, synopsis: r[P2]='P4'    */
  2.5467 -#define OP_SorterData     98 /* synopsis: r[P2]=data                       */
  2.5468 -#define OP_RowKey         99 /* synopsis: r[P2]=key                        */
  2.5469 -#define OP_RowData       100 /* synopsis: r[P2]=data                       */
  2.5470 -#define OP_Rowid         101 /* synopsis: r[P2]=rowid                      */
  2.5471 -#define OP_NullRow       102
  2.5472 -#define OP_Last          103
  2.5473 -#define OP_SorterSort    104
  2.5474 -#define OP_Sort          105
  2.5475 -#define OP_Rewind        106
  2.5476 -#define OP_SorterInsert  107
  2.5477 -#define OP_IdxInsert     108 /* synopsis: key=r[P2]                        */
  2.5478 -#define OP_IdxDelete     109 /* synopsis: key=r[P2@P3]                     */
  2.5479 -#define OP_IdxRowid      110 /* synopsis: r[P2]=rowid                      */
  2.5480 -#define OP_IdxLE         111 /* synopsis: key=r[P3@P4]                     */
  2.5481 -#define OP_IdxGT         112 /* synopsis: key=r[P3@P4]                     */
  2.5482 -#define OP_IdxLT         113 /* synopsis: key=r[P3@P4]                     */
  2.5483 -#define OP_IdxGE         114 /* synopsis: key=r[P3@P4]                     */
  2.5484 -#define OP_Destroy       115
  2.5485 -#define OP_Clear         116
  2.5486 -#define OP_ResetSorter   117
  2.5487 -#define OP_CreateIndex   118 /* synopsis: r[P2]=root iDb=P1                */
  2.5488 -#define OP_CreateTable   119 /* synopsis: r[P2]=root iDb=P1                */
  2.5489 -#define OP_ParseSchema   120
  2.5490 -#define OP_LoadAnalysis  121
  2.5491 -#define OP_DropTable     122
  2.5492 -#define OP_DropIndex     123
  2.5493 -#define OP_DropTrigger   124
  2.5494 -#define OP_IntegrityCk   125
  2.5495 -#define OP_RowSetAdd     126 /* synopsis: rowset(P1)=r[P2]                 */
  2.5496 -#define OP_RowSetRead    127 /* synopsis: r[P3]=rowset(P1)                 */
  2.5497 -#define OP_RowSetTest    128 /* synopsis: if r[P3] in rowset(P1) goto P2   */
  2.5498 -#define OP_Program       129
  2.5499 -#define OP_Param         130
  2.5500 -#define OP_FkCounter     131 /* synopsis: fkctr[P1]+=P2                    */
  2.5501 -#define OP_FkIfZero      132 /* synopsis: if fkctr[P1]==0 goto P2          */
  2.5502 +#define OP_ResetCount     98
  2.5503 +#define OP_SorterCompare  99 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
  2.5504 +#define OP_SorterData    100 /* synopsis: r[P2]=data                       */
  2.5505 +#define OP_RowKey        101 /* synopsis: r[P2]=key                        */
  2.5506 +#define OP_RowData       102 /* synopsis: r[P2]=data                       */
  2.5507 +#define OP_Rowid         103 /* synopsis: r[P2]=rowid                      */
  2.5508 +#define OP_NullRow       104
  2.5509 +#define OP_Last          105
  2.5510 +#define OP_SorterSort    106
  2.5511 +#define OP_Sort          107
  2.5512 +#define OP_Rewind        108
  2.5513 +#define OP_SorterInsert  109
  2.5514 +#define OP_IdxInsert     110 /* synopsis: key=r[P2]                        */
  2.5515 +#define OP_IdxDelete     111 /* synopsis: key=r[P2@P3]                     */
  2.5516 +#define OP_Seek          112 /* synopsis: Move P3 to P1.rowid              */
  2.5517 +#define OP_IdxRowid      113 /* synopsis: r[P2]=rowid                      */
  2.5518 +#define OP_IdxLE         114 /* synopsis: key=r[P3@P4]                     */
  2.5519 +#define OP_IdxGT         115 /* synopsis: key=r[P3@P4]                     */
  2.5520 +#define OP_IdxLT         116 /* synopsis: key=r[P3@P4]                     */
  2.5521 +#define OP_IdxGE         117 /* synopsis: key=r[P3@P4]                     */
  2.5522 +#define OP_Destroy       118
  2.5523 +#define OP_Clear         119
  2.5524 +#define OP_ResetSorter   120
  2.5525 +#define OP_CreateIndex   121 /* synopsis: r[P2]=root iDb=P1                */
  2.5526 +#define OP_CreateTable   122 /* synopsis: r[P2]=root iDb=P1                */
  2.5527 +#define OP_ParseSchema   123
  2.5528 +#define OP_LoadAnalysis  124
  2.5529 +#define OP_DropTable     125
  2.5530 +#define OP_DropIndex     126
  2.5531 +#define OP_DropTrigger   127
  2.5532 +#define OP_IntegrityCk   128
  2.5533 +#define OP_RowSetAdd     129 /* synopsis: rowset(P1)=r[P2]                 */
  2.5534 +#define OP_RowSetRead    130 /* synopsis: r[P3]=rowset(P1)                 */
  2.5535 +#define OP_RowSetTest    131 /* synopsis: if r[P3] in rowset(P1) goto P2   */
  2.5536 +#define OP_Program       132
  2.5537  #define OP_Real          133 /* same as TK_FLOAT, synopsis: r[P2]=P4       */
  2.5538 -#define OP_MemMax        134 /* synopsis: r[P1]=max(r[P1],r[P2])           */
  2.5539 -#define OP_IfPos         135 /* synopsis: if r[P1]>0 goto P2               */
  2.5540 -#define OP_IfNeg         136 /* synopsis: r[P1]+=P3, if r[P1]<0 goto P2    */
  2.5541 -#define OP_IfZero        137 /* synopsis: r[P1]+=P3, if r[P1]==0 goto P2   */
  2.5542 -#define OP_AggFinal      138 /* synopsis: accum=r[P1] N=P2                 */
  2.5543 -#define OP_IncrVacuum    139
  2.5544 -#define OP_Expire        140
  2.5545 -#define OP_TableLock     141 /* synopsis: iDb=P1 root=P2 write=P3          */
  2.5546 -#define OP_VBegin        142
  2.5547 -#define OP_ToText        143 /* same as TK_TO_TEXT                         */
  2.5548 -#define OP_ToBlob        144 /* same as TK_TO_BLOB                         */
  2.5549 -#define OP_ToNumeric     145 /* same as TK_TO_NUMERIC                      */
  2.5550 -#define OP_ToInt         146 /* same as TK_TO_INT                          */
  2.5551 -#define OP_ToReal        147 /* same as TK_TO_REAL                         */
  2.5552 -#define OP_VCreate       148
  2.5553 -#define OP_VDestroy      149
  2.5554 -#define OP_VOpen         150
  2.5555 -#define OP_VColumn       151 /* synopsis: r[P3]=vcolumn(P2)                */
  2.5556 -#define OP_VNext         152
  2.5557 -#define OP_VRename       153
  2.5558 -#define OP_Pagecount     154
  2.5559 -#define OP_MaxPgcnt      155
  2.5560 -#define OP_Init          156 /* synopsis: Start at P2                      */
  2.5561 -#define OP_Noop          157
  2.5562 -#define OP_Explain       158
  2.5563 -
  2.5564 +#define OP_Param         134
  2.5565 +#define OP_FkCounter     135 /* synopsis: fkctr[P1]+=P2                    */
  2.5566 +#define OP_FkIfZero      136 /* synopsis: if fkctr[P1]==0 goto P2          */
  2.5567 +#define OP_MemMax        137 /* synopsis: r[P1]=max(r[P1],r[P2])           */
  2.5568 +#define OP_IfPos         138 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
  2.5569 +#define OP_OffsetLimit   139 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
  2.5570 +#define OP_IfNotZero     140 /* synopsis: if r[P1]!=0 then r[P1]-=P3, goto P2 */
  2.5571 +#define OP_DecrJumpZero  141 /* synopsis: if (--r[P1])==0 goto P2          */
  2.5572 +#define OP_JumpZeroIncr  142 /* synopsis: if (r[P1]++)==0 ) goto P2        */
  2.5573 +#define OP_AggStep0      143 /* synopsis: accum=r[P3] step(r[P2@P5])       */
  2.5574 +#define OP_AggStep       144 /* synopsis: accum=r[P3] step(r[P2@P5])       */
  2.5575 +#define OP_AggFinal      145 /* synopsis: accum=r[P1] N=P2                 */
  2.5576 +#define OP_IncrVacuum    146
  2.5577 +#define OP_Expire        147
  2.5578 +#define OP_TableLock     148 /* synopsis: iDb=P1 root=P2 write=P3          */
  2.5579 +#define OP_VBegin        149
  2.5580 +#define OP_VCreate       150
  2.5581 +#define OP_VDestroy      151
  2.5582 +#define OP_VOpen         152
  2.5583 +#define OP_VColumn       153 /* synopsis: r[P3]=vcolumn(P2)                */
  2.5584 +#define OP_VNext         154
  2.5585 +#define OP_VRename       155
  2.5586 +#define OP_Pagecount     156
  2.5587 +#define OP_MaxPgcnt      157
  2.5588 +#define OP_Init          158 /* synopsis: Start at P2                      */
  2.5589 +#define OP_CursorHint    159
  2.5590 +#define OP_Noop          160
  2.5591 +#define OP_Explain       161
  2.5592  
  2.5593  /* Properties such as "out2" or "jump" that are specified in
  2.5594  ** comments following the "case" for each opcode in the vdbe.c
  2.5595  ** are encoded into bitvectors as follows:
  2.5596  */
  2.5597 -#define OPFLG_JUMP            0x0001  /* jump:  P2 holds jmp target */
  2.5598 -#define OPFLG_OUT2_PRERELEASE 0x0002  /* out2-prerelease: */
  2.5599 -#define OPFLG_IN1             0x0004  /* in1:   P1 is an input */
  2.5600 -#define OPFLG_IN2             0x0008  /* in2:   P2 is an input */
  2.5601 -#define OPFLG_IN3             0x0010  /* in3:   P3 is an input */
  2.5602 -#define OPFLG_OUT2            0x0020  /* out2:  P2 is an output */
  2.5603 -#define OPFLG_OUT3            0x0040  /* out3:  P3 is an output */
  2.5604 +#define OPFLG_JUMP        0x01  /* jump:  P2 holds jmp target */
  2.5605 +#define OPFLG_IN1         0x02  /* in1:   P1 is an input */
  2.5606 +#define OPFLG_IN2         0x04  /* in2:   P2 is an input */
  2.5607 +#define OPFLG_IN3         0x08  /* in3:   P3 is an input */
  2.5608 +#define OPFLG_OUT2        0x10  /* out2:  P2 is an output */
  2.5609 +#define OPFLG_OUT3        0x20  /* out3:  P3 is an output */
  2.5610  #define OPFLG_INITIALIZER {\
  2.5611 -/*   0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,\
  2.5612 -/*   8 */ 0x01, 0x01, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00,\
  2.5613 -/*  16 */ 0x01, 0x01, 0x04, 0x24, 0x01, 0x04, 0x05, 0x10,\
  2.5614 -/*  24 */ 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02,\
  2.5615 -/*  32 */ 0x00, 0x00, 0x20, 0x00, 0x00, 0x04, 0x05, 0x04,\
  2.5616 -/*  40 */ 0x00, 0x00, 0x01, 0x01, 0x05, 0x05, 0x00, 0x00,\
  2.5617 -/*  48 */ 0x00, 0x02, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00,\
  2.5618 -/*  56 */ 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11,\
  2.5619 -/*  64 */ 0x08, 0x11, 0x11, 0x11, 0x11, 0x02, 0x02, 0x4c,\
  2.5620 -/*  72 */ 0x4c, 0x00, 0x00, 0x00, 0x05, 0x05, 0x15, 0x15,\
  2.5621 -/*  80 */ 0x15, 0x15, 0x15, 0x15, 0x00, 0x4c, 0x4c, 0x4c,\
  2.5622 -/*  88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x00,\
  2.5623 -/*  96 */ 0x24, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01,\
  2.5624 -/* 104 */ 0x01, 0x01, 0x01, 0x08, 0x08, 0x00, 0x02, 0x01,\
  2.5625 -/* 112 */ 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x02, 0x02,\
  2.5626 -/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x45,\
  2.5627 -/* 128 */ 0x15, 0x01, 0x02, 0x00, 0x01, 0x02, 0x08, 0x05,\
  2.5628 -/* 136 */ 0x05, 0x05, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04,\
  2.5629 -/* 144 */ 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00,\
  2.5630 -/* 152 */ 0x01, 0x00, 0x02, 0x02, 0x01, 0x00, 0x00,}
  2.5631 +/*   0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01,\
  2.5632 +/*   8 */ 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x01, 0x02,\
  2.5633 +/*  16 */ 0x01, 0x02, 0x03, 0x12, 0x08, 0x00, 0x10, 0x10,\
  2.5634 +/*  24 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\
  2.5635 +/*  32 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02,\
  2.5636 +/*  40 */ 0x02, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x00,\
  2.5637 +/*  48 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,\
  2.5638 +/*  56 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,\
  2.5639 +/*  64 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x26,\
  2.5640 +/*  72 */ 0x26, 0x10, 0x10, 0x00, 0x03, 0x03, 0x0b, 0x0b,\
  2.5641 +/*  80 */ 0x0b, 0x0b, 0x0b, 0x0b, 0x00, 0x26, 0x26, 0x26,\
  2.5642 +/*  88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00,\
  2.5643 +/*  96 */ 0x12, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\
  2.5644 +/* 104 */ 0x00, 0x01, 0x01, 0x01, 0x01, 0x04, 0x04, 0x00,\
  2.5645 +/* 112 */ 0x00, 0x10, 0x01, 0x01, 0x01, 0x01, 0x10, 0x00,\
  2.5646 +/* 120 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
  2.5647 +/* 128 */ 0x00, 0x06, 0x23, 0x0b, 0x01, 0x10, 0x10, 0x00,\
  2.5648 +/* 136 */ 0x01, 0x04, 0x03, 0x1a, 0x03, 0x03, 0x03, 0x00,\
  2.5649 +/* 144 */ 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,\
  2.5650 +/* 152 */ 0x00, 0x00, 0x01, 0x00, 0x10, 0x10, 0x01, 0x00,\
  2.5651 +/* 160 */ 0x00, 0x00,}
  2.5652  
  2.5653  /************** End of opcodes.h *********************************************/
  2.5654  /************** Continuing where we left off in vdbe.h ***********************/
  2.5655 @@ -9456,17 +10987,28 @@
  2.5656  SQLITE_PRIVATE int sqlite3VdbeAddOp0(Vdbe*,int);
  2.5657  SQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe*,int,int);
  2.5658  SQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe*,int,int,int);
  2.5659 +SQLITE_PRIVATE int sqlite3VdbeGoto(Vdbe*,int);
  2.5660 +SQLITE_PRIVATE int sqlite3VdbeLoadString(Vdbe*,int,const char*);
  2.5661 +SQLITE_PRIVATE void sqlite3VdbeMultiLoad(Vdbe*,int,const char*,...);
  2.5662  SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int);
  2.5663  SQLITE_PRIVATE int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int);
  2.5664 +SQLITE_PRIVATE int sqlite3VdbeAddOp4Dup8(Vdbe*,int,int,int,int,const u8*,int);
  2.5665  SQLITE_PRIVATE int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int);
  2.5666 -SQLITE_PRIVATE int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp, int iLineno);
  2.5667 +SQLITE_PRIVATE void sqlite3VdbeEndCoroutine(Vdbe*,int);
  2.5668 +#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)
  2.5669 +SQLITE_PRIVATE   void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N);
  2.5670 +#else
  2.5671 +# define sqlite3VdbeVerifyNoMallocRequired(A,B)
  2.5672 +#endif
  2.5673 +SQLITE_PRIVATE VdbeOp *sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp, int iLineno);
  2.5674  SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*);
  2.5675 +SQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe*, u32 addr, u8);
  2.5676  SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, u32 addr, int P1);
  2.5677  SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, u32 addr, int P2);
  2.5678  SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, u32 addr, int P3);
  2.5679  SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u8 P5);
  2.5680  SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr);
  2.5681 -SQLITE_PRIVATE void sqlite3VdbeChangeToNoop(Vdbe*, int addr);
  2.5682 +SQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe*, int addr);
  2.5683  SQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op);
  2.5684  SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N);
  2.5685  SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse*, Index*);
  2.5686 @@ -9501,10 +11043,11 @@
  2.5687  SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
  2.5688  
  2.5689  SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,UnpackedRecord*);
  2.5690 -SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*,int);
  2.5691 +SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);
  2.5692 +SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(int, const void *, UnpackedRecord *, int);
  2.5693  SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo *, char *, int, char **);
  2.5694  
  2.5695 -typedef int (*RecordCompare)(int,const void*,UnpackedRecord*,int);
  2.5696 +typedef int (*RecordCompare)(int,const void*,UnpackedRecord*);
  2.5697  SQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*);
  2.5698  
  2.5699  #ifndef SQLITE_OMIT_TRIGGER
  2.5700 @@ -9571,6 +11114,12 @@
  2.5701  # define VDBE_OFFSET_LINENO(x) 0
  2.5702  #endif
  2.5703  
  2.5704 +#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
  2.5705 +SQLITE_PRIVATE void sqlite3VdbeScanStatus(Vdbe*, int, int, int, LogEst, const char*);
  2.5706 +#else
  2.5707 +# define sqlite3VdbeScanStatus(a,b,c,d,e)
  2.5708 +#endif
  2.5709 +
  2.5710  #endif
  2.5711  
  2.5712  /************** End of vdbe.h ************************************************/
  2.5713 @@ -9658,7 +11207,7 @@
  2.5714  #define PAGER_JOURNALMODE_WAL         5   /* Use write-ahead logging */
  2.5715  
  2.5716  /*
  2.5717 -** Flags that make up the mask passed to sqlite3PagerAcquire().
  2.5718 +** Flags that make up the mask passed to sqlite3PagerGet().
  2.5719  */
  2.5720  #define PAGER_GET_NOCONTENT     0x01  /* Do not load data from disk */
  2.5721  #define PAGER_GET_READONLY      0x02  /* Read-only page is acceptable */
  2.5722 @@ -9669,11 +11218,12 @@
  2.5723  #define PAGER_SYNCHRONOUS_OFF       0x01  /* PRAGMA synchronous=OFF */
  2.5724  #define PAGER_SYNCHRONOUS_NORMAL    0x02  /* PRAGMA synchronous=NORMAL */
  2.5725  #define PAGER_SYNCHRONOUS_FULL      0x03  /* PRAGMA synchronous=FULL */
  2.5726 -#define PAGER_SYNCHRONOUS_MASK      0x03  /* Mask for three values above */
  2.5727 -#define PAGER_FULLFSYNC             0x04  /* PRAGMA fullfsync=ON */
  2.5728 -#define PAGER_CKPT_FULLFSYNC        0x08  /* PRAGMA checkpoint_fullfsync=ON */
  2.5729 -#define PAGER_CACHESPILL            0x10  /* PRAGMA cache_spill=ON */
  2.5730 -#define PAGER_FLAGS_MASK            0x1c  /* All above except SYNCHRONOUS */
  2.5731 +#define PAGER_SYNCHRONOUS_EXTRA     0x04  /* PRAGMA synchronous=EXTRA */
  2.5732 +#define PAGER_SYNCHRONOUS_MASK      0x07  /* Mask for four values above */
  2.5733 +#define PAGER_FULLFSYNC             0x08  /* PRAGMA fullfsync=ON */
  2.5734 +#define PAGER_CKPT_FULLFSYNC        0x10  /* PRAGMA checkpoint_fullfsync=ON */
  2.5735 +#define PAGER_CACHESPILL            0x20  /* PRAGMA cache_spill=ON */
  2.5736 +#define PAGER_FLAGS_MASK            0x38  /* All above except SYNCHRONOUS */
  2.5737  
  2.5738  /*
  2.5739  ** The remainder of this file contains the declarations of the functions
  2.5740 @@ -9697,8 +11247,12 @@
  2.5741  /* Functions used to configure a Pager object. */
  2.5742  SQLITE_PRIVATE void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *);
  2.5743  SQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager*, u32*, int);
  2.5744 +#ifdef SQLITE_HAS_CODEC
  2.5745 +SQLITE_PRIVATE void sqlite3PagerAlignReserve(Pager*,Pager*);
  2.5746 +#endif
  2.5747  SQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager*, int);
  2.5748  SQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager*, int);
  2.5749 +SQLITE_PRIVATE int sqlite3PagerSetSpillsize(Pager*, int);
  2.5750  SQLITE_PRIVATE void sqlite3PagerSetMmapLimit(Pager *, sqlite3_int64);
  2.5751  SQLITE_PRIVATE void sqlite3PagerShrink(Pager*);
  2.5752  SQLITE_PRIVATE void sqlite3PagerSetFlags(Pager*,unsigned);
  2.5753 @@ -9708,10 +11262,10 @@
  2.5754  SQLITE_PRIVATE int sqlite3PagerOkToChangeJournalMode(Pager*);
  2.5755  SQLITE_PRIVATE i64 sqlite3PagerJournalSizeLimit(Pager *, i64);
  2.5756  SQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager*);
  2.5757 +SQLITE_PRIVATE int sqlite3PagerFlush(Pager*);
  2.5758  
  2.5759  /* Functions used to obtain and release page references. */ 
  2.5760 -SQLITE_PRIVATE int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag);
  2.5761 -#define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0)
  2.5762 +SQLITE_PRIVATE int sqlite3PagerGet(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag);
  2.5763  SQLITE_PRIVATE DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno);
  2.5764  SQLITE_PRIVATE void sqlite3PagerRef(DbPage*);
  2.5765  SQLITE_PRIVATE void sqlite3PagerUnref(DbPage*);
  2.5766 @@ -9743,6 +11297,10 @@
  2.5767  SQLITE_PRIVATE   int sqlite3PagerWalCallback(Pager *pPager);
  2.5768  SQLITE_PRIVATE   int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);
  2.5769  SQLITE_PRIVATE   int sqlite3PagerCloseWal(Pager *pPager);
  2.5770 +# ifdef SQLITE_ENABLE_SNAPSHOT
  2.5771 +SQLITE_PRIVATE   int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot);
  2.5772 +SQLITE_PRIVATE   int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot);
  2.5773 +# endif
  2.5774  #endif
  2.5775  
  2.5776  #ifdef SQLITE_ENABLE_ZIPVFS
  2.5777 @@ -9751,11 +11309,15 @@
  2.5778  
  2.5779  /* Functions used to query pager state and configuration. */
  2.5780  SQLITE_PRIVATE u8 sqlite3PagerIsreadonly(Pager*);
  2.5781 -SQLITE_PRIVATE int sqlite3PagerRefcount(Pager*);
  2.5782 +SQLITE_PRIVATE u32 sqlite3PagerDataVersion(Pager*);
  2.5783 +#ifdef SQLITE_DEBUG
  2.5784 +SQLITE_PRIVATE   int sqlite3PagerRefcount(Pager*);
  2.5785 +#endif
  2.5786  SQLITE_PRIVATE int sqlite3PagerMemUsed(Pager*);
  2.5787  SQLITE_PRIVATE const char *sqlite3PagerFilename(Pager*, int);
  2.5788 -SQLITE_PRIVATE const sqlite3_vfs *sqlite3PagerVfs(Pager*);
  2.5789 +SQLITE_PRIVATE sqlite3_vfs *sqlite3PagerVfs(Pager*);
  2.5790  SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager*);
  2.5791 +SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager*);
  2.5792  SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*);
  2.5793  SQLITE_PRIVATE int sqlite3PagerNosync(Pager*);
  2.5794  SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*);
  2.5795 @@ -9767,6 +11329,8 @@
  2.5796  /* Functions used to truncate the database file. */
  2.5797  SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno);
  2.5798  
  2.5799 +SQLITE_PRIVATE void sqlite3PagerRekey(DbPage*, Pgno, u16);
  2.5800 +
  2.5801  #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL)
  2.5802  SQLITE_PRIVATE void *sqlite3PagerCodec(DbPage *);
  2.5803  #endif
  2.5804 @@ -9840,14 +11404,16 @@
  2.5805  };
  2.5806  
  2.5807  /* Bit values for PgHdr.flags */
  2.5808 -#define PGHDR_DIRTY             0x002  /* Page has changed */
  2.5809 -#define PGHDR_NEED_SYNC         0x004  /* Fsync the rollback journal before
  2.5810 -                                       ** writing this page to the database */
  2.5811 -#define PGHDR_NEED_READ         0x008  /* Content is unread */
  2.5812 -#define PGHDR_REUSE_UNLIKELY    0x010  /* A hint that reuse is unlikely */
  2.5813 -#define PGHDR_DONT_WRITE        0x020  /* Do not write content to disk */
  2.5814 -
  2.5815 -#define PGHDR_MMAP              0x040  /* This is an mmap page object */
  2.5816 +#define PGHDR_CLEAN           0x001  /* Page not on the PCache.pDirty list */
  2.5817 +#define PGHDR_DIRTY           0x002  /* Page is on the PCache.pDirty list */
  2.5818 +#define PGHDR_WRITEABLE       0x004  /* Journaled and ready to modify */
  2.5819 +#define PGHDR_NEED_SYNC       0x008  /* Fsync the rollback journal before
  2.5820 +                                     ** writing this page to the database */
  2.5821 +#define PGHDR_NEED_READ       0x010  /* Content is unread */
  2.5822 +#define PGHDR_DONT_WRITE      0x020  /* Do not write content to disk */
  2.5823 +#define PGHDR_MMAP            0x040  /* This is an mmap page object */
  2.5824 +
  2.5825 +#define PGHDR_WAL_APPEND      0x080  /* Appended to wal file */
  2.5826  
  2.5827  /* Initialize and shutdown the page cache subsystem */
  2.5828  SQLITE_PRIVATE int sqlite3PcacheInitialize(void);
  2.5829 @@ -9862,7 +11428,7 @@
  2.5830  ** Under memory stress, invoke xStress to try to make pages clean.
  2.5831  ** Only clean and unpinned pages can be reclaimed.
  2.5832  */
  2.5833 -SQLITE_PRIVATE void sqlite3PcacheOpen(
  2.5834 +SQLITE_PRIVATE int sqlite3PcacheOpen(
  2.5835    int szPage,                    /* Size of every page */
  2.5836    int szExtra,                   /* Extra space associated with each page */
  2.5837    int bPurgeable,                /* True if pages are on backing store */
  2.5838 @@ -9872,7 +11438,7 @@
  2.5839  );
  2.5840  
  2.5841  /* Modify the page-size after the cache has been created. */
  2.5842 -SQLITE_PRIVATE void sqlite3PcacheSetPageSize(PCache *, int);
  2.5843 +SQLITE_PRIVATE int sqlite3PcacheSetPageSize(PCache *, int);
  2.5844  
  2.5845  /* Return the size in bytes of a PCache object.  Used to preallocate
  2.5846  ** storage space.
  2.5847 @@ -9882,7 +11448,9 @@
  2.5848  /* One release per successful fetch.  Page is pinned until released.
  2.5849  ** Reference counted. 
  2.5850  */
  2.5851 -SQLITE_PRIVATE int sqlite3PcacheFetch(PCache*, Pgno, int createFlag, PgHdr**);
  2.5852 +SQLITE_PRIVATE sqlite3_pcache_page *sqlite3PcacheFetch(PCache*, Pgno, int createFlag);
  2.5853 +SQLITE_PRIVATE int sqlite3PcacheFetchStress(PCache*, Pgno, sqlite3_pcache_page**);
  2.5854 +SQLITE_PRIVATE PgHdr *sqlite3PcacheFetchFinish(PCache*, Pgno, sqlite3_pcache_page *pPage);
  2.5855  SQLITE_PRIVATE void sqlite3PcacheRelease(PgHdr*);
  2.5856  
  2.5857  SQLITE_PRIVATE void sqlite3PcacheDrop(PgHdr*);         /* Remove page from cache */
  2.5858 @@ -9938,6 +11506,13 @@
  2.5859  SQLITE_PRIVATE int sqlite3PcacheGetCachesize(PCache *);
  2.5860  #endif
  2.5861  
  2.5862 +/* Set or get the suggested spill-size for the specified pager-cache.
  2.5863 +**
  2.5864 +** The spill-size is the minimum number of pages in cache before the cache
  2.5865 +** will attempt to spill dirty pages by calling xStress.
  2.5866 +*/
  2.5867 +SQLITE_PRIVATE int sqlite3PcacheSetSpillsize(PCache *, int);
  2.5868 +
  2.5869  /* Free up as much memory as possible from the page cache */
  2.5870  SQLITE_PRIVATE void sqlite3PcacheShrink(PCache*);
  2.5871  
  2.5872 @@ -9952,6 +11527,10 @@
  2.5873  
  2.5874  SQLITE_PRIVATE void sqlite3PCacheSetDefault(void);
  2.5875  
  2.5876 +/* Return the header size */
  2.5877 +SQLITE_PRIVATE int sqlite3HeaderSizePcache(void);
  2.5878 +SQLITE_PRIVATE int sqlite3HeaderSizePcache1(void);
  2.5879 +
  2.5880  #endif /* _PCACHE_H_ */
  2.5881  
  2.5882  /************** End of pcache.h **********************************************/
  2.5883 @@ -10142,7 +11721,7 @@
  2.5884  ** shared locks begins at SHARED_FIRST. 
  2.5885  **
  2.5886  ** The same locking strategy and
  2.5887 -** byte ranges are used for Unix.  This leaves open the possiblity of having
  2.5888 +** byte ranges are used for Unix.  This leaves open the possibility of having
  2.5889  ** clients on win95, winNT, and unix all talking to the same shared file
  2.5890  ** and all locking correctly.  To do so would require that samba (or whatever
  2.5891  ** tool is being used for file sharing) implements locks correctly between
  2.5892 @@ -10261,7 +11840,7 @@
  2.5893  ** Figure out what version of the code to use.  The choices are
  2.5894  **
  2.5895  **   SQLITE_MUTEX_OMIT         No mutex logic.  Not even stubs.  The
  2.5896 -**                             mutexes implemention cannot be overridden
  2.5897 +**                             mutexes implementation cannot be overridden
  2.5898  **                             at start-time.
  2.5899  **
  2.5900  **   SQLITE_MUTEX_NOOP         For single-threaded applications.  No
  2.5901 @@ -10381,7 +11960,7 @@
  2.5902  ** The number of different kinds of things that can be limited
  2.5903  ** using the sqlite3_limit() interface.
  2.5904  */
  2.5905 -#define SQLITE_N_LIMIT (SQLITE_LIMIT_TRIGGER_DEPTH+1)
  2.5906 +#define SQLITE_N_LIMIT (SQLITE_LIMIT_WORKER_THREADS+1)
  2.5907  
  2.5908  /*
  2.5909  ** Lookaside malloc is a set of fixed-size buffers that can be used
  2.5910 @@ -10404,8 +11983,8 @@
  2.5911  ** lookaside allocations are not used to construct the schema objects.
  2.5912  */
  2.5913  struct Lookaside {
  2.5914 +  u32 bDisable;           /* Only operate the lookaside when zero */
  2.5915    u16 sz;                 /* Size of each buffer in bytes */
  2.5916 -  u8 bEnabled;            /* False to disable new lookaside allocations */
  2.5917    u8 bMalloced;           /* True if pStart obtained from sqlite3_malloc() */
  2.5918    int nOut;               /* Number of buffers currently checked out */
  2.5919    int mxOut;              /* Highwater mark for nOut */
  2.5920 @@ -10428,6 +12007,45 @@
  2.5921    FuncDef *a[23];       /* Hash table for functions */
  2.5922  };
  2.5923  
  2.5924 +#ifdef SQLITE_USER_AUTHENTICATION
  2.5925 +/*
  2.5926 +** Information held in the "sqlite3" database connection object and used
  2.5927 +** to manage user authentication.
  2.5928 +*/
  2.5929 +typedef struct sqlite3_userauth sqlite3_userauth;
  2.5930 +struct sqlite3_userauth {
  2.5931 +  u8 authLevel;                 /* Current authentication level */
  2.5932 +  int nAuthPW;                  /* Size of the zAuthPW in bytes */
  2.5933 +  char *zAuthPW;                /* Password used to authenticate */
  2.5934 +  char *zAuthUser;              /* User name used to authenticate */
  2.5935 +};
  2.5936 +
  2.5937 +/* Allowed values for sqlite3_userauth.authLevel */
  2.5938 +#define UAUTH_Unknown     0     /* Authentication not yet checked */
  2.5939 +#define UAUTH_Fail        1     /* User authentication failed */
  2.5940 +#define UAUTH_User        2     /* Authenticated as a normal user */
  2.5941 +#define UAUTH_Admin       3     /* Authenticated as an administrator */
  2.5942 +
  2.5943 +/* Functions used only by user authorization logic */
  2.5944 +SQLITE_PRIVATE int sqlite3UserAuthTable(const char*);
  2.5945 +SQLITE_PRIVATE int sqlite3UserAuthCheckLogin(sqlite3*,const char*,u8*);
  2.5946 +SQLITE_PRIVATE void sqlite3UserAuthInit(sqlite3*);
  2.5947 +SQLITE_PRIVATE void sqlite3CryptFunc(sqlite3_context*,int,sqlite3_value**);
  2.5948 +
  2.5949 +#endif /* SQLITE_USER_AUTHENTICATION */
  2.5950 +
  2.5951 +/*
  2.5952 +** typedef for the authorization callback function.
  2.5953 +*/
  2.5954 +#ifdef SQLITE_USER_AUTHENTICATION
  2.5955 +  typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,
  2.5956 +                               const char*, const char*);
  2.5957 +#else
  2.5958 +  typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,
  2.5959 +                               const char*);
  2.5960 +#endif
  2.5961 +
  2.5962 +
  2.5963  /*
  2.5964  ** Each database connection is an instance of the following structure.
  2.5965  */
  2.5966 @@ -10445,9 +12063,11 @@
  2.5967    int errCode;                  /* Most recent error code (SQLITE_*) */
  2.5968    int errMask;                  /* & result codes with this before returning */
  2.5969    u16 dbOptFlags;               /* Flags to enable/disable optimizations */
  2.5970 +  u8 enc;                       /* Text encoding */
  2.5971    u8 autoCommit;                /* The auto-commit flag. */
  2.5972    u8 temp_store;                /* 1: file 2: memory 0: default */
  2.5973    u8 mallocFailed;              /* True if we have seen a malloc failure */
  2.5974 +  u8 bBenignMalloc;             /* Do not require OOMs if true */
  2.5975    u8 dfltLockMode;              /* Default locking-mode for attached dbs */
  2.5976    signed char nextAutovac;      /* Autovac setting after VACUUM if >=0 */
  2.5977    u8 suppressErr;               /* Do not issue error messages if true */
  2.5978 @@ -10458,16 +12078,19 @@
  2.5979    int nChange;                  /* Value returned by sqlite3_changes() */
  2.5980    int nTotalChange;             /* Value returned by sqlite3_total_changes() */
  2.5981    int aLimit[SQLITE_N_LIMIT];   /* Limits */
  2.5982 +  int nMaxSorterMmap;           /* Maximum size of regions mapped by sorter */
  2.5983    struct sqlite3InitInfo {      /* Information used during initialization */
  2.5984      int newTnum;                /* Rootpage of table being initialized */
  2.5985      u8 iDb;                     /* Which db file is being initialized */
  2.5986      u8 busy;                    /* TRUE if currently initializing */
  2.5987      u8 orphanTrigger;           /* Last statement is orphaned TEMP trigger */
  2.5988 +    u8 imposterTable;           /* Building an imposter table */
  2.5989    } init;
  2.5990    int nVdbeActive;              /* Number of VDBEs currently running */
  2.5991    int nVdbeRead;                /* Number of active VDBEs that read or write */
  2.5992    int nVdbeWrite;               /* Number of active VDBEs that read and write */
  2.5993    int nVdbeExec;                /* Number of nested calls to VdbeExec() */
  2.5994 +  int nVDestroy;                /* Number of active OP_VDestroy operations */
  2.5995    int nExtension;               /* Number of loaded extensions */
  2.5996    void **aExtension;            /* Array of shared library handles */
  2.5997    void (*xTrace)(void*,const char*);        /* Trace function */
  2.5998 @@ -10494,8 +12117,7 @@
  2.5999    } u1;
  2.6000    Lookaside lookaside;          /* Lookaside malloc configuration */
  2.6001  #ifndef SQLITE_OMIT_AUTHORIZATION
  2.6002 -  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*);
  2.6003 -                                /* Access authorization function */
  2.6004 +  sqlite3_xauth xAuth;          /* Access authorization function */
  2.6005    void *pAuthArg;               /* 1st argument to the access auth function */
  2.6006  #endif
  2.6007  #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
  2.6008 @@ -10521,7 +12143,6 @@
  2.6009    i64 nDeferredCons;            /* Net deferred constraints this transaction. */
  2.6010    i64 nDeferredImmCons;         /* Net deferred immediate constraints */
  2.6011    int *pnBytesFreed;            /* If not NULL, increment this in DbFree() */
  2.6012 -
  2.6013  #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
  2.6014    /* The following variables are all protected by the STATIC_MASTER 
  2.6015    ** mutex, not by sqlite3.mutex. They are used by code in notify.c. 
  2.6016 @@ -10539,22 +12160,26 @@
  2.6017    void (*xUnlockNotify)(void **, int);  /* Unlock notify callback */
  2.6018    sqlite3 *pNextBlocked;        /* Next in list of all blocked connections */
  2.6019  #endif
  2.6020 +#ifdef SQLITE_USER_AUTHENTICATION
  2.6021 +  sqlite3_userauth auth;        /* User authentication information */
  2.6022 +#endif
  2.6023  };
  2.6024  
  2.6025  /*
  2.6026  ** A macro to discover the encoding of a database.
  2.6027  */
  2.6028 -#define ENC(db) ((db)->aDb[0].pSchema->enc)
  2.6029 +#define SCHEMA_ENC(db) ((db)->aDb[0].pSchema->enc)
  2.6030 +#define ENC(db)        ((db)->enc)
  2.6031  
  2.6032  /*
  2.6033  ** Possible values for the sqlite3.flags.
  2.6034  */
  2.6035  #define SQLITE_VdbeTrace      0x00000001  /* True to trace VDBE execution */
  2.6036  #define SQLITE_InternChanges  0x00000002  /* Uncommitted Hash table changes */
  2.6037 -#define SQLITE_FullFSync      0x00000004  /* Use full fsync on the backend */
  2.6038 -#define SQLITE_CkptFullFSync  0x00000008  /* Use full fsync for checkpoint */
  2.6039 -#define SQLITE_CacheSpill     0x00000010  /* OK to spill pager cache */
  2.6040 -#define SQLITE_FullColNames   0x00000020  /* Show full column names on SELECT */
  2.6041 +#define SQLITE_FullColNames   0x00000004  /* Show full column names on SELECT */
  2.6042 +#define SQLITE_FullFSync      0x00000008  /* Use full fsync on the backend */
  2.6043 +#define SQLITE_CkptFullFSync  0x00000010  /* Use full fsync for checkpoint */
  2.6044 +#define SQLITE_CacheSpill     0x00000020  /* OK to spill pager cache */
  2.6045  #define SQLITE_ShortColNames  0x00000040  /* Show short columns names */
  2.6046  #define SQLITE_CountRows      0x00000080  /* Count rows changed by INSERT, */
  2.6047                                            /*   DELETE, or UPDATE and return */
  2.6048 @@ -10579,6 +12204,8 @@
  2.6049  #define SQLITE_DeferFKs       0x01000000  /* Defer all FK constraints */
  2.6050  #define SQLITE_QueryOnly      0x02000000  /* Disable database changes */
  2.6051  #define SQLITE_VdbeEQP        0x04000000  /* Debug EXPLAIN QUERY PLAN */
  2.6052 +#define SQLITE_Vacuum         0x08000000  /* Currently in a VACUUM */
  2.6053 +#define SQLITE_CellSizeCk     0x10000000  /* Check btree cell sizes on load */
  2.6054  
  2.6055  
  2.6056  /*
  2.6057 @@ -10597,8 +12224,8 @@
  2.6058  #define SQLITE_SubqCoroutine  0x0100   /* Evaluate subqueries as coroutines */
  2.6059  #define SQLITE_Transitive     0x0200   /* Transitive constraints */
  2.6060  #define SQLITE_OmitNoopJoin   0x0400   /* Omit unused tables in joins */
  2.6061 -#define SQLITE_Stat3          0x0800   /* Use the SQLITE_STAT3 table */
  2.6062 -#define SQLITE_AdjustOutEst   0x1000   /* Adjust output estimates using WHERE */
  2.6063 +#define SQLITE_Stat34         0x0800   /* Use STAT3 or STAT4 data */
  2.6064 +#define SQLITE_CursorHints    0x2000   /* Add OP_CursorHint opcodes */
  2.6065  #define SQLITE_AllOpts        0xffff   /* All optimizations */
  2.6066  
  2.6067  /*
  2.6068 @@ -10641,9 +12268,8 @@
  2.6069    u16 funcFlags;       /* Some combination of SQLITE_FUNC_* */
  2.6070    void *pUserData;     /* User data parameter */
  2.6071    FuncDef *pNext;      /* Next function with same name */
  2.6072 -  void (*xFunc)(sqlite3_context*,int,sqlite3_value**); /* Regular function */
  2.6073 -  void (*xStep)(sqlite3_context*,int,sqlite3_value**); /* Aggregate step */
  2.6074 -  void (*xFinalize)(sqlite3_context*);                /* Aggregate finalizer */
  2.6075 +  void (*xSFunc)(sqlite3_context*,int,sqlite3_value**); /* func or agg-step */
  2.6076 +  void (*xFinalize)(sqlite3_context*);                  /* Agg finalizer */
  2.6077    char *zName;         /* SQL name of the function. */
  2.6078    FuncDef *pHash;      /* Next with a different name but the same hash */
  2.6079    FuncDestructor *pDestructor;   /* Reference counted destructor function */
  2.6080 @@ -10671,20 +12297,24 @@
  2.6081  
  2.6082  /*
  2.6083  ** Possible values for FuncDef.flags.  Note that the _LENGTH and _TYPEOF
  2.6084 -** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG.  There
  2.6085 +** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG.  And
  2.6086 +** SQLITE_FUNC_CONSTANT must be the same as SQLITE_DETERMINISTIC.  There
  2.6087  ** are assert() statements in the code to verify this.
  2.6088  */
  2.6089 -#define SQLITE_FUNC_ENCMASK  0x003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */
  2.6090 -#define SQLITE_FUNC_LIKE     0x004 /* Candidate for the LIKE optimization */
  2.6091 -#define SQLITE_FUNC_CASE     0x008 /* Case-sensitive LIKE-type function */
  2.6092 -#define SQLITE_FUNC_EPHEM    0x010 /* Ephemeral.  Delete with VDBE */
  2.6093 -#define SQLITE_FUNC_NEEDCOLL 0x020 /* sqlite3GetFuncCollSeq() might be called */
  2.6094 -#define SQLITE_FUNC_LENGTH   0x040 /* Built-in length() function */
  2.6095 -#define SQLITE_FUNC_TYPEOF   0x080 /* Built-in typeof() function */
  2.6096 -#define SQLITE_FUNC_COUNT    0x100 /* Built-in count(*) aggregate */
  2.6097 -#define SQLITE_FUNC_COALESCE 0x200 /* Built-in coalesce() or ifnull() */
  2.6098 -#define SQLITE_FUNC_UNLIKELY 0x400 /* Built-in unlikely() function */
  2.6099 -#define SQLITE_FUNC_CONSTANT 0x800 /* Constant inputs give a constant output */
  2.6100 +#define SQLITE_FUNC_ENCMASK  0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */
  2.6101 +#define SQLITE_FUNC_LIKE     0x0004 /* Candidate for the LIKE optimization */
  2.6102 +#define SQLITE_FUNC_CASE     0x0008 /* Case-sensitive LIKE-type function */
  2.6103 +#define SQLITE_FUNC_EPHEM    0x0010 /* Ephemeral.  Delete with VDBE */
  2.6104 +#define SQLITE_FUNC_NEEDCOLL 0x0020 /* sqlite3GetFuncCollSeq() might be called*/
  2.6105 +#define SQLITE_FUNC_LENGTH   0x0040 /* Built-in length() function */
  2.6106 +#define SQLITE_FUNC_TYPEOF   0x0080 /* Built-in typeof() function */
  2.6107 +#define SQLITE_FUNC_COUNT    0x0100 /* Built-in count(*) aggregate */
  2.6108 +#define SQLITE_FUNC_COALESCE 0x0200 /* Built-in coalesce() or ifnull() */
  2.6109 +#define SQLITE_FUNC_UNLIKELY 0x0400 /* Built-in unlikely() function */
  2.6110 +#define SQLITE_FUNC_CONSTANT 0x0800 /* Constant inputs give a constant output */
  2.6111 +#define SQLITE_FUNC_MINMAX   0x1000 /* True for min() and max() aggregates */
  2.6112 +#define SQLITE_FUNC_SLOCHNG  0x2000 /* "Slow Change". Value constant during a
  2.6113 +                                    ** single query - might change over time */
  2.6114  
  2.6115  /*
  2.6116  ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
  2.6117 @@ -10700,6 +12330,12 @@
  2.6118  **   VFUNCTION(zName, nArg, iArg, bNC, xFunc)
  2.6119  **     Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag.
  2.6120  **
  2.6121 +**   DFUNCTION(zName, nArg, iArg, bNC, xFunc)
  2.6122 +**     Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag and
  2.6123 +**     adds the SQLITE_FUNC_SLOCHNG flag.  Used for date & time functions
  2.6124 +**     and functions like sqlite_version() that can change, but not during
  2.6125 +**     a single query.
  2.6126 +**
  2.6127  **   AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal)
  2.6128  **     Used to create an aggregate function definition implemented by
  2.6129  **     the C functions xStep and xFinal. The first four parameters
  2.6130 @@ -10716,22 +12352,28 @@
  2.6131  */
  2.6132  #define FUNCTION(zName, nArg, iArg, bNC, xFunc) \
  2.6133    {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
  2.6134 -   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0}
  2.6135 +   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, 0, 0}
  2.6136  #define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \
  2.6137    {nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
  2.6138 -   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0}
  2.6139 +   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, 0, 0}
  2.6140 +#define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \
  2.6141 +  {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
  2.6142 +   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, 0, 0}
  2.6143  #define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \
  2.6144    {nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\
  2.6145 -   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0}
  2.6146 +   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, 0, 0}
  2.6147  #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
  2.6148 -  {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
  2.6149 -   pArg, 0, xFunc, 0, 0, #zName, 0, 0}
  2.6150 +  {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
  2.6151 +   pArg, 0, xFunc, 0, #zName, 0, 0}
  2.6152  #define LIKEFUNC(zName, nArg, arg, flags) \
  2.6153    {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \
  2.6154 -   (void *)arg, 0, likeFunc, 0, 0, #zName, 0, 0}
  2.6155 +   (void *)arg, 0, likeFunc, 0, #zName, 0, 0}
  2.6156  #define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \
  2.6157    {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL), \
  2.6158 -   SQLITE_INT_TO_PTR(arg), 0, 0, xStep,xFinal,#zName,0,0}
  2.6159 +   SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,#zName,0,0}
  2.6160 +#define AGGREGATE2(zName, nArg, arg, nc, xStep, xFinal, extraFlags) \
  2.6161 +  {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|extraFlags, \
  2.6162 +   SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,#zName,0,0}
  2.6163  
  2.6164  /*
  2.6165  ** All current savepoints are stored in a linked list starting at
  2.6166 @@ -10765,6 +12407,7 @@
  2.6167    const char *zName;                   /* Name passed to create_module() */
  2.6168    void *pAux;                          /* pAux passed to create_module() */
  2.6169    void (*xDestroy)(void *);            /* Module destructor function */
  2.6170 +  Table *pEpoTab;                      /* Eponymous table for this module */
  2.6171  };
  2.6172  
  2.6173  /*
  2.6174 @@ -10779,7 +12422,7 @@
  2.6175    char *zColl;     /* Collating sequence.  If NULL, use the default */
  2.6176    u8 notNull;      /* An OE_ code for handling a NOT NULL constraint */
  2.6177    char affinity;   /* One of the SQLITE_AFF_... values */
  2.6178 -  u8 szEst;        /* Estimated size of this column.  INT==1 */
  2.6179 +  u8 szEst;        /* Estimated size of value in this column. sizeof(INT)==1 */
  2.6180    u8 colFlags;     /* Boolean properties.  See COLFLAG_ defines below */
  2.6181  };
  2.6182  
  2.6183 @@ -10810,6 +12453,7 @@
  2.6184  */
  2.6185  #define SQLITE_SO_ASC       0  /* Sort in ascending order */
  2.6186  #define SQLITE_SO_DESC      1  /* Sort in ascending order */
  2.6187 +#define SQLITE_SO_UNDEFINED -1 /* No sort order specified */
  2.6188  
  2.6189  /*
  2.6190  ** Column affinity types.
  2.6191 @@ -10818,18 +12462,18 @@
  2.6192  ** 't' for SQLITE_AFF_TEXT.  But we can save a little space and improve
  2.6193  ** the speed a little by numbering the values consecutively.  
  2.6194  **
  2.6195 -** But rather than start with 0 or 1, we begin with 'a'.  That way,
  2.6196 +** But rather than start with 0 or 1, we begin with 'A'.  That way,
  2.6197  ** when multiple affinity types are concatenated into a string and
  2.6198  ** used as the P4 operand, they will be more readable.
  2.6199  **
  2.6200  ** Note also that the numeric types are grouped together so that testing
  2.6201 -** for a numeric type is a single comparison.
  2.6202 -*/
  2.6203 -#define SQLITE_AFF_TEXT     'a'
  2.6204 -#define SQLITE_AFF_NONE     'b'
  2.6205 -#define SQLITE_AFF_NUMERIC  'c'
  2.6206 -#define SQLITE_AFF_INTEGER  'd'
  2.6207 -#define SQLITE_AFF_REAL     'e'
  2.6208 +** for a numeric type is a single comparison.  And the BLOB type is first.
  2.6209 +*/
  2.6210 +#define SQLITE_AFF_BLOB     'A'
  2.6211 +#define SQLITE_AFF_TEXT     'B'
  2.6212 +#define SQLITE_AFF_NUMERIC  'C'
  2.6213 +#define SQLITE_AFF_INTEGER  'D'
  2.6214 +#define SQLITE_AFF_REAL     'E'
  2.6215  
  2.6216  #define sqlite3IsNumericAffinity(X)  ((X)>=SQLITE_AFF_NUMERIC)
  2.6217  
  2.6218 @@ -10837,7 +12481,7 @@
  2.6219  ** The SQLITE_AFF_MASK values masks off the significant bits of an
  2.6220  ** affinity value. 
  2.6221  */
  2.6222 -#define SQLITE_AFF_MASK     0x67
  2.6223 +#define SQLITE_AFF_MASK     0x47
  2.6224  
  2.6225  /*
  2.6226  ** Additional bit values that can be ORed with an affinity without
  2.6227 @@ -10848,10 +12492,10 @@
  2.6228  ** operator is NULL.  It is added to certain comparison operators to
  2.6229  ** prove that the operands are always NOT NULL.
  2.6230  */
  2.6231 -#define SQLITE_JUMPIFNULL   0x08  /* jumps if either operand is NULL */
  2.6232 -#define SQLITE_STOREP2      0x10  /* Store result in reg[P2] rather than jump */
  2.6233 +#define SQLITE_JUMPIFNULL   0x10  /* jumps if either operand is NULL */
  2.6234 +#define SQLITE_STOREP2      0x20  /* Store result in reg[P2] rather than jump */
  2.6235  #define SQLITE_NULLEQ       0x80  /* NULL=NULL */
  2.6236 -#define SQLITE_NOTNULL      0x88  /* Assert that operands are never NULL */
  2.6237 +#define SQLITE_NOTNULL      0x90  /* Assert that operands are never NULL */
  2.6238  
  2.6239  /*
  2.6240  ** An object of this type is created for each virtual table present in
  2.6241 @@ -10906,34 +12550,8 @@
  2.6242  };
  2.6243  
  2.6244  /*
  2.6245 -** Each SQL table is represented in memory by an instance of the
  2.6246 -** following structure.
  2.6247 -**
  2.6248 -** Table.zName is the name of the table.  The case of the original
  2.6249 -** CREATE TABLE statement is stored, but case is not significant for
  2.6250 -** comparisons.
  2.6251 -**
  2.6252 -** Table.nCol is the number of columns in this table.  Table.aCol is a
  2.6253 -** pointer to an array of Column structures, one for each column.
  2.6254 -**
  2.6255 -** If the table has an INTEGER PRIMARY KEY, then Table.iPKey is the index of
  2.6256 -** the column that is that key.   Otherwise Table.iPKey is negative.  Note
  2.6257 -** that the datatype of the PRIMARY KEY must be INTEGER for this field to
  2.6258 -** be set.  An INTEGER PRIMARY KEY is used as the rowid for each row of
  2.6259 -** the table.  If a table has no INTEGER PRIMARY KEY, then a random rowid
  2.6260 -** is generated for each row of the table.  TF_HasPrimaryKey is set if
  2.6261 -** the table has any PRIMARY KEY, INTEGER or otherwise.
  2.6262 -**
  2.6263 -** Table.tnum is the page number for the root BTree page of the table in the
  2.6264 -** database file.  If Table.iDb is the index of the database table backend
  2.6265 -** in sqlite.aDb[].  0 is for the main database and 1 is for the file that
  2.6266 -** holds temporary tables and indices.  If TF_Ephemeral is set
  2.6267 -** then the table is stored in a file that is automatically deleted
  2.6268 -** when the VDBE cursor to the table is closed.  In this case Table.tnum 
  2.6269 -** refers VDBE cursor number that holds the table open, not to the root
  2.6270 -** page number.  Transient tables are used to hold the results of a
  2.6271 -** sub-query that appears instead of a real table name in the FROM clause 
  2.6272 -** of a SELECT statement.
  2.6273 +** The schema for each SQL table and view is represented in memory
  2.6274 +** by an instance of the following structure.
  2.6275  */
  2.6276  struct Table {
  2.6277    char *zName;         /* Name of the table or view */
  2.6278 @@ -10942,14 +12560,13 @@
  2.6279    Select *pSelect;     /* NULL for tables.  Points to definition if a view. */
  2.6280    FKey *pFKey;         /* Linked list of all foreign keys in this table */
  2.6281    char *zColAff;       /* String defining the affinity of each column */
  2.6282 -#ifndef SQLITE_OMIT_CHECK
  2.6283    ExprList *pCheck;    /* All CHECK constraints */
  2.6284 -#endif
  2.6285 -  LogEst nRowLogEst;   /* Estimated rows in table - from sqlite_stat1 table */
  2.6286 -  int tnum;            /* Root BTree node for this table (see note above) */
  2.6287 -  i16 iPKey;           /* If not negative, use aCol[iPKey] as the primary key */
  2.6288 +                       /*   ... also used as column name list in a VIEW */
  2.6289 +  int tnum;            /* Root BTree page for this table */
  2.6290 +  i16 iPKey;           /* If not negative, use aCol[iPKey] as the rowid */
  2.6291    i16 nCol;            /* Number of columns in this table */
  2.6292    u16 nRef;            /* Number of pointers to this Table */
  2.6293 +  LogEst nRowLogEst;   /* Estimated rows in table - from sqlite_stat1 table */
  2.6294    LogEst szTabRow;     /* Estimated size of each table row in bytes */
  2.6295  #ifdef SQLITE_ENABLE_COSTMULT
  2.6296    LogEst costMult;     /* Cost multiplier for using this table */
  2.6297 @@ -10961,7 +12578,7 @@
  2.6298  #endif
  2.6299  #ifndef SQLITE_OMIT_VIRTUALTABLE
  2.6300    int nModuleArg;      /* Number of arguments to the module */
  2.6301 -  char **azModuleArg;  /* Text of all module args. [0] is module name */
  2.6302 +  char **azModuleArg;  /* 0: module 1: schema 2: vtab name 3...: args */
  2.6303    VTable *pVTable;     /* List of VTable objects. */
  2.6304  #endif
  2.6305    Trigger *pTrigger;   /* List of triggers stored in pSchema */
  2.6306 @@ -10971,13 +12588,21 @@
  2.6307  
  2.6308  /*
  2.6309  ** Allowed values for Table.tabFlags.
  2.6310 +**
  2.6311 +** TF_OOOHidden applies to tables or view that have hidden columns that are
  2.6312 +** followed by non-hidden columns.  Example:  "CREATE VIRTUAL TABLE x USING
  2.6313 +** vtab1(a HIDDEN, b);".  Since "b" is a non-hidden column but "a" is hidden,
  2.6314 +** the TF_OOOHidden attribute would apply in this case.  Such tables require
  2.6315 +** special handling during INSERT processing.
  2.6316  */
  2.6317  #define TF_Readonly        0x01    /* Read-only system table */
  2.6318  #define TF_Ephemeral       0x02    /* An ephemeral table */
  2.6319  #define TF_HasPrimaryKey   0x04    /* Table has a primary key */
  2.6320  #define TF_Autoincrement   0x08    /* Integer primary key is autoincrement */
  2.6321  #define TF_Virtual         0x10    /* Is a virtual table */
  2.6322 -#define TF_WithoutRowid    0x20    /* No rowid used. PRIMARY KEY is the key */
  2.6323 +#define TF_WithoutRowid    0x20    /* No rowid.  PRIMARY KEY is the key */
  2.6324 +#define TF_NoVisibleRowid  0x40    /* No user-visible "rowid" column */
  2.6325 +#define TF_OOOHidden       0x80    /* Out-of-Order hidden columns */
  2.6326  
  2.6327  
  2.6328  /*
  2.6329 @@ -10987,14 +12612,31 @@
  2.6330  */
  2.6331  #ifndef SQLITE_OMIT_VIRTUALTABLE
  2.6332  #  define IsVirtual(X)      (((X)->tabFlags & TF_Virtual)!=0)
  2.6333 -#  define IsHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0)
  2.6334  #else
  2.6335  #  define IsVirtual(X)      0
  2.6336 -#  define IsHiddenColumn(X) 0
  2.6337 -#endif
  2.6338 +#endif
  2.6339 +
  2.6340 +/*
  2.6341 +** Macros to determine if a column is hidden.  IsOrdinaryHiddenColumn()
  2.6342 +** only works for non-virtual tables (ordinary tables and views) and is
  2.6343 +** always false unless SQLITE_ENABLE_HIDDEN_COLUMNS is defined.  The
  2.6344 +** IsHiddenColumn() macro is general purpose.
  2.6345 +*/
  2.6346 +#if defined(SQLITE_ENABLE_HIDDEN_COLUMNS)
  2.6347 +#  define IsHiddenColumn(X)         (((X)->colFlags & COLFLAG_HIDDEN)!=0)
  2.6348 +#  define IsOrdinaryHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0)
  2.6349 +#elif !defined(SQLITE_OMIT_VIRTUALTABLE)
  2.6350 +#  define IsHiddenColumn(X)         (((X)->colFlags & COLFLAG_HIDDEN)!=0)
  2.6351 +#  define IsOrdinaryHiddenColumn(X) 0
  2.6352 +#else
  2.6353 +#  define IsHiddenColumn(X)         0
  2.6354 +#  define IsOrdinaryHiddenColumn(X) 0
  2.6355 +#endif
  2.6356 +
  2.6357  
  2.6358  /* Does the table have a rowid */
  2.6359  #define HasRowid(X)     (((X)->tabFlags & TF_WithoutRowid)==0)
  2.6360 +#define VisibleRowid(X) (((X)->tabFlags & TF_NoVisibleRowid)==0)
  2.6361  
  2.6362  /*
  2.6363  ** Each foreign key constraint is an instance of the following structure.
  2.6364 @@ -11101,9 +12743,8 @@
  2.6365  };
  2.6366  
  2.6367  /*
  2.6368 -** An instance of the following structure holds information about a
  2.6369 -** single index record that has already been parsed out into individual
  2.6370 -** values.
  2.6371 +** This object holds a record which has been parsed out into individual
  2.6372 +** fields, for the purposes of doing a comparison.
  2.6373  **
  2.6374  ** A record is an object that contains one or more fields of data.
  2.6375  ** Records are used to store the content of a table row and to store
  2.6376 @@ -11111,20 +12752,40 @@
  2.6377  ** the OP_MakeRecord opcode of the VDBE and is disassembled by the
  2.6378  ** OP_Column opcode.
  2.6379  **
  2.6380 -** This structure holds a record that has already been disassembled
  2.6381 -** into its constituent fields.
  2.6382 -**
  2.6383 -** The r1 and r2 member variables are only used by the optimized comparison
  2.6384 -** functions vdbeRecordCompareInt() and vdbeRecordCompareString().
  2.6385 +** An instance of this object serves as a "key" for doing a search on
  2.6386 +** an index b+tree. The goal of the search is to find the entry that
  2.6387 +** is closed to the key described by this object.  This object might hold
  2.6388 +** just a prefix of the key.  The number of fields is given by
  2.6389 +** pKeyInfo->nField.
  2.6390 +**
  2.6391 +** The r1 and r2 fields are the values to return if this key is less than
  2.6392 +** or greater than a key in the btree, respectively.  These are normally
  2.6393 +** -1 and +1 respectively, but might be inverted to +1 and -1 if the b-tree
  2.6394 +** is in DESC order.
  2.6395 +**
  2.6396 +** The key comparison functions actually return default_rc when they find
  2.6397 +** an equals comparison.  default_rc can be -1, 0, or +1.  If there are
  2.6398 +** multiple entries in the b-tree with the same key (when only looking
  2.6399 +** at the first pKeyInfo->nFields,) then default_rc can be set to -1 to 
  2.6400 +** cause the search to find the last match, or +1 to cause the search to
  2.6401 +** find the first match.
  2.6402 +**
  2.6403 +** The key comparison functions will set eqSeen to true if they ever
  2.6404 +** get and equal results when comparing this structure to a b-tree record.
  2.6405 +** When default_rc!=0, the search might end up on the record immediately
  2.6406 +** before the first match or immediately after the last match.  The
  2.6407 +** eqSeen field will indicate whether or not an exact match exists in the
  2.6408 +** b-tree.
  2.6409  */
  2.6410  struct UnpackedRecord {
  2.6411    KeyInfo *pKeyInfo;  /* Collation and sort-order information */
  2.6412 +  Mem *aMem;          /* Values */
  2.6413    u16 nField;         /* Number of entries in apMem[] */
  2.6414    i8 default_rc;      /* Comparison result if keys are equal */
  2.6415 -  u8 isCorrupt;       /* Corruption detected by xRecordCompare() */
  2.6416 -  Mem *aMem;          /* Values */
  2.6417 -  int r1;             /* Value to return if (lhs > rhs) */
  2.6418 -  int r2;             /* Value to return if (rhs < lhs) */
  2.6419 +  u8 errCode;         /* Error detected by xRecordCompare (CORRUPT or NOMEM) */
  2.6420 +  i8 r1;              /* Value to return if (lhs > rhs) */
  2.6421 +  i8 r2;              /* Value to return if (rhs < lhs) */
  2.6422 +  u8 eqSeen;          /* True if an equality comparison has been seen */
  2.6423  };
  2.6424  
  2.6425  
  2.6426 @@ -11153,6 +12814,14 @@
  2.6427  ** and the value of Index.onError indicate the which conflict resolution 
  2.6428  ** algorithm to employ whenever an attempt is made to insert a non-unique
  2.6429  ** element.
  2.6430 +**
  2.6431 +** While parsing a CREATE TABLE or CREATE INDEX statement in order to
  2.6432 +** generate VDBE code (as opposed to parsing one read from an sqlite_master
  2.6433 +** table as part of parsing an existing database schema), transient instances
  2.6434 +** of this structure may be created. In this case the Index.tnum variable is
  2.6435 +** used to store the address of a VDBE instruction, not a database page
  2.6436 +** number (it cannot - the database page is not allocated until the VDBE
  2.6437 +** program is executed). See convertToWithoutRowidTable() for details.
  2.6438  */
  2.6439  struct Index {
  2.6440    char *zName;             /* Name of this index */
  2.6441 @@ -11163,9 +12832,9 @@
  2.6442    Index *pNext;            /* The next index associated with the same table */
  2.6443    Schema *pSchema;         /* Schema containing this index */
  2.6444    u8 *aSortOrder;          /* for each column: True==DESC, False==ASC */
  2.6445 -  char **azColl;           /* Array of collation sequence names for index */
  2.6446 +  const char **azColl;     /* Array of collation sequence names for index */
  2.6447    Expr *pPartIdxWhere;     /* WHERE clause for partial indices */
  2.6448 -  KeyInfo *pKeyInfo;       /* A KeyInfo object suitable for this index */
  2.6449 +  ExprList *aColExpr;      /* Column expressions */
  2.6450    int tnum;                /* DB Page containing root of this index */
  2.6451    LogEst szIdxRow;         /* Estimated average row size in bytes */
  2.6452    u16 nKeyCol;             /* Number of columns forming the key */
  2.6453 @@ -11176,11 +12845,14 @@
  2.6454    unsigned uniqNotNull:1;  /* True if UNIQUE and NOT NULL for all columns */
  2.6455    unsigned isResized:1;    /* True if resizeIndexObject() has been called */
  2.6456    unsigned isCovering:1;   /* True if this is a covering index */
  2.6457 +  unsigned noSkipScan:1;   /* Do not try to use skip-scan if true */
  2.6458  #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
  2.6459    int nSample;             /* Number of elements in aSample[] */
  2.6460    int nSampleCol;          /* Size of IndexSample.anEq[] and so on */
  2.6461    tRowcnt *aAvgEq;         /* Average nEq values for keys not in aSample */
  2.6462    IndexSample *aSample;    /* Samples of the left-most key */
  2.6463 +  tRowcnt *aiRowEst;       /* Non-logarithmic stat1 data for this index */
  2.6464 +  tRowcnt nRowEst0;        /* Non-logarithmic number of rows in the index */
  2.6465  #endif
  2.6466  };
  2.6467  
  2.6468 @@ -11197,6 +12869,12 @@
  2.6469  /* Return true if index X is a UNIQUE index */
  2.6470  #define IsUniqueIndex(X)      ((X)->onError!=OE_None)
  2.6471  
  2.6472 +/* The Index.aiColumn[] values are normally positive integer.  But
  2.6473 +** there are some negative values that have special meaning:
  2.6474 +*/
  2.6475 +#define XN_ROWID     (-1)     /* Indexed column is the rowid */
  2.6476 +#define XN_EXPR      (-2)     /* Indexed column is an expression */
  2.6477 +
  2.6478  /*
  2.6479  ** Each sample stored in the sqlite_stat3 table is represented in memory 
  2.6480  ** using a structure of this type.  See documentation at the top of the
  2.6481 @@ -11378,7 +13056,7 @@
  2.6482    int iTable;            /* TK_COLUMN: cursor number of table holding column
  2.6483                           ** TK_REGISTER: register number
  2.6484                           ** TK_TRIGGER: 1 -> new, 0 -> old
  2.6485 -                         ** EP_Unlikely:  1000 times likelihood */
  2.6486 +                         ** EP_Unlikely:  134217728 times likelihood */
  2.6487    ynVar iColumn;         /* TK_COLUMN: column index.  -1 for rowid.
  2.6488                           ** TK_VARIABLE: variable number (always >= 1). */
  2.6489    i16 iAgg;              /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
  2.6490 @@ -11393,7 +13071,7 @@
  2.6491  /*
  2.6492  ** The following are the meanings of bits in the Expr.flags field.
  2.6493  */
  2.6494 -#define EP_FromJoin  0x000001 /* Originated in ON or USING clause of a join */
  2.6495 +#define EP_FromJoin  0x000001 /* Originates in ON/USING clause of outer join */
  2.6496  #define EP_Agg       0x000002 /* Contains one or more aggregate functions */
  2.6497  #define EP_Resolved  0x000004 /* IDs have been resolved to COLUMNs */
  2.6498  #define EP_Error     0x000008 /* Expression contains one or more errors */
  2.6499 @@ -11412,7 +13090,15 @@
  2.6500  #define EP_MemToken  0x010000 /* Need to sqlite3DbFree() Expr.zToken */
  2.6501  #define EP_NoReduce  0x020000 /* Cannot EXPRDUP_REDUCE this Expr */
  2.6502  #define EP_Unlikely  0x040000 /* unlikely() or likelihood() function */
  2.6503 -#define EP_Constant  0x080000 /* Node is a constant */
  2.6504 +#define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */
  2.6505 +#define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */
  2.6506 +#define EP_Subquery  0x200000 /* Tree contains a TK_SELECT operator */
  2.6507 +#define EP_Alias     0x400000 /* Is an alias for a result set column */
  2.6508 +
  2.6509 +/*
  2.6510 +** Combinations of two or more EP_* flags
  2.6511 +*/
  2.6512 +#define EP_Propagate (EP_Collate|EP_Subquery) /* Propagate these bits up tree */
  2.6513  
  2.6514  /*
  2.6515  ** These macros can be used to test, set, or clear bits in the 
  2.6516 @@ -11570,11 +13256,15 @@
  2.6517      int addrFillSub;  /* Address of subroutine to manifest a subquery */
  2.6518      int regReturn;    /* Register holding return address of addrFillSub */
  2.6519      int regResult;    /* Registers holding results of a co-routine */
  2.6520 -    u8 jointype;      /* Type of join between this able and the previous */
  2.6521 -    unsigned notIndexed :1;    /* True if there is a NOT INDEXED clause */
  2.6522 -    unsigned isCorrelated :1;  /* True if sub-query is correlated */
  2.6523 -    unsigned viaCoroutine :1;  /* Implemented as a co-routine */
  2.6524 -    unsigned isRecursive :1;   /* True for recursive reference in WITH */
  2.6525 +    struct {
  2.6526 +      u8 jointype;      /* Type of join between this able and the previous */
  2.6527 +      unsigned notIndexed :1;    /* True if there is a NOT INDEXED clause */
  2.6528 +      unsigned isIndexedBy :1;   /* True if there is an INDEXED BY clause */
  2.6529 +      unsigned isTabFunc :1;     /* True if table-valued-function syntax */
  2.6530 +      unsigned isCorrelated :1;  /* True if sub-query is correlated */
  2.6531 +      unsigned viaCoroutine :1;  /* Implemented as a co-routine */
  2.6532 +      unsigned isRecursive :1;   /* True for recursive reference in WITH */
  2.6533 +    } fg;
  2.6534  #ifndef SQLITE_OMIT_EXPLAIN
  2.6535      u8 iSelectId;     /* If pSelect!=0, the id of the sub-select in EQP */
  2.6536  #endif
  2.6537 @@ -11582,8 +13272,11 @@
  2.6538      Expr *pOn;        /* The ON clause of a join */
  2.6539      IdList *pUsing;   /* The USING clause of a join */
  2.6540      Bitmask colUsed;  /* Bit N (1<<N) set if column N of pTab is used */
  2.6541 -    char *zIndex;     /* Identifier from "INDEXED BY <zIndex>" clause */
  2.6542 -    Index *pIndex;    /* Index structure corresponding to zIndex, if any */
  2.6543 +    union {
  2.6544 +      char *zIndexedBy;    /* Identifier from "INDEXED BY <zIndex>" clause */
  2.6545 +      ExprList *pFuncArg;  /* Arguments to table-valued-function */
  2.6546 +    } u1;
  2.6547 +    Index *pIBIndex;  /* Index structure corresponding to u1.zIndexedBy */
  2.6548    } a[1];             /* One entry for each identifier on the list */
  2.6549  };
  2.6550  
  2.6551 @@ -11611,12 +13304,13 @@
  2.6552  #define WHERE_OMIT_OPEN_CLOSE  0x0010 /* Table cursors are already open */
  2.6553  #define WHERE_FORCE_TABLE      0x0020 /* Do not use an index-only search */
  2.6554  #define WHERE_ONETABLE_ONLY    0x0040 /* Only code the 1st table in pTabList */
  2.6555 -#define WHERE_AND_ONLY         0x0080 /* Don't use indices for OR terms */
  2.6556 +#define WHERE_NO_AUTOINDEX     0x0080 /* Disallow automatic indexes */
  2.6557  #define WHERE_GROUPBY          0x0100 /* pOrderBy is really a GROUP BY */
  2.6558  #define WHERE_DISTINCTBY       0x0200 /* pOrderby is really a DISTINCT clause */
  2.6559  #define WHERE_WANT_DISTINCT    0x0400 /* All output needs to be distinct */
  2.6560  #define WHERE_SORTBYGROUP      0x0800 /* Support sqlite3WhereIsSorted() */
  2.6561  #define WHERE_REOPEN_IDX       0x1000 /* Try to use OP_ReopenIdx */
  2.6562 +#define WHERE_ONEPASS_MULTIROW 0x2000 /* ONEPASS is ok with multiple rows */
  2.6563  
  2.6564  /* Allowed return values from sqlite3WhereIsDistinct()
  2.6565  */
  2.6566 @@ -11654,17 +13348,23 @@
  2.6567    NameContext *pNext;  /* Next outer name context.  NULL for outermost */
  2.6568    int nRef;            /* Number of names resolved by this context */
  2.6569    int nErr;            /* Number of errors encountered while resolving names */
  2.6570 -  u8 ncFlags;          /* Zero or more NC_* flags defined below */
  2.6571 +  u16 ncFlags;         /* Zero or more NC_* flags defined below */
  2.6572  };
  2.6573  
  2.6574  /*
  2.6575  ** Allowed values for the NameContext, ncFlags field.
  2.6576 -*/
  2.6577 -#define NC_AllowAgg  0x01    /* Aggregate functions are allowed here */
  2.6578 -#define NC_HasAgg    0x02    /* One or more aggregate functions seen */
  2.6579 -#define NC_IsCheck   0x04    /* True if resolving names in a CHECK constraint */
  2.6580 -#define NC_InAggFunc 0x08    /* True if analyzing arguments to an agg func */
  2.6581 -#define NC_PartIdx   0x10    /* True if resolving a partial index WHERE */
  2.6582 +**
  2.6583 +** Note:  NC_MinMaxAgg must have the same value as SF_MinMaxAgg and
  2.6584 +** SQLITE_FUNC_MINMAX.
  2.6585 +** 
  2.6586 +*/
  2.6587 +#define NC_AllowAgg  0x0001  /* Aggregate functions are allowed here */
  2.6588 +#define NC_HasAgg    0x0002  /* One or more aggregate functions seen */
  2.6589 +#define NC_IsCheck   0x0004  /* True if resolving names in a CHECK constraint */
  2.6590 +#define NC_InAggFunc 0x0008  /* True if analyzing arguments to an agg func */
  2.6591 +#define NC_PartIdx   0x0010  /* True if resolving a partial index WHERE */
  2.6592 +#define NC_IdxExpr   0x0020  /* True if resolving columns of CREATE INDEX */
  2.6593 +#define NC_MinMaxAgg 0x1000  /* min/max aggregates seen.  See note above */
  2.6594  
  2.6595  /*
  2.6596  ** An instance of the following structure contains all information
  2.6597 @@ -11691,6 +13391,9 @@
  2.6598    u8 op;                 /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */
  2.6599    u16 selFlags;          /* Various SF_* values */
  2.6600    int iLimit, iOffset;   /* Memory registers holding LIMIT & OFFSET counters */
  2.6601 +#if SELECTTRACE_ENABLED
  2.6602 +  char zSelName[12];     /* Symbolic name of this SELECT use for debugging */
  2.6603 +#endif
  2.6604    int addrOpenEphm[2];   /* OP_OpenEphem opcodes related to this select */
  2.6605    u64 nSelectRow;        /* Estimated number of result rows */
  2.6606    SrcList *pSrc;         /* The FROM clause */
  2.6607 @@ -11710,18 +13413,21 @@
  2.6608  ** "Select Flag".
  2.6609  */
  2.6610  #define SF_Distinct        0x0001  /* Output should be DISTINCT */
  2.6611 -#define SF_Resolved        0x0002  /* Identifiers have been resolved */
  2.6612 -#define SF_Aggregate       0x0004  /* Contains aggregate functions */
  2.6613 -#define SF_UsesEphemeral   0x0008  /* Uses the OpenEphemeral opcode */
  2.6614 -#define SF_Expanded        0x0010  /* sqlite3SelectExpand() called on this */
  2.6615 -#define SF_HasTypeInfo     0x0020  /* FROM subqueries have Table metadata */
  2.6616 -                    /*     0x0040  NOT USED */
  2.6617 -#define SF_Values          0x0080  /* Synthesized from VALUES clause */
  2.6618 -                    /*     0x0100  NOT USED */
  2.6619 -#define SF_NestedFrom      0x0200  /* Part of a parenthesized FROM clause */
  2.6620 -#define SF_MaybeConvert    0x0400  /* Need convertCompoundSelectToSubquery() */
  2.6621 -#define SF_Recursive       0x0800  /* The recursive part of a recursive CTE */
  2.6622 -#define SF_Compound        0x1000  /* Part of a compound query */
  2.6623 +#define SF_All             0x0002  /* Includes the ALL keyword */
  2.6624 +#define SF_Resolved        0x0004  /* Identifiers have been resolved */
  2.6625 +#define SF_Aggregate       0x0008  /* Contains aggregate functions */
  2.6626 +#define SF_UsesEphemeral   0x0010  /* Uses the OpenEphemeral opcode */
  2.6627 +#define SF_Expanded        0x0020  /* sqlite3SelectExpand() called on this */
  2.6628 +#define SF_HasTypeInfo     0x0040  /* FROM subqueries have Table metadata */
  2.6629 +#define SF_Compound        0x0080  /* Part of a compound query */
  2.6630 +#define SF_Values          0x0100  /* Synthesized from VALUES clause */
  2.6631 +#define SF_MultiValue      0x0200  /* Single VALUES term with multiple rows */
  2.6632 +#define SF_NestedFrom      0x0400  /* Part of a parenthesized FROM clause */
  2.6633 +#define SF_MaybeConvert    0x0800  /* Need convertCompoundSelectToSubquery() */
  2.6634 +#define SF_MinMaxAgg       0x1000  /* Aggregate containing min() or max() */
  2.6635 +#define SF_Recursive       0x2000  /* The recursive part of a recursive CTE */
  2.6636 +#define SF_Converted       0x4000  /* By convertCompoundSelectToSubquery() */
  2.6637 +#define SF_IncludeHidden   0x8000  /* Include hidden columns in output */
  2.6638  
  2.6639  
  2.6640  /*
  2.6641 @@ -11825,7 +13531,7 @@
  2.6642  ** tables, the following information is attached to the Table.u.autoInc.p
  2.6643  ** pointer of each autoincrement table to record some side information that
  2.6644  ** the code generator needs.  We have to keep per-table autoincrement
  2.6645 -** information in case inserts are down within triggers.  Triggers do not
  2.6646 +** information in case inserts are done within triggers.  Triggers do not
  2.6647  ** normally coordinate their activities, but we do need to coordinate the
  2.6648  ** loading and saving of autoincrement information.
  2.6649  */
  2.6650 @@ -11917,6 +13623,7 @@
  2.6651    u8 mayAbort;         /* True if statement may throw an ABORT exception */
  2.6652    u8 hasCompound;      /* Need to invoke convertCompoundSelectToSubquery() */
  2.6653    u8 okConstFactor;    /* OK to factor out constants */
  2.6654 +  u8 disableLookaside; /* Number of times lookaside has been disabled */
  2.6655    int aTempReg[8];     /* Holding area for temporary registers */
  2.6656    int nRangeReg;       /* Size of the temporary register block */
  2.6657    int iRangeReg;       /* First register in temporary register block */
  2.6658 @@ -11926,9 +13633,10 @@
  2.6659    int nSet;            /* Number of sets used so far */
  2.6660    int nOnce;           /* Number of OP_Once instructions so far */
  2.6661    int nOpAlloc;        /* Number of slots allocated for Vdbe.aOp[] */
  2.6662 +  int szOpAlloc;       /* Bytes of memory space allocated for Vdbe.aOp[] */
  2.6663    int iFixedOp;        /* Never back out opcodes iFixedOp-1 or earlier */
  2.6664    int ckBase;          /* Base register of data during check constraints */
  2.6665 -  int iPartIdxTab;     /* Table corresponding to a partial index */
  2.6666 +  int iSelfTab;        /* Table of an index whose exprs are being coded */
  2.6667    int iCacheLevel;     /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
  2.6668    int iCacheCnt;       /* Counter used to generate aColCache[].lru values */
  2.6669    int nLabel;          /* Number of labels used */
  2.6670 @@ -11949,6 +13657,10 @@
  2.6671    int regRowid;        /* Register holding rowid of CREATE TABLE entry */
  2.6672    int regRoot;         /* Register holding root page number for new objects */
  2.6673    int nMaxArg;         /* Max args passed to user function by sub-program */
  2.6674 +#if SELECTTRACE_ENABLED
  2.6675 +  int nSelect;         /* Number of SELECT statements seen */
  2.6676 +  int nSelectIndent;   /* How far to indent SELECTTRACE() output */
  2.6677 +#endif
  2.6678  #ifndef SQLITE_OMIT_SHARED_CACHE
  2.6679    int nTableLock;        /* Number of locks in aTableLock */
  2.6680    TableLock *aTableLock; /* Required table locks for shared-cache mode */
  2.6681 @@ -11959,7 +13671,6 @@
  2.6682    Parse *pToplevel;    /* Parse structure for main program (or NULL) */
  2.6683    Table *pTriggerTab;  /* Table triggers are being coded for */
  2.6684    int addrCrTab;       /* Address of OP_CreateTable opcode on CREATE TABLE */
  2.6685 -  int addrSkipPK;      /* Address of instruction to skip PRIMARY KEY index */
  2.6686    u32 nQueryLoop;      /* Est number of iterations of a query (10*log2(N)) */
  2.6687    u32 oldmask;         /* Mask of old.* columns referenced */
  2.6688    u32 newmask;         /* Mask of new.* columns referenced */
  2.6689 @@ -11974,10 +13685,9 @@
  2.6690    ** in the recursive region.
  2.6691    ************************************************************************/
  2.6692  
  2.6693 -  int nVar;                 /* Number of '?' variables seen in the SQL so far */
  2.6694 +  ynVar nVar;               /* Number of '?' variables seen in the SQL so far */
  2.6695    int nzVar;                /* Number of available slots in azVar[] */
  2.6696    u8 iPkSortOrder;          /* ASC or DESC for INTEGER PRIMARY KEY */
  2.6697 -  u8 bFreeWith;             /* True if pWith should be freed with parser */
  2.6698    u8 explain;               /* True if the EXPLAIN flag is found on the query */
  2.6699  #ifndef SQLITE_OMIT_VIRTUALTABLE
  2.6700    u8 declareVtab;           /* True if inside sqlite3_declare_vtab() */
  2.6701 @@ -12004,6 +13714,7 @@
  2.6702    Table *pZombieTab;        /* List of Table objects to delete after code gen */
  2.6703    TriggerPrg *pTriggerPrg;  /* Linked list of coded triggers */
  2.6704    With *pWith;              /* Current WITH clause, or NULL */
  2.6705 +  With *pWithToFree;        /* Free this WITH object at the end of the parse */
  2.6706  };
  2.6707  
  2.6708  /*
  2.6709 @@ -12027,17 +13738,22 @@
  2.6710  /*
  2.6711  ** Bitfield flags for P5 value in various opcodes.
  2.6712  */
  2.6713 -#define OPFLAG_NCHANGE       0x01    /* Set to update db->nChange */
  2.6714 +#define OPFLAG_NCHANGE       0x01    /* OP_Insert: Set to update db->nChange */
  2.6715 +                                     /* Also used in P2 (not P5) of OP_Delete */
  2.6716 +#define OPFLAG_EPHEM         0x01    /* OP_Column: Ephemeral output is ok */
  2.6717  #define OPFLAG_LASTROWID     0x02    /* Set to update db->lastRowid */
  2.6718  #define OPFLAG_ISUPDATE      0x04    /* This OP_Insert is an sql UPDATE */
  2.6719  #define OPFLAG_APPEND        0x08    /* This is likely to be an append */
  2.6720  #define OPFLAG_USESEEKRESULT 0x10    /* Try to avoid a seek in BtreeInsert() */
  2.6721 -#define OPFLAG_CLEARCACHE    0x20    /* Clear pseudo-table cache in OP_Column */
  2.6722  #define OPFLAG_LENGTHARG     0x40    /* OP_Column only used for length() */
  2.6723  #define OPFLAG_TYPEOFARG     0x80    /* OP_Column only used for typeof() */
  2.6724  #define OPFLAG_BULKCSR       0x01    /* OP_Open** used to open bulk cursor */
  2.6725 -#define OPFLAG_P2ISREG       0x02    /* P2 to OP_Open** is a register number */
  2.6726 +#define OPFLAG_SEEKEQ        0x02    /* OP_Open** cursor uses EQ seek only */
  2.6727 +#define OPFLAG_FORDELETE     0x08    /* OP_Open should use BTREE_FORDELETE */
  2.6728 +#define OPFLAG_P2ISREG       0x10    /* P2 to OP_Open** is a register number */
  2.6729  #define OPFLAG_PERMUTE       0x01    /* OP_Compare: use the permutation */
  2.6730 +#define OPFLAG_SAVEPOSITION  0x02    /* OP_Delete: keep cursor position */
  2.6731 +#define OPFLAG_AUXDELETE     0x04    /* OP_Delete: index in a DELETE op */
  2.6732  
  2.6733  /*
  2.6734   * Each trigger present in the database schema is stored as an instance of
  2.6735 @@ -12095,7 +13811,7 @@
  2.6736   * orconf    -> stores the ON CONFLICT algorithm
  2.6737   * pSelect   -> If this is an INSERT INTO ... SELECT ... statement, then
  2.6738   *              this stores a pointer to the SELECT statement. Otherwise NULL.
  2.6739 - * target    -> A token holding the quoted name of the table to insert into.
  2.6740 + * zTarget   -> Dequoted name of the table to insert into.
  2.6741   * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then
  2.6742   *              this stores values to be inserted. Otherwise NULL.
  2.6743   * pIdList   -> If this is an INSERT INTO ... (<column-names>) VALUES ... 
  2.6744 @@ -12103,12 +13819,12 @@
  2.6745   *              inserted into.
  2.6746   *
  2.6747   * (op == TK_DELETE)
  2.6748 - * target    -> A token holding the quoted name of the table to delete from.
  2.6749 + * zTarget   -> Dequoted name of the table to delete from.
  2.6750   * pWhere    -> The WHERE clause of the DELETE statement if one is specified.
  2.6751   *              Otherwise NULL.
  2.6752   * 
  2.6753   * (op == TK_UPDATE)
  2.6754 - * target    -> A token holding the quoted name of the table to update rows of.
  2.6755 + * zTarget   -> Dequoted name of the table to update.
  2.6756   * pWhere    -> The WHERE clause of the UPDATE statement if one is specified.
  2.6757   *              Otherwise NULL.
  2.6758   * pExprList -> A list of the columns to update and the expressions to update
  2.6759 @@ -12120,8 +13836,8 @@
  2.6760    u8 op;               /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */
  2.6761    u8 orconf;           /* OE_Rollback etc. */
  2.6762    Trigger *pTrig;      /* The trigger that this step is a part of */
  2.6763 -  Select *pSelect;     /* SELECT statment or RHS of INSERT INTO .. SELECT ... */
  2.6764 -  Token target;        /* Target table for DELETE, UPDATE, INSERT */
  2.6765 +  Select *pSelect;     /* SELECT statement or RHS of INSERT INTO SELECT ... */
  2.6766 +  char *zTarget;       /* Target table for DELETE, UPDATE, INSERT */
  2.6767    Expr *pWhere;        /* The WHERE clause for DELETE or UPDATE steps */
  2.6768    ExprList *pExprList; /* SET clause for UPDATE. */
  2.6769    IdList *pIdList;     /* Column names for INSERT */
  2.6770 @@ -12152,14 +13868,20 @@
  2.6771    sqlite3 *db;         /* Optional database for lookaside.  Can be NULL */
  2.6772    char *zBase;         /* A base allocation.  Not from malloc. */
  2.6773    char *zText;         /* The string collected so far */
  2.6774 -  int  nChar;          /* Length of the string so far */
  2.6775 -  int  nAlloc;         /* Amount of space allocated in zText */
  2.6776 -  int  mxAlloc;        /* Maximum allowed string length */
  2.6777 -  u8   useMalloc;      /* 0: none,  1: sqlite3DbMalloc,  2: sqlite3_malloc */
  2.6778 +  u32  nChar;          /* Length of the string so far */
  2.6779 +  u32  nAlloc;         /* Amount of space allocated in zText */
  2.6780 +  u32  mxAlloc;        /* Maximum allowed allocation.  0 for no malloc usage */
  2.6781    u8   accError;       /* STRACCUM_NOMEM or STRACCUM_TOOBIG */
  2.6782 +  u8   printfFlags;    /* SQLITE_PRINTF flags below */
  2.6783  };
  2.6784  #define STRACCUM_NOMEM   1
  2.6785  #define STRACCUM_TOOBIG  2
  2.6786 +#define SQLITE_PRINTF_INTERNAL 0x01  /* Internal-use-only converters allowed */
  2.6787 +#define SQLITE_PRINTF_SQLFUNC  0x02  /* SQL function arguments to VXPrintf */
  2.6788 +#define SQLITE_PRINTF_MALLOCED 0x04  /* True if xText is allocated space */
  2.6789 +
  2.6790 +#define isMalloced(X)  (((X)->printfFlags & SQLITE_PRINTF_MALLOCED)!=0)
  2.6791 +
  2.6792  
  2.6793  /*
  2.6794  ** A pointer to this structure is used to communicate information
  2.6795 @@ -12203,6 +13925,7 @@
  2.6796    int nPage;                        /* Number of pages in pPage[] */
  2.6797    int mxParserStack;                /* maximum depth of the parser stack */
  2.6798    int sharedCacheEnabled;           /* true if shared-cache mode enabled */
  2.6799 +  u32 szPma;                        /* Maximum Sorter PMA size */
  2.6800    /* The above might be initialized to non-zero.  The following need to always
  2.6801    ** initially be zero, however. */
  2.6802    int isInit;                       /* True after initialization has finished */
  2.6803 @@ -12253,16 +13976,20 @@
  2.6804  ** Context pointer passed down through the tree-walk.
  2.6805  */
  2.6806  struct Walker {
  2.6807 +  Parse *pParse;                            /* Parser context.  */
  2.6808    int (*xExprCallback)(Walker*, Expr*);     /* Callback for expressions */
  2.6809    int (*xSelectCallback)(Walker*,Select*);  /* Callback for SELECTs */
  2.6810    void (*xSelectCallback2)(Walker*,Select*);/* Second callback for SELECTs */
  2.6811 -  Parse *pParse;                            /* Parser context.  */
  2.6812    int walkerDepth;                          /* Number of subqueries */
  2.6813 +  u8 eCode;                                 /* A small processing code */
  2.6814    union {                                   /* Extra data for callback */
  2.6815      NameContext *pNC;                          /* Naming context */
  2.6816 -    int i;                                     /* Integer value */
  2.6817 +    int n;                                     /* A counter */
  2.6818 +    int iCur;                                  /* A cursor number */
  2.6819      SrcList *pSrcList;                         /* FROM clause */
  2.6820      struct SrcCount *pSrcCount;                /* Counting column references */
  2.6821 +    struct CCurHint *pCCurHint;                /* Used by codeCursorHint() */
  2.6822 +    int *aiCol;                                /* array of column indexes */
  2.6823    } u;
  2.6824  };
  2.6825  
  2.6826 @@ -12272,6 +13999,7 @@
  2.6827  SQLITE_PRIVATE int sqlite3WalkSelect(Walker*, Select*);
  2.6828  SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker*, Select*);
  2.6829  SQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker*, Select*);
  2.6830 +SQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker*, Expr*);
  2.6831  
  2.6832  /*
  2.6833  ** Return code from the parse-tree walking primitives and their
  2.6834 @@ -12292,10 +14020,21 @@
  2.6835      char *zName;                    /* Name of this CTE */
  2.6836      ExprList *pCols;                /* List of explicit column names, or NULL */
  2.6837      Select *pSelect;                /* The definition of this CTE */
  2.6838 -    const char *zErr;               /* Error message for circular references */
  2.6839 +    const char *zCteErr;            /* Error message for circular references */
  2.6840    } a[1];
  2.6841  };
  2.6842  
  2.6843 +#ifdef SQLITE_DEBUG
  2.6844 +/*
  2.6845 +** An instance of the TreeView object is used for printing the content of
  2.6846 +** data structures on sqlite3DebugPrintf() using a tree-like view.
  2.6847 +*/
  2.6848 +struct TreeView {
  2.6849 +  int iLevel;             /* Which level of the tree we are on */
  2.6850 +  u8  bLine[100];         /* Draw vertical in column i if bLine[i] is true */
  2.6851 +};
  2.6852 +#endif /* SQLITE_DEBUG */
  2.6853 +
  2.6854  /*
  2.6855  ** Assuming zIn points to the first byte of a UTF-8 character,
  2.6856  ** advance zIn to point to the first byte of the next UTF-8 character.
  2.6857 @@ -12320,14 +14059,21 @@
  2.6858  #define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__)
  2.6859  #define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__)
  2.6860  
  2.6861 +/*
  2.6862 +** FTS3 and FTS4 both require virtual table support
  2.6863 +*/
  2.6864 +#if defined(SQLITE_OMIT_VIRTUALTABLE)
  2.6865 +# undef SQLITE_ENABLE_FTS3
  2.6866 +# undef SQLITE_ENABLE_FTS4
  2.6867 +#endif
  2.6868  
  2.6869  /*
  2.6870  ** FTS4 is really an extension for FTS3.  It is enabled using the
  2.6871 -** SQLITE_ENABLE_FTS3 macro.  But to avoid confusion we also all
  2.6872 -** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3.
  2.6873 +** SQLITE_ENABLE_FTS3 macro.  But to avoid confusion we also call
  2.6874 +** the SQLITE_ENABLE_FTS4 macro to serve as an alias for SQLITE_ENABLE_FTS3.
  2.6875  */
  2.6876  #if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)
  2.6877 -# define SQLITE_ENABLE_FTS3
  2.6878 +# define SQLITE_ENABLE_FTS3 1
  2.6879  #endif
  2.6880  
  2.6881  /*
  2.6882 @@ -12361,6 +14107,9 @@
  2.6883  # define sqlite3Isxdigit(x)  isxdigit((unsigned char)(x))
  2.6884  # define sqlite3Tolower(x)   tolower((unsigned char)(x))
  2.6885  #endif
  2.6886 +#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
  2.6887 +SQLITE_PRIVATE int sqlite3IsIdChar(u8);
  2.6888 +#endif
  2.6889  
  2.6890  /*
  2.6891  ** Internal function prototypes
  2.6892 @@ -12371,15 +14120,16 @@
  2.6893  
  2.6894  SQLITE_PRIVATE int sqlite3MallocInit(void);
  2.6895  SQLITE_PRIVATE void sqlite3MallocEnd(void);
  2.6896 -SQLITE_PRIVATE void *sqlite3Malloc(int);
  2.6897 -SQLITE_PRIVATE void *sqlite3MallocZero(int);
  2.6898 -SQLITE_PRIVATE void *sqlite3DbMallocZero(sqlite3*, int);
  2.6899 -SQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3*, int);
  2.6900 +SQLITE_PRIVATE void *sqlite3Malloc(u64);
  2.6901 +SQLITE_PRIVATE void *sqlite3MallocZero(u64);
  2.6902 +SQLITE_PRIVATE void *sqlite3DbMallocZero(sqlite3*, u64);
  2.6903 +SQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3*, u64);
  2.6904 +SQLITE_PRIVATE void *sqlite3DbMallocRawNN(sqlite3*, u64);
  2.6905  SQLITE_PRIVATE char *sqlite3DbStrDup(sqlite3*,const char*);
  2.6906 -SQLITE_PRIVATE char *sqlite3DbStrNDup(sqlite3*,const char*, int);
  2.6907 -SQLITE_PRIVATE void *sqlite3Realloc(void*, int);
  2.6908 -SQLITE_PRIVATE void *sqlite3DbReallocOrFree(sqlite3 *, void *, int);
  2.6909 -SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *, void *, int);
  2.6910 +SQLITE_PRIVATE char *sqlite3DbStrNDup(sqlite3*,const char*, u64);
  2.6911 +SQLITE_PRIVATE void *sqlite3Realloc(void*, u64);
  2.6912 +SQLITE_PRIVATE void *sqlite3DbReallocOrFree(sqlite3 *, void *, u64);
  2.6913 +SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *, void *, u64);
  2.6914  SQLITE_PRIVATE void sqlite3DbFree(sqlite3*, void*);
  2.6915  SQLITE_PRIVATE int sqlite3MallocSize(void*);
  2.6916  SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3*, void*);
  2.6917 @@ -12388,7 +14138,9 @@
  2.6918  SQLITE_PRIVATE void *sqlite3PageMalloc(int);
  2.6919  SQLITE_PRIVATE void sqlite3PageFree(void*);
  2.6920  SQLITE_PRIVATE void sqlite3MemSetDefault(void);
  2.6921 +#ifndef SQLITE_OMIT_BUILTIN_TEST
  2.6922  SQLITE_PRIVATE void sqlite3BenignMallocHooks(void (*)(void), void (*)(void));
  2.6923 +#endif
  2.6924  SQLITE_PRIVATE int sqlite3HeapNearlyFull(void);
  2.6925  
  2.6926  /*
  2.6927 @@ -12424,10 +14176,20 @@
  2.6928  SQLITE_PRIVATE   int sqlite3MutexInit(void);
  2.6929  SQLITE_PRIVATE   int sqlite3MutexEnd(void);
  2.6930  #endif
  2.6931 -
  2.6932 -SQLITE_PRIVATE int sqlite3StatusValue(int);
  2.6933 -SQLITE_PRIVATE void sqlite3StatusAdd(int, int);
  2.6934 -SQLITE_PRIVATE void sqlite3StatusSet(int, int);
  2.6935 +#if !defined(SQLITE_MUTEX_OMIT) && !defined(SQLITE_MUTEX_NOOP)
  2.6936 +SQLITE_PRIVATE   void sqlite3MemoryBarrier(void);
  2.6937 +#else
  2.6938 +# define sqlite3MemoryBarrier()
  2.6939 +#endif
  2.6940 +
  2.6941 +SQLITE_PRIVATE sqlite3_int64 sqlite3StatusValue(int);
  2.6942 +SQLITE_PRIVATE void sqlite3StatusUp(int, int);
  2.6943 +SQLITE_PRIVATE void sqlite3StatusDown(int, int);
  2.6944 +SQLITE_PRIVATE void sqlite3StatusHighwater(int, int);
  2.6945 +
  2.6946 +/* Access to mutexes used by sqlite3_status() */
  2.6947 +SQLITE_PRIVATE sqlite3_mutex *sqlite3Pcache1Mutex(void);
  2.6948 +SQLITE_PRIVATE sqlite3_mutex *sqlite3MallocMutex(void);
  2.6949  
  2.6950  #ifndef SQLITE_OMIT_FLOATING_POINT
  2.6951  SQLITE_PRIVATE   int sqlite3IsNaN(double);
  2.6952 @@ -12445,45 +14207,29 @@
  2.6953    sqlite3_value **apArg;   /* The argument values */
  2.6954  };
  2.6955  
  2.6956 -#define SQLITE_PRINTF_INTERNAL 0x01
  2.6957 -#define SQLITE_PRINTF_SQLFUNC  0x02
  2.6958 -SQLITE_PRIVATE void sqlite3VXPrintf(StrAccum*, u32, const char*, va_list);
  2.6959 -SQLITE_PRIVATE void sqlite3XPrintf(StrAccum*, u32, const char*, ...);
  2.6960 +SQLITE_PRIVATE void sqlite3VXPrintf(StrAccum*, const char*, va_list);
  2.6961 +SQLITE_PRIVATE void sqlite3XPrintf(StrAccum*, const char*, ...);
  2.6962  SQLITE_PRIVATE char *sqlite3MPrintf(sqlite3*,const char*, ...);
  2.6963  SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
  2.6964 -SQLITE_PRIVATE char *sqlite3MAppendf(sqlite3*,char*,const char*,...);
  2.6965 -#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
  2.6966 +#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
  2.6967  SQLITE_PRIVATE   void sqlite3DebugPrintf(const char*, ...);
  2.6968  #endif
  2.6969  #if defined(SQLITE_TEST)
  2.6970  SQLITE_PRIVATE   void *sqlite3TestTextToPtr(const char*);
  2.6971  #endif
  2.6972  
  2.6973 -/* Output formatting for SQLITE_TESTCTRL_EXPLAIN */
  2.6974 -#if defined(SQLITE_ENABLE_TREE_EXPLAIN)
  2.6975 -SQLITE_PRIVATE   void sqlite3ExplainBegin(Vdbe*);
  2.6976 -SQLITE_PRIVATE   void sqlite3ExplainPrintf(Vdbe*, const char*, ...);
  2.6977 -SQLITE_PRIVATE   void sqlite3ExplainNL(Vdbe*);
  2.6978 -SQLITE_PRIVATE   void sqlite3ExplainPush(Vdbe*);
  2.6979 -SQLITE_PRIVATE   void sqlite3ExplainPop(Vdbe*);
  2.6980 -SQLITE_PRIVATE   void sqlite3ExplainFinish(Vdbe*);
  2.6981 -SQLITE_PRIVATE   void sqlite3ExplainSelect(Vdbe*, Select*);
  2.6982 -SQLITE_PRIVATE   void sqlite3ExplainExpr(Vdbe*, Expr*);
  2.6983 -SQLITE_PRIVATE   void sqlite3ExplainExprList(Vdbe*, ExprList*);
  2.6984 -SQLITE_PRIVATE   const char *sqlite3VdbeExplanation(Vdbe*);
  2.6985 -#else
  2.6986 -# define sqlite3ExplainBegin(X)
  2.6987 -# define sqlite3ExplainSelect(A,B)
  2.6988 -# define sqlite3ExplainExpr(A,B)
  2.6989 -# define sqlite3ExplainExprList(A,B)
  2.6990 -# define sqlite3ExplainFinish(X)
  2.6991 -# define sqlite3VdbeExplanation(X) 0
  2.6992 -#endif
  2.6993 -
  2.6994 -
  2.6995 -SQLITE_PRIVATE void sqlite3SetString(char **, sqlite3*, const char*, ...);
  2.6996 +#if defined(SQLITE_DEBUG)
  2.6997 +SQLITE_PRIVATE   void sqlite3TreeViewExpr(TreeView*, const Expr*, u8);
  2.6998 +SQLITE_PRIVATE   void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*);
  2.6999 +SQLITE_PRIVATE   void sqlite3TreeViewSelect(TreeView*, const Select*, u8);
  2.7000 +SQLITE_PRIVATE   void sqlite3TreeViewWith(TreeView*, const With*, u8);
  2.7001 +#endif
  2.7002 +
  2.7003 +
  2.7004 +SQLITE_PRIVATE void sqlite3SetString(char **, sqlite3*, const char*);
  2.7005  SQLITE_PRIVATE void sqlite3ErrorMsg(Parse*, const char*, ...);
  2.7006  SQLITE_PRIVATE int sqlite3Dequote(char*);
  2.7007 +SQLITE_PRIVATE void sqlite3TokenInit(Token*,char*);
  2.7008  SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char*, int);
  2.7009  SQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*, char **);
  2.7010  SQLITE_PRIVATE void sqlite3FinishCoding(Parse*);
  2.7011 @@ -12501,22 +14247,30 @@
  2.7012  SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*);
  2.7013  SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
  2.7014  SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
  2.7015 +SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int);
  2.7016  SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
  2.7017  SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan*);
  2.7018  SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);
  2.7019 +SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*);
  2.7020  SQLITE_PRIVATE int sqlite3Init(sqlite3*, char**);
  2.7021  SQLITE_PRIVATE int sqlite3InitCallback(void*, int, char**, char**);
  2.7022  SQLITE_PRIVATE void sqlite3Pragma(Parse*,Token*,Token*,Token*,int);
  2.7023  SQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3*);
  2.7024  SQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3*,int);
  2.7025  SQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*);
  2.7026 -SQLITE_PRIVATE void sqlite3BeginParse(Parse*,int);
  2.7027  SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*);
  2.7028 +SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*);
  2.7029 +SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);
  2.7030  SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*);
  2.7031  SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int);
  2.7032  SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*);
  2.7033  SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index*, i16);
  2.7034  SQLITE_PRIVATE void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);
  2.7035 +#if SQLITE_ENABLE_HIDDEN_COLUMNS
  2.7036 +SQLITE_PRIVATE   void sqlite3ColumnPropertiesFromName(Table*, Column*);
  2.7037 +#else
  2.7038 +# define sqlite3ColumnPropertiesFromName(T,C) /* no-op */
  2.7039 +#endif
  2.7040  SQLITE_PRIVATE void sqlite3AddColumn(Parse*,Token*);
  2.7041  SQLITE_PRIVATE void sqlite3AddNotNull(Parse*, int);
  2.7042  SQLITE_PRIVATE void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int);
  2.7043 @@ -12538,11 +14292,14 @@
  2.7044  
  2.7045  SQLITE_PRIVATE Bitvec *sqlite3BitvecCreate(u32);
  2.7046  SQLITE_PRIVATE int sqlite3BitvecTest(Bitvec*, u32);
  2.7047 +SQLITE_PRIVATE int sqlite3BitvecTestNotNull(Bitvec*, u32);
  2.7048  SQLITE_PRIVATE int sqlite3BitvecSet(Bitvec*, u32);
  2.7049  SQLITE_PRIVATE void sqlite3BitvecClear(Bitvec*, u32, void*);
  2.7050  SQLITE_PRIVATE void sqlite3BitvecDestroy(Bitvec*);
  2.7051  SQLITE_PRIVATE u32 sqlite3BitvecSize(Bitvec*);
  2.7052 +#ifndef SQLITE_OMIT_BUILTIN_TEST
  2.7053  SQLITE_PRIVATE int sqlite3BitvecBuiltinTest(int,int*);
  2.7054 +#endif
  2.7055  
  2.7056  SQLITE_PRIVATE RowSet *sqlite3RowSetInit(sqlite3*, void*, unsigned int);
  2.7057  SQLITE_PRIVATE void sqlite3RowSetClear(RowSet*);
  2.7058 @@ -12550,7 +14307,7 @@
  2.7059  SQLITE_PRIVATE int sqlite3RowSetTest(RowSet*, int iBatch, i64);
  2.7060  SQLITE_PRIVATE int sqlite3RowSetNext(RowSet*, i64*);
  2.7061  
  2.7062 -SQLITE_PRIVATE void sqlite3CreateView(Parse*,Token*,Token*,Token*,Select*,int,int);
  2.7063 +SQLITE_PRIVATE void sqlite3CreateView(Parse*,Token*,Token*,Token*,ExprList*,Select*,int,int);
  2.7064  
  2.7065  #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)
  2.7066  SQLITE_PRIVATE   int sqlite3ViewGetColumnNames(Parse*,Table*);
  2.7067 @@ -12580,6 +14337,7 @@
  2.7068  SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*,
  2.7069                                        Token*, Select*, Expr*, IdList*);
  2.7070  SQLITE_PRIVATE void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token *);
  2.7071 +SQLITE_PRIVATE void sqlite3SrcListFuncArgs(Parse*, SrcList*, ExprList*);
  2.7072  SQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *, struct SrcList_item *);
  2.7073  SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);
  2.7074  SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);
  2.7075 @@ -12610,7 +14368,12 @@
  2.7076  SQLITE_PRIVATE int sqlite3WhereContinueLabel(WhereInfo*);
  2.7077  SQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*);
  2.7078  SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*, int*);
  2.7079 +#define ONEPASS_OFF      0        /* Use of ONEPASS not allowed */
  2.7080 +#define ONEPASS_SINGLE   1        /* ONEPASS valid for a single row update */
  2.7081 +#define ONEPASS_MULTI    2        /* ONEPASS is valid for multiple rows */
  2.7082 +SQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn(Parse*, Index*, int, int, int);
  2.7083  SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8);
  2.7084 +SQLITE_PRIVATE void sqlite3ExprCodeGetColumnToReg(Parse*, Table*, int, int, int);
  2.7085  SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
  2.7086  SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);
  2.7087  SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse*, int, int, int);
  2.7088 @@ -12620,16 +14383,19 @@
  2.7089  SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse*);
  2.7090  SQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse*, int, int);
  2.7091  SQLITE_PRIVATE void sqlite3ExprCode(Parse*, Expr*, int);
  2.7092 +SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int);
  2.7093  SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
  2.7094  SQLITE_PRIVATE void sqlite3ExprCodeAtInit(Parse*, Expr*, int, u8);
  2.7095  SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
  2.7096  SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int);
  2.7097  SQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse*, Expr*, int);
  2.7098 -SQLITE_PRIVATE int sqlite3ExprCodeExprList(Parse*, ExprList*, int, u8);
  2.7099 +SQLITE_PRIVATE int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int, u8);
  2.7100  #define SQLITE_ECEL_DUP      0x01  /* Deep, not shallow copies */
  2.7101  #define SQLITE_ECEL_FACTOR   0x02  /* Factor out constant terms */
  2.7102 +#define SQLITE_ECEL_REF      0x04  /* Use ExprList.u.x.iOrderByCol */
  2.7103  SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse*, Expr*, int, int);
  2.7104  SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse*, Expr*, int, int);
  2.7105 +SQLITE_PRIVATE void sqlite3ExprIfFalseDup(Parse*, Expr*, int, int);
  2.7106  SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3*,const char*, const char*);
  2.7107  SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,int isView,const char*, const char*);
  2.7108  SQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,int isView,struct SrcList_item *);
  2.7109 @@ -12646,8 +14412,10 @@
  2.7110  SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
  2.7111  SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
  2.7112  SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
  2.7113 +#ifndef SQLITE_OMIT_BUILTIN_TEST
  2.7114  SQLITE_PRIVATE void sqlite3PrngSaveState(void);
  2.7115  SQLITE_PRIVATE void sqlite3PrngRestoreState(void);
  2.7116 +#endif
  2.7117  SQLITE_PRIVATE void sqlite3RollbackAll(sqlite3*,int);
  2.7118  SQLITE_PRIVATE void sqlite3CodeVerifySchema(Parse*, int);
  2.7119  SQLITE_PRIVATE void sqlite3CodeVerifyNamedSchema(Parse*, const char *zDb);
  2.7120 @@ -12659,19 +14427,24 @@
  2.7121  SQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3*);
  2.7122  SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr*);
  2.7123  SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr*);
  2.7124 -SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr*);
  2.7125 +SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr*, u8);
  2.7126 +SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr*,int);
  2.7127 +#ifdef SQLITE_ENABLE_CURSOR_HINTS
  2.7128 +SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr*);
  2.7129 +#endif
  2.7130  SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr*, int*);
  2.7131  SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*);
  2.7132  SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
  2.7133  SQLITE_PRIVATE int sqlite3IsRowid(const char*);
  2.7134 -SQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8);
  2.7135 -SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*);
  2.7136 +SQLITE_PRIVATE void sqlite3GenerateRowDelete(
  2.7137 +    Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int);
  2.7138 +SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);
  2.7139  SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int);
  2.7140  SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int);
  2.7141  SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,
  2.7142 -                                     u8,u8,int,int*);
  2.7143 +                                     u8,u8,int,int*,int*);
  2.7144  SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int);
  2.7145 -SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int, u8*, int*, int*);
  2.7146 +SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, u8, int, u8*, int*, int*);
  2.7147  SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
  2.7148  SQLITE_PRIVATE void sqlite3MultiWrite(Parse*);
  2.7149  SQLITE_PRIVATE void sqlite3MayAbort(Parse*);
  2.7150 @@ -12683,6 +14456,11 @@
  2.7151  SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);
  2.7152  SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*);
  2.7153  SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int);
  2.7154 +#if SELECTTRACE_ENABLED
  2.7155 +SQLITE_PRIVATE void sqlite3SelectSetName(Select*,const char*);
  2.7156 +#else
  2.7157 +# define sqlite3SelectSetName(A,B)
  2.7158 +#endif
  2.7159  SQLITE_PRIVATE void sqlite3FuncDefInsert(FuncDefHash*, FuncDef*);
  2.7160  SQLITE_PRIVATE FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,int,u8,u8);
  2.7161  SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(sqlite3*);
  2.7162 @@ -12718,6 +14496,7 @@
  2.7163  SQLITE_PRIVATE   void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
  2.7164  SQLITE_PRIVATE   u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);
  2.7165  # define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p))
  2.7166 +# define sqlite3IsToplevel(p) ((p)->pToplevel==0)
  2.7167  #else
  2.7168  # define sqlite3TriggersExist(B,C,D,E,F) 0
  2.7169  # define sqlite3DeleteTrigger(A,B)
  2.7170 @@ -12727,6 +14506,7 @@
  2.7171  # define sqlite3CodeRowTriggerDirect(A,B,C,D,E,F)
  2.7172  # define sqlite3TriggerList(X, Y) 0
  2.7173  # define sqlite3ParseToplevel(p) p
  2.7174 +# define sqlite3IsToplevel(p) 1
  2.7175  # define sqlite3TriggerColmask(A,B,C,D,E,F,G) 0
  2.7176  #endif
  2.7177  
  2.7178 @@ -12769,55 +14549,41 @@
  2.7179  /*
  2.7180  ** Routines to read and write variable-length integers.  These used to
  2.7181  ** be defined locally, but now we use the varint routines in the util.c
  2.7182 -** file.  Code should use the MACRO forms below, as the Varint32 versions
  2.7183 -** are coded to assume the single byte case is already handled (which 
  2.7184 -** the MACRO form does).
  2.7185 +** file.
  2.7186  */
  2.7187  SQLITE_PRIVATE int sqlite3PutVarint(unsigned char*, u64);
  2.7188 -SQLITE_PRIVATE int sqlite3PutVarint32(unsigned char*, u32);
  2.7189  SQLITE_PRIVATE u8 sqlite3GetVarint(const unsigned char *, u64 *);
  2.7190  SQLITE_PRIVATE u8 sqlite3GetVarint32(const unsigned char *, u32 *);
  2.7191  SQLITE_PRIVATE int sqlite3VarintLen(u64 v);
  2.7192  
  2.7193  /*
  2.7194 -** The header of a record consists of a sequence variable-length integers.
  2.7195 -** These integers are almost always small and are encoded as a single byte.
  2.7196 -** The following macros take advantage this fact to provide a fast encode
  2.7197 -** and decode of the integers in a record header.  It is faster for the common
  2.7198 -** case where the integer is a single byte.  It is a little slower when the
  2.7199 -** integer is two or more bytes.  But overall it is faster.
  2.7200 -**
  2.7201 -** The following expressions are equivalent:
  2.7202 -**
  2.7203 -**     x = sqlite3GetVarint32( A, &B );
  2.7204 -**     x = sqlite3PutVarint32( A, B );
  2.7205 -**
  2.7206 -**     x = getVarint32( A, B );
  2.7207 -**     x = putVarint32( A, B );
  2.7208 -**
  2.7209 +** The common case is for a varint to be a single byte.  They following
  2.7210 +** macros handle the common case without a procedure call, but then call
  2.7211 +** the procedure for larger varints.
  2.7212  */
  2.7213  #define getVarint32(A,B)  \
  2.7214    (u8)((*(A)<(u8)0x80)?((B)=(u32)*(A)),1:sqlite3GetVarint32((A),(u32 *)&(B)))
  2.7215  #define putVarint32(A,B)  \
  2.7216    (u8)(((u32)(B)<(u32)0x80)?(*(A)=(unsigned char)(B)),1:\
  2.7217 -  sqlite3PutVarint32((A),(B)))
  2.7218 +  sqlite3PutVarint((A),(B)))
  2.7219  #define getVarint    sqlite3GetVarint
  2.7220  #define putVarint    sqlite3PutVarint
  2.7221  
  2.7222  
  2.7223 -SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(Vdbe *, Index *);
  2.7224 +SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3*, Index*);
  2.7225  SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe*, Table*, int);
  2.7226  SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2);
  2.7227  SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity);
  2.7228  SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr);
  2.7229  SQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*, int, u8);
  2.7230  SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char*, i64*);
  2.7231 -SQLITE_PRIVATE void sqlite3Error(sqlite3*, int, const char*,...);
  2.7232 +SQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...);
  2.7233 +SQLITE_PRIVATE void sqlite3Error(sqlite3*,int);
  2.7234  SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n);
  2.7235  SQLITE_PRIVATE u8 sqlite3HexToInt(int h);
  2.7236  SQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);
  2.7237  
  2.7238 -#if defined(SQLITE_TEST) 
  2.7239 +#if defined(SQLITE_NEED_ERR_NAME)
  2.7240  SQLITE_PRIVATE const char *sqlite3ErrName(int);
  2.7241  #endif
  2.7242  
  2.7243 @@ -12826,7 +14592,7 @@
  2.7244  SQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int);
  2.7245  SQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName);
  2.7246  SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr);
  2.7247 -SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*);
  2.7248 +SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int);
  2.7249  SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);
  2.7250  SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);
  2.7251  SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);
  2.7252 @@ -12855,6 +14621,7 @@
  2.7253  SQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);
  2.7254  #ifndef SQLITE_AMALGAMATION
  2.7255  SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[];
  2.7256 +SQLITE_PRIVATE const char sqlite3StrBINARY[];
  2.7257  SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[];
  2.7258  SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[];
  2.7259  SQLITE_PRIVATE const Token sqlite3IntTokens[];
  2.7260 @@ -12873,8 +14640,10 @@
  2.7261  SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*);
  2.7262  SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *, Expr *, int, int);
  2.7263  SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
  2.7264 +SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);
  2.7265  SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
  2.7266  SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);
  2.7267 +SQLITE_PRIVATE int sqlite3ResolveExprListNames(NameContext*, ExprList*);
  2.7268  SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
  2.7269  SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
  2.7270  SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
  2.7271 @@ -12892,7 +14661,6 @@
  2.7272  SQLITE_PRIVATE void sqlite3DefaultRowEst(Index*);
  2.7273  SQLITE_PRIVATE void sqlite3RegisterLikeFunctions(sqlite3*, int);
  2.7274  SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);
  2.7275 -SQLITE_PRIVATE void sqlite3MinimumFileFormat(Parse*, int, int);
  2.7276  SQLITE_PRIVATE void sqlite3SchemaClear(void *);
  2.7277  SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *, Btree *);
  2.7278  SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
  2.7279 @@ -12908,13 +14676,15 @@
  2.7280    void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
  2.7281    FuncDestructor *pDestructor
  2.7282  );
  2.7283 +SQLITE_PRIVATE void sqlite3OomFault(sqlite3*);
  2.7284 +SQLITE_PRIVATE void sqlite3OomClear(sqlite3*);
  2.7285  SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int);
  2.7286  SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *);
  2.7287  
  2.7288 -SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, char*, int, int);
  2.7289 +SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int);
  2.7290  SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum*,const char*,int);
  2.7291  SQLITE_PRIVATE void sqlite3StrAccumAppendAll(StrAccum*,const char*);
  2.7292 -SQLITE_PRIVATE void sqlite3AppendSpace(StrAccum*,int);
  2.7293 +SQLITE_PRIVATE void sqlite3AppendChar(StrAccum*,int,char);
  2.7294  SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*);
  2.7295  SQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum*);
  2.7296  SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int);
  2.7297 @@ -12934,7 +14704,7 @@
  2.7298  /*
  2.7299  ** The interface to the LEMON-generated parser
  2.7300  */
  2.7301 -SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(size_t));
  2.7302 +SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(u64));
  2.7303  SQLITE_PRIVATE void sqlite3ParserFree(void*, void(*)(void*));
  2.7304  SQLITE_PRIVATE void sqlite3Parser(void*, int, Token, Parse*);
  2.7305  #ifdef YYTRACKMAXSTACKDEPTH
  2.7306 @@ -12983,6 +14753,8 @@
  2.7307  SQLITE_PRIVATE    VTable *sqlite3GetVTable(sqlite3*, Table*);
  2.7308  #  define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0)
  2.7309  #endif
  2.7310 +SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*);
  2.7311 +SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*);
  2.7312  SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*);
  2.7313  SQLITE_PRIVATE void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*, int);
  2.7314  SQLITE_PRIVATE void sqlite3VtabFinishParse(Parse*, Token*);
  2.7315 @@ -13095,12 +14867,11 @@
  2.7316  SQLITE_PRIVATE int sqlite3MemJournalSize(void);
  2.7317  SQLITE_PRIVATE int sqlite3IsMemJournal(sqlite3_file *);
  2.7318  
  2.7319 +SQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p);
  2.7320  #if SQLITE_MAX_EXPR_DEPTH>0
  2.7321 -SQLITE_PRIVATE   void sqlite3ExprSetHeight(Parse *pParse, Expr *p);
  2.7322  SQLITE_PRIVATE   int sqlite3SelectExprHeight(Select *);
  2.7323  SQLITE_PRIVATE   int sqlite3ExprCheckHeight(Parse*, int);
  2.7324  #else
  2.7325 -  #define sqlite3ExprSetHeight(x,y)
  2.7326    #define sqlite3SelectExprHeight(x) 0
  2.7327    #define sqlite3ExprCheckHeight(x,y)
  2.7328  #endif
  2.7329 @@ -13130,7 +14901,7 @@
  2.7330  #ifdef SQLITE_ENABLE_IOTRACE
  2.7331  # define IOTRACE(A)  if( sqlite3IoTrace ){ sqlite3IoTrace A; }
  2.7332  SQLITE_PRIVATE   void sqlite3VdbeIOTraceSql(Vdbe*);
  2.7333 -SQLITE_PRIVATE void (*sqlite3IoTrace)(const char*,...);
  2.7334 +SQLITE_API SQLITE_EXTERN void (SQLITE_CDECL *sqlite3IoTrace)(const char*,...);
  2.7335  #else
  2.7336  # define IOTRACE(A)
  2.7337  # define sqlite3VdbeIOTraceSql(X)
  2.7338 @@ -13174,10 +14945,21 @@
  2.7339  # define sqlite3MemdebugNoType(X,Y)   1
  2.7340  #endif
  2.7341  #define MEMTYPE_HEAP       0x01  /* General heap allocations */
  2.7342 -#define MEMTYPE_LOOKASIDE  0x02  /* Might have been lookaside memory */
  2.7343 +#define MEMTYPE_LOOKASIDE  0x02  /* Heap that might have been lookaside */
  2.7344  #define MEMTYPE_SCRATCH    0x04  /* Scratch allocations */
  2.7345  #define MEMTYPE_PCACHE     0x08  /* Page cache allocations */
  2.7346 -#define MEMTYPE_DB         0x10  /* Uses sqlite3DbMalloc, not sqlite_malloc */
  2.7347 +
  2.7348 +/*
  2.7349 +** Threading interface
  2.7350 +*/
  2.7351 +#if SQLITE_MAX_WORKER_THREADS>0
  2.7352 +SQLITE_PRIVATE int sqlite3ThreadCreate(SQLiteThread**,void*(*)(void*),void*);
  2.7353 +SQLITE_PRIVATE int sqlite3ThreadJoin(SQLiteThread*, void**);
  2.7354 +#endif
  2.7355 +
  2.7356 +#if defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)
  2.7357 +SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3*);
  2.7358 +#endif
  2.7359  
  2.7360  #endif /* _SQLITEINT_H_ */
  2.7361  
  2.7362 @@ -13195,8 +14977,9 @@
  2.7363  **
  2.7364  *************************************************************************
  2.7365  **
  2.7366 -** This file contains definitions of global variables and contants.
  2.7367 -*/
  2.7368 +** This file contains definitions of global variables and constants.
  2.7369 +*/
  2.7370 +/* #include "sqliteInt.h" */
  2.7371  
  2.7372  /* An array to map all upper-case characters into their corresponding
  2.7373  ** lower-case character. 
  2.7374 @@ -13230,16 +15013,16 @@
  2.7375       48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 3x */
  2.7376       64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 4x */
  2.7377       80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 5x */
  2.7378 -     96, 97, 66, 67, 68, 69, 70, 71, 72, 73,106,107,108,109,110,111, /* 6x */
  2.7379 -    112, 81, 82, 83, 84, 85, 86, 87, 88, 89,122,123,124,125,126,127, /* 7x */
  2.7380 +     96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 6x */
  2.7381 +    112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 7x */
  2.7382      128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, /* 8x */
  2.7383 -    144,145,146,147,148,149,150,151,152,153,154,155,156,157,156,159, /* 9x */
  2.7384 +    144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, /* 9x */
  2.7385      160,161,162,163,164,165,166,167,168,169,170,171,140,141,142,175, /* Ax */
  2.7386      176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, /* Bx */
  2.7387      192,129,130,131,132,133,134,135,136,137,202,203,204,205,206,207, /* Cx */
  2.7388      208,145,146,147,148,149,150,151,152,153,218,219,220,221,222,223, /* Dx */
  2.7389 -    224,225,162,163,164,165,166,167,168,169,232,203,204,205,206,207, /* Ex */
  2.7390 -    239,240,241,242,243,244,245,246,247,248,249,219,220,221,222,255, /* Fx */
  2.7391 +    224,225,162,163,164,165,166,167,168,169,234,235,236,237,238,239, /* Ex */
  2.7392 +    240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255, /* Fx */
  2.7393  #endif
  2.7394  };
  2.7395  
  2.7396 @@ -13313,14 +15096,36 @@
  2.7397  };
  2.7398  #endif
  2.7399  
  2.7400 +/* EVIDENCE-OF: R-02982-34736 In order to maintain full backwards
  2.7401 +** compatibility for legacy applications, the URI filename capability is
  2.7402 +** disabled by default.
  2.7403 +**
  2.7404 +** EVIDENCE-OF: R-38799-08373 URI filenames can be enabled or disabled
  2.7405 +** using the SQLITE_USE_URI=1 or SQLITE_USE_URI=0 compile-time options.
  2.7406 +**
  2.7407 +** EVIDENCE-OF: R-43642-56306 By default, URI handling is globally
  2.7408 +** disabled. The default value may be changed by compiling with the
  2.7409 +** SQLITE_USE_URI symbol defined.
  2.7410 +*/
  2.7411  #ifndef SQLITE_USE_URI
  2.7412  # define  SQLITE_USE_URI 0
  2.7413  #endif
  2.7414  
  2.7415 +/* EVIDENCE-OF: R-38720-18127 The default setting is determined by the
  2.7416 +** SQLITE_ALLOW_COVERING_INDEX_SCAN compile-time option, or is "on" if
  2.7417 +** that compile-time option is omitted.
  2.7418 +*/
  2.7419  #ifndef SQLITE_ALLOW_COVERING_INDEX_SCAN
  2.7420  # define SQLITE_ALLOW_COVERING_INDEX_SCAN 1
  2.7421  #endif
  2.7422  
  2.7423 +/* The minimum PMA size is set to this value multiplied by the database
  2.7424 +** page size in bytes.
  2.7425 +*/
  2.7426 +#ifndef SQLITE_SORTER_PMASZ
  2.7427 +# define SQLITE_SORTER_PMASZ 250
  2.7428 +#endif
  2.7429 +
  2.7430  /*
  2.7431  ** The following singleton contains the global configuration for
  2.7432  ** the SQLite library.
  2.7433 @@ -13348,9 +15153,10 @@
  2.7434     0,                         /* nScratch */
  2.7435     (void*)0,                  /* pPage */
  2.7436     0,                         /* szPage */
  2.7437 -   0,                         /* nPage */
  2.7438 +   SQLITE_DEFAULT_PCACHE_INITSZ, /* nPage */
  2.7439     0,                         /* mxParserStack */
  2.7440     0,                         /* sharedCacheEnabled */
  2.7441 +   SQLITE_SORTER_PMASZ,       /* szPma */
  2.7442     /* All the rest should always be initialized to zero */
  2.7443     0,                         /* isInit */
  2.7444     0,                         /* inProgress */
  2.7445 @@ -13406,13 +15212,14 @@
  2.7446  **
  2.7447  ** IMPORTANT:  Changing the pending byte to any value other than
  2.7448  ** 0x40000000 results in an incompatible database file format!
  2.7449 -** Changing the pending byte during operating results in undefined
  2.7450 -** and dileterious behavior.
  2.7451 +** Changing the pending byte during operation will result in undefined
  2.7452 +** and incorrect behavior.
  2.7453  */
  2.7454  #ifndef SQLITE_OMIT_WSD
  2.7455  SQLITE_PRIVATE int sqlite3PendingByte = 0x40000000;
  2.7456  #endif
  2.7457  
  2.7458 +/* #include "opcodes.h" */
  2.7459  /*
  2.7460  ** Properties of opcodes.  The OPFLG_INITIALIZER macro is
  2.7461  ** created by mkopcodeh.awk during compilation.  Data is obtained
  2.7462 @@ -13421,6 +15228,11 @@
  2.7463  */
  2.7464  SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER;
  2.7465  
  2.7466 +/*
  2.7467 +** Name of the default collating sequence
  2.7468 +*/
  2.7469 +SQLITE_PRIVATE const char sqlite3StrBINARY[] = "BINARY";
  2.7470 +
  2.7471  /************** End of global.c **********************************************/
  2.7472  /************** Begin file ctime.c *******************************************/
  2.7473  /*
  2.7474 @@ -13441,6 +15253,7 @@
  2.7475  
  2.7476  #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
  2.7477  
  2.7478 +/* #include "sqliteInt.h" */
  2.7479  
  2.7480  /*
  2.7481  ** An array of names of all compile-time options.  This array should 
  2.7482 @@ -13457,88 +15270,103 @@
  2.7483  #define CTIMEOPT_VAL_(opt) #opt
  2.7484  #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
  2.7485  
  2.7486 -#ifdef SQLITE_32BIT_ROWID
  2.7487 +#if SQLITE_32BIT_ROWID
  2.7488    "32BIT_ROWID",
  2.7489  #endif
  2.7490 -#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC
  2.7491 +#if SQLITE_4_BYTE_ALIGNED_MALLOC
  2.7492    "4_BYTE_ALIGNED_MALLOC",
  2.7493  #endif
  2.7494 -#ifdef SQLITE_CASE_SENSITIVE_LIKE
  2.7495 +#if SQLITE_CASE_SENSITIVE_LIKE
  2.7496    "CASE_SENSITIVE_LIKE",
  2.7497  #endif
  2.7498 -#ifdef SQLITE_CHECK_PAGES
  2.7499 +#if SQLITE_CHECK_PAGES
  2.7500    "CHECK_PAGES",
  2.7501  #endif
  2.7502 -#ifdef SQLITE_COVERAGE_TEST
  2.7503 +#if SQLITE_COVERAGE_TEST
  2.7504    "COVERAGE_TEST",
  2.7505  #endif
  2.7506 -#ifdef SQLITE_DEBUG
  2.7507 +#if SQLITE_DEBUG
  2.7508    "DEBUG",
  2.7509  #endif
  2.7510 -#ifdef SQLITE_DEFAULT_LOCKING_MODE
  2.7511 +#if SQLITE_DEFAULT_LOCKING_MODE
  2.7512    "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
  2.7513  #endif
  2.7514  #if defined(SQLITE_DEFAULT_MMAP_SIZE) && !defined(SQLITE_DEFAULT_MMAP_SIZE_xc)
  2.7515    "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
  2.7516  #endif
  2.7517 -#ifdef SQLITE_DISABLE_DIRSYNC
  2.7518 +#if SQLITE_DISABLE_DIRSYNC
  2.7519    "DISABLE_DIRSYNC",
  2.7520  #endif
  2.7521 -#ifdef SQLITE_DISABLE_LFS
  2.7522 +#if SQLITE_DISABLE_LFS
  2.7523    "DISABLE_LFS",
  2.7524  #endif
  2.7525 -#ifdef SQLITE_ENABLE_ATOMIC_WRITE
  2.7526 +#if SQLITE_ENABLE_8_3_NAMES
  2.7527 +  "ENABLE_8_3_NAMES",
  2.7528 +#endif
  2.7529 +#if SQLITE_ENABLE_API_ARMOR
  2.7530 +  "ENABLE_API_ARMOR",
  2.7531 +#endif
  2.7532 +#if SQLITE_ENABLE_ATOMIC_WRITE
  2.7533    "ENABLE_ATOMIC_WRITE",
  2.7534  #endif
  2.7535 -#ifdef SQLITE_ENABLE_CEROD
  2.7536 +#if SQLITE_ENABLE_CEROD
  2.7537    "ENABLE_CEROD",
  2.7538  #endif
  2.7539 -#ifdef SQLITE_ENABLE_COLUMN_METADATA
  2.7540 +#if SQLITE_ENABLE_COLUMN_METADATA
  2.7541    "ENABLE_COLUMN_METADATA",
  2.7542  #endif
  2.7543 -#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
  2.7544 +#if SQLITE_ENABLE_DBSTAT_VTAB
  2.7545 +  "ENABLE_DBSTAT_VTAB",
  2.7546 +#endif
  2.7547 +#if SQLITE_ENABLE_EXPENSIVE_ASSERT
  2.7548    "ENABLE_EXPENSIVE_ASSERT",
  2.7549  #endif
  2.7550 -#ifdef SQLITE_ENABLE_FTS1
  2.7551 +#if SQLITE_ENABLE_FTS1
  2.7552    "ENABLE_FTS1",
  2.7553  #endif
  2.7554 -#ifdef SQLITE_ENABLE_FTS2
  2.7555 +#if SQLITE_ENABLE_FTS2
  2.7556    "ENABLE_FTS2",
  2.7557  #endif
  2.7558 -#ifdef SQLITE_ENABLE_FTS3
  2.7559 +#if SQLITE_ENABLE_FTS3
  2.7560    "ENABLE_FTS3",
  2.7561  #endif
  2.7562 -#ifdef SQLITE_ENABLE_FTS3_PARENTHESIS
  2.7563 +#if SQLITE_ENABLE_FTS3_PARENTHESIS
  2.7564    "ENABLE_FTS3_PARENTHESIS",
  2.7565  #endif
  2.7566 -#ifdef SQLITE_ENABLE_FTS4
  2.7567 +#if SQLITE_ENABLE_FTS4
  2.7568    "ENABLE_FTS4",
  2.7569  #endif
  2.7570 -#ifdef SQLITE_ENABLE_ICU
  2.7571 +#if SQLITE_ENABLE_FTS5
  2.7572 +  "ENABLE_FTS5",
  2.7573 +#endif
  2.7574 +#if SQLITE_ENABLE_ICU
  2.7575    "ENABLE_ICU",
  2.7576  #endif
  2.7577 -#ifdef SQLITE_ENABLE_IOTRACE
  2.7578 +#if SQLITE_ENABLE_IOTRACE
  2.7579    "ENABLE_IOTRACE",
  2.7580  #endif
  2.7581 -#ifdef SQLITE_ENABLE_LOAD_EXTENSION
  2.7582 +#if SQLITE_ENABLE_JSON1
  2.7583 +  "ENABLE_JSON1",
  2.7584 +#endif
  2.7585 +#if SQLITE_ENABLE_LOAD_EXTENSION
  2.7586    "ENABLE_LOAD_EXTENSION",
  2.7587  #endif
  2.7588 -#ifdef SQLITE_ENABLE_LOCKING_STYLE
  2.7589 +#if SQLITE_ENABLE_LOCKING_STYLE
  2.7590    "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),
  2.7591  #endif
  2.7592 -#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
  2.7593 +#if SQLITE_ENABLE_MEMORY_MANAGEMENT
  2.7594    "ENABLE_MEMORY_MANAGEMENT",
  2.7595  #endif
  2.7596 -#ifdef SQLITE_ENABLE_MEMSYS3
  2.7597 +#if SQLITE_ENABLE_MEMSYS3
  2.7598    "ENABLE_MEMSYS3",
  2.7599  #endif
  2.7600 -#ifdef SQLITE_ENABLE_MEMSYS5
  2.7601 +#if SQLITE_ENABLE_MEMSYS5
  2.7602    "ENABLE_MEMSYS5",
  2.7603  #endif
  2.7604 -#ifdef SQLITE_ENABLE_OVERSIZE_CELL_CHECK
  2.7605 +#if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
  2.7606    "ENABLE_OVERSIZE_CELL_CHECK",
  2.7607  #endif
  2.7608 -#ifdef SQLITE_ENABLE_RTREE
  2.7609 +#if SQLITE_ENABLE_RTREE
  2.7610    "ENABLE_RTREE",
  2.7611  #endif
  2.7612  #if defined(SQLITE_ENABLE_STAT4)
  2.7613 @@ -13546,31 +15374,34 @@
  2.7614  #elif defined(SQLITE_ENABLE_STAT3)
  2.7615    "ENABLE_STAT3",
  2.7616  #endif
  2.7617 -#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
  2.7618 +#if SQLITE_ENABLE_UNLOCK_NOTIFY
  2.7619    "ENABLE_UNLOCK_NOTIFY",
  2.7620  #endif
  2.7621 -#ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
  2.7622 +#if SQLITE_ENABLE_UPDATE_DELETE_LIMIT
  2.7623    "ENABLE_UPDATE_DELETE_LIMIT",
  2.7624  #endif
  2.7625 -#ifdef SQLITE_HAS_CODEC
  2.7626 +#if SQLITE_HAS_CODEC
  2.7627    "HAS_CODEC",
  2.7628  #endif
  2.7629 -#ifdef SQLITE_HAVE_ISNAN
  2.7630 +#if HAVE_ISNAN || SQLITE_HAVE_ISNAN
  2.7631    "HAVE_ISNAN",
  2.7632  #endif
  2.7633 -#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX
  2.7634 +#if SQLITE_HOMEGROWN_RECURSIVE_MUTEX
  2.7635    "HOMEGROWN_RECURSIVE_MUTEX",
  2.7636  #endif
  2.7637 -#ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS
  2.7638 +#if SQLITE_IGNORE_AFP_LOCK_ERRORS
  2.7639    "IGNORE_AFP_LOCK_ERRORS",
  2.7640  #endif
  2.7641 -#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS
  2.7642 +#if SQLITE_IGNORE_FLOCK_LOCK_ERRORS
  2.7643    "IGNORE_FLOCK_LOCK_ERRORS",
  2.7644  #endif
  2.7645  #ifdef SQLITE_INT64_TYPE
  2.7646    "INT64_TYPE",
  2.7647  #endif
  2.7648 -#ifdef SQLITE_LOCK_TRACE
  2.7649 +#ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS
  2.7650 +  "LIKE_DOESNT_MATCH_BLOBS",
  2.7651 +#endif
  2.7652 +#if SQLITE_LOCK_TRACE
  2.7653    "LOCK_TRACE",
  2.7654  #endif
  2.7655  #if defined(SQLITE_MAX_MMAP_SIZE) && !defined(SQLITE_MAX_MMAP_SIZE_xc)
  2.7656 @@ -13579,223 +15410,226 @@
  2.7657  #ifdef SQLITE_MAX_SCHEMA_RETRY
  2.7658    "MAX_SCHEMA_RETRY=" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY),
  2.7659  #endif
  2.7660 -#ifdef SQLITE_MEMDEBUG
  2.7661 +#if SQLITE_MEMDEBUG
  2.7662    "MEMDEBUG",
  2.7663  #endif
  2.7664 -#ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT
  2.7665 +#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT
  2.7666    "MIXED_ENDIAN_64BIT_FLOAT",
  2.7667  #endif
  2.7668 -#ifdef SQLITE_NO_SYNC
  2.7669 +#if SQLITE_NO_SYNC
  2.7670    "NO_SYNC",
  2.7671  #endif
  2.7672 -#ifdef SQLITE_OMIT_ALTERTABLE
  2.7673 +#if SQLITE_OMIT_ALTERTABLE
  2.7674    "OMIT_ALTERTABLE",
  2.7675  #endif
  2.7676 -#ifdef SQLITE_OMIT_ANALYZE
  2.7677 +#if SQLITE_OMIT_ANALYZE
  2.7678    "OMIT_ANALYZE",
  2.7679  #endif
  2.7680 -#ifdef SQLITE_OMIT_ATTACH
  2.7681 +#if SQLITE_OMIT_ATTACH
  2.7682    "OMIT_ATTACH",
  2.7683  #endif
  2.7684 -#ifdef SQLITE_OMIT_AUTHORIZATION
  2.7685 +#if SQLITE_OMIT_AUTHORIZATION
  2.7686    "OMIT_AUTHORIZATION",
  2.7687  #endif
  2.7688 -#ifdef SQLITE_OMIT_AUTOINCREMENT
  2.7689 +#if SQLITE_OMIT_AUTOINCREMENT
  2.7690    "OMIT_AUTOINCREMENT",
  2.7691  #endif
  2.7692 -#ifdef SQLITE_OMIT_AUTOINIT
  2.7693 +#if SQLITE_OMIT_AUTOINIT
  2.7694    "OMIT_AUTOINIT",
  2.7695  #endif
  2.7696 -#ifdef SQLITE_OMIT_AUTOMATIC_INDEX
  2.7697 +#if SQLITE_OMIT_AUTOMATIC_INDEX
  2.7698    "OMIT_AUTOMATIC_INDEX",
  2.7699  #endif
  2.7700 -#ifdef SQLITE_OMIT_AUTORESET
  2.7701 +#if SQLITE_OMIT_AUTORESET
  2.7702    "OMIT_AUTORESET",
  2.7703  #endif
  2.7704 -#ifdef SQLITE_OMIT_AUTOVACUUM
  2.7705 +#if SQLITE_OMIT_AUTOVACUUM
  2.7706    "OMIT_AUTOVACUUM",
  2.7707  #endif
  2.7708 -#ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION
  2.7709 +#if SQLITE_OMIT_BETWEEN_OPTIMIZATION
  2.7710    "OMIT_BETWEEN_OPTIMIZATION",
  2.7711  #endif
  2.7712 -#ifdef SQLITE_OMIT_BLOB_LITERAL
  2.7713 +#if SQLITE_OMIT_BLOB_LITERAL
  2.7714    "OMIT_BLOB_LITERAL",
  2.7715  #endif
  2.7716 -#ifdef SQLITE_OMIT_BTREECOUNT
  2.7717 +#if SQLITE_OMIT_BTREECOUNT
  2.7718    "OMIT_BTREECOUNT",
  2.7719  #endif
  2.7720 -#ifdef SQLITE_OMIT_BUILTIN_TEST
  2.7721 +#if SQLITE_OMIT_BUILTIN_TEST
  2.7722    "OMIT_BUILTIN_TEST",
  2.7723  #endif
  2.7724 -#ifdef SQLITE_OMIT_CAST
  2.7725 +#if SQLITE_OMIT_CAST
  2.7726    "OMIT_CAST",
  2.7727  #endif
  2.7728 -#ifdef SQLITE_OMIT_CHECK
  2.7729 +#if SQLITE_OMIT_CHECK
  2.7730    "OMIT_CHECK",
  2.7731  #endif
  2.7732 -#ifdef SQLITE_OMIT_COMPLETE
  2.7733 +#if SQLITE_OMIT_COMPLETE
  2.7734    "OMIT_COMPLETE",
  2.7735  #endif
  2.7736 -#ifdef SQLITE_OMIT_COMPOUND_SELECT
  2.7737 +#if SQLITE_OMIT_COMPOUND_SELECT
  2.7738    "OMIT_COMPOUND_SELECT",
  2.7739  #endif
  2.7740 -#ifdef SQLITE_OMIT_CTE
  2.7741 +#if SQLITE_OMIT_CTE
  2.7742    "OMIT_CTE",
  2.7743  #endif
  2.7744 -#ifdef SQLITE_OMIT_DATETIME_FUNCS
  2.7745 +#if SQLITE_OMIT_DATETIME_FUNCS
  2.7746    "OMIT_DATETIME_FUNCS",
  2.7747  #endif
  2.7748 -#ifdef SQLITE_OMIT_DECLTYPE
  2.7749 +#if SQLITE_OMIT_DECLTYPE
  2.7750    "OMIT_DECLTYPE",
  2.7751  #endif
  2.7752 -#ifdef SQLITE_OMIT_DEPRECATED
  2.7753 +#if SQLITE_OMIT_DEPRECATED
  2.7754    "OMIT_DEPRECATED",
  2.7755  #endif
  2.7756 -#ifdef SQLITE_OMIT_DISKIO
  2.7757 +#if SQLITE_OMIT_DISKIO
  2.7758    "OMIT_DISKIO",
  2.7759  #endif
  2.7760 -#ifdef SQLITE_OMIT_EXPLAIN
  2.7761 +#if SQLITE_OMIT_EXPLAIN
  2.7762    "OMIT_EXPLAIN",
  2.7763  #endif
  2.7764 -#ifdef SQLITE_OMIT_FLAG_PRAGMAS
  2.7765 +#if SQLITE_OMIT_FLAG_PRAGMAS
  2.7766    "OMIT_FLAG_PRAGMAS",
  2.7767  #endif
  2.7768 -#ifdef SQLITE_OMIT_FLOATING_POINT
  2.7769 +#if SQLITE_OMIT_FLOATING_POINT
  2.7770    "OMIT_FLOATING_POINT",
  2.7771  #endif
  2.7772 -#ifdef SQLITE_OMIT_FOREIGN_KEY
  2.7773 +#if SQLITE_OMIT_FOREIGN_KEY
  2.7774    "OMIT_FOREIGN_KEY",
  2.7775  #endif
  2.7776 -#ifdef SQLITE_OMIT_GET_TABLE
  2.7777 +#if SQLITE_OMIT_GET_TABLE
  2.7778    "OMIT_GET_TABLE",
  2.7779  #endif
  2.7780 -#ifdef SQLITE_OMIT_INCRBLOB
  2.7781 +#if SQLITE_OMIT_INCRBLOB
  2.7782    "OMIT_INCRBLOB",
  2.7783  #endif
  2.7784 -#ifdef SQLITE_OMIT_INTEGRITY_CHECK
  2.7785 +#if SQLITE_OMIT_INTEGRITY_CHECK
  2.7786    "OMIT_INTEGRITY_CHECK",
  2.7787  #endif
  2.7788 -#ifdef SQLITE_OMIT_LIKE_OPTIMIZATION
  2.7789 +#if SQLITE_OMIT_LIKE_OPTIMIZATION
  2.7790    "OMIT_LIKE_OPTIMIZATION",
  2.7791  #endif
  2.7792 -#ifdef SQLITE_OMIT_LOAD_EXTENSION
  2.7793 +#if SQLITE_OMIT_LOAD_EXTENSION
  2.7794    "OMIT_LOAD_EXTENSION",
  2.7795  #endif
  2.7796 -#ifdef SQLITE_OMIT_LOCALTIME
  2.7797 +#if SQLITE_OMIT_LOCALTIME
  2.7798    "OMIT_LOCALTIME",
  2.7799  #endif
  2.7800 -#ifdef SQLITE_OMIT_LOOKASIDE
  2.7801 +#if SQLITE_OMIT_LOOKASIDE
  2.7802    "OMIT_LOOKASIDE",
  2.7803  #endif
  2.7804 -#ifdef SQLITE_OMIT_MEMORYDB
  2.7805 +#if SQLITE_OMIT_MEMORYDB
  2.7806    "OMIT_MEMORYDB",
  2.7807  #endif
  2.7808 -#ifdef SQLITE_OMIT_OR_OPTIMIZATION
  2.7809 +#if SQLITE_OMIT_OR_OPTIMIZATION
  2.7810    "OMIT_OR_OPTIMIZATION",
  2.7811  #endif
  2.7812 -#ifdef SQLITE_OMIT_PAGER_PRAGMAS
  2.7813 +#if SQLITE_OMIT_PAGER_PRAGMAS
  2.7814    "OMIT_PAGER_PRAGMAS",
  2.7815  #endif
  2.7816 -#ifdef SQLITE_OMIT_PRAGMA
  2.7817 +#if SQLITE_OMIT_PRAGMA
  2.7818    "OMIT_PRAGMA",
  2.7819  #endif
  2.7820 -#ifdef SQLITE_OMIT_PROGRESS_CALLBACK
  2.7821 +#if SQLITE_OMIT_PROGRESS_CALLBACK
  2.7822    "OMIT_PROGRESS_CALLBACK",
  2.7823  #endif
  2.7824 -#ifdef SQLITE_OMIT_QUICKBALANCE
  2.7825 +#if SQLITE_OMIT_QUICKBALANCE
  2.7826    "OMIT_QUICKBALANCE",
  2.7827  #endif
  2.7828 -#ifdef SQLITE_OMIT_REINDEX
  2.7829 +#if SQLITE_OMIT_REINDEX
  2.7830    "OMIT_REINDEX",