src/sqlite3.h
changeset 491 d32c60ada438
parent 130 507895068f83
child 716 498156bf9993
     1.1 --- a/src/sqlite3.h	Thu Mar 03 11:14:07 2016 +0100
     1.2 +++ b/src/sqlite3.h	Thu Mar 03 13:09:12 2016 +0100
     1.3 @@ -23,7 +23,7 @@
     1.4  **
     1.5  ** The official C-language API documentation for SQLite is derived
     1.6  ** from comments in this file.  This file is the authoritative source
     1.7 -** on how SQLite interfaces are suppose to operate.
     1.8 +** on how SQLite interfaces are supposed to operate.
     1.9  **
    1.10  ** The name of this file under configuration management is "sqlite.h.in".
    1.11  ** The makefile makes some minor changes to this file (such as inserting
    1.12 @@ -43,21 +43,25 @@
    1.13  
    1.14  
    1.15  /*
    1.16 -** Add the ability to override 'extern'
    1.17 +** Provide the ability to override linkage features of the interface.
    1.18  */
    1.19  #ifndef SQLITE_EXTERN
    1.20  # define SQLITE_EXTERN extern
    1.21  #endif
    1.22 -
    1.23  #ifndef SQLITE_API
    1.24  # define SQLITE_API
    1.25  #endif
    1.26 -
    1.27 +#ifndef SQLITE_CDECL
    1.28 +# define SQLITE_CDECL
    1.29 +#endif
    1.30 +#ifndef SQLITE_STDCALL
    1.31 +# define SQLITE_STDCALL
    1.32 +#endif
    1.33  
    1.34  /*
    1.35  ** These no-op macros are used in front of interfaces to mark those
    1.36  ** interfaces as either deprecated or experimental.  New applications
    1.37 -** should not use deprecated interfaces - they are support for backwards
    1.38 +** should not use deprecated interfaces - they are supported for backwards
    1.39  ** compatibility only.  Application writers should be aware that
    1.40  ** experimental interfaces are subject to change in point releases.
    1.41  **
    1.42 @@ -107,9 +111,9 @@
    1.43  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
    1.44  ** [sqlite_version()] and [sqlite_source_id()].
    1.45  */
    1.46 -#define SQLITE_VERSION        "3.8.6"
    1.47 -#define SQLITE_VERSION_NUMBER 3008006
    1.48 -#define SQLITE_SOURCE_ID      "2014-08-15 11:46:33 9491ba7d738528f168657adb43a198238abde19e"
    1.49 +#define SQLITE_VERSION        "3.11.0"
    1.50 +#define SQLITE_VERSION_NUMBER 3011000
    1.51 +#define SQLITE_SOURCE_ID      "2016-02-15 17:29:24 3d862f207e3adc00f78066799ac5a8c282430a5f"
    1.52  
    1.53  /*
    1.54  ** CAPI3REF: Run-Time Library Version Numbers
    1.55 @@ -120,7 +124,7 @@
    1.56  ** but are associated with the library instead of the header file.  ^(Cautious
    1.57  ** programmers might include assert() statements in their application to
    1.58  ** verify that values returned by these interfaces match the macros in
    1.59 -** the header, and thus insure that the application is
    1.60 +** the header, and thus ensure that the application is
    1.61  ** compiled with matching library and header files.
    1.62  **
    1.63  ** <blockquote><pre>
    1.64 @@ -142,9 +146,9 @@
    1.65  ** See also: [sqlite_version()] and [sqlite_source_id()].
    1.66  */
    1.67  SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
    1.68 -SQLITE_API const char *sqlite3_libversion(void);
    1.69 -SQLITE_API const char *sqlite3_sourceid(void);
    1.70 -SQLITE_API int sqlite3_libversion_number(void);
    1.71 +SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void);
    1.72 +SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void);
    1.73 +SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void);
    1.74  
    1.75  /*
    1.76  ** CAPI3REF: Run-Time Library Compilation Options Diagnostics
    1.77 @@ -169,8 +173,8 @@
    1.78  ** [sqlite_compileoption_get()] and the [compile_options pragma].
    1.79  */
    1.80  #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
    1.81 -SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
    1.82 -SQLITE_API const char *sqlite3_compileoption_get(int N);
    1.83 +SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName);
    1.84 +SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N);
    1.85  #endif
    1.86  
    1.87  /*
    1.88 @@ -201,7 +205,7 @@
    1.89  ** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
    1.90  ** can be fully or partially disabled using a call to [sqlite3_config()]
    1.91  ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
    1.92 -** or [SQLITE_CONFIG_MUTEX].  ^(The return value of the
    1.93 +** or [SQLITE_CONFIG_SERIALIZED].  ^(The return value of the
    1.94  ** sqlite3_threadsafe() function shows only the compile-time setting of
    1.95  ** thread safety, not any run-time changes to that setting made by
    1.96  ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
    1.97 @@ -209,7 +213,7 @@
    1.98  **
    1.99  ** See the [threading mode] documentation for additional information.
   1.100  */
   1.101 -SQLITE_API int sqlite3_threadsafe(void);
   1.102 +SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void);
   1.103  
   1.104  /*
   1.105  ** CAPI3REF: Database Connection Handle
   1.106 @@ -266,6 +270,7 @@
   1.107  
   1.108  /*
   1.109  ** CAPI3REF: Closing A Database Connection
   1.110 +** DESTRUCTOR: sqlite3
   1.111  **
   1.112  ** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors
   1.113  ** for the [sqlite3] object.
   1.114 @@ -305,8 +310,8 @@
   1.115  ** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
   1.116  ** argument is a harmless no-op.
   1.117  */
   1.118 -SQLITE_API int sqlite3_close(sqlite3*);
   1.119 -SQLITE_API int sqlite3_close_v2(sqlite3*);
   1.120 +SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3*);
   1.121 +SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3*);
   1.122  
   1.123  /*
   1.124  ** The type for a callback function.
   1.125 @@ -317,6 +322,7 @@
   1.126  
   1.127  /*
   1.128  ** CAPI3REF: One-Step Query Execution Interface
   1.129 +** METHOD: sqlite3
   1.130  **
   1.131  ** The sqlite3_exec() interface is a convenience wrapper around
   1.132  ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
   1.133 @@ -341,7 +347,7 @@
   1.134  ** from [sqlite3_malloc()] and passed back through the 5th parameter.
   1.135  ** To avoid memory leaks, the application should invoke [sqlite3_free()]
   1.136  ** on error message strings returned through the 5th parameter of
   1.137 -** of sqlite3_exec() after the error message string is no longer needed.
   1.138 +** sqlite3_exec() after the error message string is no longer needed.
   1.139  ** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors
   1.140  ** occur, then sqlite3_exec() sets the pointer in its 5th parameter to
   1.141  ** NULL before returning.
   1.142 @@ -368,7 +374,7 @@
   1.143  ** Restrictions:
   1.144  **
   1.145  ** <ul>
   1.146 -** <li> The application must insure that the 1st parameter to sqlite3_exec()
   1.147 +** <li> The application must ensure that the 1st parameter to sqlite3_exec()
   1.148  **      is a valid and open [database connection].
   1.149  ** <li> The application must not close the [database connection] specified by
   1.150  **      the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
   1.151 @@ -376,7 +382,7 @@
   1.152  **      the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
   1.153  ** </ul>
   1.154  */
   1.155 -SQLITE_API int sqlite3_exec(
   1.156 +SQLITE_API int SQLITE_STDCALL sqlite3_exec(
   1.157    sqlite3*,                                  /* An open database */
   1.158    const char *sql,                           /* SQL to be evaluated */
   1.159    int (*callback)(void*,int,char**,char**),  /* Callback function */
   1.160 @@ -471,6 +477,8 @@
   1.161  #define SQLITE_IOERR_MMAP              (SQLITE_IOERR | (24<<8))
   1.162  #define SQLITE_IOERR_GETTEMPPATH       (SQLITE_IOERR | (25<<8))
   1.163  #define SQLITE_IOERR_CONVPATH          (SQLITE_IOERR | (26<<8))
   1.164 +#define SQLITE_IOERR_VNODE             (SQLITE_IOERR | (27<<8))
   1.165 +#define SQLITE_IOERR_AUTH              (SQLITE_IOERR | (28<<8))
   1.166  #define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))
   1.167  #define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))
   1.168  #define SQLITE_BUSY_SNAPSHOT           (SQLITE_BUSY   |  (2<<8))
   1.169 @@ -497,6 +505,7 @@
   1.170  #define SQLITE_NOTICE_RECOVER_WAL      (SQLITE_NOTICE | (1<<8))
   1.171  #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
   1.172  #define SQLITE_WARNING_AUTOINDEX       (SQLITE_WARNING | (1<<8))
   1.173 +#define SQLITE_AUTH_USER               (SQLITE_AUTH | (1<<8))
   1.174  
   1.175  /*
   1.176  ** CAPI3REF: Flags For File Open Operations
   1.177 @@ -755,14 +764,16 @@
   1.178  ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
   1.179  ** interface.
   1.180  **
   1.181 +** <ul>
   1.182 +** <li>[[SQLITE_FCNTL_LOCKSTATE]]
   1.183  ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging.  This
   1.184  ** opcode causes the xFileControl method to write the current state of
   1.185  ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
   1.186  ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
   1.187  ** into an integer that the pArg argument points to. This capability
   1.188 -** is used during testing and only needs to be supported when SQLITE_TEST
   1.189 -** is defined.
   1.190 -** <ul>
   1.191 +** is used during testing and is only available when the SQLITE_TEST
   1.192 +** compile-time option is used.
   1.193 +**
   1.194  ** <li>[[SQLITE_FCNTL_SIZE_HINT]]
   1.195  ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
   1.196  ** layer a hint of how large the database file will grow to be during the
   1.197 @@ -783,8 +794,13 @@
   1.198  ** <li>[[SQLITE_FCNTL_FILE_POINTER]]
   1.199  ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer
   1.200  ** to the [sqlite3_file] object associated with a particular database
   1.201 -** connection.  See the [sqlite3_file_control()] documentation for
   1.202 -** additional information.
   1.203 +** connection.  See also [SQLITE_FCNTL_JOURNAL_POINTER].
   1.204 +**
   1.205 +** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]]
   1.206 +** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer
   1.207 +** to the [sqlite3_file] object associated with the journal file (either
   1.208 +** the [rollback journal] or the [write-ahead log]) for a particular database
   1.209 +** connection.  See also [SQLITE_FCNTL_FILE_POINTER].
   1.210  **
   1.211  ** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]
   1.212  ** No longer in use.
   1.213 @@ -871,6 +887,15 @@
   1.214  ** pointer in case this file-control is not implemented.  This file-control
   1.215  ** is intended for diagnostic use only.
   1.216  **
   1.217 +** <li>[[SQLITE_FCNTL_VFS_POINTER]]
   1.218 +** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level
   1.219 +** [VFSes] currently in use.  ^(The argument X in
   1.220 +** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be
   1.221 +** of type "[sqlite3_vfs] **".  This opcodes will set *X
   1.222 +** to a pointer to the top-level VFS.)^
   1.223 +** ^When there are multiple VFS shims in the stack, this opcode finds the
   1.224 +** upper-most shim only.
   1.225 +**
   1.226  ** <li>[[SQLITE_FCNTL_PRAGMA]]
   1.227  ** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] 
   1.228  ** file control is sent to the open [sqlite3_file] object corresponding
   1.229 @@ -887,7 +912,9 @@
   1.230  ** [PRAGMA] processing continues.  ^If the [SQLITE_FCNTL_PRAGMA]
   1.231  ** file control returns [SQLITE_OK], then the parser assumes that the
   1.232  ** VFS has handled the PRAGMA itself and the parser generates a no-op
   1.233 -** prepared statement.  ^If the [SQLITE_FCNTL_PRAGMA] file control returns
   1.234 +** prepared statement if result string is NULL, or that returns a copy
   1.235 +** of the result string if the string is non-NULL.
   1.236 +** ^If the [SQLITE_FCNTL_PRAGMA] file control returns
   1.237  ** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
   1.238  ** that the VFS encountered an error while handling the [PRAGMA] and the
   1.239  ** compilation of the PRAGMA fails with an error.  ^The [SQLITE_FCNTL_PRAGMA]
   1.240 @@ -945,12 +972,27 @@
   1.241  ** pointed to by the pArg argument.  This capability is used during testing
   1.242  ** and only needs to be supported when SQLITE_TEST is defined.
   1.243  **
   1.244 +** <li>[[SQLITE_FCNTL_WAL_BLOCK]]
   1.245 +** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might
   1.246 +** be advantageous to block on the next WAL lock if the lock is not immediately
   1.247 +** available.  The WAL subsystem issues this signal during rare
   1.248 +** circumstances in order to fix a problem with priority inversion.
   1.249 +** Applications should <em>not</em> use this file-control.
   1.250 +**
   1.251 +** <li>[[SQLITE_FCNTL_ZIPVFS]]
   1.252 +** The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other
   1.253 +** VFS should return SQLITE_NOTFOUND for this opcode.
   1.254 +**
   1.255 +** <li>[[SQLITE_FCNTL_RBU]]
   1.256 +** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by
   1.257 +** the RBU extension only.  All other VFS should return SQLITE_NOTFOUND for
   1.258 +** this opcode.  
   1.259  ** </ul>
   1.260  */
   1.261  #define SQLITE_FCNTL_LOCKSTATE               1
   1.262 -#define SQLITE_GET_LOCKPROXYFILE             2
   1.263 -#define SQLITE_SET_LOCKPROXYFILE             3
   1.264 -#define SQLITE_LAST_ERRNO                    4
   1.265 +#define SQLITE_FCNTL_GET_LOCKPROXYFILE       2
   1.266 +#define SQLITE_FCNTL_SET_LOCKPROXYFILE       3
   1.267 +#define SQLITE_FCNTL_LAST_ERRNO              4
   1.268  #define SQLITE_FCNTL_SIZE_HINT               5
   1.269  #define SQLITE_FCNTL_CHUNK_SIZE              6
   1.270  #define SQLITE_FCNTL_FILE_POINTER            7
   1.271 @@ -969,6 +1011,17 @@
   1.272  #define SQLITE_FCNTL_SYNC                   21
   1.273  #define SQLITE_FCNTL_COMMIT_PHASETWO        22
   1.274  #define SQLITE_FCNTL_WIN32_SET_HANDLE       23
   1.275 +#define SQLITE_FCNTL_WAL_BLOCK              24
   1.276 +#define SQLITE_FCNTL_ZIPVFS                 25
   1.277 +#define SQLITE_FCNTL_RBU                    26
   1.278 +#define SQLITE_FCNTL_VFS_POINTER            27
   1.279 +#define SQLITE_FCNTL_JOURNAL_POINTER        28
   1.280 +
   1.281 +/* deprecated names */
   1.282 +#define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE
   1.283 +#define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE
   1.284 +#define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO
   1.285 +
   1.286  
   1.287  /*
   1.288  ** CAPI3REF: Mutex Handle
   1.289 @@ -1220,7 +1273,7 @@
   1.290  ** </ul>
   1.291  **
   1.292  ** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as
   1.293 -** was given no the corresponding lock.  
   1.294 +** was given on the corresponding lock.  
   1.295  **
   1.296  ** The xShmLock method can transition between unlocked and SHARED or
   1.297  ** between unlocked and EXCLUSIVE.  It cannot transition between SHARED
   1.298 @@ -1317,10 +1370,10 @@
   1.299  ** must return [SQLITE_OK] on success and some other [error code] upon
   1.300  ** failure.
   1.301  */
   1.302 -SQLITE_API int sqlite3_initialize(void);
   1.303 -SQLITE_API int sqlite3_shutdown(void);
   1.304 -SQLITE_API int sqlite3_os_init(void);
   1.305 -SQLITE_API int sqlite3_os_end(void);
   1.306 +SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void);
   1.307 +SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void);
   1.308 +SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void);
   1.309 +SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void);
   1.310  
   1.311  /*
   1.312  ** CAPI3REF: Configuring The SQLite Library
   1.313 @@ -1331,9 +1384,11 @@
   1.314  ** applications and so this routine is usually not necessary.  It is
   1.315  ** provided to support rare applications with unusual needs.
   1.316  **
   1.317 -** The sqlite3_config() interface is not threadsafe.  The application
   1.318 -** must insure that no other SQLite interfaces are invoked by other
   1.319 -** threads while sqlite3_config() is running.  Furthermore, sqlite3_config()
   1.320 +** <b>The sqlite3_config() interface is not threadsafe. The application
   1.321 +** must ensure that no other SQLite interfaces are invoked by other
   1.322 +** threads while sqlite3_config() is running.</b>
   1.323 +**
   1.324 +** The sqlite3_config() interface
   1.325  ** may only be invoked prior to library initialization using
   1.326  ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
   1.327  ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
   1.328 @@ -1351,10 +1406,11 @@
   1.329  ** ^If the option is unknown or SQLite is unable to set the option
   1.330  ** then this routine returns a non-zero [error code].
   1.331  */
   1.332 -SQLITE_API int sqlite3_config(int, ...);
   1.333 +SQLITE_API int SQLITE_CDECL sqlite3_config(int, ...);
   1.334  
   1.335  /*
   1.336  ** CAPI3REF: Configure database connections
   1.337 +** METHOD: sqlite3
   1.338  **
   1.339  ** The sqlite3_db_config() interface is used to make configuration
   1.340  ** changes to a [database connection].  The interface is similar to
   1.341 @@ -1369,7 +1425,7 @@
   1.342  ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
   1.343  ** the call is considered successful.
   1.344  */
   1.345 -SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
   1.346 +SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3*, int op, ...);
   1.347  
   1.348  /*
   1.349  ** CAPI3REF: Memory Allocation Routines
   1.350 @@ -1503,31 +1559,33 @@
   1.351  ** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
   1.352  **
   1.353  ** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>
   1.354 -** <dd> ^(This option takes a single argument which is a pointer to an
   1.355 -** instance of the [sqlite3_mem_methods] structure.  The argument specifies
   1.356 +** <dd> ^(The SQLITE_CONFIG_MALLOC option takes a single argument which is 
   1.357 +** a pointer to an instance of the [sqlite3_mem_methods] structure.
   1.358 +** The argument specifies
   1.359  ** alternative low-level memory allocation routines to be used in place of
   1.360  ** the memory allocation routines built into SQLite.)^ ^SQLite makes
   1.361  ** its own private copy of the content of the [sqlite3_mem_methods] structure
   1.362  ** before the [sqlite3_config()] call returns.</dd>
   1.363  **
   1.364  ** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>
   1.365 -** <dd> ^(This option takes a single argument which is a pointer to an
   1.366 -** instance of the [sqlite3_mem_methods] structure.  The [sqlite3_mem_methods]
   1.367 +** <dd> ^(The SQLITE_CONFIG_GETMALLOC option takes a single argument which
   1.368 +** is a pointer to an instance of the [sqlite3_mem_methods] structure.
   1.369 +** The [sqlite3_mem_methods]
   1.370  ** structure is filled with the currently defined memory allocation routines.)^
   1.371  ** This option can be used to overload the default memory allocation
   1.372  ** routines with a wrapper that simulations memory allocation failure or
   1.373  ** tracks memory usage, for example. </dd>
   1.374  **
   1.375  ** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>
   1.376 -** <dd> ^This option takes single argument of type int, interpreted as a 
   1.377 -** boolean, which enables or disables the collection of memory allocation 
   1.378 -** statistics. ^(When memory allocation statistics are disabled, the 
   1.379 -** following SQLite interfaces become non-operational:
   1.380 +** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,
   1.381 +** interpreted as a boolean, which enables or disables the collection of
   1.382 +** memory allocation statistics. ^(When memory allocation statistics are
   1.383 +** disabled, the following SQLite interfaces become non-operational:
   1.384  **   <ul>
   1.385  **   <li> [sqlite3_memory_used()]
   1.386  **   <li> [sqlite3_memory_highwater()]
   1.387  **   <li> [sqlite3_soft_heap_limit64()]
   1.388 -**   <li> [sqlite3_status()]
   1.389 +**   <li> [sqlite3_status64()]
   1.390  **   </ul>)^
   1.391  ** ^Memory allocation statistics are enabled by default unless SQLite is
   1.392  ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
   1.393 @@ -1535,53 +1593,72 @@
   1.394  ** </dd>
   1.395  **
   1.396  ** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt>
   1.397 -** <dd> ^This option specifies a static memory buffer that SQLite can use for
   1.398 -** scratch memory.  There are three arguments:  A pointer an 8-byte
   1.399 +** <dd> ^The SQLITE_CONFIG_SCRATCH option specifies a static memory buffer
   1.400 +** that SQLite can use for scratch memory.  ^(There are three arguments
   1.401 +** to SQLITE_CONFIG_SCRATCH:  A pointer an 8-byte
   1.402  ** aligned memory buffer from which the scratch allocations will be
   1.403  ** drawn, the size of each scratch allocation (sz),
   1.404 -** and the maximum number of scratch allocations (N).  The sz
   1.405 -** argument must be a multiple of 16.
   1.406 +** and the maximum number of scratch allocations (N).)^
   1.407  ** The first argument must be a pointer to an 8-byte aligned buffer
   1.408  ** of at least sz*N bytes of memory.
   1.409 -** ^SQLite will use no more than two scratch buffers per thread.  So
   1.410 -** N should be set to twice the expected maximum number of threads.
   1.411 -** ^SQLite will never require a scratch buffer that is more than 6
   1.412 -** times the database page size. ^If SQLite needs needs additional
   1.413 +** ^SQLite will not use more than one scratch buffers per thread.
   1.414 +** ^SQLite will never request a scratch buffer that is more than 6
   1.415 +** times the database page size.
   1.416 +** ^If SQLite needs needs additional
   1.417  ** scratch memory beyond what is provided by this configuration option, then 
   1.418 -** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
   1.419 +** [sqlite3_malloc()] will be used to obtain the memory needed.<p>
   1.420 +** ^When the application provides any amount of scratch memory using
   1.421 +** SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary large
   1.422 +** [sqlite3_malloc|heap allocations].
   1.423 +** This can help [Robson proof|prevent memory allocation failures] due to heap
   1.424 +** fragmentation in low-memory embedded systems.
   1.425 +** </dd>
   1.426  **
   1.427  ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
   1.428 -** <dd> ^This option specifies a static memory buffer that SQLite can use for
   1.429 -** the database page cache with the default page cache implementation.  
   1.430 -** This configuration should not be used if an application-define page
   1.431 -** cache implementation is loaded using the SQLITE_CONFIG_PCACHE2 option.
   1.432 -** There are three arguments to this option: A pointer to 8-byte aligned
   1.433 -** memory, the size of each page buffer (sz), and the number of pages (N).
   1.434 +** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool
   1.435 +** that SQLite can use for the database page cache with the default page
   1.436 +** cache implementation.  
   1.437 +** This configuration option is a no-op if an application-define page
   1.438 +** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2].
   1.439 +** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to
   1.440 +** 8-byte aligned memory (pMem), the size of each page cache line (sz),
   1.441 +** and the number of cache lines (N).
   1.442  ** The sz argument should be the size of the largest database page
   1.443 -** (a power of two between 512 and 32768) plus a little extra for each
   1.444 -** page header.  ^The page header size is 20 to 40 bytes depending on
   1.445 -** the host architecture.  ^It is harmless, apart from the wasted memory,
   1.446 -** to make sz a little too large.  The first
   1.447 -** argument should point to an allocation of at least sz*N bytes of memory.
   1.448 -** ^SQLite will use the memory provided by the first argument to satisfy its
   1.449 -** memory needs for the first N pages that it adds to cache.  ^If additional
   1.450 -** page cache memory is needed beyond what is provided by this option, then
   1.451 -** SQLite goes to [sqlite3_malloc()] for the additional storage space.
   1.452 -** The pointer in the first argument must
   1.453 -** be aligned to an 8-byte boundary or subsequent behavior of SQLite
   1.454 -** will be undefined.</dd>
   1.455 +** (a power of two between 512 and 65536) plus some extra bytes for each
   1.456 +** page header.  ^The number of extra bytes needed by the page header
   1.457 +** can be determined using [SQLITE_CONFIG_PCACHE_HDRSZ].
   1.458 +** ^It is harmless, apart from the wasted memory,
   1.459 +** for the sz parameter to be larger than necessary.  The pMem
   1.460 +** argument must be either a NULL pointer or a pointer to an 8-byte
   1.461 +** aligned block of memory of at least sz*N bytes, otherwise
   1.462 +** subsequent behavior is undefined.
   1.463 +** ^When pMem is not NULL, SQLite will strive to use the memory provided
   1.464 +** to satisfy page cache needs, falling back to [sqlite3_malloc()] if
   1.465 +** a page cache line is larger than sz bytes or if all of the pMem buffer
   1.466 +** is exhausted.
   1.467 +** ^If pMem is NULL and N is non-zero, then each database connection
   1.468 +** does an initial bulk allocation for page cache memory
   1.469 +** from [sqlite3_malloc()] sufficient for N cache lines if N is positive or
   1.470 +** of -1024*N bytes if N is negative, . ^If additional
   1.471 +** page cache memory is needed beyond what is provided by the initial
   1.472 +** allocation, then SQLite goes to [sqlite3_malloc()] separately for each
   1.473 +** additional cache line. </dd>
   1.474  **
   1.475  ** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>
   1.476 -** <dd> ^This option specifies a static memory buffer that SQLite will use
   1.477 -** for all of its dynamic memory allocation needs beyond those provided
   1.478 -** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
   1.479 -** There are three arguments: An 8-byte aligned pointer to the memory,
   1.480 +** <dd> ^The SQLITE_CONFIG_HEAP option specifies a static memory buffer 
   1.481 +** that SQLite will use for all of its dynamic memory allocation needs
   1.482 +** beyond those provided for by [SQLITE_CONFIG_SCRATCH] and
   1.483 +** [SQLITE_CONFIG_PAGECACHE].
   1.484 +** ^The SQLITE_CONFIG_HEAP option is only available if SQLite is compiled
   1.485 +** with either [SQLITE_ENABLE_MEMSYS3] or [SQLITE_ENABLE_MEMSYS5] and returns
   1.486 +** [SQLITE_ERROR] if invoked otherwise.
   1.487 +** ^There are three arguments to SQLITE_CONFIG_HEAP:
   1.488 +** An 8-byte aligned pointer to the memory,
   1.489  ** the number of bytes in the memory buffer, and the minimum allocation size.
   1.490  ** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts
   1.491  ** to using its default memory allocator (the system malloc() implementation),
   1.492  ** undoing any prior invocation of [SQLITE_CONFIG_MALLOC].  ^If the
   1.493 -** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or
   1.494 -** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
   1.495 +** memory pointer is not NULL then the alternative memory
   1.496  ** allocator is engaged to handle all of SQLites memory allocation needs.
   1.497  ** The first pointer (the memory pointer) must be aligned to an 8-byte
   1.498  ** boundary or subsequent behavior of SQLite will be undefined.
   1.499 @@ -1589,11 +1666,11 @@
   1.500  ** for the minimum allocation size are 2**5 through 2**8.</dd>
   1.501  **
   1.502  ** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>
   1.503 -** <dd> ^(This option takes a single argument which is a pointer to an
   1.504 -** instance of the [sqlite3_mutex_methods] structure.  The argument specifies
   1.505 -** alternative low-level mutex routines to be used in place
   1.506 -** the mutex routines built into SQLite.)^  ^SQLite makes a copy of the
   1.507 -** content of the [sqlite3_mutex_methods] structure before the call to
   1.508 +** <dd> ^(The SQLITE_CONFIG_MUTEX option takes a single argument which is a
   1.509 +** pointer to an instance of the [sqlite3_mutex_methods] structure.
   1.510 +** The argument specifies alternative low-level mutex routines to be used
   1.511 +** in place the mutex routines built into SQLite.)^  ^SQLite makes a copy of
   1.512 +** the content of the [sqlite3_mutex_methods] structure before the call to
   1.513  ** [sqlite3_config()] returns. ^If SQLite is compiled with
   1.514  ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
   1.515  ** the entire mutexing subsystem is omitted from the build and hence calls to
   1.516 @@ -1601,8 +1678,8 @@
   1.517  ** return [SQLITE_ERROR].</dd>
   1.518  **
   1.519  ** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt>
   1.520 -** <dd> ^(This option takes a single argument which is a pointer to an
   1.521 -** instance of the [sqlite3_mutex_methods] structure.  The
   1.522 +** <dd> ^(The SQLITE_CONFIG_GETMUTEX option takes a single argument which
   1.523 +** is a pointer to an instance of the [sqlite3_mutex_methods] structure.  The
   1.524  ** [sqlite3_mutex_methods]
   1.525  ** structure is filled with the currently defined mutex routines.)^
   1.526  ** This option can be used to overload the default mutex allocation
   1.527 @@ -1614,25 +1691,25 @@
   1.528  ** return [SQLITE_ERROR].</dd>
   1.529  **
   1.530  ** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>
   1.531 -** <dd> ^(This option takes two arguments that determine the default
   1.532 -** memory allocation for the lookaside memory allocator on each
   1.533 -** [database connection].  The first argument is the
   1.534 +** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine
   1.535 +** the default size of lookaside memory on each [database connection].
   1.536 +** The first argument is the
   1.537  ** size of each lookaside buffer slot and the second is the number of
   1.538 -** slots allocated to each database connection.)^  ^(This option sets the
   1.539 -** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
   1.540 -** verb to [sqlite3_db_config()] can be used to change the lookaside
   1.541 +** slots allocated to each database connection.)^  ^(SQLITE_CONFIG_LOOKASIDE
   1.542 +** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
   1.543 +** option to [sqlite3_db_config()] can be used to change the lookaside
   1.544  ** configuration on individual connections.)^ </dd>
   1.545  **
   1.546  ** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>
   1.547 -** <dd> ^(This option takes a single argument which is a pointer to
   1.548 -** an [sqlite3_pcache_methods2] object.  This object specifies the interface
   1.549 -** to a custom page cache implementation.)^  ^SQLite makes a copy of the
   1.550 -** object and uses it for page cache memory allocations.</dd>
   1.551 +** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is 
   1.552 +** a pointer to an [sqlite3_pcache_methods2] object.  This object specifies
   1.553 +** the interface to a custom page cache implementation.)^
   1.554 +** ^SQLite makes a copy of the [sqlite3_pcache_methods2] object.</dd>
   1.555  **
   1.556  ** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>
   1.557 -** <dd> ^(This option takes a single argument which is a pointer to an
   1.558 -** [sqlite3_pcache_methods2] object.  SQLite copies of the current
   1.559 -** page cache implementation into that object.)^ </dd>
   1.560 +** <dd> ^(The SQLITE_CONFIG_GETPCACHE2 option takes a single argument which
   1.561 +** is a pointer to an [sqlite3_pcache_methods2] object.  SQLite copies of
   1.562 +** the current page cache implementation into that object.)^ </dd>
   1.563  **
   1.564  ** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>
   1.565  ** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite
   1.566 @@ -1655,10 +1732,11 @@
   1.567  ** function must be threadsafe. </dd>
   1.568  **
   1.569  ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
   1.570 -** <dd>^(This option takes a single argument of type int. If non-zero, then
   1.571 -** URI handling is globally enabled. If the parameter is zero, then URI handling
   1.572 -** is globally disabled.)^ ^If URI handling is globally enabled, all filenames
   1.573 -** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
   1.574 +** <dd>^(The SQLITE_CONFIG_URI option takes a single argument of type int.
   1.575 +** If non-zero, then URI handling is globally enabled. If the parameter is zero,
   1.576 +** then URI handling is globally disabled.)^ ^If URI handling is globally
   1.577 +** enabled, all filenames passed to [sqlite3_open()], [sqlite3_open_v2()],
   1.578 +** [sqlite3_open16()] or
   1.579  ** specified as part of [ATTACH] commands are interpreted as URIs, regardless
   1.580  ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
   1.581  ** connection is opened. ^If it is globally disabled, filenames are
   1.582 @@ -1668,9 +1746,10 @@
   1.583  ** [SQLITE_USE_URI] symbol defined.)^
   1.584  **
   1.585  ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
   1.586 -** <dd>^This option takes a single integer argument which is interpreted as
   1.587 -** a boolean in order to enable or disable the use of covering indices for
   1.588 -** full table scans in the query optimizer.  ^The default setting is determined
   1.589 +** <dd>^The SQLITE_CONFIG_COVERING_INDEX_SCAN option takes a single integer
   1.590 +** argument which is interpreted as a boolean in order to enable or disable
   1.591 +** the use of covering indices for full table scans in the query optimizer.
   1.592 +** ^The default setting is determined
   1.593  ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
   1.594  ** if that compile-time option is omitted.
   1.595  ** The ability to disable the use of covering indices for full table scans
   1.596 @@ -1710,18 +1789,37 @@
   1.597  ** ^The default setting can be overridden by each database connection using
   1.598  ** either the [PRAGMA mmap_size] command, or by using the
   1.599  ** [SQLITE_FCNTL_MMAP_SIZE] file control.  ^(The maximum allowed mmap size
   1.600 -** cannot be changed at run-time.  Nor may the maximum allowed mmap size
   1.601 -** exceed the compile-time maximum mmap size set by the
   1.602 +** will be silently truncated if necessary so that it does not exceed the
   1.603 +** compile-time maximum mmap size set by the
   1.604  ** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
   1.605  ** ^If either argument to this option is negative, then that argument is
   1.606  ** changed to its compile-time default.
   1.607  **
   1.608  ** [[SQLITE_CONFIG_WIN32_HEAPSIZE]]
   1.609  ** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
   1.610 -** <dd>^This option is only available if SQLite is compiled for Windows
   1.611 -** with the [SQLITE_WIN32_MALLOC] pre-processor macro defined.
   1.612 -** SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
   1.613 +** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is
   1.614 +** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro
   1.615 +** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
   1.616  ** that specifies the maximum size of the created heap.
   1.617 +**
   1.618 +** [[SQLITE_CONFIG_PCACHE_HDRSZ]]
   1.619 +** <dt>SQLITE_CONFIG_PCACHE_HDRSZ
   1.620 +** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which
   1.621 +** is a pointer to an integer and writes into that integer the number of extra
   1.622 +** bytes per page required for each page in [SQLITE_CONFIG_PAGECACHE].
   1.623 +** The amount of extra space required can change depending on the compiler,
   1.624 +** target platform, and SQLite version.
   1.625 +**
   1.626 +** [[SQLITE_CONFIG_PMASZ]]
   1.627 +** <dt>SQLITE_CONFIG_PMASZ
   1.628 +** <dd>^The SQLITE_CONFIG_PMASZ option takes a single parameter which
   1.629 +** is an unsigned integer and sets the "Minimum PMA Size" for the multithreaded
   1.630 +** sorter to that integer.  The default minimum PMA Size is set by the
   1.631 +** [SQLITE_SORTER_PMASZ] compile-time option.  New threads are launched
   1.632 +** to help with sort operations when multithreaded sorting
   1.633 +** is enabled (using the [PRAGMA threads] command) and the amount of content
   1.634 +** to be sorted exceeds the page size times the minimum of the
   1.635 +** [PRAGMA cache_size] setting and this value.
   1.636  ** </dl>
   1.637  */
   1.638  #define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */
   1.639 @@ -1747,6 +1845,8 @@
   1.640  #define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */
   1.641  #define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */
   1.642  #define SQLITE_CONFIG_WIN32_HEAPSIZE      23  /* int nByte */
   1.643 +#define SQLITE_CONFIG_PCACHE_HDRSZ        24  /* int *psz */
   1.644 +#define SQLITE_CONFIG_PMASZ               25  /* unsigned int szPma */
   1.645  
   1.646  /*
   1.647  ** CAPI3REF: Database Connection Configuration Options
   1.648 @@ -1813,15 +1913,17 @@
   1.649  
   1.650  /*
   1.651  ** CAPI3REF: Enable Or Disable Extended Result Codes
   1.652 +** METHOD: sqlite3
   1.653  **
   1.654  ** ^The sqlite3_extended_result_codes() routine enables or disables the
   1.655  ** [extended result codes] feature of SQLite. ^The extended result
   1.656  ** codes are disabled by default for historical compatibility.
   1.657  */
   1.658 -SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
   1.659 +SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3*, int onoff);
   1.660  
   1.661  /*
   1.662  ** CAPI3REF: Last Insert Rowid
   1.663 +** METHOD: sqlite3
   1.664  **
   1.665  ** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
   1.666  ** has a unique 64-bit signed
   1.667 @@ -1869,52 +1971,51 @@
   1.668  ** unpredictable and might not equal either the old or the new
   1.669  ** last insert [rowid].
   1.670  */
   1.671 -SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
   1.672 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3*);
   1.673  
   1.674  /*
   1.675  ** CAPI3REF: Count The Number Of Rows Modified
   1.676 -**
   1.677 -** ^This function returns the number of database rows that were changed
   1.678 -** or inserted or deleted by the most recently completed SQL statement
   1.679 -** on the [database connection] specified by the first parameter.
   1.680 -** ^(Only changes that are directly specified by the [INSERT], [UPDATE],
   1.681 -** or [DELETE] statement are counted.  Auxiliary changes caused by
   1.682 -** triggers or [foreign key actions] are not counted.)^ Use the
   1.683 -** [sqlite3_total_changes()] function to find the total number of changes
   1.684 -** including changes caused by triggers and foreign key actions.
   1.685 -**
   1.686 -** ^Changes to a view that are simulated by an [INSTEAD OF trigger]
   1.687 -** are not counted.  Only real table changes are counted.
   1.688 -**
   1.689 -** ^(A "row change" is a change to a single row of a single table
   1.690 -** caused by an INSERT, DELETE, or UPDATE statement.  Rows that
   1.691 -** are changed as side effects of [REPLACE] constraint resolution,
   1.692 -** rollback, ABORT processing, [DROP TABLE], or by any other
   1.693 -** mechanisms do not count as direct row changes.)^
   1.694 -**
   1.695 -** A "trigger context" is a scope of execution that begins and
   1.696 -** ends with the script of a [CREATE TRIGGER | trigger]. 
   1.697 -** Most SQL statements are
   1.698 -** evaluated outside of any trigger.  This is the "top level"
   1.699 -** trigger context.  If a trigger fires from the top level, a
   1.700 -** new trigger context is entered for the duration of that one
   1.701 -** trigger.  Subtriggers create subcontexts for their duration.
   1.702 -**
   1.703 -** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
   1.704 -** not create a new trigger context.
   1.705 -**
   1.706 -** ^This function returns the number of direct row changes in the
   1.707 -** most recent INSERT, UPDATE, or DELETE statement within the same
   1.708 -** trigger context.
   1.709 -**
   1.710 -** ^Thus, when called from the top level, this function returns the
   1.711 -** number of changes in the most recent INSERT, UPDATE, or DELETE
   1.712 -** that also occurred at the top level.  ^(Within the body of a trigger,
   1.713 -** the sqlite3_changes() interface can be called to find the number of
   1.714 -** changes in the most recently completed INSERT, UPDATE, or DELETE
   1.715 -** statement within the body of the same trigger.
   1.716 -** However, the number returned does not include changes
   1.717 -** caused by subtriggers since those have their own context.)^
   1.718 +** METHOD: sqlite3
   1.719 +**
   1.720 +** ^This function returns the number of rows modified, inserted or
   1.721 +** deleted by the most recently completed INSERT, UPDATE or DELETE
   1.722 +** statement on the database connection specified by the only parameter.
   1.723 +** ^Executing any other type of SQL statement does not modify the value
   1.724 +** returned by this function.
   1.725 +**
   1.726 +** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are
   1.727 +** considered - auxiliary changes caused by [CREATE TRIGGER | triggers], 
   1.728 +** [foreign key actions] or [REPLACE] constraint resolution are not counted.
   1.729 +** 
   1.730 +** Changes to a view that are intercepted by 
   1.731 +** [INSTEAD OF trigger | INSTEAD OF triggers] are not counted. ^The value 
   1.732 +** returned by sqlite3_changes() immediately after an INSERT, UPDATE or 
   1.733 +** DELETE statement run on a view is always zero. Only changes made to real 
   1.734 +** tables are counted.
   1.735 +**
   1.736 +** Things are more complicated if the sqlite3_changes() function is
   1.737 +** executed while a trigger program is running. This may happen if the
   1.738 +** program uses the [changes() SQL function], or if some other callback
   1.739 +** function invokes sqlite3_changes() directly. Essentially:
   1.740 +** 
   1.741 +** <ul>
   1.742 +**   <li> ^(Before entering a trigger program the value returned by
   1.743 +**        sqlite3_changes() function is saved. After the trigger program 
   1.744 +**        has finished, the original value is restored.)^
   1.745 +** 
   1.746 +**   <li> ^(Within a trigger program each INSERT, UPDATE and DELETE 
   1.747 +**        statement sets the value returned by sqlite3_changes() 
   1.748 +**        upon completion as normal. Of course, this value will not include 
   1.749 +**        any changes performed by sub-triggers, as the sqlite3_changes() 
   1.750 +**        value will be saved and restored after each sub-trigger has run.)^
   1.751 +** </ul>
   1.752 +** 
   1.753 +** ^This means that if the changes() SQL function (or similar) is used
   1.754 +** by the first INSERT, UPDATE or DELETE statement within a trigger, it 
   1.755 +** returns the value as set when the calling statement began executing.
   1.756 +** ^If it is used by the second or subsequent such statement within a trigger 
   1.757 +** program, the value returned reflects the number of rows modified by the 
   1.758 +** previous INSERT, UPDATE or DELETE statement within the same trigger.
   1.759  **
   1.760  ** See also the [sqlite3_total_changes()] interface, the
   1.761  ** [count_changes pragma], and the [changes() SQL function].
   1.762 @@ -1923,25 +2024,23 @@
   1.763  ** while [sqlite3_changes()] is running then the value returned
   1.764  ** is unpredictable and not meaningful.
   1.765  */
   1.766 -SQLITE_API int sqlite3_changes(sqlite3*);
   1.767 +SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3*);
   1.768  
   1.769  /*
   1.770  ** CAPI3REF: Total Number Of Rows Modified
   1.771 -**
   1.772 -** ^This function returns the number of row changes caused by [INSERT],
   1.773 -** [UPDATE] or [DELETE] statements since the [database connection] was opened.
   1.774 -** ^(The count returned by sqlite3_total_changes() includes all changes
   1.775 -** from all [CREATE TRIGGER | trigger] contexts and changes made by
   1.776 -** [foreign key actions]. However,
   1.777 -** the count does not include changes used to implement [REPLACE] constraints,
   1.778 -** do rollbacks or ABORT processing, or [DROP TABLE] processing.  The
   1.779 -** count does not include rows of views that fire an [INSTEAD OF trigger],
   1.780 -** though if the INSTEAD OF trigger makes changes of its own, those changes 
   1.781 -** are counted.)^
   1.782 -** ^The sqlite3_total_changes() function counts the changes as soon as
   1.783 -** the statement that makes them is completed (when the statement handle
   1.784 -** is passed to [sqlite3_reset()] or [sqlite3_finalize()]).
   1.785 -**
   1.786 +** METHOD: sqlite3
   1.787 +**
   1.788 +** ^This function returns the total number of rows inserted, modified or
   1.789 +** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
   1.790 +** since the database connection was opened, including those executed as
   1.791 +** part of trigger programs. ^Executing any other type of SQL statement
   1.792 +** does not affect the value returned by sqlite3_total_changes().
   1.793 +** 
   1.794 +** ^Changes made as part of [foreign key actions] are included in the
   1.795 +** count, but those made as part of REPLACE constraint resolution are
   1.796 +** not. ^Changes to a view that are intercepted by INSTEAD OF triggers 
   1.797 +** are not counted.
   1.798 +** 
   1.799  ** See also the [sqlite3_changes()] interface, the
   1.800  ** [count_changes pragma], and the [total_changes() SQL function].
   1.801  **
   1.802 @@ -1949,10 +2048,11 @@
   1.803  ** while [sqlite3_total_changes()] is running then the value
   1.804  ** returned is unpredictable and not meaningful.
   1.805  */
   1.806 -SQLITE_API int sqlite3_total_changes(sqlite3*);
   1.807 +SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3*);
   1.808  
   1.809  /*
   1.810  ** CAPI3REF: Interrupt A Long-Running Query
   1.811 +** METHOD: sqlite3
   1.812  **
   1.813  ** ^This function causes any pending database operation to abort and
   1.814  ** return at its earliest opportunity. This routine is typically
   1.815 @@ -1988,7 +2088,7 @@
   1.816  ** If the database connection closes while [sqlite3_interrupt()]
   1.817  ** is running then bad things will likely happen.
   1.818  */
   1.819 -SQLITE_API void sqlite3_interrupt(sqlite3*);
   1.820 +SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3*);
   1.821  
   1.822  /*
   1.823  ** CAPI3REF: Determine If An SQL Statement Is Complete
   1.824 @@ -2023,11 +2123,13 @@
   1.825  ** The input to [sqlite3_complete16()] must be a zero-terminated
   1.826  ** UTF-16 string in native byte order.
   1.827  */
   1.828 -SQLITE_API int sqlite3_complete(const char *sql);
   1.829 -SQLITE_API int sqlite3_complete16(const void *sql);
   1.830 +SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *sql);
   1.831 +SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *sql);
   1.832  
   1.833  /*
   1.834  ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
   1.835 +** KEYWORDS: {busy-handler callback} {busy handler}
   1.836 +** METHOD: sqlite3
   1.837  **
   1.838  ** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X
   1.839  ** that might be invoked with argument P whenever
   1.840 @@ -2044,7 +2146,7 @@
   1.841  ** ^The first argument to the busy handler is a copy of the void* pointer which
   1.842  ** is the third argument to sqlite3_busy_handler().  ^The second argument to
   1.843  ** the busy handler callback is the number of times that the busy handler has
   1.844 -** been invoked for the same locking event.  ^If the
   1.845 +** been invoked previously for the same locking event.  ^If the
   1.846  ** busy callback returns 0, then no additional attempts are made to
   1.847  ** access the database and [SQLITE_BUSY] is returned
   1.848  ** to the application.
   1.849 @@ -2083,10 +2185,11 @@
   1.850  ** A busy handler must not close the database connection
   1.851  ** or [prepared statement] that invoked the busy handler.
   1.852  */
   1.853 -SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
   1.854 +SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
   1.855  
   1.856  /*
   1.857  ** CAPI3REF: Set A Busy Timeout
   1.858 +** METHOD: sqlite3
   1.859  **
   1.860  ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
   1.861  ** for a specified amount of time when a table is locked.  ^The handler
   1.862 @@ -2099,16 +2202,17 @@
   1.863  ** turns off all busy handlers.
   1.864  **
   1.865  ** ^(There can only be a single busy handler for a particular
   1.866 -** [database connection] any any given moment.  If another busy handler
   1.867 +** [database connection] at any given moment.  If another busy handler
   1.868  ** was defined  (using [sqlite3_busy_handler()]) prior to calling
   1.869  ** this routine, that other busy handler is cleared.)^
   1.870  **
   1.871  ** See also:  [PRAGMA busy_timeout]
   1.872  */
   1.873 -SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
   1.874 +SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3*, int ms);
   1.875  
   1.876  /*
   1.877  ** CAPI3REF: Convenience Routines For Running Queries
   1.878 +** METHOD: sqlite3
   1.879  **
   1.880  ** This is a legacy interface that is preserved for backwards compatibility.
   1.881  ** Use of this interface is not recommended.
   1.882 @@ -2179,7 +2283,7 @@
   1.883  ** reflected in subsequent calls to [sqlite3_errcode()] or
   1.884  ** [sqlite3_errmsg()].
   1.885  */
   1.886 -SQLITE_API int sqlite3_get_table(
   1.887 +SQLITE_API int SQLITE_STDCALL sqlite3_get_table(
   1.888    sqlite3 *db,          /* An open database */
   1.889    const char *zSql,     /* SQL to be evaluated */
   1.890    char ***pazResult,    /* Results of the query */
   1.891 @@ -2187,13 +2291,17 @@
   1.892    int *pnColumn,        /* Number of result columns written here */
   1.893    char **pzErrmsg       /* Error msg written here */
   1.894  );
   1.895 -SQLITE_API void sqlite3_free_table(char **result);
   1.896 +SQLITE_API void SQLITE_STDCALL sqlite3_free_table(char **result);
   1.897  
   1.898  /*
   1.899  ** CAPI3REF: Formatted String Printing Functions
   1.900  **
   1.901  ** These routines are work-alikes of the "printf()" family of functions
   1.902  ** from the standard C library.
   1.903 +** These routines understand most of the common K&R formatting options,
   1.904 +** plus some additional non-standard formats, detailed below.
   1.905 +** Note that some of the more obscure formatting options from recent
   1.906 +** C-library standards are omitted from this implementation.
   1.907  **
   1.908  ** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
   1.909  ** results into memory obtained from [sqlite3_malloc()].
   1.910 @@ -2226,7 +2334,7 @@
   1.911  ** These routines all implement some additional formatting
   1.912  ** options that are useful for constructing SQL statements.
   1.913  ** All of the usual printf() formatting options apply.  In addition, there
   1.914 -** is are "%q", "%Q", and "%z" options.
   1.915 +** is are "%q", "%Q", "%w" and "%z" options.
   1.916  **
   1.917  ** ^(The %q option works like %s in that it substitutes a nul-terminated
   1.918  ** string from the argument list.  But %q also doubles every '\'' character.
   1.919 @@ -2279,14 +2387,20 @@
   1.920  ** The code above will render a correct SQL statement in the zSQL
   1.921  ** variable even if the zText variable is a NULL pointer.
   1.922  **
   1.923 +** ^(The "%w" formatting option is like "%q" except that it expects to
   1.924 +** be contained within double-quotes instead of single quotes, and it
   1.925 +** escapes the double-quote character instead of the single-quote
   1.926 +** character.)^  The "%w" formatting option is intended for safely inserting
   1.927 +** table and column names into a constructed SQL statement.
   1.928 +**
   1.929  ** ^(The "%z" formatting option works like "%s" but with the
   1.930  ** addition that after the string has been read and copied into
   1.931  ** the result, [sqlite3_free()] is called on the input string.)^
   1.932  */
   1.933 -SQLITE_API char *sqlite3_mprintf(const char*,...);
   1.934 -SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
   1.935 -SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
   1.936 -SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
   1.937 +SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char*,...);
   1.938 +SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char*, va_list);
   1.939 +SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int,char*,const char*, ...);
   1.940 +SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int,char*,const char*, va_list);
   1.941  
   1.942  /*
   1.943  ** CAPI3REF: Memory Allocation Subsystem
   1.944 @@ -2303,6 +2417,10 @@
   1.945  ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns
   1.946  ** a NULL pointer.
   1.947  **
   1.948 +** ^The sqlite3_malloc64(N) routine works just like
   1.949 +** sqlite3_malloc(N) except that N is an unsigned 64-bit integer instead
   1.950 +** of a signed 32-bit integer.
   1.951 +**
   1.952  ** ^Calling sqlite3_free() with a pointer previously returned
   1.953  ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so
   1.954  ** that it might be reused.  ^The sqlite3_free() routine is
   1.955 @@ -2314,24 +2432,38 @@
   1.956  ** might result if sqlite3_free() is called with a non-NULL pointer that
   1.957  ** was not obtained from sqlite3_malloc() or sqlite3_realloc().
   1.958  **
   1.959 -** ^(The sqlite3_realloc() interface attempts to resize a
   1.960 -** prior memory allocation to be at least N bytes, where N is the
   1.961 -** second parameter.  The memory allocation to be resized is the first
   1.962 -** parameter.)^ ^ If the first parameter to sqlite3_realloc()
   1.963 +** ^The sqlite3_realloc(X,N) interface attempts to resize a
   1.964 +** prior memory allocation X to be at least N bytes.
   1.965 +** ^If the X parameter to sqlite3_realloc(X,N)
   1.966  ** is a NULL pointer then its behavior is identical to calling
   1.967 -** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc().
   1.968 -** ^If the second parameter to sqlite3_realloc() is zero or
   1.969 +** sqlite3_malloc(N).
   1.970 +** ^If the N parameter to sqlite3_realloc(X,N) is zero or
   1.971  ** negative then the behavior is exactly the same as calling
   1.972 -** sqlite3_free(P) where P is the first parameter to sqlite3_realloc().
   1.973 -** ^sqlite3_realloc() returns a pointer to a memory allocation
   1.974 -** of at least N bytes in size or NULL if sufficient memory is unavailable.
   1.975 +** sqlite3_free(X).
   1.976 +** ^sqlite3_realloc(X,N) returns a pointer to a memory allocation
   1.977 +** of at least N bytes in size or NULL if insufficient memory is available.
   1.978  ** ^If M is the size of the prior allocation, then min(N,M) bytes
   1.979  ** of the prior allocation are copied into the beginning of buffer returned
   1.980 -** by sqlite3_realloc() and the prior allocation is freed.
   1.981 -** ^If sqlite3_realloc() returns NULL, then the prior allocation
   1.982 -** is not freed.
   1.983 -**
   1.984 -** ^The memory returned by sqlite3_malloc() and sqlite3_realloc()
   1.985 +** by sqlite3_realloc(X,N) and the prior allocation is freed.
   1.986 +** ^If sqlite3_realloc(X,N) returns NULL and N is positive, then the
   1.987 +** prior allocation is not freed.
   1.988 +**
   1.989 +** ^The sqlite3_realloc64(X,N) interfaces works the same as
   1.990 +** sqlite3_realloc(X,N) except that N is a 64-bit unsigned integer instead
   1.991 +** of a 32-bit signed integer.
   1.992 +**
   1.993 +** ^If X is a memory allocation previously obtained from sqlite3_malloc(),
   1.994 +** sqlite3_malloc64(), sqlite3_realloc(), or sqlite3_realloc64(), then
   1.995 +** sqlite3_msize(X) returns the size of that memory allocation in bytes.
   1.996 +** ^The value returned by sqlite3_msize(X) might be larger than the number
   1.997 +** of bytes requested when X was allocated.  ^If X is a NULL pointer then
   1.998 +** sqlite3_msize(X) returns zero.  If X points to something that is not
   1.999 +** the beginning of memory allocation, or if it points to a formerly
  1.1000 +** valid memory allocation that has now been freed, then the behavior
  1.1001 +** of sqlite3_msize(X) is undefined and possibly harmful.
  1.1002 +**
  1.1003 +** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(),
  1.1004 +** sqlite3_malloc64(), and sqlite3_realloc64()
  1.1005  ** is always aligned to at least an 8 byte boundary, or to a
  1.1006  ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time
  1.1007  ** option is used.
  1.1008 @@ -2358,9 +2490,12 @@
  1.1009  ** a block of memory after it has been released using
  1.1010  ** [sqlite3_free()] or [sqlite3_realloc()].
  1.1011  */
  1.1012 -SQLITE_API void *sqlite3_malloc(int);
  1.1013 -SQLITE_API void *sqlite3_realloc(void*, int);
  1.1014 -SQLITE_API void sqlite3_free(void*);
  1.1015 +SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int);
  1.1016 +SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64);
  1.1017 +SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void*, int);
  1.1018 +SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void*, sqlite3_uint64);
  1.1019 +SQLITE_API void SQLITE_STDCALL sqlite3_free(void*);
  1.1020 +SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void*);
  1.1021  
  1.1022  /*
  1.1023  ** CAPI3REF: Memory Allocator Statistics
  1.1024 @@ -2385,8 +2520,8 @@
  1.1025  ** by [sqlite3_memory_highwater(1)] is the high-water mark
  1.1026  ** prior to the reset.
  1.1027  */
  1.1028 -SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
  1.1029 -SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
  1.1030 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void);
  1.1031 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag);
  1.1032  
  1.1033  /*
  1.1034  ** CAPI3REF: Pseudo-Random Number Generator
  1.1035 @@ -2398,20 +2533,22 @@
  1.1036  ** applications to access the same PRNG for other purposes.
  1.1037  **
  1.1038  ** ^A call to this routine stores N bytes of randomness into buffer P.
  1.1039 -** ^If N is less than one, then P can be a NULL pointer.
  1.1040 +** ^The P parameter can be a NULL pointer.
  1.1041  **
  1.1042  ** ^If this routine has not been previously called or if the previous
  1.1043 -** call had N less than one, then the PRNG is seeded using randomness
  1.1044 -** obtained from the xRandomness method of the default [sqlite3_vfs] object.
  1.1045 -** ^If the previous call to this routine had an N of 1 or more then
  1.1046 -** the pseudo-randomness is generated
  1.1047 +** call had N less than one or a NULL pointer for P, then the PRNG is
  1.1048 +** seeded using randomness obtained from the xRandomness method of
  1.1049 +** the default [sqlite3_vfs] object.
  1.1050 +** ^If the previous call to this routine had an N of 1 or more and a
  1.1051 +** non-NULL P then the pseudo-randomness is generated
  1.1052  ** internally and without recourse to the [sqlite3_vfs] xRandomness
  1.1053  ** method.
  1.1054  */
  1.1055 -SQLITE_API void sqlite3_randomness(int N, void *P);
  1.1056 +SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *P);
  1.1057  
  1.1058  /*
  1.1059  ** CAPI3REF: Compile-Time Authorization Callbacks
  1.1060 +** METHOD: sqlite3
  1.1061  **
  1.1062  ** ^This routine registers an authorizer callback with a particular
  1.1063  ** [database connection], supplied in the first argument.
  1.1064 @@ -2490,7 +2627,7 @@
  1.1065  ** as stated in the previous paragraph, sqlite3_step() invokes
  1.1066  ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
  1.1067  */
  1.1068 -SQLITE_API int sqlite3_set_authorizer(
  1.1069 +SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
  1.1070    sqlite3*,
  1.1071    int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
  1.1072    void *pUserData
  1.1073 @@ -2568,6 +2705,7 @@
  1.1074  
  1.1075  /*
  1.1076  ** CAPI3REF: Tracing And Profiling Functions
  1.1077 +** METHOD: sqlite3
  1.1078  **
  1.1079  ** These routines register callback functions that can be used for
  1.1080  ** tracing and profiling the execution of SQL statements.
  1.1081 @@ -2594,12 +2732,13 @@
  1.1082  ** sqlite3_profile() function is considered experimental and is
  1.1083  ** subject to change in future versions of SQLite.
  1.1084  */
  1.1085 -SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
  1.1086 -SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
  1.1087 +SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
  1.1088 +SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
  1.1089     void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
  1.1090  
  1.1091  /*
  1.1092  ** CAPI3REF: Query Progress Callbacks
  1.1093 +** METHOD: sqlite3
  1.1094  **
  1.1095  ** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback
  1.1096  ** function X to be invoked periodically during long running calls to
  1.1097 @@ -2629,10 +2768,11 @@
  1.1098  ** database connections for the meaning of "modify" in this paragraph.
  1.1099  **
  1.1100  */
  1.1101 -SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
  1.1102 +SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
  1.1103  
  1.1104  /*
  1.1105  ** CAPI3REF: Opening A New Database Connection
  1.1106 +** CONSTRUCTOR: sqlite3
  1.1107  **
  1.1108  ** ^These routines open an SQLite database file as specified by the 
  1.1109  ** filename argument. ^The filename argument is interpreted as UTF-8 for
  1.1110 @@ -2647,9 +2787,9 @@
  1.1111  ** an English language description of the error following a failure of any
  1.1112  ** of the sqlite3_open() routines.
  1.1113  **
  1.1114 -** ^The default encoding for the database will be UTF-8 if
  1.1115 -** sqlite3_open() or sqlite3_open_v2() is called and
  1.1116 -** UTF-16 in the native byte order if sqlite3_open16() is used.
  1.1117 +** ^The default encoding will be UTF-8 for databases created using
  1.1118 +** sqlite3_open() or sqlite3_open_v2().  ^The default encoding for databases
  1.1119 +** created using sqlite3_open16() will be UTF-16 in the native byte order.
  1.1120  **
  1.1121  ** Whether or not an error occurs when it is opened, resources
  1.1122  ** associated with the [database connection] handle should be released by
  1.1123 @@ -2737,13 +2877,14 @@
  1.1124  ** then it is interpreted as an absolute path. ^If the path does not begin 
  1.1125  ** with a '/' (meaning that the authority section is omitted from the URI)
  1.1126  ** then the path is interpreted as a relative path. 
  1.1127 -** ^On windows, the first component of an absolute path 
  1.1128 -** is a drive specification (e.g. "C:").
  1.1129 +** ^(On windows, the first component of an absolute path 
  1.1130 +** is a drive specification (e.g. "C:").)^
  1.1131  **
  1.1132  ** [[core URI query parameters]]
  1.1133  ** The query component of a URI may contain parameters that are interpreted
  1.1134  ** either by SQLite itself, or by a [VFS | custom VFS implementation].
  1.1135 -** SQLite interprets the following three query parameters:
  1.1136 +** SQLite and its built-in [VFSes] interpret the
  1.1137 +** following query parameters:
  1.1138  **
  1.1139  ** <ul>
  1.1140  **   <li> <b>vfs</b>: ^The "vfs" parameter may be used to specify the name of
  1.1141 @@ -2778,11 +2919,9 @@
  1.1142  **     a URI filename, its value overrides any behavior requested by setting
  1.1143  **     SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag.
  1.1144  **
  1.1145 -**  <li> <b>psow</b>: ^The psow parameter may be "true" (or "on" or "yes" or
  1.1146 -**     "1") or "false" (or "off" or "no" or "0") to indicate that the
  1.1147 +**  <li> <b>psow</b>: ^The psow parameter indicates whether or not the
  1.1148  **     [powersafe overwrite] property does or does not apply to the
  1.1149 -**     storage media on which the database file resides.  ^The psow query
  1.1150 -**     parameter only works for the built-in unix and Windows VFSes.
  1.1151 +**     storage media on which the database file resides.
  1.1152  **
  1.1153  **  <li> <b>nolock</b>: ^The nolock parameter is a boolean query parameter
  1.1154  **     which if set disables file locking in rollback journal modes.  This
  1.1155 @@ -2858,15 +2997,15 @@
  1.1156  **
  1.1157  ** See also: [sqlite3_temp_directory]
  1.1158  */
  1.1159 -SQLITE_API int sqlite3_open(
  1.1160 +SQLITE_API int SQLITE_STDCALL sqlite3_open(
  1.1161    const char *filename,   /* Database filename (UTF-8) */
  1.1162    sqlite3 **ppDb          /* OUT: SQLite db handle */
  1.1163  );
  1.1164 -SQLITE_API int sqlite3_open16(
  1.1165 +SQLITE_API int SQLITE_STDCALL sqlite3_open16(
  1.1166    const void *filename,   /* Database filename (UTF-16) */
  1.1167    sqlite3 **ppDb          /* OUT: SQLite db handle */
  1.1168  );
  1.1169 -SQLITE_API int sqlite3_open_v2(
  1.1170 +SQLITE_API int SQLITE_STDCALL sqlite3_open_v2(
  1.1171    const char *filename,   /* Database filename (UTF-8) */
  1.1172    sqlite3 **ppDb,         /* OUT: SQLite db handle */
  1.1173    int flags,              /* Flags */
  1.1174 @@ -2912,19 +3051,22 @@
  1.1175  ** VFS method, then the behavior of this routine is undefined and probably
  1.1176  ** undesirable.
  1.1177  */
  1.1178 -SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
  1.1179 -SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
  1.1180 -SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
  1.1181 +SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam);
  1.1182 +SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
  1.1183 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
  1.1184  
  1.1185  
  1.1186  /*
  1.1187  ** CAPI3REF: Error Codes And Messages
  1.1188 -**
  1.1189 -** ^The sqlite3_errcode() interface returns the numeric [result code] or
  1.1190 -** [extended result code] for the most recent failed sqlite3_* API call
  1.1191 -** associated with a [database connection]. If a prior API call failed
  1.1192 -** but the most recent API call succeeded, the return value from
  1.1193 -** sqlite3_errcode() is undefined.  ^The sqlite3_extended_errcode()
  1.1194 +** METHOD: sqlite3
  1.1195 +**
  1.1196 +** ^If the most recent sqlite3_* API call associated with 
  1.1197 +** [database connection] D failed, then the sqlite3_errcode(D) interface
  1.1198 +** returns the numeric [result code] or [extended result code] for that
  1.1199 +** API call.
  1.1200 +** If the most recent API call was successful,
  1.1201 +** then the return value from sqlite3_errcode() is undefined.
  1.1202 +** ^The sqlite3_extended_errcode()
  1.1203  ** interface is the same except that it always returns the 
  1.1204  ** [extended result code] even when extended result codes are
  1.1205  ** disabled.
  1.1206 @@ -2955,40 +3097,41 @@
  1.1207  ** was invoked incorrectly by the application.  In that case, the
  1.1208  ** error code and message may or may not be set.
  1.1209  */
  1.1210 -SQLITE_API int sqlite3_errcode(sqlite3 *db);
  1.1211 -SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
  1.1212 -SQLITE_API const char *sqlite3_errmsg(sqlite3*);
  1.1213 -SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
  1.1214 -SQLITE_API const char *sqlite3_errstr(int);
  1.1215 -
  1.1216 -/*
  1.1217 -** CAPI3REF: SQL Statement Object
  1.1218 +SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db);
  1.1219 +SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db);
  1.1220 +SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3*);
  1.1221 +SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3*);
  1.1222 +SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int);
  1.1223 +
  1.1224 +/*
  1.1225 +** CAPI3REF: Prepared Statement Object
  1.1226  ** KEYWORDS: {prepared statement} {prepared statements}
  1.1227  **
  1.1228 -** An instance of this object represents a single SQL statement.
  1.1229 -** This object is variously known as a "prepared statement" or a
  1.1230 -** "compiled SQL statement" or simply as a "statement".
  1.1231 -**
  1.1232 -** The life of a statement object goes something like this:
  1.1233 +** An instance of this object represents a single SQL statement that
  1.1234 +** has been compiled into binary form and is ready to be evaluated.
  1.1235 +**
  1.1236 +** Think of each SQL statement as a separate computer program.  The
  1.1237 +** original SQL text is source code.  A prepared statement object 
  1.1238 +** is the compiled object code.  All SQL must be converted into a
  1.1239 +** prepared statement before it can be run.
  1.1240 +**
  1.1241 +** The life-cycle of a prepared statement object usually goes like this:
  1.1242  **
  1.1243  ** <ol>
  1.1244 -** <li> Create the object using [sqlite3_prepare_v2()] or a related
  1.1245 -**      function.
  1.1246 -** <li> Bind values to [host parameters] using the sqlite3_bind_*()
  1.1247 +** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
  1.1248 +** <li> Bind values to [parameters] using the sqlite3_bind_*()
  1.1249  **      interfaces.
  1.1250  ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
  1.1251 -** <li> Reset the statement using [sqlite3_reset()] then go back
  1.1252 +** <li> Reset the prepared statement using [sqlite3_reset()] then go back
  1.1253  **      to step 2.  Do this zero or more times.
  1.1254  ** <li> Destroy the object using [sqlite3_finalize()].
  1.1255  ** </ol>
  1.1256 -**
  1.1257 -** Refer to documentation on individual methods above for additional
  1.1258 -** information.
  1.1259  */
  1.1260  typedef struct sqlite3_stmt sqlite3_stmt;
  1.1261  
  1.1262  /*
  1.1263  ** CAPI3REF: Run-time Limits
  1.1264 +** METHOD: sqlite3
  1.1265  **
  1.1266  ** ^(This interface allows the size of various constructs to be limited
  1.1267  ** on a connection by connection basis.  The first parameter is the
  1.1268 @@ -3026,7 +3169,7 @@
  1.1269  **
  1.1270  ** New run-time limit categories may be added in future releases.
  1.1271  */
  1.1272 -SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
  1.1273 +SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3*, int id, int newVal);
  1.1274  
  1.1275  /*
  1.1276  ** CAPI3REF: Run-Time Limit Categories
  1.1277 @@ -3078,6 +3221,10 @@
  1.1278  **
  1.1279  ** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
  1.1280  ** <dd>The maximum depth of recursion for triggers.</dd>)^
  1.1281 +**
  1.1282 +** [[SQLITE_LIMIT_WORKER_THREADS]] ^(<dt>SQLITE_LIMIT_WORKER_THREADS</dt>
  1.1283 +** <dd>The maximum number of auxiliary worker threads that a single
  1.1284 +** [prepared statement] may start.</dd>)^
  1.1285  ** </dl>
  1.1286  */
  1.1287  #define SQLITE_LIMIT_LENGTH                    0
  1.1288 @@ -3091,10 +3238,13 @@
  1.1289  #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH       8
  1.1290  #define SQLITE_LIMIT_VARIABLE_NUMBER           9
  1.1291  #define SQLITE_LIMIT_TRIGGER_DEPTH            10
  1.1292 +#define SQLITE_LIMIT_WORKER_THREADS           11
  1.1293  
  1.1294  /*
  1.1295  ** CAPI3REF: Compiling An SQL Statement
  1.1296  ** KEYWORDS: {SQL statement compiler}
  1.1297 +** METHOD: sqlite3
  1.1298 +** CONSTRUCTOR: sqlite3_stmt
  1.1299  **
  1.1300  ** To execute an SQL query, it must first be compiled into a byte-code
  1.1301  ** program using one of these routines.
  1.1302 @@ -3108,16 +3258,14 @@
  1.1303  ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
  1.1304  ** use UTF-16.
  1.1305  **
  1.1306 -** ^If the nByte argument is less than zero, then zSql is read up to the
  1.1307 -** first zero terminator. ^If nByte is non-negative, then it is the maximum
  1.1308 -** number of  bytes read from zSql.  ^When nByte is non-negative, the
  1.1309 -** zSql string ends at either the first '\000' or '\u0000' character or
  1.1310 -** the nByte-th byte, whichever comes first. If the caller knows
  1.1311 -** that the supplied string is nul-terminated, then there is a small
  1.1312 -** performance advantage to be gained by passing an nByte parameter that
  1.1313 -** is equal to the number of bytes in the input string <i>including</i>
  1.1314 -** the nul-terminator bytes as this saves SQLite from having to
  1.1315 -** make a copy of the input string.
  1.1316 +** ^If the nByte argument is negative, then zSql is read up to the
  1.1317 +** first zero terminator. ^If nByte is positive, then it is the
  1.1318 +** number of bytes read from zSql.  ^If nByte is zero, then no prepared
  1.1319 +** statement is generated.
  1.1320 +** If the caller knows that the supplied string is nul-terminated, then
  1.1321 +** there is a small performance advantage to passing an nByte parameter that
  1.1322 +** is the number of bytes in the input string <i>including</i>
  1.1323 +** the nul-terminator.
  1.1324  **
  1.1325  ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
  1.1326  ** past the end of the first SQL statement in zSql.  These routines only
  1.1327 @@ -3173,28 +3321,28 @@
  1.1328  ** </li>
  1.1329  ** </ol>
  1.1330  */
  1.1331 -SQLITE_API int sqlite3_prepare(
  1.1332 +SQLITE_API int SQLITE_STDCALL sqlite3_prepare(
  1.1333    sqlite3 *db,            /* Database handle */
  1.1334    const char *zSql,       /* SQL statement, UTF-8 encoded */
  1.1335    int nByte,              /* Maximum length of zSql in bytes. */
  1.1336    sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  1.1337    const char **pzTail     /* OUT: Pointer to unused portion of zSql */
  1.1338  );
  1.1339 -SQLITE_API int sqlite3_prepare_v2(
  1.1340 +SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2(
  1.1341    sqlite3 *db,            /* Database handle */
  1.1342    const char *zSql,       /* SQL statement, UTF-8 encoded */
  1.1343    int nByte,              /* Maximum length of zSql in bytes. */
  1.1344    sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  1.1345    const char **pzTail     /* OUT: Pointer to unused portion of zSql */
  1.1346  );
  1.1347 -SQLITE_API int sqlite3_prepare16(
  1.1348 +SQLITE_API int SQLITE_STDCALL sqlite3_prepare16(
  1.1349    sqlite3 *db,            /* Database handle */
  1.1350    const void *zSql,       /* SQL statement, UTF-16 encoded */
  1.1351    int nByte,              /* Maximum length of zSql in bytes. */
  1.1352    sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  1.1353    const void **pzTail     /* OUT: Pointer to unused portion of zSql */
  1.1354  );
  1.1355 -SQLITE_API int sqlite3_prepare16_v2(
  1.1356 +SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
  1.1357    sqlite3 *db,            /* Database handle */
  1.1358    const void *zSql,       /* SQL statement, UTF-16 encoded */
  1.1359    int nByte,              /* Maximum length of zSql in bytes. */
  1.1360 @@ -3204,15 +3352,17 @@
  1.1361  
  1.1362  /*
  1.1363  ** CAPI3REF: Retrieving Statement SQL
  1.1364 +** METHOD: sqlite3_stmt
  1.1365  **
  1.1366  ** ^This interface can be used to retrieve a saved copy of the original
  1.1367  ** SQL text used to create a [prepared statement] if that statement was
  1.1368  ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
  1.1369  */
  1.1370 -SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
  1.1371 +SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
  1.1372  
  1.1373  /*
  1.1374  ** CAPI3REF: Determine If An SQL Statement Writes The Database
  1.1375 +** METHOD: sqlite3_stmt
  1.1376  **
  1.1377  ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
  1.1378  ** and only if the [prepared statement] X makes no direct changes to
  1.1379 @@ -3240,14 +3390,16 @@
  1.1380  ** change the configuration of a database connection, they do not make 
  1.1381  ** changes to the content of the database files on disk.
  1.1382  */
  1.1383 -SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
  1.1384 +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
  1.1385  
  1.1386  /*
  1.1387  ** CAPI3REF: Determine If A Prepared Statement Has Been Reset
  1.1388 +** METHOD: sqlite3_stmt
  1.1389  **
  1.1390  ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
  1.1391  ** [prepared statement] S has been stepped at least once using 
  1.1392 -** [sqlite3_step(S)] but has not run to completion and/or has not 
  1.1393 +** [sqlite3_step(S)] but has neither run to completion (returned
  1.1394 +** [SQLITE_DONE] from [sqlite3_step(S)]) nor
  1.1395  ** been reset using [sqlite3_reset(S)].  ^The sqlite3_stmt_busy(S)
  1.1396  ** interface returns false if S is a NULL pointer.  If S is not a 
  1.1397  ** NULL pointer and is not a pointer to a valid [prepared statement]
  1.1398 @@ -3259,7 +3411,7 @@
  1.1399  ** for example, in diagnostic routines to search for prepared 
  1.1400  ** statements that are holding a transaction open.
  1.1401  */
  1.1402 -SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
  1.1403 +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt*);
  1.1404  
  1.1405  /*
  1.1406  ** CAPI3REF: Dynamically Typed Value Object
  1.1407 @@ -3274,7 +3426,9 @@
  1.1408  ** Some interfaces require a protected sqlite3_value.  Other interfaces
  1.1409  ** will accept either a protected or an unprotected sqlite3_value.
  1.1410  ** Every interface that accepts sqlite3_value arguments specifies
  1.1411 -** whether or not it requires a protected sqlite3_value.
  1.1412 +** whether or not it requires a protected sqlite3_value.  The
  1.1413 +** [sqlite3_value_dup()] interface can be used to construct a new 
  1.1414 +** protected sqlite3_value from an unprotected sqlite3_value.
  1.1415  **
  1.1416  ** The terms "protected" and "unprotected" refer to whether or not
  1.1417  ** a mutex is held.  An internal mutex is held for a protected
  1.1418 @@ -3318,6 +3472,7 @@
  1.1419  ** CAPI3REF: Binding Values To Prepared Statements
  1.1420  ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
  1.1421  ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
  1.1422 +** METHOD: sqlite3_stmt
  1.1423  **
  1.1424  ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
  1.1425  ** literals may be replaced by a [parameter] that matches one of following
  1.1426 @@ -3364,18 +3519,18 @@
  1.1427  ** If the fourth parameter to sqlite3_bind_blob() is negative, then
  1.1428  ** the behavior is undefined.
  1.1429  ** If a non-negative fourth parameter is provided to sqlite3_bind_text()
  1.1430 -** or sqlite3_bind_text16() then that parameter must be the byte offset
  1.1431 +** or sqlite3_bind_text16() or sqlite3_bind_text64() then
  1.1432 +** that parameter must be the byte offset
  1.1433  ** where the NUL terminator would occur assuming the string were NUL
  1.1434  ** terminated.  If any NUL characters occur at byte offsets less than 
  1.1435  ** the value of the fourth parameter then the resulting string value will
  1.1436  ** contain embedded NULs.  The result of expressions involving strings
  1.1437  ** with embedded NULs is undefined.
  1.1438  **
  1.1439 -** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
  1.1440 -** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
  1.1441 +** ^The fifth argument to the BLOB and string binding interfaces
  1.1442 +** is a destructor used to dispose of the BLOB or
  1.1443  ** string after SQLite has finished with it.  ^The destructor is called
  1.1444 -** to dispose of the BLOB or string even if the call to sqlite3_bind_blob(),
  1.1445 -** sqlite3_bind_text(), or sqlite3_bind_text16() fails.  
  1.1446 +** to dispose of the BLOB or string even if the call to bind API fails.
  1.1447  ** ^If the fifth argument is
  1.1448  ** the special value [SQLITE_STATIC], then SQLite assumes that the
  1.1449  ** information is in static, unmanaged space and does not need to be freed.
  1.1450 @@ -3383,6 +3538,14 @@
  1.1451  ** SQLite makes its own private copy of the data immediately, before
  1.1452  ** the sqlite3_bind_*() routine returns.
  1.1453  **
  1.1454 +** ^The sixth argument to sqlite3_bind_text64() must be one of
  1.1455 +** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]
  1.1456 +** to specify the encoding of the text in the third parameter.  If
  1.1457 +** the sixth argument to sqlite3_bind_text64() is not one of the
  1.1458 +** allowed values shown above, or if the text encoding is different
  1.1459 +** from the encoding specified by the sixth parameter, then the behavior
  1.1460 +** is undefined.
  1.1461 +**
  1.1462  ** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
  1.1463  ** is filled with zeroes.  ^A zeroblob uses a fixed amount of memory
  1.1464  ** (just an integer to hold its size) while it is being processed.
  1.1465 @@ -3403,24 +3566,33 @@
  1.1466  **
  1.1467  ** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an
  1.1468  ** [error code] if anything goes wrong.
  1.1469 +** ^[SQLITE_TOOBIG] might be returned if the size of a string or BLOB
  1.1470 +** exceeds limits imposed by [sqlite3_limit]([SQLITE_LIMIT_LENGTH]) or
  1.1471 +** [SQLITE_MAX_LENGTH].
  1.1472  ** ^[SQLITE_RANGE] is returned if the parameter
  1.1473  ** index is out of range.  ^[SQLITE_NOMEM] is returned if malloc() fails.
  1.1474  **
  1.1475  ** See also: [sqlite3_bind_parameter_count()],
  1.1476  ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
  1.1477  */
  1.1478 -SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
  1.1479 -SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
  1.1480 -SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
  1.1481 -SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
  1.1482 -SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
  1.1483 -SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));
  1.1484 -SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
  1.1485 -SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
  1.1486 -SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
  1.1487 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
  1.1488 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
  1.1489 +                        void(*)(void*));
  1.1490 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt*, int, double);
  1.1491 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt*, int, int);
  1.1492 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
  1.1493 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt*, int);
  1.1494 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
  1.1495 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
  1.1496 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
  1.1497 +                         void(*)(void*), unsigned char encoding);
  1.1498 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
  1.1499 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
  1.1500 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
  1.1501  
  1.1502  /*
  1.1503  ** CAPI3REF: Number Of SQL Parameters
  1.1504 +** METHOD: sqlite3_stmt
  1.1505  **
  1.1506  ** ^This routine can be used to find the number of [SQL parameters]
  1.1507  ** in a [prepared statement].  SQL parameters are tokens of the
  1.1508 @@ -3437,10 +3609,11 @@
  1.1509  ** [sqlite3_bind_parameter_name()], and
  1.1510  ** [sqlite3_bind_parameter_index()].
  1.1511  */
  1.1512 -SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
  1.1513 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt*);
  1.1514  
  1.1515  /*
  1.1516  ** CAPI3REF: Name Of A Host Parameter
  1.1517 +** METHOD: sqlite3_stmt
  1.1518  **
  1.1519  ** ^The sqlite3_bind_parameter_name(P,N) interface returns
  1.1520  ** the name of the N-th [SQL parameter] in the [prepared statement] P.
  1.1521 @@ -3464,10 +3637,11 @@
  1.1522  ** [sqlite3_bind_parameter_count()], and
  1.1523  ** [sqlite3_bind_parameter_index()].
  1.1524  */
  1.1525 -SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
  1.1526 +SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt*, int);
  1.1527  
  1.1528  /*
  1.1529  ** CAPI3REF: Index Of A Parameter With A Given Name
  1.1530 +** METHOD: sqlite3_stmt
  1.1531  **
  1.1532  ** ^Return the index of an SQL parameter given its name.  ^The
  1.1533  ** index value returned is suitable for use as the second
  1.1534 @@ -3478,21 +3652,23 @@
  1.1535  **
  1.1536  ** See also: [sqlite3_bind_blob|sqlite3_bind()],
  1.1537  ** [sqlite3_bind_parameter_count()], and
  1.1538 -** [sqlite3_bind_parameter_index()].
  1.1539 -*/
  1.1540 -SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
  1.1541 +** [sqlite3_bind_parameter_name()].
  1.1542 +*/
  1.1543 +SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
  1.1544  
  1.1545  /*
  1.1546  ** CAPI3REF: Reset All Bindings On A Prepared Statement
  1.1547 +** METHOD: sqlite3_stmt
  1.1548  **
  1.1549  ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
  1.1550  ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
  1.1551  ** ^Use this routine to reset all host parameters to NULL.
  1.1552  */
  1.1553 -SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
  1.1554 +SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt*);
  1.1555  
  1.1556  /*
  1.1557  ** CAPI3REF: Number Of Columns In A Result Set
  1.1558 +** METHOD: sqlite3_stmt
  1.1559  **
  1.1560  ** ^Return the number of columns in the result set returned by the
  1.1561  ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
  1.1562 @@ -3500,10 +3676,11 @@
  1.1563  **
  1.1564  ** See also: [sqlite3_data_count()]
  1.1565  */
  1.1566 -SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
  1.1567 +SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt);
  1.1568  
  1.1569  /*
  1.1570  ** CAPI3REF: Column Names In A Result Set
  1.1571 +** METHOD: sqlite3_stmt
  1.1572  **
  1.1573  ** ^These routines return the name assigned to a particular column
  1.1574  ** in the result set of a [SELECT] statement.  ^The sqlite3_column_name()
  1.1575 @@ -3528,11 +3705,12 @@
  1.1576  ** then the name of the column is unspecified and may change from
  1.1577  ** one release of SQLite to the next.
  1.1578  */
  1.1579 -SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
  1.1580 -SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
  1.1581 +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt*, int N);
  1.1582 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt*, int N);
  1.1583  
  1.1584  /*
  1.1585  ** CAPI3REF: Source Of Data In A Query Result
  1.1586 +** METHOD: sqlite3_stmt
  1.1587  **
  1.1588  ** ^These routines provide a means to determine the database, table, and
  1.1589  ** table column that is the origin of a particular result column in
  1.1590 @@ -3576,15 +3754,16 @@
  1.1591  ** for the same [prepared statement] and result column
  1.1592  ** at the same time then the results are undefined.
  1.1593  */
  1.1594 -SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);
  1.1595 -SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
  1.1596 -SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);
  1.1597 -SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
  1.1598 -SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
  1.1599 -SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
  1.1600 +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt*,int);
  1.1601 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt*,int);
  1.1602 +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt*,int);
  1.1603 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt*,int);
  1.1604 +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt*,int);
  1.1605 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt*,int);
  1.1606  
  1.1607  /*
  1.1608  ** CAPI3REF: Declared Datatype Of A Query Result
  1.1609 +** METHOD: sqlite3_stmt
  1.1610  **
  1.1611  ** ^(The first parameter is a [prepared statement].
  1.1612  ** If this statement is a [SELECT] statement and the Nth column of the
  1.1613 @@ -3612,11 +3791,12 @@
  1.1614  ** is associated with individual values, not with the containers
  1.1615  ** used to hold those values.
  1.1616  */
  1.1617 -SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
  1.1618 -SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
  1.1619 +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt*,int);
  1.1620 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt*,int);
  1.1621  
  1.1622  /*
  1.1623  ** CAPI3REF: Evaluate An SQL Statement
  1.1624 +** METHOD: sqlite3_stmt
  1.1625  **
  1.1626  ** After a [prepared statement] has been prepared using either
  1.1627  ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
  1.1628 @@ -3692,10 +3872,11 @@
  1.1629  ** then the more specific [error codes] are returned directly
  1.1630  ** by sqlite3_step().  The use of the "v2" interface is recommended.
  1.1631  */
  1.1632 -SQLITE_API int sqlite3_step(sqlite3_stmt*);
  1.1633 +SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt*);
  1.1634  
  1.1635  /*
  1.1636  ** CAPI3REF: Number of columns in a result set
  1.1637 +** METHOD: sqlite3_stmt
  1.1638  **
  1.1639  ** ^The sqlite3_data_count(P) interface returns the number of columns in the
  1.1640  ** current row of the result set of [prepared statement] P.
  1.1641 @@ -3712,7 +3893,7 @@
  1.1642  **
  1.1643  ** See also: [sqlite3_column_count()]
  1.1644  */
  1.1645 -SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
  1.1646 +SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt);
  1.1647  
  1.1648  /*
  1.1649  ** CAPI3REF: Fundamental Datatypes
  1.1650 @@ -3749,8 +3930,7 @@
  1.1651  /*
  1.1652  ** CAPI3REF: Result Values From A Query
  1.1653  ** KEYWORDS: {column access functions}
  1.1654 -**
  1.1655 -** These routines form the "result set" interface.
  1.1656 +** METHOD: sqlite3_stmt
  1.1657  **
  1.1658  ** ^These routines return information about a single column of the current
  1.1659  ** result row of a query.  ^In every case the first argument is a pointer
  1.1660 @@ -3811,13 +3991,14 @@
  1.1661  ** even empty strings, are always zero-terminated.  ^The return
  1.1662  ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
  1.1663  **
  1.1664 -** ^The object returned by [sqlite3_column_value()] is an
  1.1665 -** [unprotected sqlite3_value] object.  An unprotected sqlite3_value object
  1.1666 -** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
  1.1667 +** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
  1.1668 +** [unprotected sqlite3_value] object.  In a multithreaded environment,
  1.1669 +** an unprotected sqlite3_value object may only be used safely with
  1.1670 +** [sqlite3_bind_value()] and [sqlite3_result_value()].
  1.1671  ** If the [unprotected sqlite3_value] object returned by
  1.1672  ** [sqlite3_column_value()] is used in any other way, including calls
  1.1673  ** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
  1.1674 -** or [sqlite3_value_bytes()], then the behavior is undefined.
  1.1675 +** or [sqlite3_value_bytes()], the behavior is not threadsafe.
  1.1676  **
  1.1677  ** These routines attempt to convert the value where appropriate.  ^For
  1.1678  ** example, if the internal representation is FLOAT and a text result
  1.1679 @@ -3848,12 +4029,6 @@
  1.1680  ** </table>
  1.1681  ** </blockquote>)^
  1.1682  **
  1.1683 -** The table above makes reference to standard C library functions atoi()
  1.1684 -** and atof().  SQLite does not really use these functions.  It has its
  1.1685 -** own equivalent internal routines.  The atoi() and atof() names are
  1.1686 -** used in the table for brevity and because they are familiar to most
  1.1687 -** C programmers.
  1.1688 -**
  1.1689  ** Note that when type conversions occur, pointers returned by prior
  1.1690  ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
  1.1691  ** sqlite3_column_text16() may be invalidated.
  1.1692 @@ -3878,7 +4053,7 @@
  1.1693  ** of conversion are done in place when it is possible, but sometimes they
  1.1694  ** are not possible and in those cases prior pointers are invalidated.
  1.1695  **
  1.1696 -** The safest and easiest to remember policy is to invoke these routines
  1.1697 +** The safest policy is to invoke these routines
  1.1698  ** in one of the following ways:
  1.1699  **
  1.1700  ** <ul>
  1.1701 @@ -3898,7 +4073,7 @@
  1.1702  ** ^The pointers returned are valid until a type conversion occurs as
  1.1703  ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
  1.1704  ** [sqlite3_finalize()] is called.  ^The memory space used to hold strings
  1.1705 -** and BLOBs is freed automatically.  Do <b>not</b> pass the pointers returned
  1.1706 +** and BLOBs is freed automatically.  Do <em>not</em> pass the pointers returned
  1.1707  ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
  1.1708  ** [sqlite3_free()].
  1.1709  **
  1.1710 @@ -3908,19 +4083,20 @@
  1.1711  ** pointer.  Subsequent calls to [sqlite3_errcode()] will return
  1.1712  ** [SQLITE_NOMEM].)^
  1.1713  */
  1.1714 -SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
  1.1715 -SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
  1.1716 -SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
  1.1717 -SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
  1.1718 -SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
  1.1719 -SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
  1.1720 -SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
  1.1721 -SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
  1.1722 -SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
  1.1723 -SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
  1.1724 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt*, int iCol);
  1.1725 +SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt*, int iCol);
  1.1726 +SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
  1.1727 +SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt*, int iCol);
  1.1728 +SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt*, int iCol);
  1.1729 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt*, int iCol);
  1.1730 +SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt*, int iCol);
  1.1731 +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt*, int iCol);
  1.1732 +SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt*, int iCol);
  1.1733 +SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt*, int iCol);
  1.1734  
  1.1735  /*
  1.1736  ** CAPI3REF: Destroy A Prepared Statement Object
  1.1737 +** DESTRUCTOR: sqlite3_stmt
  1.1738  **
  1.1739  ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
  1.1740  ** ^If the most recent evaluation of the statement encountered no errors
  1.1741 @@ -3944,10 +4120,11 @@
  1.1742  ** statement after it has been finalized can result in undefined and
  1.1743  ** undesirable behavior such as segfaults and heap corruption.
  1.1744  */
  1.1745 -SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
  1.1746 +SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt);
  1.1747  
  1.1748  /*
  1.1749  ** CAPI3REF: Reset A Prepared Statement Object
  1.1750 +** METHOD: sqlite3_stmt
  1.1751  **
  1.1752  ** The sqlite3_reset() function is called to reset a [prepared statement]
  1.1753  ** object back to its initial state, ready to be re-executed.
  1.1754 @@ -3970,13 +4147,14 @@
  1.1755  ** ^The [sqlite3_reset(S)] interface does not change the values
  1.1756  ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
  1.1757  */
  1.1758 -SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
  1.1759 +SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt);
  1.1760  
  1.1761  /*
  1.1762  ** CAPI3REF: Create Or Redefine SQL Functions
  1.1763  ** KEYWORDS: {function creation routines}
  1.1764  ** KEYWORDS: {application-defined SQL function}
  1.1765  ** KEYWORDS: {application-defined SQL functions}
  1.1766 +** METHOD: sqlite3
  1.1767  **
  1.1768  ** ^These functions (collectively known as "function creation routines")
  1.1769  ** are used to add SQL functions or aggregates or to redefine the behavior
  1.1770 @@ -4069,7 +4247,7 @@
  1.1771  ** close the database connection nor finalize or reset the prepared
  1.1772  ** statement in which the function is running.
  1.1773  */
  1.1774 -SQLITE_API int sqlite3_create_function(
  1.1775 +SQLITE_API int SQLITE_STDCALL sqlite3_create_function(
  1.1776    sqlite3 *db,
  1.1777    const char *zFunctionName,
  1.1778    int nArg,
  1.1779 @@ -4079,7 +4257,7 @@
  1.1780    void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  1.1781    void (*xFinal)(sqlite3_context*)
  1.1782  );
  1.1783 -SQLITE_API int sqlite3_create_function16(
  1.1784 +SQLITE_API int SQLITE_STDCALL sqlite3_create_function16(
  1.1785    sqlite3 *db,
  1.1786    const void *zFunctionName,
  1.1787    int nArg,
  1.1788 @@ -4089,7 +4267,7 @@
  1.1789    void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  1.1790    void (*xFinal)(sqlite3_context*)
  1.1791  );
  1.1792 -SQLITE_API int sqlite3_create_function_v2(
  1.1793 +SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2(
  1.1794    sqlite3 *db,
  1.1795    const char *zFunctionName,
  1.1796    int nArg,
  1.1797 @@ -4107,9 +4285,9 @@
  1.1798  ** These constant define integer codes that represent the various
  1.1799  ** text encodings supported by SQLite.
  1.1800  */
  1.1801 -#define SQLITE_UTF8           1
  1.1802 -#define SQLITE_UTF16LE        2
  1.1803 -#define SQLITE_UTF16BE        3
  1.1804 +#define SQLITE_UTF8           1    /* IMP: R-37514-35566 */
  1.1805 +#define SQLITE_UTF16LE        2    /* IMP: R-03371-37637 */
  1.1806 +#define SQLITE_UTF16BE        3    /* IMP: R-51971-34154 */
  1.1807  #define SQLITE_UTF16          4    /* Use native byte order */
  1.1808  #define SQLITE_ANY            5    /* Deprecated */
  1.1809  #define SQLITE_UTF16_ALIGNED  8    /* sqlite3_create_collation only */
  1.1810 @@ -4131,25 +4309,26 @@
  1.1811  ** These functions are [deprecated].  In order to maintain
  1.1812  ** backwards compatibility with older code, these functions continue 
  1.1813  ** to be supported.  However, new applications should avoid
  1.1814 -** the use of these functions.  To help encourage people to avoid
  1.1815 -** using these functions, we are not going to tell you what they do.
  1.1816 +** the use of these functions.  To encourage programmers to avoid
  1.1817 +** these functions, we will not explain what they do.
  1.1818  */
  1.1819  #ifndef SQLITE_OMIT_DEPRECATED
  1.1820 -SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
  1.1821 -SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
  1.1822 -SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
  1.1823 -SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
  1.1824 -SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
  1.1825 -SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
  1.1826 +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context*);
  1.1827 +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt*);
  1.1828 +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
  1.1829 +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_global_recover(void);
  1.1830 +SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_thread_cleanup(void);
  1.1831 +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
  1.1832                        void*,sqlite3_int64);
  1.1833  #endif
  1.1834  
  1.1835  /*
  1.1836 -** CAPI3REF: Obtaining SQL Function Parameter Values
  1.1837 +** CAPI3REF: Obtaining SQL Values
  1.1838 +** METHOD: sqlite3_value
  1.1839  **
  1.1840  ** The C-language implementation of SQL functions and aggregates uses
  1.1841  ** this set of interface routines to access the parameter values on
  1.1842 -** the function or aggregate.
  1.1843 +** the function or aggregate.  
  1.1844  **
  1.1845  ** The xFunc (for scalar functions) or xStep (for aggregates) parameters
  1.1846  ** to [sqlite3_create_function()] and [sqlite3_create_function16()]
  1.1847 @@ -4164,7 +4343,7 @@
  1.1848  ** object results in undefined behavior.
  1.1849  **
  1.1850  ** ^These routines work just like the corresponding [column access functions]
  1.1851 -** except that  these routines take a single [protected sqlite3_value] object
  1.1852 +** except that these routines take a single [protected sqlite3_value] object
  1.1853  ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
  1.1854  **
  1.1855  ** ^The sqlite3_value_text16() interface extracts a UTF-16 string
  1.1856 @@ -4189,21 +4368,55 @@
  1.1857  ** These routines must be called from the same thread as
  1.1858  ** the SQL function that supplied the [sqlite3_value*] parameters.
  1.1859  */
  1.1860 -SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
  1.1861 -SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
  1.1862 -SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
  1.1863 -SQLITE_API double sqlite3_value_double(sqlite3_value*);
  1.1864 -SQLITE_API int sqlite3_value_int(sqlite3_value*);
  1.1865 -SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
  1.1866 -SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
  1.1867 -SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
  1.1868 -SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
  1.1869 -SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
  1.1870 -SQLITE_API int sqlite3_value_type(sqlite3_value*);
  1.1871 -SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
  1.1872 +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value*);
  1.1873 +SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value*);
  1.1874 +SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value*);
  1.1875 +SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value*);
  1.1876 +SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value*);
  1.1877 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value*);
  1.1878 +SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value*);
  1.1879 +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value*);
  1.1880 +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value*);
  1.1881 +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value*);
  1.1882 +SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value*);
  1.1883 +SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value*);
  1.1884 +
  1.1885 +/*
  1.1886 +** CAPI3REF: Finding The Subtype Of SQL Values
  1.1887 +** METHOD: sqlite3_value
  1.1888 +**
  1.1889 +** The sqlite3_value_subtype(V) function returns the subtype for
  1.1890 +** an [application-defined SQL function] argument V.  The subtype
  1.1891 +** information can be used to pass a limited amount of context from
  1.1892 +** one SQL function to another.  Use the [sqlite3_result_subtype()]
  1.1893 +** routine to set the subtype for the return value of an SQL function.
  1.1894 +**
  1.1895 +** SQLite makes no use of subtype itself.  It merely passes the subtype
  1.1896 +** from the result of one [application-defined SQL function] into the
  1.1897 +** input of another.
  1.1898 +*/
  1.1899 +SQLITE_API unsigned int SQLITE_STDCALL sqlite3_value_subtype(sqlite3_value*);
  1.1900 +
  1.1901 +/*
  1.1902 +** CAPI3REF: Copy And Free SQL Values
  1.1903 +** METHOD: sqlite3_value
  1.1904 +**
  1.1905 +** ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value]
  1.1906 +** object D and returns a pointer to that copy.  ^The [sqlite3_value] returned
  1.1907 +** is a [protected sqlite3_value] object even if the input is not.
  1.1908 +** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a
  1.1909 +** memory allocation fails.
  1.1910 +**
  1.1911 +** ^The sqlite3_value_free(V) interface frees an [sqlite3_value] object
  1.1912 +** previously obtained from [sqlite3_value_dup()].  ^If V is a NULL pointer
  1.1913 +** then sqlite3_value_free(V) is a harmless no-op.
  1.1914 +*/
  1.1915 +SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_value_dup(const sqlite3_value*);
  1.1916 +SQLITE_API void SQLITE_STDCALL sqlite3_value_free(sqlite3_value*);
  1.1917  
  1.1918  /*
  1.1919  ** CAPI3REF: Obtain Aggregate Function Context
  1.1920 +** METHOD: sqlite3_context
  1.1921  **
  1.1922  ** Implementations of aggregate SQL functions use this
  1.1923  ** routine to allocate memory for storing their state.
  1.1924 @@ -4244,10 +4457,11 @@
  1.1925  ** This routine must be called from the same thread in which
  1.1926  ** the aggregate SQL function is running.
  1.1927  */
  1.1928 -SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
  1.1929 +SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context*, int nBytes);
  1.1930  
  1.1931  /*
  1.1932  ** CAPI3REF: User Data For Functions
  1.1933 +** METHOD: sqlite3_context
  1.1934  **
  1.1935  ** ^The sqlite3_user_data() interface returns a copy of
  1.1936  ** the pointer that was the pUserData parameter (the 5th parameter)
  1.1937 @@ -4258,10 +4472,11 @@
  1.1938  ** This routine must be called from the same thread in which
  1.1939  ** the application-defined function is running.
  1.1940  */
  1.1941 -SQLITE_API void *sqlite3_user_data(sqlite3_context*);
  1.1942 +SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context*);
  1.1943  
  1.1944  /*
  1.1945  ** CAPI3REF: Database Connection For Functions
  1.1946 +** METHOD: sqlite3_context
  1.1947  **
  1.1948  ** ^The sqlite3_context_db_handle() interface returns a copy of
  1.1949  ** the pointer to the [database connection] (the 1st parameter)
  1.1950 @@ -4269,10 +4484,11 @@
  1.1951  ** and [sqlite3_create_function16()] routines that originally
  1.1952  ** registered the application defined function.
  1.1953  */
  1.1954 -SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
  1.1955 +SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context*);
  1.1956  
  1.1957  /*
  1.1958  ** CAPI3REF: Function Auxiliary Data
  1.1959 +** METHOD: sqlite3_context
  1.1960  **
  1.1961  ** These functions may be used by (non-aggregate) SQL functions to
  1.1962  ** associate metadata with argument values. If the same value is passed to
  1.1963 @@ -4321,8 +4537,8 @@
  1.1964  ** These routines must be called from the same thread in which
  1.1965  ** the SQL function is running.
  1.1966  */
  1.1967 -SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
  1.1968 -SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
  1.1969 +SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context*, int N);
  1.1970 +SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
  1.1971  
  1.1972  
  1.1973  /*
  1.1974 @@ -4345,6 +4561,7 @@
  1.1975  
  1.1976  /*
  1.1977  ** CAPI3REF: Setting The Result Of An SQL Function
  1.1978 +** METHOD: sqlite3_context
  1.1979  **
  1.1980  ** These routines are used by the xFunc or xFinal callbacks that
  1.1981  ** implement SQL functions and aggregates.  See
  1.1982 @@ -4360,9 +4577,9 @@
  1.1983  ** to by the second parameter and which is N bytes long where N is the
  1.1984  ** third parameter.
  1.1985  **
  1.1986 -** ^The sqlite3_result_zeroblob() interfaces set the result of
  1.1987 -** the application-defined function to be a BLOB containing all zero
  1.1988 -** bytes and N bytes in size, where N is the value of the 2nd parameter.
  1.1989 +** ^The sqlite3_result_zeroblob(C,N) and sqlite3_result_zeroblob64(C,N)
  1.1990 +** interfaces set the result of the application-defined function to be
  1.1991 +** a BLOB containing all zero bytes and N bytes in size.
  1.1992  **
  1.1993  ** ^The sqlite3_result_double() interface sets the result from
  1.1994  ** an application-defined function to be a floating point value specified
  1.1995 @@ -4411,6 +4628,10 @@
  1.1996  ** set the return value of the application-defined function to be
  1.1997  ** a text string which is represented as UTF-8, UTF-16 native byte order,
  1.1998  ** UTF-16 little endian, or UTF-16 big endian, respectively.
  1.1999 +** ^The sqlite3_result_text64() interface sets the return value of an
  1.2000 +** application-defined function to be a text string in an encoding
  1.2001 +** specified by the fifth (and last) parameter, which must be one
  1.2002 +** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].
  1.2003  ** ^SQLite takes the text result from the application from
  1.2004  ** the 2nd parameter of the sqlite3_result_text* interfaces.
  1.2005  ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
  1.2006 @@ -4440,7 +4661,7 @@
  1.2007  ** from [sqlite3_malloc()] before it returns.
  1.2008  **
  1.2009  ** ^The sqlite3_result_value() interface sets the result of
  1.2010 -** the application-defined function to be a copy the
  1.2011 +** the application-defined function to be a copy of the
  1.2012  ** [unprotected sqlite3_value] object specified by the 2nd parameter.  ^The
  1.2013  ** sqlite3_result_value() interface makes a copy of the [sqlite3_value]
  1.2014  ** so that the [sqlite3_value] specified in the parameter may change or
  1.2015 @@ -4453,25 +4674,46 @@
  1.2016  ** than the one containing the application-defined function that received
  1.2017  ** the [sqlite3_context] pointer, the results are undefined.
  1.2018  */
  1.2019 -SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
  1.2020 -SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
  1.2021 -SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
  1.2022 -SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
  1.2023 -SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);
  1.2024 -SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);
  1.2025 -SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);
  1.2026 -SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
  1.2027 -SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
  1.2028 -SQLITE_API void sqlite3_result_null(sqlite3_context*);
  1.2029 -SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
  1.2030 -SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
  1.2031 -SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
  1.2032 -SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
  1.2033 -SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
  1.2034 -SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
  1.2035 +SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
  1.2036 +SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(sqlite3_context*,const void*,
  1.2037 +                           sqlite3_uint64,void(*)(void*));
  1.2038 +SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context*, double);
  1.2039 +SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context*, const char*, int);
  1.2040 +SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context*, const void*, int);
  1.2041 +SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context*);
  1.2042 +SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context*);
  1.2043 +SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context*, int);
  1.2044 +SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context*, int);
  1.2045 +SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
  1.2046 +SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context*);
  1.2047 +SQLITE_API void SQLITE_STDCALL sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
  1.2048 +SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
  1.2049 +                           void(*)(void*), unsigned char encoding);
  1.2050 +SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
  1.2051 +SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
  1.2052 +SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
  1.2053 +SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context*, sqlite3_value*);
  1.2054 +SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context*, int n);
  1.2055 +SQLITE_API int SQLITE_STDCALL sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
  1.2056 +
  1.2057 +
  1.2058 +/*
  1.2059 +** CAPI3REF: Setting The Subtype Of An SQL Function
  1.2060 +** METHOD: sqlite3_context
  1.2061 +**
  1.2062 +** The sqlite3_result_subtype(C,T) function causes the subtype of
  1.2063 +** the result from the [application-defined SQL function] with 
  1.2064 +** [sqlite3_context] C to be the value T.  Only the lower 8 bits 
  1.2065 +** of the subtype T are preserved in current versions of SQLite;
  1.2066 +** higher order bits are discarded.
  1.2067 +** The number of subtype bytes preserved by SQLite might increase
  1.2068 +** in future releases of SQLite.
  1.2069 +*/
  1.2070 +SQLITE_API void SQLITE_STDCALL sqlite3_result_subtype(sqlite3_context*,unsigned int);
  1.2071  
  1.2072  /*
  1.2073  ** CAPI3REF: Define New Collating Sequences
  1.2074 +** METHOD: sqlite3
  1.2075  **
  1.2076  ** ^These functions add, remove, or modify a [collation] associated
  1.2077  ** with the [database connection] specified as the first argument.
  1.2078 @@ -4549,14 +4791,14 @@
  1.2079  **
  1.2080  ** See also:  [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
  1.2081  */
  1.2082 -SQLITE_API int sqlite3_create_collation(
  1.2083 +SQLITE_API int SQLITE_STDCALL sqlite3_create_collation(
  1.2084    sqlite3*, 
  1.2085    const char *zName, 
  1.2086    int eTextRep, 
  1.2087    void *pArg,
  1.2088    int(*xCompare)(void*,int,const void*,int,const void*)
  1.2089  );
  1.2090 -SQLITE_API int sqlite3_create_collation_v2(
  1.2091 +SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2(
  1.2092    sqlite3*, 
  1.2093    const char *zName, 
  1.2094    int eTextRep, 
  1.2095 @@ -4564,7 +4806,7 @@
  1.2096    int(*xCompare)(void*,int,const void*,int,const void*),
  1.2097    void(*xDestroy)(void*)
  1.2098  );
  1.2099 -SQLITE_API int sqlite3_create_collation16(
  1.2100 +SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16(
  1.2101    sqlite3*, 
  1.2102    const void *zName,
  1.2103    int eTextRep, 
  1.2104 @@ -4574,6 +4816,7 @@
  1.2105  
  1.2106  /*
  1.2107  ** CAPI3REF: Collation Needed Callbacks
  1.2108 +** METHOD: sqlite3
  1.2109  **
  1.2110  ** ^To avoid having to register all collation sequences before a database
  1.2111  ** can be used, a single callback function may be registered with the
  1.2112 @@ -4598,12 +4841,12 @@
  1.2113  ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
  1.2114  ** [sqlite3_create_collation_v2()].
  1.2115  */
  1.2116 -SQLITE_API int sqlite3_collation_needed(
  1.2117 +SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed(
  1.2118    sqlite3*, 
  1.2119    void*, 
  1.2120    void(*)(void*,sqlite3*,int eTextRep,const char*)
  1.2121  );
  1.2122 -SQLITE_API int sqlite3_collation_needed16(
  1.2123 +SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16(
  1.2124    sqlite3*, 
  1.2125    void*,
  1.2126    void(*)(void*,sqlite3*,int eTextRep,const void*)
  1.2127 @@ -4617,11 +4860,11 @@
  1.2128  ** The code to implement this API is not available in the public release
  1.2129  ** of SQLite.
  1.2130  */
  1.2131 -SQLITE_API int sqlite3_key(
  1.2132 +SQLITE_API int SQLITE_STDCALL sqlite3_key(
  1.2133    sqlite3 *db,                   /* Database to be rekeyed */
  1.2134    const void *pKey, int nKey     /* The key */
  1.2135  );
  1.2136 -SQLITE_API int sqlite3_key_v2(
  1.2137 +SQLITE_API int SQLITE_STDCALL sqlite3_key_v2(
  1.2138    sqlite3 *db,                   /* Database to be rekeyed */
  1.2139    const char *zDbName,           /* Name of the database */
  1.2140    const void *pKey, int nKey     /* The key */
  1.2141 @@ -4635,11 +4878,11 @@
  1.2142  ** The code to implement this API is not available in the public release
  1.2143  ** of SQLite.
  1.2144  */
  1.2145 -SQLITE_API int sqlite3_rekey(
  1.2146 +SQLITE_API int SQLITE_STDCALL sqlite3_rekey(
  1.2147    sqlite3 *db,                   /* Database to be rekeyed */
  1.2148    const void *pKey, int nKey     /* The new key */
  1.2149  );
  1.2150 -SQLITE_API int sqlite3_rekey_v2(
  1.2151 +SQLITE_API int SQLITE_STDCALL sqlite3_rekey_v2(
  1.2152    sqlite3 *db,                   /* Database to be rekeyed */
  1.2153    const char *zDbName,           /* Name of the database */
  1.2154    const void *pKey, int nKey     /* The new key */
  1.2155 @@ -4649,7 +4892,7 @@
  1.2156  ** Specify the activation key for a SEE database.  Unless 
  1.2157  ** activated, none of the SEE routines will work.
  1.2158  */
  1.2159 -SQLITE_API void sqlite3_activate_see(
  1.2160 +SQLITE_API void SQLITE_STDCALL sqlite3_activate_see(
  1.2161    const char *zPassPhrase        /* Activation phrase */
  1.2162  );
  1.2163  #endif
  1.2164 @@ -4659,7 +4902,7 @@
  1.2165  ** Specify the activation key for a CEROD database.  Unless 
  1.2166  ** activated, none of the CEROD routines will work.
  1.2167  */
  1.2168 -SQLITE_API void sqlite3_activate_cerod(
  1.2169 +SQLITE_API void SQLITE_STDCALL sqlite3_activate_cerod(
  1.2170    const char *zPassPhrase        /* Activation phrase */
  1.2171  );
  1.2172  #endif
  1.2173 @@ -4681,7 +4924,7 @@
  1.2174  ** all, then the behavior of sqlite3_sleep() may deviate from the description
  1.2175  ** in the previous paragraphs.
  1.2176  */
  1.2177 -SQLITE_API int sqlite3_sleep(int);
  1.2178 +SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int);
  1.2179  
  1.2180  /*
  1.2181  ** CAPI3REF: Name Of The Folder Holding Temporary Files
  1.2182 @@ -4781,6 +5024,7 @@
  1.2183  /*
  1.2184  ** CAPI3REF: Test For Auto-Commit Mode
  1.2185  ** KEYWORDS: {autocommit mode}
  1.2186 +** METHOD: sqlite3
  1.2187  **
  1.2188  ** ^The sqlite3_get_autocommit() interface returns non-zero or
  1.2189  ** zero if the given database connection is or is not in autocommit mode,
  1.2190 @@ -4799,10 +5043,11 @@
  1.2191  ** connection while this routine is running, then the return value
  1.2192  ** is undefined.
  1.2193  */
  1.2194 -SQLITE_API int sqlite3_get_autocommit(sqlite3*);
  1.2195 +SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3*);
  1.2196  
  1.2197  /*
  1.2198  ** CAPI3REF: Find The Database Handle Of A Prepared Statement
  1.2199 +** METHOD: sqlite3_stmt
  1.2200  **
  1.2201  ** ^The sqlite3_db_handle interface returns the [database connection] handle
  1.2202  ** to which a [prepared statement] belongs.  ^The [database connection]
  1.2203 @@ -4811,10 +5056,11 @@
  1.2204  ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
  1.2205  ** create the statement in the first place.
  1.2206  */
  1.2207 -SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
  1.2208 +SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt*);
  1.2209  
  1.2210  /*
  1.2211  ** CAPI3REF: Return The Filename For A Database Connection
  1.2212 +** METHOD: sqlite3
  1.2213  **
  1.2214  ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
  1.2215  ** associated with database N of connection D.  ^The main database file
  1.2216 @@ -4827,19 +5073,21 @@
  1.2217  ** will be an absolute pathname, even if the filename used
  1.2218  ** to open the database originally was a URI or relative pathname.
  1.2219  */
  1.2220 -SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
  1.2221 +SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName);
  1.2222  
  1.2223  /*
  1.2224  ** CAPI3REF: Determine if a database is read-only
  1.2225 +** METHOD: sqlite3
  1.2226  **
  1.2227  ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
  1.2228  ** of connection D is read-only, 0 if it is read/write, or -1 if N is not
  1.2229  ** the name of a database on connection D.
  1.2230  */
  1.2231 -SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
  1.2232 +SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
  1.2233  
  1.2234  /*
  1.2235  ** CAPI3REF: Find the next prepared statement
  1.2236 +** METHOD: sqlite3
  1.2237  **
  1.2238  ** ^This interface returns a pointer to the next [prepared statement] after
  1.2239  ** pStmt associated with the [database connection] pDb.  ^If pStmt is NULL
  1.2240 @@ -4851,10 +5099,11 @@
  1.2241  ** [sqlite3_next_stmt(D,S)] must refer to an open database
  1.2242  ** connection and in particular must not be a NULL pointer.
  1.2243  */
  1.2244 -SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
  1.2245 +SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
  1.2246  
  1.2247  /*
  1.2248  ** CAPI3REF: Commit And Rollback Notification Callbacks
  1.2249 +** METHOD: sqlite3
  1.2250  **
  1.2251  ** ^The sqlite3_commit_hook() interface registers a callback
  1.2252  ** function to be invoked whenever a transaction is [COMMIT | committed].
  1.2253 @@ -4899,11 +5148,12 @@
  1.2254  **
  1.2255  ** See also the [sqlite3_update_hook()] interface.
  1.2256  */
  1.2257 -SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
  1.2258 -SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
  1.2259 +SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
  1.2260 +SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
  1.2261  
  1.2262  /*
  1.2263  ** CAPI3REF: Data Change Notification Callbacks
  1.2264 +** METHOD: sqlite3
  1.2265  **
  1.2266  ** ^The sqlite3_update_hook() interface registers a callback function
  1.2267  ** with the [database connection] identified by the first argument
  1.2268 @@ -4950,7 +5200,7 @@
  1.2269  ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
  1.2270  ** interfaces.
  1.2271  */
  1.2272 -SQLITE_API void *sqlite3_update_hook(
  1.2273 +SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
  1.2274    sqlite3*, 
  1.2275    void(*)(void *,int ,char const *,char const *,sqlite3_int64),
  1.2276    void*
  1.2277 @@ -4980,12 +5230,17 @@
  1.2278  ** future releases of SQLite.  Applications that care about shared
  1.2279  ** cache setting should set it explicitly.
  1.2280  **
  1.2281 +** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0
  1.2282 +** and will always return SQLITE_MISUSE. On those systems, 
  1.2283 +** shared cache mode should be enabled per-database connection via 
  1.2284 +** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE].
  1.2285 +**
  1.2286  ** This interface is threadsafe on processors where writing a
  1.2287  ** 32-bit integer is atomic.
  1.2288  **
  1.2289  ** See Also:  [SQLite Shared-Cache Mode]
  1.2290  */
  1.2291 -SQLITE_API int sqlite3_enable_shared_cache(int);
  1.2292 +SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int);
  1.2293  
  1.2294  /*
  1.2295  ** CAPI3REF: Attempt To Free Heap Memory
  1.2296 @@ -5001,10 +5256,11 @@
  1.2297  **
  1.2298  ** See also: [sqlite3_db_release_memory()]
  1.2299  */
  1.2300 -SQLITE_API int sqlite3_release_memory(int);
  1.2301 +SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int);
  1.2302  
  1.2303  /*
  1.2304  ** CAPI3REF: Free Memory Used By A Database Connection
  1.2305 +** METHOD: sqlite3
  1.2306  **
  1.2307  ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
  1.2308  ** memory as possible from database connection D. Unlike the
  1.2309 @@ -5014,7 +5270,7 @@
  1.2310  **
  1.2311  ** See also: [sqlite3_release_memory()]
  1.2312  */
  1.2313 -SQLITE_API int sqlite3_db_release_memory(sqlite3*);
  1.2314 +SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3*);
  1.2315  
  1.2316  /*
  1.2317  ** CAPI3REF: Impose A Limit On Heap Size
  1.2318 @@ -5066,7 +5322,7 @@
  1.2319  ** The circumstances under which SQLite will enforce the soft heap limit may
  1.2320  ** changes in future releases of SQLite.
  1.2321  */
  1.2322 -SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
  1.2323 +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 N);
  1.2324  
  1.2325  /*
  1.2326  ** CAPI3REF: Deprecated Soft Heap Limit Interface
  1.2327 @@ -5077,26 +5333,34 @@
  1.2328  ** only.  All new applications should use the
  1.2329  ** [sqlite3_soft_heap_limit64()] interface rather than this one.
  1.2330  */
  1.2331 -SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
  1.2332 +SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_soft_heap_limit(int N);
  1.2333  
  1.2334  
  1.2335  /*
  1.2336  ** CAPI3REF: Extract Metadata About A Column Of A Table
  1.2337 -**
  1.2338 -** ^This routine returns metadata about a specific column of a specific
  1.2339 -** database table accessible using the [database connection] handle
  1.2340 -** passed as the first function argument.
  1.2341 +** METHOD: sqlite3
  1.2342 +**
  1.2343 +** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
  1.2344 +** information about column C of table T in database D
  1.2345 +** on [database connection] X.)^  ^The sqlite3_table_column_metadata()
  1.2346 +** interface returns SQLITE_OK and fills in the non-NULL pointers in
  1.2347 +** the final five arguments with appropriate values if the specified
  1.2348 +** column exists.  ^The sqlite3_table_column_metadata() interface returns
  1.2349 +** SQLITE_ERROR and if the specified column does not exist.
  1.2350 +** ^If the column-name parameter to sqlite3_table_column_metadata() is a
  1.2351 +** NULL pointer, then this routine simply checks for the existance of the
  1.2352 +** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
  1.2353 +** does not.
  1.2354  **
  1.2355  ** ^The column is identified by the second, third and fourth parameters to
  1.2356 -** this function. ^The second parameter is either the name of the database
  1.2357 +** this function. ^(The second parameter is either the name of the database
  1.2358  ** (i.e. "main", "temp", or an attached database) containing the specified
  1.2359 -** table or NULL. ^If it is NULL, then all attached databases are searched
  1.2360 +** table or NULL.)^ ^If it is NULL, then all attached databases are searched
  1.2361  ** for the table using the same algorithm used by the database engine to
  1.2362  ** resolve unqualified table references.
  1.2363  **
  1.2364  ** ^The third and fourth parameters to this function are the table and column
  1.2365 -** name of the desired column, respectively. Neither of these parameters
  1.2366 -** may be NULL.
  1.2367 +** name of the desired column, respectively.
  1.2368  **
  1.2369  ** ^Metadata is returned by writing to the memory locations passed as the 5th
  1.2370  ** and subsequent parameters to this function. ^Any of these arguments may be
  1.2371 @@ -5115,16 +5379,17 @@
  1.2372  ** </blockquote>)^
  1.2373  **
  1.2374  ** ^The memory pointed to by the character pointers returned for the
  1.2375 -** declaration type and collation sequence is valid only until the next
  1.2376 +** declaration type and collation sequence is valid until the next
  1.2377  ** call to any SQLite API function.
  1.2378  **
  1.2379  ** ^If the specified table is actually a view, an [error code] is returned.
  1.2380  **
  1.2381 -** ^If the specified column is "rowid", "oid" or "_rowid_" and an
  1.2382 +** ^If the specified column is "rowid", "oid" or "_rowid_" and the table 
  1.2383 +** is not a [WITHOUT ROWID] table and an
  1.2384  ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
  1.2385  ** parameters are set for the explicitly declared column. ^(If there is no
  1.2386 -** explicitly declared [INTEGER PRIMARY KEY] column, then the output
  1.2387 -** parameters are set as follows:
  1.2388 +** [INTEGER PRIMARY KEY] column, then the outputs
  1.2389 +** for the [rowid] are set as follows:
  1.2390  **
  1.2391  ** <pre>
  1.2392  **     data type: "INTEGER"
  1.2393 @@ -5134,15 +5399,11 @@
  1.2394  **     auto increment: 0
  1.2395  ** </pre>)^
  1.2396  **
  1.2397 -** ^(This function may load one or more schemas from database files. If an
  1.2398 -** error occurs during this process, or if the requested table or column
  1.2399 -** cannot be found, an [error code] is returned and an error message left
  1.2400 -** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
  1.2401 -**
  1.2402 -** ^This API is only available if the library was compiled with the
  1.2403 -** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
  1.2404 -*/
  1.2405 -SQLITE_API int sqlite3_table_column_metadata(
  1.2406 +** ^This function causes all database schemas to be read from disk and
  1.2407 +** parsed, if that has not already been done, and returns an error if
  1.2408 +** any errors are encountered while loading the schema.
  1.2409 +*/
  1.2410 +SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
  1.2411    sqlite3 *db,                /* Connection handle */
  1.2412    const char *zDbName,        /* Database name or NULL */
  1.2413    const char *zTableName,     /* Table name */
  1.2414 @@ -5156,6 +5417,7 @@
  1.2415  
  1.2416  /*
  1.2417  ** CAPI3REF: Load An Extension
  1.2418 +** METHOD: sqlite3
  1.2419  **
  1.2420  ** ^This interface loads an SQLite extension library from the named file.
  1.2421  **
  1.2422 @@ -5188,7 +5450,7 @@
  1.2423  **
  1.2424  ** See also the [load_extension() SQL function].
  1.2425  */
  1.2426 -SQLITE_API int sqlite3_load_extension(
  1.2427 +SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
  1.2428    sqlite3 *db,          /* Load the extension into this database connection */
  1.2429    const char *zFile,    /* Name of the shared library containing extension */
  1.2430    const char *zProc,    /* Entry point.  Derived from zFile if 0 */
  1.2431 @@ -5197,6 +5459,7 @@
  1.2432  
  1.2433  /*
  1.2434  ** CAPI3REF: Enable Or Disable Extension Loading
  1.2435 +** METHOD: sqlite3
  1.2436  **
  1.2437  ** ^So as not to open security holes in older applications that are
  1.2438  ** unprepared to deal with [extension loading], and as a means of disabling
  1.2439 @@ -5208,7 +5471,7 @@
  1.2440  ** to turn extension loading on and call it with onoff==0 to turn
  1.2441  ** it back off again.
  1.2442  */
  1.2443 -SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
  1.2444 +SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff);
  1.2445  
  1.2446  /*
  1.2447  ** CAPI3REF: Automatically Load Statically Linked Extensions
  1.2448 @@ -5246,7 +5509,7 @@
  1.2449  ** See also: [sqlite3_reset_auto_extension()]
  1.2450  ** and [sqlite3_cancel_auto_extension()]
  1.2451  */
  1.2452 -SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
  1.2453 +SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
  1.2454  
  1.2455  /*
  1.2456  ** CAPI3REF: Cancel Automatic Extension Loading
  1.2457 @@ -5258,7 +5521,7 @@
  1.2458  ** unregistered and it returns 0 if X was not on the list of initialization
  1.2459  ** routines.
  1.2460  */
  1.2461 -SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
  1.2462 +SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
  1.2463  
  1.2464  /*
  1.2465  ** CAPI3REF: Reset Automatic Extension Loading
  1.2466 @@ -5266,7 +5529,7 @@
  1.2467  ** ^This interface disables all automatic extensions previously
  1.2468  ** registered using [sqlite3_auto_extension()].
  1.2469  */
  1.2470 -SQLITE_API void sqlite3_reset_auto_extension(void);
  1.2471 +SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void);
  1.2472  
  1.2473  /*
  1.2474  ** The interface to the virtual-table mechanism is currently considered
  1.2475 @@ -5368,6 +5631,17 @@
  1.2476  ** ^Information about the ORDER BY clause is stored in aOrderBy[].
  1.2477  ** ^Each term of aOrderBy records a column of the ORDER BY clause.
  1.2478  **
  1.2479 +** The colUsed field indicates which columns of the virtual table may be
  1.2480 +** required by the current scan. Virtual table columns are numbered from
  1.2481 +** zero in the order in which they appear within the CREATE TABLE statement
  1.2482 +** passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62),
  1.2483 +** the corresponding bit is set within the colUsed mask if the column may be
  1.2484 +** required by SQLite. If the table has at least 64 columns and any column
  1.2485 +** to the right of the first 63 is required, then bit 63 of colUsed is also
  1.2486 +** set. In other words, column iCol may be required if the expression
  1.2487 +** (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to 
  1.2488 +** non-zero.
  1.2489 +**
  1.2490  ** The [xBestIndex] method must fill aConstraintUsage[] with information
  1.2491  ** about what parameters to pass to xFilter.  ^If argvIndex>0 then
  1.2492  ** the right-hand side of the corresponding aConstraint[] is evaluated
  1.2493 @@ -5393,19 +5667,37 @@
  1.2494  ** ^The estimatedRows value is an estimate of the number of rows that
  1.2495  ** will be returned by the strategy.
  1.2496  **
  1.2497 +** The xBestIndex method may optionally populate the idxFlags field with a 
  1.2498 +** mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag -
  1.2499 +** SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite
  1.2500 +** assumes that the strategy may visit at most one row. 
  1.2501 +**
  1.2502 +** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then
  1.2503 +** SQLite also assumes that if a call to the xUpdate() method is made as
  1.2504 +** part of the same statement to delete or update a virtual table row and the
  1.2505 +** implementation returns SQLITE_CONSTRAINT, then there is no need to rollback
  1.2506 +** any database changes. In other words, if the xUpdate() returns
  1.2507 +** SQLITE_CONSTRAINT, the database contents must be exactly as they were
  1.2508 +** before xUpdate was called. By contrast, if SQLITE_INDEX_SCAN_UNIQUE is not
  1.2509 +** set and xUpdate returns SQLITE_CONSTRAINT, any database changes made by
  1.2510 +** the xUpdate method are automatically rolled back by SQLite.
  1.2511 +**
  1.2512  ** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info
  1.2513  ** structure for SQLite version 3.8.2. If a virtual table extension is
  1.2514  ** used with an SQLite version earlier than 3.8.2, the results of attempting 
  1.2515  ** to read or write the estimatedRows field are undefined (but are likely 
  1.2516  ** to included crashing the application). The estimatedRows field should
  1.2517  ** therefore only be used if [sqlite3_libversion_number()] returns a
  1.2518 -** value greater than or equal to 3008002.
  1.2519 +** value greater than or equal to 3008002. Similarly, the idxFlags field
  1.2520 +** was added for version 3.9.0. It may therefore only be used if
  1.2521 +** sqlite3_libversion_number() returns a value greater than or equal to
  1.2522 +** 3009000.
  1.2523  */
  1.2524  struct sqlite3_index_info {
  1.2525    /* Inputs */
  1.2526    int nConstraint;           /* Number of entries in aConstraint */
  1.2527    struct sqlite3_index_constraint {
  1.2528 -     int iColumn;              /* Column on left-hand side of constraint */
  1.2529 +     int iColumn;              /* Column constrained.  -1 for ROWID */
  1.2530       unsigned char op;         /* Constraint operator */
  1.2531       unsigned char usable;     /* True if this constraint is usable */
  1.2532       int iTermOffset;          /* Used internally - xBestIndex should ignore */
  1.2533 @@ -5427,9 +5719,18 @@
  1.2534    double estimatedCost;           /* Estimated cost of using this index */
  1.2535    /* Fields below are only available in SQLite 3.8.2 and later */
  1.2536    sqlite3_int64 estimatedRows;    /* Estimated number of rows returned */
  1.2537 +  /* Fields below are only available in SQLite 3.9.0 and later */
  1.2538 +  int idxFlags;              /* Mask of SQLITE_INDEX_SCAN_* flags */
  1.2539 +  /* Fields below are only available in SQLite 3.10.0 and later */
  1.2540 +  sqlite3_uint64 colUsed;    /* Input: Mask of columns used by statement */
  1.2541  };
  1.2542  
  1.2543  /*
  1.2544 +** CAPI3REF: Virtual Table Scan Flags
  1.2545 +*/
  1.2546 +#define SQLITE_INDEX_SCAN_UNIQUE      1     /* Scan visits at most 1 row */
  1.2547 +
  1.2548 +/*
  1.2549  ** CAPI3REF: Virtual Table Constraint Operator Codes
  1.2550  **
  1.2551  ** These macros defined the allowed values for the
  1.2552 @@ -5437,15 +5738,19 @@
  1.2553  ** an operator that is part of a constraint term in the wHERE clause of
  1.2554  ** a query that uses a [virtual table].
  1.2555  */
  1.2556 -#define SQLITE_INDEX_CONSTRAINT_EQ    2
  1.2557 -#define SQLITE_INDEX_CONSTRAINT_GT    4
  1.2558 -#define SQLITE_INDEX_CONSTRAINT_LE    8
  1.2559 -#define SQLITE_INDEX_CONSTRAINT_LT    16
  1.2560 -#define SQLITE_INDEX_CONSTRAINT_GE    32
  1.2561 -#define SQLITE_INDEX_CONSTRAINT_MATCH 64
  1.2562 +#define SQLITE_INDEX_CONSTRAINT_EQ      2
  1.2563 +#define SQLITE_INDEX_CONSTRAINT_GT      4
  1.2564 +#define SQLITE_INDEX_CONSTRAINT_LE      8
  1.2565 +#define SQLITE_INDEX_CONSTRAINT_LT     16
  1.2566 +#define SQLITE_INDEX_CONSTRAINT_GE     32
  1.2567 +#define SQLITE_INDEX_CONSTRAINT_MATCH  64
  1.2568 +#define SQLITE_INDEX_CONSTRAINT_LIKE   65
  1.2569 +#define SQLITE_INDEX_CONSTRAINT_GLOB   66
  1.2570 +#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
  1.2571  
  1.2572  /*
  1.2573  ** CAPI3REF: Register A Virtual Table Implementation
  1.2574 +** METHOD: sqlite3
  1.2575  **
  1.2576  ** ^These routines are used to register a new [virtual table module] name.
  1.2577  ** ^Module names must be registered before
  1.2578 @@ -5469,13 +5774,13 @@
  1.2579  ** interface is equivalent to sqlite3_create_module_v2() with a NULL
  1.2580  ** destructor.
  1.2581  */
  1.2582 -SQLITE_API int sqlite3_create_module(
  1.2583 +SQLITE_API int SQLITE_STDCALL sqlite3_create_module(
  1.2584    sqlite3 *db,               /* SQLite connection to register module with */
  1.2585    const char *zName,         /* Name of the module */
  1.2586    const sqlite3_module *p,   /* Methods for the module */
  1.2587    void *pClientData          /* Client data for xCreate/xConnect */
  1.2588  );
  1.2589 -SQLITE_API int sqlite3_create_module_v2(
  1.2590 +SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2(
  1.2591    sqlite3 *db,               /* SQLite connection to register module with */
  1.2592    const char *zName,         /* Name of the module */
  1.2593    const sqlite3_module *p,   /* Methods for the module */
  1.2594 @@ -5503,7 +5808,7 @@
  1.2595  */
  1.2596  struct sqlite3_vtab {
  1.2597    const sqlite3_module *pModule;  /* The module for this virtual table */
  1.2598 -  int nRef;                       /* NO LONGER USED */
  1.2599 +  int nRef;                       /* Number of open cursors */
  1.2600    char *zErrMsg;                  /* Error message from sqlite3_mprintf() */
  1.2601    /* Virtual table implementations will typically add additional fields */
  1.2602  };
  1.2603 @@ -5538,10 +5843,11 @@
  1.2604  ** to declare the format (the names and datatypes of the columns) of
  1.2605  ** the virtual tables they implement.
  1.2606  */
  1.2607 -SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
  1.2608 +SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3*, const char *zSQL);
  1.2609  
  1.2610  /*
  1.2611  ** CAPI3REF: Overload A Function For A Virtual Table
  1.2612 +** METHOD: sqlite3
  1.2613  **
  1.2614  ** ^(Virtual tables can provide alternative implementations of functions
  1.2615  ** using the [xFindFunction] method of the [virtual table module].  
  1.2616 @@ -5556,7 +5862,7 @@
  1.2617  ** purpose is to be a placeholder function that can be overloaded
  1.2618  ** by a [virtual table].
  1.2619  */
  1.2620 -SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
  1.2621 +SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
  1.2622  
  1.2623  /*
  1.2624  ** The interface to the virtual-table mechanism defined above (back up
  1.2625 @@ -5584,6 +5890,8 @@
  1.2626  
  1.2627  /*
  1.2628  ** CAPI3REF: Open A BLOB For Incremental I/O
  1.2629 +** METHOD: sqlite3
  1.2630 +** CONSTRUCTOR: sqlite3_blob
  1.2631  **
  1.2632  ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located
  1.2633  ** in row iRow, column zColumn, table zTable in database zDb;
  1.2634 @@ -5593,26 +5901,42 @@
  1.2635  **     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
  1.2636  ** </pre>)^
  1.2637  **
  1.2638 +** ^(Parameter zDb is not the filename that contains the database, but 
  1.2639 +** rather the symbolic name of the database. For attached databases, this is
  1.2640 +** the name that appears after the AS keyword in the [ATTACH] statement.
  1.2641 +** For the main database file, the database name is "main". For TEMP
  1.2642 +** tables, the database name is "temp".)^
  1.2643 +**
  1.2644  ** ^If the flags parameter is non-zero, then the BLOB is opened for read
  1.2645 -** and write access. ^If it is zero, the BLOB is opened for read access.
  1.2646 -** ^It is not possible to open a column that is part of an index or primary 
  1.2647 -** key for writing. ^If [foreign key constraints] are enabled, it is 
  1.2648 -** not possible to open a column that is part of a [child key] for writing.
  1.2649 -**
  1.2650 -** ^Note that the database name is not the filename that contains
  1.2651 -** the database but rather the symbolic name of the database that
  1.2652 -** appears after the AS keyword when the database is connected using [ATTACH].
  1.2653 -** ^For the main database file, the database name is "main".
  1.2654 -** ^For TEMP tables, the database name is "temp".
  1.2655 -**
  1.2656 -** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written
  1.2657 -** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set
  1.2658 -** to be a null pointer.)^
  1.2659 -** ^This function sets the [database connection] error code and message
  1.2660 -** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related
  1.2661 -** functions. ^Note that the *ppBlob variable is always initialized in a
  1.2662 -** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob
  1.2663 -** regardless of the success or failure of this routine.
  1.2664 +** and write access. ^If the flags parameter is zero, the BLOB is opened for
  1.2665 +** read-only access.
  1.2666 +**
  1.2667 +** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is stored
  1.2668 +** in *ppBlob. Otherwise an [error code] is returned and, unless the error
  1.2669 +** code is SQLITE_MISUSE, *ppBlob is set to NULL.)^ ^This means that, provided
  1.2670 +** the API is not misused, it is always safe to call [sqlite3_blob_close()] 
  1.2671 +** on *ppBlob after this function it returns.
  1.2672 +**
  1.2673 +** This function fails with SQLITE_ERROR if any of the following are true:
  1.2674 +** <ul>
  1.2675 +**   <li> ^(Database zDb does not exist)^, 
  1.2676 +**   <li> ^(Table zTable does not exist within database zDb)^, 
  1.2677 +**   <li> ^(Table zTable is a WITHOUT ROWID table)^, 
  1.2678 +**   <li> ^(Column zColumn does not exist)^,
  1.2679 +**   <li> ^(Row iRow is not present in the table)^,
  1.2680 +**   <li> ^(The specified column of row iRow contains a value that is not
  1.2681 +**         a TEXT or BLOB value)^,
  1.2682 +**   <li> ^(Column zColumn is part of an index, PRIMARY KEY or UNIQUE 
  1.2683 +**         constraint and the blob is being opened for read/write access)^,
  1.2684 +**   <li> ^([foreign key constraints | Foreign key constraints] are enabled, 
  1.2685 +**         column zColumn is part of a [child key] definition and the blob is
  1.2686 +**         being opened for read/write access)^.
  1.2687 +** </ul>
  1.2688 +**
  1.2689 +** ^Unless it returns SQLITE_MISUSE, this function sets the 
  1.2690 +** [database connection] error code and message accessible via 
  1.2691 +** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. 
  1.2692 +**
  1.2693  **
  1.2694  ** ^(If the row that a BLOB handle points to is modified by an
  1.2695  ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects
  1.2696 @@ -5630,18 +5954,14 @@
  1.2697  ** interface.  Use the [UPDATE] SQL command to change the size of a
  1.2698  ** blob.
  1.2699  **
  1.2700 -** ^The [sqlite3_blob_open()] interface will fail for a [WITHOUT ROWID]
  1.2701 -** table.  Incremental BLOB I/O is not possible on [WITHOUT ROWID] tables.
  1.2702 -**
  1.2703  ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
  1.2704 -** and the built-in [zeroblob] SQL function can be used, if desired,
  1.2705 -** to create an empty, zero-filled blob in which to read or write using
  1.2706 -** this interface.
  1.2707 +** and the built-in [zeroblob] SQL function may be used to create a 
  1.2708 +** zero-filled blob to read or write using the incremental-blob interface.
  1.2709  **
  1.2710  ** To avoid a resource leak, every open [BLOB handle] should eventually
  1.2711  ** be released by a call to [sqlite3_blob_close()].
  1.2712  */
  1.2713 -SQLITE_API int sqlite3_blob_open(
  1.2714 +SQLITE_API int SQLITE_STDCALL sqlite3_blob_open(
  1.2715    sqlite3*,
  1.2716    const char *zDb,
  1.2717    const char *zTable,
  1.2718 @@ -5653,6 +5973,7 @@
  1.2719  
  1.2720  /*
  1.2721  ** CAPI3REF: Move a BLOB Handle to a New Row
  1.2722 +** METHOD: sqlite3_blob
  1.2723  **
  1.2724  ** ^This function is used to move an existing blob handle so that it points
  1.2725  ** to a different row of the same database table. ^The new row is identified
  1.2726 @@ -5673,34 +5994,34 @@
  1.2727  **
  1.2728  ** ^This function sets the database handle error code and message.
  1.2729  */
  1.2730 -SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
  1.2731 +SQLITE_API int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
  1.2732  
  1.2733  /*
  1.2734  ** CAPI3REF: Close A BLOB Handle
  1.2735 -**
  1.2736 -** ^Closes an open [BLOB handle].
  1.2737 -**
  1.2738 -** ^Closing a BLOB shall cause the current transaction to commit
  1.2739 -** if there are no other BLOBs, no pending prepared statements, and the
  1.2740 -** database connection is in [autocommit mode].
  1.2741 -** ^If any writes were made to the BLOB, they might be held in cache
  1.2742 -** until the close operation if they will fit.
  1.2743 -**
  1.2744 -** ^(Closing the BLOB often forces the changes
  1.2745 -** out to disk and so if any I/O errors occur, they will likely occur
  1.2746 -** at the time when the BLOB is closed.  Any errors that occur during
  1.2747 -** closing are reported as a non-zero return value.)^
  1.2748 -**
  1.2749 -** ^(The BLOB is closed unconditionally.  Even if this routine returns
  1.2750 -** an error code, the BLOB is still closed.)^
  1.2751 -**
  1.2752 -** ^Calling this routine with a null pointer (such as would be returned
  1.2753 -** by a failed call to [sqlite3_blob_open()]) is a harmless no-op.
  1.2754 -*/
  1.2755 -SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
  1.2756 +** DESTRUCTOR: sqlite3_blob
  1.2757 +**
  1.2758 +** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed
  1.2759 +** unconditionally.  Even if this routine returns an error code, the 
  1.2760 +** handle is still closed.)^
  1.2761 +**
  1.2762 +** ^If the blob handle being closed was opened for read-write access, and if
  1.2763 +** the database is in auto-commit mode and there are no other open read-write
  1.2764 +** blob handles or active write statements, the current transaction is
  1.2765 +** committed. ^If an error occurs while committing the transaction, an error
  1.2766 +** code is returned and the transaction rolled back.
  1.2767 +**
  1.2768 +** Calling this function with an argument that is not a NULL pointer or an
  1.2769 +** open blob handle results in undefined behaviour. ^Calling this routine 
  1.2770 +** with a null pointer (such as would be returned by a failed call to 
  1.2771 +** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
  1.2772 +** is passed a valid open blob handle, the values returned by the 
  1.2773 +** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
  1.2774 +*/
  1.2775 +SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *);
  1.2776  
  1.2777  /*
  1.2778  ** CAPI3REF: Return The Size Of An Open BLOB
  1.2779 +** METHOD: sqlite3_blob
  1.2780  **
  1.2781  ** ^Returns the size in bytes of the BLOB accessible via the 
  1.2782  ** successfully opened [BLOB handle] in its only argument.  ^The
  1.2783 @@ -5712,10 +6033,11 @@
  1.2784  ** been closed by [sqlite3_blob_close()].  Passing any other pointer in
  1.2785  ** to this routine results in undefined and probably undesirable behavior.
  1.2786  */
  1.2787 -SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
  1.2788 +SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *);
  1.2789  
  1.2790  /*
  1.2791  ** CAPI3REF: Read Data From A BLOB Incrementally
  1.2792 +** METHOD: sqlite3_blob
  1.2793  **
  1.2794  ** ^(This function is used to read data from an open [BLOB handle] into a
  1.2795  ** caller-supplied buffer. N bytes of data are copied into buffer Z
  1.2796 @@ -5740,26 +6062,33 @@
  1.2797  **
  1.2798  ** See also: [sqlite3_blob_write()].
  1.2799  */
  1.2800 -SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
  1.2801 +SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
  1.2802  
  1.2803  /*
  1.2804  ** CAPI3REF: Write Data Into A BLOB Incrementally
  1.2805 -**
  1.2806 -** ^This function is used to write data into an open [BLOB handle] from a
  1.2807 -** caller-supplied buffer. ^N bytes of data are copied from the buffer Z
  1.2808 -** into the open BLOB, starting at offset iOffset.
  1.2809 +** METHOD: sqlite3_blob
  1.2810 +**
  1.2811 +** ^(This function is used to write data into an open [BLOB handle] from a
  1.2812 +** caller-supplied buffer. N bytes of data are copied from the buffer Z
  1.2813 +** into the open BLOB, starting at offset iOffset.)^
  1.2814 +**
  1.2815 +** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
  1.2816 +** Otherwise, an  [error code] or an [extended error code] is returned.)^
  1.2817 +** ^Unless SQLITE_MISUSE is returned, this function sets the 
  1.2818 +** [database connection] error code and message accessible via 
  1.2819 +** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. 
  1.2820  **
  1.2821  ** ^If the [BLOB handle] passed as the first argument was not opened for
  1.2822  ** writing (the flags parameter to [sqlite3_blob_open()] was zero),
  1.2823  ** this function returns [SQLITE_READONLY].
  1.2824  **
  1.2825 -** ^This function may only modify the contents of the BLOB; it is
  1.2826 +** This function may only modify the contents of the BLOB; it is
  1.2827  ** not possible to increase the size of a BLOB using this API.
  1.2828  ** ^If offset iOffset is less than N bytes from the end of the BLOB,
  1.2829 -** [SQLITE_ERROR] is returned and no data is written.  ^If N is
  1.2830 -** less than zero [SQLITE_ERROR] is returned and no data is written.
  1.2831 -** The size of the BLOB (and hence the maximum value of N+iOffset)
  1.2832 -** can be determined using the [sqlite3_blob_bytes()] interface.
  1.2833 +** [SQLITE_ERROR] is returned and no data is written. The size of the 
  1.2834 +** BLOB (and hence the maximum value of N+iOffset) can be determined 
  1.2835 +** using the [sqlite3_blob_bytes()] interface. ^If N or iOffset are less 
  1.2836 +** than zero [SQLITE_ERROR] is returned and no data is written.
  1.2837  **
  1.2838  ** ^An attempt to write to an expired [BLOB handle] fails with an
  1.2839  ** error code of [SQLITE_ABORT].  ^Writes to the BLOB that occurred
  1.2840 @@ -5768,9 +6097,6 @@
  1.2841  ** have been overwritten by the statement that expired the BLOB handle
  1.2842  ** or by other independent statements.
  1.2843  **
  1.2844 -** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
  1.2845 -** Otherwise, an  [error code] or an [extended error code] is returned.)^
  1.2846 -**
  1.2847  ** This routine only works on a [BLOB handle] which has been created
  1.2848  ** by a prior successful call to [sqlite3_blob_open()] and which has not
  1.2849  ** been closed by [sqlite3_blob_close()].  Passing any other pointer in
  1.2850 @@ -5778,7 +6104,7 @@
  1.2851  **
  1.2852  ** See also: [sqlite3_blob_read()].
  1.2853  */
  1.2854 -SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
  1.2855 +SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
  1.2856  
  1.2857  /*
  1.2858  ** CAPI3REF: Virtual File System Objects
  1.2859 @@ -5809,9 +6135,9 @@
  1.2860  ** ^(If the default VFS is unregistered, another VFS is chosen as
  1.2861  ** the default.  The choice for the new VFS is arbitrary.)^
  1.2862  */
  1.2863 -SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
  1.2864 -SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
  1.2865 -SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
  1.2866 +SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfsName);
  1.2867 +SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
  1.2868 +SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs*);
  1.2869  
  1.2870  /*
  1.2871  ** CAPI3REF: Mutexes
  1.2872 @@ -5823,34 +6149,34 @@
  1.2873  **
  1.2874  ** The SQLite source code contains multiple implementations
  1.2875  ** of these mutex routines.  An appropriate implementation
  1.2876 -** is selected automatically at compile-time.  ^(The following
  1.2877 +** is selected automatically at compile-time.  The following
  1.2878  ** implementations are available in the SQLite core:
  1.2879  **
  1.2880  ** <ul>
  1.2881  ** <li>   SQLITE_MUTEX_PTHREADS
  1.2882  ** <li>   SQLITE_MUTEX_W32
  1.2883  ** <li>   SQLITE_MUTEX_NOOP
  1.2884 -** </ul>)^
  1.2885 -**
  1.2886 -** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
  1.2887 +** </ul>
  1.2888 +**
  1.2889 +** The SQLITE_MUTEX_NOOP implementation is a set of routines
  1.2890  ** that does no real locking and is appropriate for use in
  1.2891 -** a single-threaded application.  ^The SQLITE_MUTEX_PTHREADS and
  1.2892 +** a single-threaded application.  The SQLITE_MUTEX_PTHREADS and
  1.2893  ** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix
  1.2894  ** and Windows.
  1.2895  **
  1.2896 -** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
  1.2897 +** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
  1.2898  ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
  1.2899  ** implementation is included with the library. In this case the
  1.2900  ** application must supply a custom mutex implementation using the
  1.2901  ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function
  1.2902  ** before calling sqlite3_initialize() or any other public sqlite3_
  1.2903 -** function that calls sqlite3_initialize().)^
  1.2904 +** function that calls sqlite3_initialize().
  1.2905  **
  1.2906  ** ^The sqlite3_mutex_alloc() routine allocates a new
  1.2907 -** mutex and returns a pointer to it. ^If it returns NULL
  1.2908 -** that means that a mutex could not be allocated.  ^SQLite
  1.2909 -** will unwind its stack and return an error.  ^(The argument
  1.2910 -** to sqlite3_mutex_alloc() is one of these integer constants:
  1.2911 +** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()
  1.2912 +** routine returns NULL if it is unable to allocate the requested
  1.2913 +** mutex.  The argument to sqlite3_mutex_alloc() must one of these
  1.2914 +** integer constants:
  1.2915  **
  1.2916  ** <ul>
  1.2917  ** <li>  SQLITE_MUTEX_FAST
  1.2918 @@ -5863,7 +6189,11 @@
  1.2919  ** <li>  SQLITE_MUTEX_STATIC_PMEM
  1.2920  ** <li>  SQLITE_MUTEX_STATIC_APP1
  1.2921  ** <li>  SQLITE_MUTEX_STATIC_APP2
  1.2922 -** </ul>)^
  1.2923 +** <li>  SQLITE_MUTEX_STATIC_APP3
  1.2924 +** <li>  SQLITE_MUTEX_STATIC_VFS1
  1.2925 +** <li>  SQLITE_MUTEX_STATIC_VFS2
  1.2926 +** <li>  SQLITE_MUTEX_STATIC_VFS3
  1.2927 +** </ul>
  1.2928  **
  1.2929  ** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)
  1.2930  ** cause sqlite3_mutex_alloc() to create
  1.2931 @@ -5871,14 +6201,14 @@
  1.2932  ** is used but not necessarily so when SQLITE_MUTEX_FAST is used.
  1.2933  ** The mutex implementation does not need to make a distinction
  1.2934  ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
  1.2935 -** not want to.  ^SQLite will only request a recursive mutex in
  1.2936 -** cases where it really needs one.  ^If a faster non-recursive mutex
  1.2937 +** not want to.  SQLite will only request a recursive mutex in
  1.2938 +** cases where it really needs one.  If a faster non-recursive mutex
  1.2939  ** implementation is available on the host platform, the mutex subsystem
  1.2940  ** might return such a mutex in response to SQLITE_MUTEX_FAST.
  1.2941  **
  1.2942  ** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other
  1.2943  ** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return
  1.2944 -** a pointer to a static preexisting mutex.  ^Six static mutexes are
  1.2945 +** a pointer to a static preexisting mutex.  ^Nine static mutexes are
  1.2946  ** used by the current version of SQLite.  Future versions of SQLite
  1.2947  ** may add additional static mutexes.  Static mutexes are for internal
  1.2948  ** use by SQLite only.  Applications that use SQLite mutexes should
  1.2949 @@ -5887,16 +6217,13 @@
  1.2950  **
  1.2951  ** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
  1.2952  ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()
  1.2953 -** returns a different mutex on every call.  ^But for the static
  1.2954 +** returns a different mutex on every call.  ^For the static
  1.2955  ** mutex types, the same mutex is returned on every call that has
  1.2956  ** the same type number.
  1.2957  **
  1.2958  ** ^The sqlite3_mutex_free() routine deallocates a previously
  1.2959 -** allocated dynamic mutex.  ^SQLite is careful to deallocate every
  1.2960 -** dynamic mutex that it allocates.  The dynamic mutexes must not be in
  1.2961 -** use when they are deallocated.  Attempting to deallocate a static
  1.2962 -** mutex results in undefined behavior.  ^SQLite never deallocates
  1.2963 -** a static mutex.
  1.2964 +** allocated dynamic mutex.  Attempting to deallocate a static
  1.2965 +** mutex results in undefined behavior.
  1.2966  **
  1.2967  ** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
  1.2968  ** to enter a mutex.  ^If another thread is already within the mutex,
  1.2969 @@ -5904,23 +6231,21 @@
  1.2970  ** SQLITE_BUSY.  ^The sqlite3_mutex_try() interface returns [SQLITE_OK]
  1.2971  ** upon successful entry.  ^(Mutexes created using
  1.2972  ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.
  1.2973 -** In such cases the,
  1.2974 +** In such cases, the
  1.2975  ** mutex must be exited an equal number of times before another thread
  1.2976 -** can enter.)^  ^(If the same thread tries to enter any other
  1.2977 -** kind of mutex more than once, the behavior is undefined.
  1.2978 -** SQLite will never exhibit
  1.2979 -** such behavior in its own use of mutexes.)^
  1.2980 +** can enter.)^  If the same thread tries to enter any mutex other
  1.2981 +** than an SQLITE_MUTEX_RECURSIVE more than once, the behavior is undefined.
  1.2982  **
  1.2983  ** ^(Some systems (for example, Windows 95) do not support the operation
  1.2984  ** implemented by sqlite3_mutex_try().  On those systems, sqlite3_mutex_try()
  1.2985 -** will always return SQLITE_BUSY.  The SQLite core only ever uses
  1.2986 -** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^
  1.2987 +** will always return SQLITE_BUSY. The SQLite core only ever uses
  1.2988 +** sqlite3_mutex_try() as an optimization so this is acceptable 
  1.2989 +** behavior.)^
  1.2990  **
  1.2991  ** ^The sqlite3_mutex_leave() routine exits a mutex that was
  1.2992 -** previously entered by the same thread.   ^(The behavior
  1.2993 +** previously entered by the same thread.   The behavior
  1.2994  ** is undefined if the mutex is not currently entered by the
  1.2995 -** calling thread or is not currently allocated.  SQLite will
  1.2996 -** never do either.)^
  1.2997 +** calling thread or is not currently allocated.
  1.2998  **
  1.2999  ** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
  1.3000  ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
  1.3001 @@ -5928,11 +6253,11 @@
  1.3002  **
  1.3003  ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
  1.3004  */
  1.3005 -SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);
  1.3006 -SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);
  1.3007 -SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
  1.3008 -SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
  1.3009 -SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
  1.3010 +SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int);
  1.3011 +SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex*);
  1.3012 +SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex*);
  1.3013 +SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex*);
  1.3014 +SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex*);
  1.3015  
  1.3016  /*
  1.3017  ** CAPI3REF: Mutex Methods Object
  1.3018 @@ -5941,9 +6266,9 @@
  1.3019  ** used to allocate and use mutexes.
  1.3020  **
  1.3021  ** Usually, the default mutex implementations provided by SQLite are
  1.3022 -** sufficient, however the user has the option of substituting a custom
  1.3023 +** sufficient, however the application has the option of substituting a custom
  1.3024  ** implementation for specialized deployments or systems for which SQLite
  1.3025 -** does not provide a suitable implementation. In this case, the user
  1.3026 +** does not provide a suitable implementation. In this case, the application
  1.3027  ** creates and populates an instance of this structure to pass
  1.3028  ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.
  1.3029  ** Additionally, an instance of this structure can be used as an
  1.3030 @@ -5984,13 +6309,13 @@
  1.3031  ** (i.e. it is acceptable to provide an implementation that segfaults if
  1.3032  ** it is passed a NULL pointer).
  1.3033  **
  1.3034 -** The xMutexInit() method must be threadsafe.  ^It must be harmless to
  1.3035 +** The xMutexInit() method must be threadsafe.  It must be harmless to
  1.3036  ** invoke xMutexInit() multiple times within the same process and without
  1.3037  ** intervening calls to xMutexEnd().  Second and subsequent calls to
  1.3038  ** xMutexInit() must be no-ops.
  1.3039  **
  1.3040 -** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
  1.3041 -** and its associates).  ^Similarly, xMutexAlloc() must not use SQLite memory
  1.3042 +** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
  1.3043 +** and its associates).  Similarly, xMutexAlloc() must not use SQLite memory
  1.3044  ** allocation for a static mutex.  ^However xMutexAlloc() may use SQLite
  1.3045  ** memory allocation for a fast or recursive mutex.
  1.3046  **
  1.3047 @@ -6016,34 +6341,34 @@
  1.3048  ** CAPI3REF: Mutex Verification Routines
  1.3049  **
  1.3050  ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines
  1.3051 -** are intended for use inside assert() statements.  ^The SQLite core
  1.3052 +** are intended for use inside assert() statements.  The SQLite core
  1.3053  ** never uses these routines except inside an assert() and applications
  1.3054 -** are advised to follow the lead of the core.  ^The SQLite core only
  1.3055 +** are advised to follow the lead of the core.  The SQLite core only
  1.3056  ** provides implementations for these routines when it is compiled
  1.3057 -** with the SQLITE_DEBUG flag.  ^External mutex implementations
  1.3058 +** with the SQLITE_DEBUG flag.  External mutex implementations
  1.3059  ** are only required to provide these routines if SQLITE_DEBUG is
  1.3060  ** defined and if NDEBUG is not defined.
  1.3061  **
  1.3062 -** ^These routines should return true if the mutex in their argument
  1.3063 +** These routines should return true if the mutex in their argument
  1.3064  ** is held or not held, respectively, by the calling thread.
  1.3065  **
  1.3066 -** ^The implementation is not required to provide versions of these
  1.3067 +** The implementation is not required to provide versions of these
  1.3068  ** routines that actually work. If the implementation does not provide working
  1.3069  ** versions of these routines, it should at least provide stubs that always
  1.3070  ** return true so that one does not get spurious assertion failures.
  1.3071  **
  1.3072 -** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
  1.3073 +** If the argument to sqlite3_mutex_held() is a NULL pointer then
  1.3074  ** the routine should return 1.   This seems counter-intuitive since
  1.3075  ** clearly the mutex cannot be held if it does not exist.  But
  1.3076  ** the reason the mutex does not exist is because the build is not
  1.3077  ** using mutexes.  And we do not want the assert() containing the
  1.3078  ** call to sqlite3_mutex_held() to fail, so a non-zero return is
  1.3079 -** the appropriate thing to do.  ^The sqlite3_mutex_notheld()
  1.3080 +** the appropriate thing to do.  The sqlite3_mutex_notheld()
  1.3081  ** interface should also return 1 when given a NULL pointer.
  1.3082  */
  1.3083  #ifndef NDEBUG
  1.3084 -SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
  1.3085 -SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
  1.3086 +SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex*);
  1.3087 +SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex*);
  1.3088  #endif
  1.3089  
  1.3090  /*
  1.3091 @@ -6069,9 +6394,13 @@
  1.3092  #define SQLITE_MUTEX_STATIC_APP1      8  /* For use by application */
  1.3093  #define SQLITE_MUTEX_STATIC_APP2      9  /* For use by application */
  1.3094  #define SQLITE_MUTEX_STATIC_APP3     10  /* For use by application */
  1.3095 +#define SQLITE_MUTEX_STATIC_VFS1     11  /* For use by built-in VFS */
  1.3096 +#define SQLITE_MUTEX_STATIC_VFS2     12  /* For use by extension VFS */
  1.3097 +#define SQLITE_MUTEX_STATIC_VFS3     13  /* For use by application VFS */
  1.3098  
  1.3099  /*
  1.3100  ** CAPI3REF: Retrieve the mutex for a database connection
  1.3101 +** METHOD: sqlite3
  1.3102  **
  1.3103  ** ^This interface returns a pointer the [sqlite3_mutex] object that 
  1.3104  ** serializes access to the [database connection] given in the argument
  1.3105 @@ -6079,10 +6408,11 @@
  1.3106  ** ^If the [threading mode] is Single-thread or Multi-thread then this
  1.3107  ** routine returns a NULL pointer.
  1.3108  */
  1.3109 -SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
  1.3110 +SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3*);
  1.3111  
  1.3112  /*
  1.3113  ** CAPI3REF: Low-Level Control Of Database Files
  1.3114 +** METHOD: sqlite3
  1.3115  **
  1.3116  ** ^The [sqlite3_file_control()] interface makes a direct call to the
  1.3117  ** xFileControl method for the [sqlite3_io_methods] object associated
  1.3118 @@ -6113,7 +6443,7 @@
  1.3119  **
  1.3120  ** See also: [SQLITE_FCNTL_LOCKSTATE]
  1.3121  */
  1.3122 -SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
  1.3123 +SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
  1.3124  
  1.3125  /*
  1.3126  ** CAPI3REF: Testing Interface
  1.3127 @@ -6132,7 +6462,7 @@
  1.3128  ** Unlike most of the SQLite API, this function is not guaranteed to
  1.3129  ** operate consistently from one release to the next.
  1.3130  */
  1.3131 -SQLITE_API int sqlite3_test_control(int op, ...);
  1.3132 +SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...);
  1.3133  
  1.3134  /*
  1.3135  ** CAPI3REF: Testing Interface Operation Codes
  1.3136 @@ -6160,17 +6490,19 @@
  1.3137  #define SQLITE_TESTCTRL_ISKEYWORD               16
  1.3138  #define SQLITE_TESTCTRL_SCRATCHMALLOC           17
  1.3139  #define SQLITE_TESTCTRL_LOCALTIME_FAULT         18
  1.3140 -#define SQLITE_TESTCTRL_EXPLAIN_STMT            19
  1.3141 +#define SQLITE_TESTCTRL_EXPLAIN_STMT            19  /* NOT USED */
  1.3142  #define SQLITE_TESTCTRL_NEVER_CORRUPT           20
  1.3143  #define SQLITE_TESTCTRL_VDBE_COVERAGE           21
  1.3144  #define SQLITE_TESTCTRL_BYTEORDER               22
  1.3145  #define SQLITE_TESTCTRL_ISINIT                  23
  1.3146 -#define SQLITE_TESTCTRL_LAST                    23
  1.3147 +#define SQLITE_TESTCTRL_SORTER_MMAP             24
  1.3148 +#define SQLITE_TESTCTRL_IMPOSTER                25
  1.3149 +#define SQLITE_TESTCTRL_LAST                    25
  1.3150  
  1.3151  /*
  1.3152  ** CAPI3REF: SQLite Runtime Status
  1.3153  **
  1.3154 -** ^This interface is used to retrieve runtime status information
  1.3155 +** ^These interfaces are used to retrieve runtime status information
  1.3156  ** about the performance of SQLite, and optionally to reset various
  1.3157  ** highwater marks.  ^The first argument is an integer code for
  1.3158  ** the specific parameter to measure.  ^(Recognized integer codes
  1.3159 @@ -6184,19 +6516,22 @@
  1.3160  ** ^(Other parameters record only the highwater mark and not the current
  1.3161  ** value.  For these latter parameters nothing is written into *pCurrent.)^
  1.3162  **
  1.3163 -** ^The sqlite3_status() routine returns SQLITE_OK on success and a
  1.3164 -** non-zero [error code] on failure.
  1.3165 -**
  1.3166 -** This routine is threadsafe but is not atomic.  This routine can be
  1.3167 -** called while other threads are running the same or different SQLite
  1.3168 -** interfaces.  However the values returned in *pCurrent and
  1.3169 -** *pHighwater reflect the status of SQLite at different points in time
  1.3170 -** and it is possible that another thread might change the parameter
  1.3171 -** in between the times when *pCurrent and *pHighwater are written.
  1.3172 +** ^The sqlite3_status() and sqlite3_status64() routines return
  1.3173 +** SQLITE_OK on success and a non-zero [error code] on failure.
  1.3174 +**
  1.3175 +** If either the current value or the highwater mark is too large to
  1.3176 +** be represented by a 32-bit integer, then the values returned by
  1.3177 +** sqlite3_status() are undefined.
  1.3178  **
  1.3179  ** See also: [sqlite3_db_status()]
  1.3180  */
  1.3181 -SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
  1.3182 +SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
  1.3183 +SQLITE_API int SQLITE_STDCALL sqlite3_status64(
  1.3184 +  int op,
  1.3185 +  sqlite3_int64 *pCurrent,
  1.3186 +  sqlite3_int64 *pHighwater,
  1.3187 +  int resetFlag
  1.3188 +);
  1.3189  
  1.3190  
  1.3191  /*
  1.3192 @@ -6275,7 +6610,8 @@
  1.3193  ** The value written into the *pCurrent parameter is undefined.</dd>)^
  1.3194  **
  1.3195  ** [[SQLITE_STATUS_PARSER_STACK]] ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>
  1.3196 -** <dd>This parameter records the deepest parser stack.  It is only
  1.3197 +** <dd>The *pHighwater parameter records the deepest parser stack. 
  1.3198 +** The *pCurrent value is undefined.  The *pHighwater value is only
  1.3199  ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^
  1.3200  ** </dl>
  1.3201  **
  1.3202 @@ -6294,6 +6630,7 @@
  1.3203  
  1.3204  /*
  1.3205  ** CAPI3REF: Database Connection Status
  1.3206 +** METHOD: sqlite3
  1.3207  **
  1.3208  ** ^This interface is used to retrieve runtime status information 
  1.3209  ** about a single [database connection].  ^The first argument is the
  1.3210 @@ -6314,7 +6651,7 @@
  1.3211  **
  1.3212  ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
  1.3213  */
  1.3214 -SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
  1.3215 +SQLITE_API int SQLITE_STDCALL sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
  1.3216  
  1.3217  /*
  1.3218  ** CAPI3REF: Status Parameters for database connections
  1.3219 @@ -6356,12 +6693,12 @@
  1.3220  ** the current value is always zero.)^
  1.3221  **
  1.3222  ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
  1.3223 -** <dd>This parameter returns the approximate number of of bytes of heap
  1.3224 +** <dd>This parameter returns the approximate number of bytes of heap
  1.3225  ** memory used by all pager caches associated with the database connection.)^
  1.3226  ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
  1.3227  **
  1.3228  ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
  1.3229 -** <dd>This parameter returns the approximate number of of bytes of heap
  1.3230 +** <dd>This parameter returns the approximate number of bytes of heap
  1.3231  ** memory used to store the schema for all databases associated
  1.3232  ** with the connection - main, temp, and any [ATTACH]-ed databases.)^ 
  1.3233  ** ^The full amount of memory used by the schemas is reported, even if the
  1.3234 @@ -6370,7 +6707,7 @@
  1.3235  ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.
  1.3236  **
  1.3237  ** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>
  1.3238 -** <dd>This parameter returns the approximate number of of bytes of heap
  1.3239 +** <dd>This parameter returns the approximate number of bytes of heap
  1.3240  ** and lookaside memory used by all prepared statements associated with
  1.3241  ** the database connection.)^
  1.3242  ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0.
  1.3243 @@ -6422,6 +6759,7 @@
  1.3244  
  1.3245  /*
  1.3246  ** CAPI3REF: Prepared Statement Status
  1.3247 +** METHOD: sqlite3_stmt
  1.3248  **
  1.3249  ** ^(Each prepared statement maintains various
  1.3250  ** [SQLITE_STMTSTATUS counters] that measure the number
  1.3251 @@ -6443,7 +6781,7 @@
  1.3252  **
  1.3253  ** See also: [sqlite3_status()] and [sqlite3_db_status()].
  1.3254  */
  1.3255 -SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
  1.3256 +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
  1.3257  
  1.3258  /*
  1.3259  ** CAPI3REF: Status Parameters for prepared statements
  1.3260 @@ -6770,6 +7108,10 @@
  1.3261  ** must be different or else sqlite3_backup_init(D,N,S,M) will fail with
  1.3262  ** an error.
  1.3263  **
  1.3264 +** ^A call to sqlite3_backup_init() will fail, returning SQLITE_ERROR, if 
  1.3265 +** there is already a read or read-write transaction open on the 
  1.3266 +** destination database.
  1.3267 +**
  1.3268  ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is
  1.3269  ** returned and an error code and error message are stored in the
  1.3270  ** destination [database connection] D.
  1.3271 @@ -6862,20 +7204,20 @@
  1.3272  ** is not a permanent error and does not affect the return value of
  1.3273  ** sqlite3_backup_finish().
  1.3274  **
  1.3275 -** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]]
  1.3276 +** [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]]
  1.3277  ** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>
  1.3278  **
  1.3279 -** ^Each call to sqlite3_backup_step() sets two values inside
  1.3280 -** the [sqlite3_backup] object: the number of pages still to be backed
  1.3281 -** up and the total number of pages in the source database file.
  1.3282 -** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces
  1.3283 -** retrieve these two values, respectively.
  1.3284 -**
  1.3285 -** ^The values returned by these functions are only updated by
  1.3286 -** sqlite3_backup_step(). ^If the source database is modified during a backup
  1.3287 -** operation, then the values are not updated to account for any extra
  1.3288 -** pages that need to be updated or the size of the source database file
  1.3289 -** changing.
  1.3290 +** ^The sqlite3_backup_remaining() routine returns the number of pages still
  1.3291 +** to be backed up at the conclusion of the most recent sqlite3_backup_step().
  1.3292 +** ^The sqlite3_backup_pagecount() routine returns the total number of pages
  1.3293 +** in the source database at the conclusion of the most recent
  1.3294 +** sqlite3_backup_step().
  1.3295 +** ^(The values returned by these functions are only updated by
  1.3296 +** sqlite3_backup_step(). If the source database is modified in a way that
  1.3297 +** changes the size of the source database or the number of pages remaining,
  1.3298 +** those changes are not reflected in the output of sqlite3_backup_pagecount()
  1.3299 +** and sqlite3_backup_remaining() until after the next
  1.3300 +** sqlite3_backup_step().)^
  1.3301  **
  1.3302  ** <b>Concurrent Usage of Database Handles</b>
  1.3303  **
  1.3304 @@ -6908,19 +7250,20 @@
  1.3305  ** same time as another thread is invoking sqlite3_backup_step() it is
  1.3306  ** possible that they return invalid values.
  1.3307  */
  1.3308 -SQLITE_API sqlite3_backup *sqlite3_backup_init(
  1.3309 +SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init(
  1.3310    sqlite3 *pDest,                        /* Destination database handle */
  1.3311    const char *zDestName,                 /* Destination database name */
  1.3312    sqlite3 *pSource,                      /* Source database handle */
  1.3313    const char *zSourceName                /* Source database name */
  1.3314  );
  1.3315 -SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);
  1.3316 -SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);
  1.3317 -SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);
  1.3318 -SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
  1.3319 +SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage);
  1.3320 +SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p);
  1.3321 +SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p);
  1.3322 +SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p);
  1.3323  
  1.3324  /*
  1.3325  ** CAPI3REF: Unlock Notification
  1.3326 +** METHOD: sqlite3
  1.3327  **
  1.3328  ** ^When running in shared-cache mode, a database operation may fail with
  1.3329  ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
  1.3330 @@ -7033,7 +7376,7 @@
  1.3331  ** the special "DROP TABLE/INDEX" case, the extended error code is just 
  1.3332  ** SQLITE_LOCKED.)^
  1.3333  */
  1.3334 -SQLITE_API int sqlite3_unlock_notify(
  1.3335 +SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify(
  1.3336    sqlite3 *pBlocked,                          /* Waiting connection */
  1.3337    void (*xNotify)(void **apArg, int nArg),    /* Callback function to invoke */
  1.3338    void *pNotifyArg                            /* Argument to pass to xNotify */
  1.3339 @@ -7048,23 +7391,48 @@
  1.3340  ** strings in a case-independent fashion, using the same definition of "case
  1.3341  ** independence" that SQLite uses internally when comparing identifiers.
  1.3342  */
  1.3343 -SQLITE_API int sqlite3_stricmp(const char *, const char *);
  1.3344 -SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
  1.3345 +SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *, const char *);
  1.3346 +SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *, const char *, int);
  1.3347  
  1.3348  /*
  1.3349  ** CAPI3REF: String Globbing
  1.3350  *
  1.3351 -** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches
  1.3352 -** the glob pattern P, and it returns non-zero if string X does not match
  1.3353 -** the glob pattern P.  ^The definition of glob pattern matching used in
  1.3354 +** ^The [sqlite3_strglob(P,X)] interface returns zero if and only if
  1.3355 +** string X matches the [GLOB] pattern P.
  1.3356 +** ^The definition of [GLOB] pattern matching used in
  1.3357  ** [sqlite3_strglob(P,X)] is the same as for the "X GLOB P" operator in the
  1.3358 -** SQL dialect used by SQLite.  ^The sqlite3_strglob(P,X) function is case
  1.3359 -** sensitive.
  1.3360 +** SQL dialect understood by SQLite.  ^The [sqlite3_strglob(P,X)] function
  1.3361 +** is case sensitive.
  1.3362  **
  1.3363  ** Note that this routine returns zero on a match and non-zero if the strings
  1.3364  ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
  1.3365 -*/
  1.3366 -SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);
  1.3367 +**
  1.3368 +** See also: [sqlite3_strlike()].
  1.3369 +*/
  1.3370 +SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlob, const char *zStr);
  1.3371 +
  1.3372 +/*
  1.3373 +** CAPI3REF: String LIKE Matching
  1.3374 +*
  1.3375 +** ^The [sqlite3_strlike(P,X,E)] interface returns zero if and only if
  1.3376 +** string X matches the [LIKE] pattern P with escape character E.
  1.3377 +** ^The definition of [LIKE] pattern matching used in
  1.3378 +** [sqlite3_strlike(P,X,E)] is the same as for the "X LIKE P ESCAPE E"
  1.3379 +** operator in the SQL dialect understood by SQLite.  ^For "X LIKE P" without
  1.3380 +** the ESCAPE clause, set the E parameter of [sqlite3_strlike(P,X,E)] to 0.
  1.3381 +** ^As with the LIKE operator, the [sqlite3_strlike(P,X,E)] function is case
  1.3382 +** insensitive - equivalent upper and lower case ASCII characters match
  1.3383 +** one another.
  1.3384 +**
  1.3385 +** ^The [sqlite3_strlike(P,X,E)] function matches Unicode characters, though
  1.3386 +** only ASCII characters are case folded.
  1.3387 +**
  1.3388 +** Note that this routine returns zero on a match and non-zero if the strings
  1.3389 +** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
  1.3390 +**
  1.3391 +** See also: [sqlite3_strglob()].
  1.3392 +*/
  1.3393 +SQLITE_API int SQLITE_STDCALL sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc);
  1.3394  
  1.3395  /*
  1.3396  ** CAPI3REF: Error Logging Interface
  1.3397 @@ -7087,18 +7455,17 @@
  1.3398  ** a few hundred characters, it will be truncated to the length of the
  1.3399  ** buffer.
  1.3400  */
  1.3401 -SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
  1.3402 +SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...);
  1.3403  
  1.3404  /*
  1.3405  ** CAPI3REF: Write-Ahead Log Commit Hook
  1.3406 +** METHOD: sqlite3
  1.3407  **
  1.3408  ** ^The [sqlite3_wal_hook()] function is used to register a callback that
  1.3409 -** will be invoked each time a database connection commits data to a
  1.3410 -** [write-ahead log] (i.e. whenever a transaction is committed in
  1.3411 -** [journal_mode | journal_mode=WAL mode]). 
  1.3412 -**
  1.3413 -** ^The callback is invoked by SQLite after the commit has taken place and 
  1.3414 -** the associated write-lock on the database released, so the implementation 
  1.3415 +** is invoked each time data is committed to a database in wal mode.
  1.3416 +**
  1.3417 +** ^(The callback is invoked by SQLite after the commit has taken place and 
  1.3418 +** the associated write-lock on the database released)^, so the implementation 
  1.3419  ** may read, write or [checkpoint] the database as required.
  1.3420  **
  1.3421  ** ^The first parameter passed to the callback function when it is invoked
  1.3422 @@ -7124,7 +7491,7 @@
  1.3423  ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
  1.3424  ** those overwrite any prior [sqlite3_wal_hook()] settings.
  1.3425  */
  1.3426 -SQLITE_API void *sqlite3_wal_hook(
  1.3427 +SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
  1.3428    sqlite3*, 
  1.3429    int(*)(void *,sqlite3*,const char*,int),
  1.3430    void*
  1.3431 @@ -7132,6 +7499,7 @@
  1.3432  
  1.3433  /*
  1.3434  ** CAPI3REF: Configure an auto-checkpoint
  1.3435 +** METHOD: sqlite3
  1.3436  **
  1.3437  ** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around
  1.3438  ** [sqlite3_wal_hook()] that causes any database on [database connection] D
  1.3439 @@ -7158,104 +7526,123 @@
  1.3440  ** is only necessary if the default setting is found to be suboptimal
  1.3441  ** for a particular application.
  1.3442  */
  1.3443 -SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
  1.3444 +SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
  1.3445  
  1.3446  /*
  1.3447  ** CAPI3REF: Checkpoint a database
  1.3448 -**
  1.3449 -** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X
  1.3450 -** on [database connection] D to be [checkpointed].  ^If X is NULL or an
  1.3451 -** empty string, then a checkpoint is run on all databases of
  1.3452 -** connection D.  ^If the database connection D is not in
  1.3453 -** [WAL | write-ahead log mode] then this interface is a harmless no-op.
  1.3454 -** ^The [sqlite3_wal_checkpoint(D,X)] interface initiates a
  1.3455 -** [sqlite3_wal_checkpoint_v2|PASSIVE] checkpoint.
  1.3456 -** Use the [sqlite3_wal_checkpoint_v2()] interface to get a FULL
  1.3457 -** or RESET checkpoint.
  1.3458 -**
  1.3459 -** ^The [wal_checkpoint pragma] can be used to invoke this interface
  1.3460 -** from SQL.  ^The [sqlite3_wal_autocheckpoint()] interface and the
  1.3461 -** [wal_autocheckpoint pragma] can be used to cause this interface to be
  1.3462 -** run whenever the WAL reaches a certain size threshold.
  1.3463 -**
  1.3464 -** See also: [sqlite3_wal_checkpoint_v2()]
  1.3465 -*/
  1.3466 -SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
  1.3467 +** METHOD: sqlite3
  1.3468 +**
  1.3469 +** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
  1.3470 +** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^
  1.3471 +**
  1.3472 +** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the 
  1.3473 +** [write-ahead log] for database X on [database connection] D to be
  1.3474 +** transferred into the database file and for the write-ahead log to
  1.3475 +** be reset.  See the [checkpointing] documentation for addition
  1.3476 +** information.
  1.3477 +**
  1.3478 +** This interface used to be the only way to cause a checkpoint to
  1.3479 +** occur.  But then the newer and more powerful [sqlite3_wal_checkpoint_v2()]
  1.3480 +** interface was added.  This interface is retained for backwards
  1.3481 +** compatibility and as a convenience for applications that need to manually
  1.3482 +** start a callback but which do not need the full power (and corresponding
  1.3483 +** complication) of [sqlite3_wal_checkpoint_v2()].
  1.3484 +*/
  1.3485 +SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
  1.3486  
  1.3487  /*
  1.3488  ** CAPI3REF: Checkpoint a database
  1.3489 -**
  1.3490 -** Run a checkpoint operation on WAL database zDb attached to database 
  1.3491 -** handle db. The specific operation is determined by the value of the 
  1.3492 -** eMode parameter:
  1.3493 +** METHOD: sqlite3
  1.3494 +**
  1.3495 +** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
  1.3496 +** operation on database X of [database connection] D in mode M.  Status
  1.3497 +** information is written back into integers pointed to by L and C.)^
  1.3498 +** ^(The M parameter must be a valid [checkpoint mode]:)^
  1.3499  **
  1.3500  ** <dl>
  1.3501  ** <dt>SQLITE_CHECKPOINT_PASSIVE<dd>
  1.3502 -**   Checkpoint as many frames as possible without waiting for any database 
  1.3503 -**   readers or writers to finish. Sync the db file if all frames in the log
  1.3504 -**   are checkpointed. This mode is the same as calling 
  1.3505 -**   sqlite3_wal_checkpoint(). The [sqlite3_busy_handler|busy-handler callback]
  1.3506 -**   is never invoked.
  1.3507 +**   ^Checkpoint as many frames as possible without waiting for any database 
  1.3508 +**   readers or writers to finish, then sync the database file if all frames 
  1.3509 +**   in the log were checkpointed. ^The [busy-handler callback]
  1.3510 +**   is never invoked in the SQLITE_CHECKPOINT_PASSIVE mode.  
  1.3511 +**   ^On the other hand, passive mode might leave the checkpoint unfinished
  1.3512 +**   if there are concurrent readers or writers.
  1.3513  **
  1.3514  ** <dt>SQLITE_CHECKPOINT_FULL<dd>
  1.3515 -**   This mode blocks (it invokes the
  1.3516 +**   ^This mode blocks (it invokes the
  1.3517  **   [sqlite3_busy_handler|busy-handler callback]) until there is no
  1.3518  **   database writer and all readers are reading from the most recent database
  1.3519 -**   snapshot. It then checkpoints all frames in the log file and syncs the
  1.3520 -**   database file. This call blocks database writers while it is running,
  1.3521 -**   but not database readers.
  1.3522 +**   snapshot. ^It then checkpoints all frames in the log file and syncs the
  1.3523 +**   database file. ^This mode blocks new database writers while it is pending,
  1.3524 +**   but new database readers are allowed to continue unimpeded.
  1.3525  **
  1.3526  ** <dt>SQLITE_CHECKPOINT_RESTART<dd>
  1.3527 -**   This mode works the same way as SQLITE_CHECKPOINT_FULL, except after 
  1.3528 -**   checkpointing the log file it blocks (calls the 
  1.3529 -**   [sqlite3_busy_handler|busy-handler callback])
  1.3530 -**   until all readers are reading from the database file only. This ensures 
  1.3531 -**   that the next client to write to the database file restarts the log file 
  1.3532 -**   from the beginning. This call blocks database writers while it is running,
  1.3533 -**   but not database readers.
  1.3534 +**   ^This mode works the same way as SQLITE_CHECKPOINT_FULL with the addition
  1.3535 +**   that after checkpointing the log file it blocks (calls the 
  1.3536 +**   [busy-handler callback])
  1.3537 +**   until all readers are reading from the database file only. ^This ensures 
  1.3538 +**   that the next writer will restart the log file from the beginning.
  1.3539 +**   ^Like SQLITE_CHECKPOINT_FULL, this mode blocks new
  1.3540 +**   database writer attempts while it is pending, but does not impede readers.
  1.3541 +**
  1.3542 +** <dt>SQLITE_CHECKPOINT_TRUNCATE<dd>
  1.3543 +**   ^This mode works the same way as SQLITE_CHECKPOINT_RESTART with the
  1.3544 +**   addition that it also truncates the log file to zero bytes just prior
  1.3545 +**   to a successful return.
  1.3546  ** </dl>
  1.3547  **
  1.3548 -** If pnLog is not NULL, then *pnLog is set to the total number of frames in
  1.3549 -** the log file before returning. If pnCkpt is not NULL, then *pnCkpt is set to
  1.3550 -** the total number of checkpointed frames (including any that were already
  1.3551 -** checkpointed when this function is called). *pnLog and *pnCkpt may be
  1.3552 -** populated even if sqlite3_wal_checkpoint_v2() returns other than SQLITE_OK.
  1.3553 -** If no values are available because of an error, they are both set to -1
  1.3554 -** before returning to communicate this to the caller.
  1.3555 -**
  1.3556 -** All calls obtain an exclusive "checkpoint" lock on the database file. If
  1.3557 +** ^If pnLog is not NULL, then *pnLog is set to the total number of frames in
  1.3558 +** the log file or to -1 if the checkpoint could not run because
  1.3559 +** of an error or because the database is not in [WAL mode]. ^If pnCkpt is not
  1.3560 +** NULL,then *pnCkpt is set to the total number of checkpointed frames in the
  1.3561 +** log file (including any that were already checkpointed before the function
  1.3562 +** was called) or to -1 if the checkpoint could not run due to an error or
  1.3563 +** because the database is not in WAL mode. ^Note that upon successful
  1.3564 +** completion of an SQLITE_CHECKPOINT_TRUNCATE, the log file will have been
  1.3565 +** truncated to zero bytes and so both *pnLog and *pnCkpt will be set to zero.
  1.3566 +**
  1.3567 +** ^All calls obtain an exclusive "checkpoint" lock on the database file. ^If
  1.3568  ** any other process is running a checkpoint operation at the same time, the 
  1.3569 -** lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a 
  1.3570 +** lock cannot be obtained and SQLITE_BUSY is returned. ^Even if there is a 
  1.3571  ** busy-handler configured, it will not be invoked in this case.
  1.3572  **
  1.3573 -** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive 
  1.3574 -** "writer" lock on the database file. If the writer lock cannot be obtained
  1.3575 -** immediately, and a busy-handler is configured, it is invoked and the writer
  1.3576 -** lock retried until either the busy-handler returns 0 or the lock is
  1.3577 -** successfully obtained. The busy-handler is also invoked while waiting for
  1.3578 -** database readers as described above. If the busy-handler returns 0 before
  1.3579 +** ^The SQLITE_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the 
  1.3580 +** exclusive "writer" lock on the database file. ^If the writer lock cannot be
  1.3581 +** obtained immediately, and a busy-handler is configured, it is invoked and
  1.3582 +** the writer lock retried until either the busy-handler returns 0 or the lock
  1.3583 +** is successfully obtained. ^The busy-handler is also invoked while waiting for
  1.3584 +** database readers as described above. ^If the busy-handler returns 0 before
  1.3585  ** the writer lock is obtained or while waiting for database readers, the
  1.3586  ** checkpoint operation proceeds from that point in the same way as 
  1.3587  ** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible 
  1.3588 -** without blocking any further. SQLITE_BUSY is returned in this case.
  1.3589 -**
  1.3590 -** If parameter zDb is NULL or points to a zero length string, then the
  1.3591 -** specified operation is attempted on all WAL databases. In this case the
  1.3592 -** values written to output parameters *pnLog and *pnCkpt are undefined. If 
  1.3593 +** without blocking any further. ^SQLITE_BUSY is returned in this case.
  1.3594 +**
  1.3595 +** ^If parameter zDb is NULL or points to a zero length string, then the
  1.3596 +** specified operation is attempted on all WAL databases [attached] to 
  1.3597 +** [database connection] db.  In this case the
  1.3598 +** values written to output parameters *pnLog and *pnCkpt are undefined. ^If 
  1.3599  ** an SQLITE_BUSY error is encountered when processing one or more of the 
  1.3600  ** attached WAL databases, the operation is still attempted on any remaining 
  1.3601 -** attached databases and SQLITE_BUSY is returned to the caller. If any other 
  1.3602 +** attached databases and SQLITE_BUSY is returned at the end. ^If any other 
  1.3603  ** error occurs while processing an attached database, processing is abandoned 
  1.3604 -** and the error code returned to the caller immediately. If no error 
  1.3605 +** and the error code is returned to the caller immediately. ^If no error 
  1.3606  ** (SQLITE_BUSY or otherwise) is encountered while processing the attached 
  1.3607  ** databases, SQLITE_OK is returned.
  1.3608  **
  1.3609 -** If database zDb is the name of an attached database that is not in WAL
  1.3610 -** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. If
  1.3611 +** ^If database zDb is the name of an attached database that is not in WAL
  1.3612 +** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. ^If
  1.3613  ** zDb is not NULL (or a zero length string) and is not the name of any
  1.3614  ** attached database, SQLITE_ERROR is returned to the caller.
  1.3615 -*/
  1.3616 -SQLITE_API int sqlite3_wal_checkpoint_v2(
  1.3617 +**
  1.3618 +** ^Unless it returns SQLITE_MISUSE,
  1.3619 +** the sqlite3_wal_checkpoint_v2() interface
  1.3620 +** sets the error information that is queried by
  1.3621 +** [sqlite3_errcode()] and [sqlite3_errmsg()].
  1.3622 +**
  1.3623 +** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
  1.3624 +** from SQL.
  1.3625 +*/
  1.3626 +SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
  1.3627    sqlite3 *db,                    /* Database handle */
  1.3628    const char *zDb,                /* Name of attached database (or NULL) */
  1.3629    int eMode,                      /* SQLITE_CHECKPOINT_* value */
  1.3630 @@ -7264,16 +7651,18 @@
  1.3631  );
  1.3632  
  1.3633  /*
  1.3634 -** CAPI3REF: Checkpoint operation parameters
  1.3635 -**
  1.3636 -** These constants can be used as the 3rd parameter to
  1.3637 -** [sqlite3_wal_checkpoint_v2()].  See the [sqlite3_wal_checkpoint_v2()]
  1.3638 -** documentation for additional information about the meaning and use of
  1.3639 -** each of these values.
  1.3640 -*/
  1.3641 -#define SQLITE_CHECKPOINT_PASSIVE 0
  1.3642 -#define SQLITE_CHECKPOINT_FULL    1
  1.3643 -#define SQLITE_CHECKPOINT_RESTART 2
  1.3644 +** CAPI3REF: Checkpoint Mode Values
  1.3645 +** KEYWORDS: {checkpoint mode}
  1.3646 +**
  1.3647 +** These constants define all valid values for the "checkpoint mode" passed
  1.3648 +** as the third parameter to the [sqlite3_wal_checkpoint_v2()] interface.
  1.3649 +** See the [sqlite3_wal_checkpoint_v2()] documentation for details on the
  1.3650 +** meaning of each of these checkpoint modes.
  1.3651 +*/
  1.3652 +#define SQLITE_CHECKPOINT_PASSIVE  0  /* Do as much as possible w/o blocking */
  1.3653 +#define SQLITE_CHECKPOINT_FULL     1  /* Wait for writers, then checkpoint */
  1.3654 +#define SQLITE_CHECKPOINT_RESTART  2  /* Like FULL but wait for for readers */
  1.3655 +#define SQLITE_CHECKPOINT_TRUNCATE 3  /* Like RESTART but also truncate WAL */
  1.3656  
  1.3657  /*
  1.3658  ** CAPI3REF: Virtual Table Interface Configuration
  1.3659 @@ -7289,7 +7678,7 @@
  1.3660  ** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].)  Further options
  1.3661  ** may be added in the future.
  1.3662  */
  1.3663 -SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
  1.3664 +SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3*, int op, ...);
  1.3665  
  1.3666  /*
  1.3667  ** CAPI3REF: Virtual Table Configuration Options
  1.3668 @@ -7342,7 +7731,7 @@
  1.3669  ** of the SQL statement that triggered the call to the [xUpdate] method of the
  1.3670  ** [virtual table].
  1.3671  */
  1.3672 -SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
  1.3673 +SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *);
  1.3674  
  1.3675  /*
  1.3676  ** CAPI3REF: Conflict resolution modes
  1.3677 @@ -7362,7 +7751,232 @@
  1.3678  /* #define SQLITE_ABORT 4  // Also an error code */
  1.3679  #define SQLITE_REPLACE  5
  1.3680  
  1.3681 -
  1.3682 +/*
  1.3683 +** CAPI3REF: Prepared Statement Scan Status Opcodes
  1.3684 +** KEYWORDS: {scanstatus options}
  1.3685 +**
  1.3686 +** The following constants can be used for the T parameter to the
  1.3687 +** [sqlite3_stmt_scanstatus(S,X,T,V)] interface.  Each constant designates a
  1.3688 +** different metric for sqlite3_stmt_scanstatus() to return.
  1.3689 +**
  1.3690 +** When the value returned to V is a string, space to hold that string is
  1.3691 +** managed by the prepared statement S and will be automatically freed when
  1.3692 +** S is finalized.
  1.3693 +**
  1.3694 +** <dl>
  1.3695 +** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>
  1.3696 +** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be
  1.3697 +** set to the total number of times that the X-th loop has run.</dd>
  1.3698 +**
  1.3699 +** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt>
  1.3700 +** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set
  1.3701 +** to the total number of rows examined by all iterations of the X-th loop.</dd>
  1.3702 +**
  1.3703 +** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>
  1.3704 +** <dd>^The "double" variable pointed to by the T parameter will be set to the
  1.3705 +** query planner's estimate for the average number of rows output from each
  1.3706 +** iteration of the X-th loop.  If the query planner's estimates was accurate,
  1.3707 +** then this value will approximate the quotient NVISIT/NLOOP and the
  1.3708 +** product of this value for all prior loops with the same SELECTID will
  1.3709 +** be the NLOOP value for the current loop.
  1.3710 +**
  1.3711 +** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>
  1.3712 +** <dd>^The "const char *" variable pointed to by the T parameter will be set
  1.3713 +** to a zero-terminated UTF-8 string containing the name of the index or table
  1.3714 +** used for the X-th loop.
  1.3715 +**
  1.3716 +** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>
  1.3717 +** <dd>^The "const char *" variable pointed to by the T parameter will be set
  1.3718 +** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]
  1.3719 +** description for the X-th loop.
  1.3720 +**
  1.3721 +** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt>
  1.3722 +** <dd>^The "int" variable pointed to by the T parameter will be set to the
  1.3723 +** "select-id" for the X-th loop.  The select-id identifies which query or
  1.3724 +** subquery the loop is part of.  The main query has a select-id of zero.
  1.3725 +** The select-id is the same value as is output in the first column
  1.3726 +** of an [EXPLAIN QUERY PLAN] query.
  1.3727 +** </dl>
  1.3728 +*/
  1.3729 +#define SQLITE_SCANSTAT_NLOOP    0
  1.3730 +#define SQLITE_SCANSTAT_NVISIT   1
  1.3731 +#define SQLITE_SCANSTAT_EST      2
  1.3732 +#define SQLITE_SCANSTAT_NAME     3
  1.3733 +#define SQLITE_SCANSTAT_EXPLAIN  4
  1.3734 +#define SQLITE_SCANSTAT_SELECTID 5
  1.3735 +
  1.3736 +/*
  1.3737 +** CAPI3REF: Prepared Statement Scan Status
  1.3738 +** METHOD: sqlite3_stmt
  1.3739 +**
  1.3740 +** This interface returns information about the predicted and measured
  1.3741 +** performance for pStmt.  Advanced applications can use this
  1.3742 +** interface to compare the predicted and the measured performance and
  1.3743 +** issue warnings and/or rerun [ANALYZE] if discrepancies are found.
  1.3744 +**
  1.3745 +** Since this interface is expected to be rarely used, it is only
  1.3746 +** available if SQLite is compiled using the [SQLITE_ENABLE_STMT_SCANSTATUS]
  1.3747 +** compile-time option.
  1.3748 +**
  1.3749 +** The "iScanStatusOp" parameter determines which status information to return.
  1.3750 +** The "iScanStatusOp" must be one of the [scanstatus options] or the behavior
  1.3751 +** of this interface is undefined.
  1.3752 +** ^The requested measurement is written into a variable pointed to by
  1.3753 +** the "pOut" parameter.
  1.3754 +** Parameter "idx" identifies the specific loop to retrieve statistics for.
  1.3755 +** Loops are numbered starting from zero. ^If idx is out of range - less than
  1.3756 +** zero or greater than or equal to the total number of loops used to implement
  1.3757 +** the statement - a non-zero value is returned and the variable that pOut
  1.3758 +** points to is unchanged.
  1.3759 +**
  1.3760 +** ^Statistics might not be available for all loops in all statements. ^In cases
  1.3761 +** where there exist loops with no available statistics, this function behaves
  1.3762 +** as if the loop did not exist - it returns non-zero and leave the variable
  1.3763 +** that pOut points to unchanged.
  1.3764 +**
  1.3765 +** See also: [sqlite3_stmt_scanstatus_reset()]
  1.3766 +*/
  1.3767 +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_scanstatus(
  1.3768 +  sqlite3_stmt *pStmt,      /* Prepared statement for which info desired */
  1.3769 +  int idx,                  /* Index of loop to report on */
  1.3770 +  int iScanStatusOp,        /* Information desired.  SQLITE_SCANSTAT_* */
  1.3771 +  void *pOut                /* Result written here */
  1.3772 +);     
  1.3773 +
  1.3774 +/*
  1.3775 +** CAPI3REF: Zero Scan-Status Counters
  1.3776 +** METHOD: sqlite3_stmt
  1.3777 +**
  1.3778 +** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.
  1.3779 +**
  1.3780 +** This API is only available if the library is built with pre-processor
  1.3781 +** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.
  1.3782 +*/
  1.3783 +SQLITE_API void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
  1.3784 +
  1.3785 +/*
  1.3786 +** CAPI3REF: Flush caches to disk mid-transaction
  1.3787 +**
  1.3788 +** ^If a write-transaction is open on [database connection] D when the
  1.3789 +** [sqlite3_db_cacheflush(D)] interface invoked, any dirty
  1.3790 +** pages in the pager-cache that are not currently in use are written out 
  1.3791 +** to disk. A dirty page may be in use if a database cursor created by an
  1.3792 +** active SQL statement is reading from it, or if it is page 1 of a database
  1.3793 +** file (page 1 is always "in use").  ^The [sqlite3_db_cacheflush(D)]
  1.3794 +** interface flushes caches for all schemas - "main", "temp", and
  1.3795 +** any [attached] databases.
  1.3796 +**
  1.3797 +** ^If this function needs to obtain extra database locks before dirty pages 
  1.3798 +** can be flushed to disk, it does so. ^If those locks cannot be obtained 
  1.3799 +** immediately and there is a busy-handler callback configured, it is invoked
  1.3800 +** in the usual manner. ^If the required lock still cannot be obtained, then
  1.3801 +** the database is skipped and an attempt made to flush any dirty pages
  1.3802 +** belonging to the next (if any) database. ^If any databases are skipped
  1.3803 +** because locks cannot be obtained, but no other error occurs, this
  1.3804 +** function returns SQLITE_BUSY.
  1.3805 +**
  1.3806 +** ^If any other error occurs while flushing dirty pages to disk (for
  1.3807 +** example an IO error or out-of-memory condition), then processing is
  1.3808 +** abandoned and an SQLite [error code] is returned to the caller immediately.
  1.3809 +**
  1.3810 +** ^Otherwise, if no error occurs, [sqlite3_db_cacheflush()] returns SQLITE_OK.
  1.3811 +**
  1.3812 +** ^This function does not set the database handle error code or message
  1.3813 +** returned by the [sqlite3_errcode()] and [sqlite3_errmsg()] functions.
  1.3814 +*/
  1.3815 +SQLITE_API int SQLITE_STDCALL sqlite3_db_cacheflush(sqlite3*);
  1.3816 +
  1.3817 +/*
  1.3818 +** CAPI3REF: Database Snapshot
  1.3819 +** KEYWORDS: {snapshot}
  1.3820 +** EXPERIMENTAL
  1.3821 +**
  1.3822 +** An instance of the snapshot object records the state of a [WAL mode]
  1.3823 +** database for some specific point in history.
  1.3824 +**
  1.3825 +** In [WAL mode], multiple [database connections] that are open on the
  1.3826 +** same database file can each be reading a different historical version
  1.3827 +** of the database file.  When a [database connection] begins a read
  1.3828 +** transaction, that connection sees an unchanging copy of the database
  1.3829 +** as it existed for the point in time when the transaction first started.
  1.3830 +** Subsequent changes to the database from other connections are not seen
  1.3831 +** by the reader until a new read transaction is started.
  1.3832 +**
  1.3833 +** The sqlite3_snapshot object records state information about an historical
  1.3834 +** version of the database file so that it is possible to later open a new read
  1.3835 +** transaction that sees that historical version of the database rather than
  1.3836 +** the most recent version.
  1.3837 +**
  1.3838 +** The constructor for this object is [sqlite3_snapshot_get()].  The
  1.3839 +** [sqlite3_snapshot_open()] method causes a fresh read transaction to refer
  1.3840 +** to an historical snapshot (if possible).  The destructor for 
  1.3841 +** sqlite3_snapshot objects is [sqlite3_snapshot_free()].
  1.3842 +*/
  1.3843 +typedef struct sqlite3_snapshot sqlite3_snapshot;
  1.3844 +
  1.3845 +/*
  1.3846 +** CAPI3REF: Record A Database Snapshot
  1.3847 +** EXPERIMENTAL
  1.3848 +**
  1.3849 +** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a
  1.3850 +** new [sqlite3_snapshot] object that records the current state of
  1.3851 +** schema S in database connection D.  ^On success, the
  1.3852 +** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
  1.3853 +** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.
  1.3854 +** ^If schema S of [database connection] D is not a [WAL mode] database
  1.3855 +** that is in a read transaction, then [sqlite3_snapshot_get(D,S,P)]
  1.3856 +** leaves the *P value unchanged and returns an appropriate [error code].
  1.3857 +**
  1.3858 +** The [sqlite3_snapshot] object returned from a successful call to
  1.3859 +** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()]
  1.3860 +** to avoid a memory leak.
  1.3861 +**
  1.3862 +** The [sqlite3_snapshot_get()] interface is only available when the
  1.3863 +** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
  1.3864 +*/
  1.3865 +SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_snapshot_get(
  1.3866 +  sqlite3 *db,
  1.3867 +  const char *zSchema,
  1.3868 +  sqlite3_snapshot **ppSnapshot
  1.3869 +);
  1.3870 +
  1.3871 +/*
  1.3872 +** CAPI3REF: Start a read transaction on an historical snapshot
  1.3873 +** EXPERIMENTAL
  1.3874 +**
  1.3875 +** ^The [sqlite3_snapshot_open(D,S,P)] interface attempts to move the
  1.3876 +** read transaction that is currently open on schema S of
  1.3877 +** [database connection] D so that it refers to historical [snapshot] P.
  1.3878 +** ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK on success
  1.3879 +** or an appropriate [error code] if it fails.
  1.3880 +**
  1.3881 +** ^In order to succeed, a call to [sqlite3_snapshot_open(D,S,P)] must be
  1.3882 +** the first operation, apart from other sqlite3_snapshot_open() calls,
  1.3883 +** following the [BEGIN] that starts a new read transaction.
  1.3884 +** ^A [snapshot] will fail to open if it has been overwritten by a 
  1.3885 +** [checkpoint].  
  1.3886 +**
  1.3887 +** The [sqlite3_snapshot_open()] interface is only available when the
  1.3888 +** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
  1.3889 +*/
  1.3890 +SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_snapshot_open(
  1.3891 +  sqlite3 *db,
  1.3892 +  const char *zSchema,
  1.3893 +  sqlite3_snapshot *pSnapshot
  1.3894 +);
  1.3895 +
  1.3896 +/*
  1.3897 +** CAPI3REF: Destroy a snapshot
  1.3898 +** EXPERIMENTAL
  1.3899 +**
  1.3900 +** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.
  1.3901 +** The application must eventually free every [sqlite3_snapshot] object
  1.3902 +** using this routine to avoid a memory leak.
  1.3903 +**
  1.3904 +** The [sqlite3_snapshot_free()] interface is only available when the
  1.3905 +** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
  1.3906 +*/
  1.3907 +SQLITE_API SQLITE_EXPERIMENTAL void SQLITE_STDCALL sqlite3_snapshot_free(sqlite3_snapshot*);
  1.3908  
  1.3909  /*
  1.3910  ** Undo the hack that converts floating point types to integer for
  1.3911 @@ -7416,7 +8030,7 @@
  1.3912  **
  1.3913  **   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
  1.3914  */
  1.3915 -SQLITE_API int sqlite3_rtree_geometry_callback(
  1.3916 +SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback(
  1.3917    sqlite3 *db,
  1.3918    const char *zGeom,
  1.3919    int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),
  1.3920 @@ -7442,7 +8056,7 @@
  1.3921  **
  1.3922  **   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)
  1.3923  */
  1.3924 -SQLITE_API int sqlite3_rtree_query_callback(
  1.3925 +SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback(
  1.3926    sqlite3 *db,
  1.3927    const char *zQueryFunc,
  1.3928    int (*xQueryFunc)(sqlite3_rtree_query_info*),
  1.3929 @@ -7476,6 +8090,8 @@
  1.3930    int eParentWithin;                /* Visibility of parent node */
  1.3931    int eWithin;                      /* OUT: Visiblity */
  1.3932    sqlite3_rtree_dbl rScore;         /* OUT: Write the score here */
  1.3933 +  /* The following fields are only available in 3.8.11 and later */
  1.3934 +  sqlite3_value **apSqlParam;       /* Original SQL values of parameters */
  1.3935  };
  1.3936  
  1.3937  /*
  1.3938 @@ -7492,3 +8108,581 @@
  1.3939  
  1.3940  #endif  /* ifndef _SQLITE3RTREE_H_ */
  1.3941  
  1.3942 +/*
  1.3943 +** 2014 May 31
  1.3944 +**
  1.3945 +** The author disclaims copyright to this source code.  In place of
  1.3946 +** a legal notice, here is a blessing:
  1.3947 +**
  1.3948 +**    May you do good and not evil.
  1.3949 +**    May you find forgiveness for yourself and forgive others.
  1.3950 +**    May you share freely, never taking more than you give.
  1.3951 +**
  1.3952 +******************************************************************************
  1.3953 +**
  1.3954 +** Interfaces to extend FTS5. Using the interfaces defined in this file, 
  1.3955 +** FTS5 may be extended with:
  1.3956 +**
  1.3957 +**     * custom tokenizers, and
  1.3958 +**     * custom auxiliary functions.
  1.3959 +*/
  1.3960 +
  1.3961 +
  1.3962 +#ifndef _FTS5_H
  1.3963 +#define _FTS5_H
  1.3964 +
  1.3965 +
  1.3966 +#ifdef __cplusplus
  1.3967 +extern "C" {
  1.3968 +#endif
  1.3969 +
  1.3970 +/*************************************************************************
  1.3971 +** CUSTOM AUXILIARY FUNCTIONS
  1.3972 +**
  1.3973 +** Virtual table implementations may overload SQL functions by implementing
  1.3974 +** the sqlite3_module.xFindFunction() method.
  1.3975 +*/
  1.3976 +
  1.3977 +typedef struct Fts5ExtensionApi Fts5ExtensionApi;
  1.3978 +typedef struct Fts5Context Fts5Context;
  1.3979 +typedef struct Fts5PhraseIter Fts5PhraseIter;
  1.3980 +
  1.3981 +typedef void (*fts5_extension_function)(
  1.3982 +  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */
  1.3983 +  Fts5Context *pFts,              /* First arg to pass to pApi functions */
  1.3984 +  sqlite3_context *pCtx,          /* Context for returning result/error */
  1.3985 +  int nVal,                       /* Number of values in apVal[] array */
  1.3986 +  sqlite3_value **apVal           /* Array of trailing arguments */
  1.3987 +);
  1.3988 +
  1.3989 +struct Fts5PhraseIter {
  1.3990 +  const unsigned char *a;
  1.3991 +  const unsigned char *b;
  1.3992 +};
  1.3993 +
  1.3994 +/*
  1.3995 +** EXTENSION API FUNCTIONS
  1.3996 +**
  1.3997 +** xUserData(pFts):
  1.3998 +**   Return a copy of the context pointer the extension function was 
  1.3999 +**   registered with.
  1.4000 +**
  1.4001 +** xColumnTotalSize(pFts, iCol, pnToken):
  1.4002 +**   If parameter iCol is less than zero, set output variable *pnToken
  1.4003 +**   to the total number of tokens in the FTS5 table. Or, if iCol is
  1.4004 +**   non-negative but less than the number of columns in the table, return
  1.4005 +**   the total number of tokens in column iCol, considering all rows in 
  1.4006 +**   the FTS5 table.
  1.4007 +**
  1.4008 +**   If parameter iCol is greater than or equal to the number of columns
  1.4009 +**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
  1.4010 +**   an OOM condition or IO error), an appropriate SQLite error code is 
  1.4011 +**   returned.
  1.4012 +**
  1.4013 +** xColumnCount(pFts):
  1.4014 +**   Return the number of columns in the table.
  1.4015 +**
  1.4016 +** xColumnSize(pFts, iCol, pnToken):
  1.4017 +**   If parameter iCol is less than zero, set output variable *pnToken
  1.4018 +**   to the total number of tokens in the current row. Or, if iCol is
  1.4019 +**   non-negative but less than the number of columns in the table, set
  1.4020 +**   *pnToken to the number of tokens in column iCol of the current row.
  1.4021 +**
  1.4022 +**   If parameter iCol is greater than or equal to the number of columns
  1.4023 +**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
  1.4024 +**   an OOM condition or IO error), an appropriate SQLite error code is 
  1.4025 +**   returned.
  1.4026 +**
  1.4027 +**   This function may be quite inefficient if used with an FTS5 table
  1.4028 +**   created with the "columnsize=0" option.
  1.4029 +**
  1.4030 +** xColumnText:
  1.4031 +**   This function attempts to retrieve the text of column iCol of the
  1.4032 +**   current document. If successful, (*pz) is set to point to a buffer
  1.4033 +**   containing the text in utf-8 encoding, (*pn) is set to the size in bytes
  1.4034 +**   (not characters) of the buffer and SQLITE_OK is returned. Otherwise,
  1.4035 +**   if an error occurs, an SQLite error code is returned and the final values
  1.4036 +**   of (*pz) and (*pn) are undefined.
  1.4037 +**
  1.4038 +** xPhraseCount:
  1.4039 +**   Returns the number of phrases in the current query expression.
  1.4040 +**
  1.4041 +** xPhraseSize:
  1.4042 +**   Returns the number of tokens in phrase iPhrase of the query. Phrases
  1.4043 +**   are numbered starting from zero.
  1.4044 +**
  1.4045 +** xInstCount:
  1.4046 +**   Set *pnInst to the total number of occurrences of all phrases within
  1.4047 +**   the query within the current row. Return SQLITE_OK if successful, or
  1.4048 +**   an error code (i.e. SQLITE_NOMEM) if an error occurs.
  1.4049 +**
  1.4050 +**   This API can be quite slow if used with an FTS5 table created with the
  1.4051 +**   "detail=none" or "detail=column" option. If the FTS5 table is created 
  1.4052 +**   with either "detail=none" or "detail=column" and "content=" option 
  1.4053 +**   (i.e. if it is a contentless table), then this API always returns 0.
  1.4054 +**
  1.4055 +** xInst:
  1.4056 +**   Query for the details of phrase match iIdx within the current row.
  1.4057 +**   Phrase matches are numbered starting from zero, so the iIdx argument
  1.4058 +**   should be greater than or equal to zero and smaller than the value
  1.4059 +**   output by xInstCount().
  1.4060 +**
  1.4061 +**   Usually, output parameter *piPhrase is set to the phrase number, *piCol
  1.4062 +**   to the column in which it occurs and *piOff the token offset of the
  1.4063 +**   first token of the phrase. The exception is if the table was created
  1.4064 +**   with the offsets=0 option specified. In this case *piOff is always
  1.4065 +**   set to -1.
  1.4066 +**
  1.4067 +**   Returns SQLITE_OK if successful, or an error code (i.e. SQLITE_NOMEM) 
  1.4068 +**   if an error occurs.
  1.4069 +**
  1.4070 +**   This API can be quite slow if used with an FTS5 table created with the
  1.4071 +**   "detail=none" or "detail=column" option. 
  1.4072 +**
  1.4073 +** xRowid:
  1.4074 +**   Returns the rowid of the current row.
  1.4075 +**
  1.4076 +** xTokenize:
  1.4077 +**   Tokenize text using the tokenizer belonging to the FTS5 table.
  1.4078 +**
  1.4079 +** xQueryPhrase(pFts5, iPhrase, pUserData, xCallback):
  1.4080 +**   This API function is used to query the FTS table for phrase iPhrase
  1.4081 +**   of the current query. Specifically, a query equivalent to:
  1.4082 +**
  1.4083 +**       ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid
  1.4084 +**
  1.4085 +**   with $p set to a phrase equivalent to the phrase iPhrase of the
  1.4086 +**   current query is executed. For each row visited, the callback function
  1.4087 +**   passed as the fourth argument is invoked. The context and API objects 
  1.4088 +**   passed to the callback function may be used to access the properties of
  1.4089 +**   each matched row. Invoking Api.xUserData() returns a copy of the pointer
  1.4090 +**   passed as the third argument to pUserData.
  1.4091 +**
  1.4092 +**   If the callback function returns any value other than SQLITE_OK, the
  1.4093 +**   query is abandoned and the xQueryPhrase function returns immediately.
  1.4094 +**   If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK.
  1.4095 +**   Otherwise, the error code is propagated upwards.
  1.4096 +**
  1.4097 +**   If the query runs to completion without incident, SQLITE_OK is returned.
  1.4098 +**   Or, if some error occurs before the query completes or is aborted by
  1.4099 +**   the callback, an SQLite error code is returned.
  1.4100 +**
  1.4101 +**
  1.4102 +** xSetAuxdata(pFts5, pAux, xDelete)
  1.4103 +**
  1.4104 +**   Save the pointer passed as the second argument as the extension functions 
  1.4105 +**   "auxiliary data". The pointer may then be retrieved by the current or any
  1.4106 +**   future invocation of the same fts5 extension function made as part of
  1.4107 +**   of the same MATCH query using the xGetAuxdata() API.
  1.4108 +**
  1.4109 +**   Each extension function is allocated a single auxiliary data slot for
  1.4110 +**   each FTS query (MATCH expression). If the extension function is invoked 
  1.4111 +**   more than once for a single FTS query, then all invocations share a 
  1.4112 +**   single auxiliary data context.
  1.4113 +**
  1.4114 +**   If there is already an auxiliary data pointer when this function is
  1.4115 +**   invoked, then it is replaced by the new pointer. If an xDelete callback
  1.4116 +**   was specified along with the original pointer, it is invoked at this
  1.4117 +**   point.
  1.4118 +**
  1.4119 +**   The xDelete callback, if one is specified, is also invoked on the
  1.4120 +**   auxiliary data pointer after the FTS5 query has finished.
  1.4121 +**
  1.4122 +**   If an error (e.g. an OOM condition) occurs within this function, an
  1.4123 +**   the auxiliary data is set to NULL and an error code returned. If the
  1.4124 +**   xDelete parameter was not NULL, it is invoked on the auxiliary data
  1.4125 +**   pointer before returning.
  1.4126 +**
  1.4127 +**
  1.4128 +** xGetAuxdata(pFts5, bClear)
  1.4129 +**
  1.4130 +**   Returns the current auxiliary data pointer for the fts5 extension 
  1.4131 +**   function. See the xSetAuxdata() method for details.
  1.4132 +**
  1.4133 +**   If the bClear argument is non-zero, then the auxiliary data is cleared
  1.4134 +**   (set to NULL) before this function returns. In this case the xDelete,
  1.4135 +**   if any, is not invoked.
  1.4136 +**
  1.4137 +**
  1.4138 +** xRowCount(pFts5, pnRow)
  1.4139 +**
  1.4140 +**   This function is used to retrieve the total number of rows in the table.
  1.4141 +**   In other words, the same value that would be returned by:
  1.4142 +**
  1.4143 +**        SELECT count(*) FROM ftstable;
  1.4144 +**
  1.4145 +** xPhraseFirst()
  1.4146 +**   This function is used, along with type Fts5PhraseIter and the xPhraseNext
  1.4147 +**   method, to iterate through all instances of a single query phrase within
  1.4148 +**   the current row. This is the same information as is accessible via the
  1.4149 +**   xInstCount/xInst APIs. While the xInstCount/xInst APIs are more convenient
  1.4150 +**   to use, this API may be faster under some circumstances. To iterate 
  1.4151 +**   through instances of phrase iPhrase, use the following code:
  1.4152 +**
  1.4153 +**       Fts5PhraseIter iter;
  1.4154 +**       int iCol, iOff;
  1.4155 +**       for(pApi->xPhraseFirst(pFts, iPhrase, &iter, &iCol, &iOff);
  1.4156 +**           iCol>=0;
  1.4157 +**           pApi->xPhraseNext(pFts, &iter, &iCol, &iOff)
  1.4158 +**       ){
  1.4159 +**         // An instance of phrase iPhrase at offset iOff of column iCol
  1.4160 +**       }
  1.4161 +**
  1.4162 +**   The Fts5PhraseIter structure is defined above. Applications should not
  1.4163 +**   modify this structure directly - it should only be used as shown above
  1.4164 +**   with the xPhraseFirst() and xPhraseNext() API methods (and by
  1.4165 +**   xPhraseFirstColumn() and xPhraseNextColumn() as illustrated below).
  1.4166 +**
  1.4167 +**   This API can be quite slow if used with an FTS5 table created with the
  1.4168 +**   "detail=none" or "detail=column" option. If the FTS5 table is created 
  1.4169 +**   with either "detail=none" or "detail=column" and "content=" option 
  1.4170 +**   (i.e. if it is a contentless table), then this API always iterates
  1.4171 +**   through an empty set (all calls to xPhraseFirst() set iCol to -1).
  1.4172 +**
  1.4173 +** xPhraseNext()
  1.4174 +**   See xPhraseFirst above.
  1.4175 +**
  1.4176 +** xPhraseFirstColumn()
  1.4177 +**   This function and xPhraseNextColumn() are similar to the xPhraseFirst()
  1.4178 +**   and xPhraseNext() APIs described above. The difference is that instead
  1.4179 +**   of iterating through all instances of a phrase in the current row, these
  1.4180 +**   APIs are used to iterate through the set of columns in the current row
  1.4181 +**   that contain one or more instances of a specified phrase. For example:
  1.4182 +**
  1.4183 +**       Fts5PhraseIter iter;
  1.4184 +**       int iCol;
  1.4185 +**       for(pApi->xPhraseFirstColumn(pFts, iPhrase, &iter, &iCol);
  1.4186 +**           iCol>=0;
  1.4187 +**           pApi->xPhraseNextColumn(pFts, &iter, &iCol)
  1.4188 +**       ){
  1.4189 +**         // Column iCol contains at least one instance of phrase iPhrase
  1.4190 +**       }
  1.4191 +**
  1.4192 +**   This API can be quite slow if used with an FTS5 table created with the
  1.4193 +**   "detail=none" option. If the FTS5 table is created with either 
  1.4194 +**   "detail=none" "content=" option (i.e. if it is a contentless table), 
  1.4195 +**   then this API always iterates through an empty set (all calls to 
  1.4196 +**   xPhraseFirstColumn() set iCol to -1).
  1.4197 +**
  1.4198 +**   The information accessed using this API and its companion
  1.4199 +**   xPhraseFirstColumn() may also be obtained using xPhraseFirst/xPhraseNext
  1.4200 +**   (or xInst/xInstCount). The chief advantage of this API is that it is
  1.4201 +**   significantly more efficient than those alternatives when used with
  1.4202 +**   "detail=column" tables.  
  1.4203 +**
  1.4204 +** xPhraseNextColumn()
  1.4205 +**   See xPhraseFirstColumn above.
  1.4206 +*/
  1.4207 +struct Fts5ExtensionApi {
  1.4208 +  int iVersion;                   /* Currently always set to 3 */
  1.4209 +
  1.4210 +  void *(*xUserData)(Fts5Context*);
  1.4211 +
  1.4212 +  int (*xColumnCount)(Fts5Context*);
  1.4213 +  int (*xRowCount)(Fts5Context*, sqlite3_int64 *pnRow);
  1.4214 +  int (*xColumnTotalSize)(Fts5Context*, int iCol, sqlite3_int64 *pnToken);
  1.4215 +
  1.4216 +  int (*xTokenize)(Fts5Context*, 
  1.4217 +    const char *pText, int nText, /* Text to tokenize */
  1.4218 +    void *pCtx,                   /* Context passed to xToken() */
  1.4219 +    int (*xToken)(void*, int, const char*, int, int, int)       /* Callback */
  1.4220 +  );
  1.4221 +
  1.4222 +  int (*xPhraseCount)(Fts5Context*);
  1.4223 +  int (*xPhraseSize)(Fts5Context*, int iPhrase);
  1.4224 +
  1.4225 +  int (*xInstCount)(Fts5Context*, int *pnInst);
  1.4226 +  int (*xInst)(Fts5Context*, int iIdx, int *piPhrase, int *piCol, int *piOff);
  1.4227 +
  1.4228 +  sqlite3_int64 (*xRowid)(Fts5Context*);
  1.4229 +  int (*xColumnText)(Fts5Context*, int iCol, const char **pz, int *pn);
  1.4230 +  int (*xColumnSize)(Fts5Context*, int iCol, int *pnToken);
  1.4231 +
  1.4232 +  int (*xQueryPhrase)(Fts5Context*, int iPhrase, void *pUserData,
  1.4233 +    int(*)(const Fts5ExtensionApi*,Fts5Context*,void*)
  1.4234 +  );
  1.4235 +  int (*xSetAuxdata)(Fts5Context*, void *pAux, void(*xDelete)(void*));
  1.4236 +  void *(*xGetAuxdata)(Fts5Context*, int bClear);
  1.4237 +
  1.4238 +  int (*xPhraseFirst)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*, int*);
  1.4239 +  void (*xPhraseNext)(Fts5Context*, Fts5PhraseIter*, int *piCol, int *piOff);
  1.4240 +
  1.4241 +  int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*);
  1.4242 +  void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol);
  1.4243 +};
  1.4244 +
  1.4245 +/* 
  1.4246 +** CUSTOM AUXILIARY FUNCTIONS
  1.4247 +*************************************************************************/
  1.4248 +
  1.4249 +/*************************************************************************
  1.4250 +** CUSTOM TOKENIZERS
  1.4251 +**
  1.4252 +** Applications may also register custom tokenizer types. A tokenizer 
  1.4253 +** is registered by providing fts5 with a populated instance of the 
  1.4254 +** following structure. All structure methods must be defined, setting
  1.4255 +** any member of the fts5_tokenizer struct to NULL leads to undefined
  1.4256 +** behaviour. The structure methods are expected to function as follows:
  1.4257 +**
  1.4258 +** xCreate:
  1.4259 +**   This function is used to allocate and inititalize a tokenizer instance.
  1.4260 +**   A tokenizer instance is required to actually tokenize text.
  1.4261 +**
  1.4262 +**   The first argument passed to this function is a copy of the (void*)
  1.4263 +**   pointer provided by the application when the fts5_tokenizer object
  1.4264 +**   was registered with FTS5 (the third argument to xCreateTokenizer()). 
  1.4265 +**   The second and third arguments are an array of nul-terminated strings
  1.4266 +**   containing the tokenizer arguments, if any, specified following the
  1.4267 +**   tokenizer name as part of the CREATE VIRTUAL TABLE statement used
  1.4268 +**   to create the FTS5 table.
  1.4269 +**
  1.4270 +**   The final argument is an output variable. If successful, (*ppOut) 
  1.4271 +**   should be set to point to the new tokenizer handle and SQLITE_OK
  1.4272 +**   returned. If an error occurs, some value other than SQLITE_OK should
  1.4273 +**   be returned. In this case, fts5 assumes that the final value of *ppOut 
  1.4274 +**   is undefined.
  1.4275 +**
  1.4276 +** xDelete:
  1.4277 +**   This function is invoked to delete a tokenizer handle previously
  1.4278 +**   allocated using xCreate(). Fts5 guarantees that this function will
  1.4279 +**   be invoked exactly once for each successful call to xCreate().
  1.4280 +**
  1.4281 +** xTokenize:
  1.4282 +**   This function is expected to tokenize the nText byte string indicated 
  1.4283 +**   by argument pText. pText may or may not be nul-terminated. The first
  1.4284 +**   argument passed to this function is a pointer to an Fts5Tokenizer object
  1.4285 +**   returned by an earlier call to xCreate().
  1.4286 +**
  1.4287 +**   The second argument indicates the reason that FTS5 is requesting
  1.4288 +**   tokenization of the supplied text. This is always one of the following
  1.4289 +**   four values:
  1.4290 +**
  1.4291 +**   <ul><li> <b>FTS5_TOKENIZE_DOCUMENT</b> - A document is being inserted into
  1.4292 +**            or removed from the FTS table. The tokenizer is being invoked to
  1.4293 +**            determine the set of tokens to add to (or delete from) the
  1.4294 +**            FTS index.
  1.4295 +**
  1.4296 +**       <li> <b>FTS5_TOKENIZE_QUERY</b> - A MATCH query is being executed 
  1.4297 +**            against the FTS index. The tokenizer is being called to tokenize 
  1.4298 +**            a bareword or quoted string specified as part of the query.
  1.4299 +**
  1.4300 +**       <li> <b>(FTS5_TOKENIZE_QUERY | FTS5_TOKENIZE_PREFIX)</b> - Same as
  1.4301 +**            FTS5_TOKENIZE_QUERY, except that the bareword or quoted string is
  1.4302 +**            followed by a "*" character, indicating that the last token
  1.4303 +**            returned by the tokenizer will be treated as a token prefix.
  1.4304 +**
  1.4305 +**       <li> <b>FTS5_TOKENIZE_AUX</b> - The tokenizer is being invoked to 
  1.4306 +**            satisfy an fts5_api.xTokenize() request made by an auxiliary
  1.4307 +**            function. Or an fts5_api.xColumnSize() request made by the same
  1.4308 +**            on a columnsize=0 database.  
  1.4309 +**   </ul>
  1.4310 +**
  1.4311 +**   For each token in the input string, the supplied callback xToken() must
  1.4312 +**   be invoked. The first argument to it should be a copy of the pointer
  1.4313 +**   passed as the second argument to xTokenize(). The third and fourth
  1.4314 +**   arguments are a pointer to a buffer containing the token text, and the
  1.4315 +**   size of the token in bytes. The 4th and 5th arguments are the byte offsets
  1.4316 +**   of the first byte of and first byte immediately following the text from
  1.4317 +**   which the token is derived within the input.
  1.4318 +**
  1.4319 +**   The second argument passed to the xToken() callback ("tflags") should
  1.4320 +**   normally be set to 0. The exception is if the tokenizer supports 
  1.4321 +**   synonyms. In this case see the discussion below for details.
  1.4322 +**
  1.4323 +**   FTS5 assumes the xToken() callback is invoked for each token in the 
  1.4324 +**   order that they occur within the input text.
  1.4325 +**
  1.4326 +**   If an xToken() callback returns any value other than SQLITE_OK, then
  1.4327 +**   the tokenization should be abandoned and the xTokenize() method should
  1.4328 +**   immediately return a copy of the xToken() return value. Or, if the
  1.4329 +**   input buffer is exhausted, xTokenize() should return SQLITE_OK. Finally,
  1.4330 +**   if an error occurs with the xTokenize() implementation itself, it
  1.4331 +**   may abandon the tokenization and return any error code other than
  1.4332 +**   SQLITE_OK or SQLITE_DONE.
  1.4333 +**
  1.4334 +** SYNONYM SUPPORT
  1.4335 +**
  1.4336 +**   Custom tokenizers may also support synonyms. Consider a case in which a
  1.4337 +**   user wishes to query for a phrase such as "first place". Using the 
  1.4338 +**   built-in tokenizers, the FTS5 query 'first + place' will match instances
  1.4339 +**   of "first place" within the document set, but not alternative forms
  1.4340 +**   such as "1st place". In some applications, it would be better to match
  1.4341 +**   all instances of "first place" or "1st place" regardless of which form
  1.4342 +**   the user specified in the MATCH query text.
  1.4343 +**
  1.4344 +**   There are several ways to approach this in FTS5:
  1.4345 +**
  1.4346 +**   <ol><li> By mapping all synonyms to a single token. In this case, the 
  1.4347 +**            In the above example, this means that the tokenizer returns the
  1.4348 +**            same token for inputs "first" and "1st". Say that token is in
  1.4349 +**            fact "first", so that when the user inserts the document "I won
  1.4350 +**            1st place" entries are added to the index for tokens "i", "won",
  1.4351 +**            "first" and "place". If the user then queries for '1st + place',
  1.4352 +**            the tokenizer substitutes "first" for "1st" and the query works
  1.4353 +**            as expected.
  1.4354 +**
  1.4355 +**       <li> By adding multiple synonyms for a single term to the FTS index.
  1.4356 +**            In this case, when tokenizing query text, the tokenizer may 
  1.4357 +**            provide multiple synonyms for a single term within the document.
  1.4358 +**            FTS5 then queries the index for each synonym individually. For
  1.4359 +**            example, faced with the query:
  1.4360 +**
  1.4361 +**   <codeblock>
  1.4362 +**     ... MATCH 'first place'</codeblock>
  1.4363 +**
  1.4364 +**            the tokenizer offers both "1st" and "first" as synonyms for the
  1.4365 +**            first token in the MATCH query and FTS5 effectively runs a query 
  1.4366 +**            similar to:
  1.4367 +**
  1.4368 +**   <codeblock>
  1.4369 +**     ... MATCH '(first OR 1st) place'</codeblock>
  1.4370 +**
  1.4371 +**            except that, for the purposes of auxiliary functions, the query
  1.4372 +**            still appears to contain just two phrases - "(first OR 1st)" 
  1.4373 +**            being treated as a single phrase.
  1.4374 +**
  1.4375 +**       <li> By adding multiple synonyms for a single term to the FTS index.
  1.4376 +**            Using this method, when tokenizing document text, the tokenizer
  1.4377 +**            provides multiple synonyms for each token. So that when a 
  1.4378 +**            document such as "I won first place" is tokenized, entries are
  1.4379 +**            added to the FTS index for "i", "won", "first", "1st" and
  1.4380 +**            "place".
  1.4381 +**
  1.4382 +**            This way, even if the tokenizer does not provide synonyms
  1.4383 +**            when tokenizing query text (it should not - to do would be
  1.4384 +**            inefficient), it doesn't matter if the user queries for 
  1.4385 +**            'first + place' or '1st + place', as there are entires in the
  1.4386 +**            FTS index corresponding to both forms of the first token.
  1.4387 +**   </ol>
  1.4388 +**
  1.4389 +**   Whether it is parsing document or query text, any call to xToken that
  1.4390 +**   specifies a <i>tflags</i> argument with the FTS5_TOKEN_COLOCATED bit
  1.4391 +**   is considered to supply a synonym for the previous token. For example,
  1.4392 +**   when parsing the document "I won first place", a tokenizer that supports
  1.4393 +**   synonyms would call xToken() 5 times, as follows:
  1.4394 +**
  1.4395 +**   <codeblock>
  1.4396 +**       xToken(pCtx, 0, "i",                      1,  0,  1);
  1.4397 +**       xToken(pCtx, 0, "won",                    3,  2,  5);
  1.4398 +**       xToken(pCtx, 0, "first",                  5,  6, 11);
  1.4399 +**       xToken(pCtx, FTS5_TOKEN_COLOCATED, "1st", 3,  6, 11);
  1.4400 +**       xToken(pCtx, 0, "place",                  5, 12, 17);
  1.4401 +**</codeblock>
  1.4402 +**
  1.4403 +**   It is an error to specify the FTS5_TOKEN_COLOCATED flag the first time
  1.4404 +**   xToken() is called. Multiple synonyms may be specified for a single token
  1.4405 +**   by making multiple calls to xToken(FTS5_TOKEN_COLOCATED) in sequence. 
  1.4406 +**   There is no limit to the number of synonyms that may be provided for a
  1.4407 +**   single token.
  1.4408 +**
  1.4409 +**   In many cases, method (1) above is the best approach. It does not add 
  1.4410 +**   extra data to the FTS index or require FTS5 to query for multiple terms,
  1.4411 +**   so it is efficient in terms of disk space and query speed. However, it
  1.4412 +**   does not support prefix queries very well. If, as suggested above, the
  1.4413 +**   token "first" is subsituted for "1st" by the tokenizer, then the query:
  1.4414 +**
  1.4415 +**   <codeblock>
  1.4416 +**     ... MATCH '1s*'</codeblock>
  1.4417 +**
  1.4418 +**   will not match documents that contain the token "1st" (as the tokenizer
  1.4419 +**   will probably not map "1s" to any prefix of "first").
  1.4420 +**
  1.4421 +**   For full prefix support, method (3) may be preferred. In this case, 
  1.4422 +**   because the index contains entries for both "first" and "1st", prefix
  1.4423 +**   queries such as 'fi*' or '1s*' will match correctly. However, because
  1.4424 +**   extra entries are added to the FTS index, this method uses more space
  1.4425 +**   within the database.
  1.4426 +**
  1.4427 +**   Method (2) offers a midpoint between (1) and (3). Using this method,
  1.4428 +**   a query such as '1s*' will match documents that contain the literal 
  1.4429 +**   token "1st", but not "first" (assuming the tokenizer is not able to
  1.4430 +**   provide synonyms for prefixes). However, a non-prefix query like '1st'
  1.4431 +**   will match against "1st" and "first". This method does not require
  1.4432 +**   extra disk space, as no extra entries are added to the FTS index. 
  1.4433 +**   On the other hand, it may require more CPU cycles to run MATCH queries,
  1.4434 +**   as separate queries of the FTS index are required for each synonym.
  1.4435 +**
  1.4436 +**   When using methods (2) or (3), it is important that the tokenizer only
  1.4437 +**   provide synonyms when tokenizing document text (method (2)) or query
  1.4438 +**   text (method (3)), not both. Doing so will not cause any errors, but is
  1.4439 +**   inefficient.
  1.4440 +*/
  1.4441 +typedef struct Fts5Tokenizer Fts5Tokenizer;
  1.4442 +typedef struct fts5_tokenizer fts5_tokenizer;
  1.4443 +struct fts5_tokenizer {
  1.4444 +  int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut);
  1.4445 +  void (*xDelete)(Fts5Tokenizer*);
  1.4446 +  int (*xTokenize)(Fts5Tokenizer*, 
  1.4447 +      void *pCtx,
  1.4448 +      int flags,            /* Mask of FTS5_TOKENIZE_* flags */
  1.4449 +      const char *pText, int nText, 
  1.4450 +      int (*xToken)(
  1.4451 +        void *pCtx,         /* Copy of 2nd argument to xTokenize() */
  1.4452 +        int tflags,         /* Mask of FTS5_TOKEN_* flags */
  1.4453 +        const char *pToken, /* Pointer to buffer containing token */
  1.4454 +        int nToken,         /* Size of token in bytes */
  1.4455 +        int iStart,         /* Byte offset of token within input text */
  1.4456 +        int iEnd            /* Byte offset of end of token within input text */
  1.4457 +      )
  1.4458 +  );
  1.4459 +};
  1.4460 +
  1.4461 +/* Flags that may be passed as the third argument to xTokenize() */
  1.4462 +#define FTS5_TOKENIZE_QUERY     0x0001
  1.4463 +#define FTS5_TOKENIZE_PREFIX    0x0002
  1.4464 +#define FTS5_TOKENIZE_DOCUMENT  0x0004
  1.4465 +#define FTS5_TOKENIZE_AUX       0x0008
  1.4466 +
  1.4467 +/* Flags that may be passed by the tokenizer implementation back to FTS5
  1.4468 +** as the third argument to the supplied xToken callback. */
  1.4469 +#define FTS5_TOKEN_COLOCATED    0x0001      /* Same position as prev. token */
  1.4470 +
  1.4471 +/*
  1.4472 +** END OF CUSTOM TOKENIZERS
  1.4473 +*************************************************************************/
  1.4474 +
  1.4475 +/*************************************************************************
  1.4476 +** FTS5 EXTENSION REGISTRATION API
  1.4477 +*/
  1.4478 +typedef struct fts5_api fts5_api;
  1.4479 +struct fts5_api {
  1.4480 +  int iVersion;                   /* Currently always set to 2 */
  1.4481 +
  1.4482 +  /* Create a new tokenizer */
  1.4483 +  int (*xCreateTokenizer)(
  1.4484 +    fts5_api *pApi,
  1.4485 +    const char *zName,
  1.4486 +    void *pContext,
  1.4487 +    fts5_tokenizer *pTokenizer,
  1.4488 +    void (*xDestroy)(void*)
  1.4489 +  );
  1.4490 +
  1.4491 +  /* Find an existing tokenizer */
  1.4492 +  int (*xFindTokenizer)(
  1.4493 +    fts5_api *pApi,
  1.4494 +    const char *zName,
  1.4495 +    void **ppContext,
  1.4496 +    fts5_tokenizer *pTokenizer
  1.4497 +  );
  1.4498 +
  1.4499 +  /* Create a new auxiliary function */
  1.4500 +  int (*xCreateFunction)(
  1.4501 +    fts5_api *pApi,
  1.4502 +    const char *zName,
  1.4503 +    void *pContext,
  1.4504 +    fts5_extension_function xFunction,
  1.4505 +    void (*xDestroy)(void*)
  1.4506 +  );
  1.4507 +};
  1.4508 +
  1.4509 +/*
  1.4510 +** END OF REGISTRATION API
  1.4511 +*************************************************************************/
  1.4512 +
  1.4513 +#ifdef __cplusplus
  1.4514 +}  /* end of the 'extern "C"' block */
  1.4515 +#endif
  1.4516 +
  1.4517 +#endif /* _FTS5_H */
  1.4518 +
  1.4519 +