SQLite Archiver
Check-in [52199b0fb4]
Not logged in

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

Overview
Comment:Update to the version 3.13.0 of SQLite.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:52199b0fb4ee685a2e6c2223b68b95c940e26273
User & Date: drh 2016-07-11 19:22:30
Context
2016-08-22
17:23
Add the -d option to delete content from the SQLAR. Accept GLOB patterns as filenames for -l, -e, and -d. check-in: b45aa9345e user: drh tags: trunk
2016-07-11
19:22
Update to the version 3.13.0 of SQLite. check-in: 52199b0fb4 user: drh tags: trunk
19:21
Add support for encrypted SQL archives using the SQLite Encryption Extension. check-in: 06c26c027e user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to sqlite3.c.

more than 10,000 changes

Changes to sqlite3.h.

    19     19   ** "experimental".  Experimental interfaces are normally new
    20     20   ** features recently added to SQLite.  We do not anticipate changes
    21     21   ** to experimental interfaces but reserve the right to make minor changes
    22     22   ** if experience from use "in the wild" suggest such changes are prudent.
    23     23   **
    24     24   ** The official C-language API documentation for SQLite is derived
    25     25   ** from comments in this file.  This file is the authoritative source
    26         -** on how SQLite interfaces are suppose to operate.
           26  +** on how SQLite interfaces are supposed to operate.
    27     27   **
    28     28   ** The name of this file under configuration management is "sqlite.h.in".
    29     29   ** The makefile makes some minor changes to this file (such as inserting
    30     30   ** the version number) and changes its name to "sqlite3.h" as
    31     31   ** part of the build process.
    32     32   */
    33     33   #ifndef _SQLITE3_H_
................................................................................
    39     39   */
    40     40   #ifdef __cplusplus
    41     41   extern "C" {
    42     42   #endif
    43     43   
    44     44   
    45     45   /*
    46         -** Add the ability to override 'extern'
           46  +** Provide the ability to override linkage features of the interface.
    47     47   */
    48     48   #ifndef SQLITE_EXTERN
    49     49   # define SQLITE_EXTERN extern
    50     50   #endif
    51         -
    52     51   #ifndef SQLITE_API
    53     52   # define SQLITE_API
    54     53   #endif
    55         -
           54  +#ifndef SQLITE_CDECL
           55  +# define SQLITE_CDECL
           56  +#endif
           57  +#ifndef SQLITE_STDCALL
           58  +# define SQLITE_STDCALL
           59  +#endif
    56     60   
    57     61   /*
    58     62   ** These no-op macros are used in front of interfaces to mark those
    59     63   ** interfaces as either deprecated or experimental.  New applications
    60         -** should not use deprecated interfaces - they are support for backwards
           64  +** should not use deprecated interfaces - they are supported for backwards
    61     65   ** compatibility only.  Application writers should be aware that
    62     66   ** experimental interfaces are subject to change in point releases.
    63     67   **
    64     68   ** These macros used to resolve to various kinds of compiler magic that
    65     69   ** would generate warning messages when they were used.  But that
    66     70   ** compiler magic ended up generating such a flurry of bug reports
    67     71   ** that we have taken it all out and gone back to using simple
................................................................................
   103    107   ** string contains the date and time of the check-in (UTC) and an SHA1
   104    108   ** hash of the entire source tree.
   105    109   **
   106    110   ** See also: [sqlite3_libversion()],
   107    111   ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
   108    112   ** [sqlite_version()] and [sqlite_source_id()].
   109    113   */
   110         -#define SQLITE_VERSION        "3.8.6"
   111         -#define SQLITE_VERSION_NUMBER 3008006
   112         -#define SQLITE_SOURCE_ID      "2014-08-15 11:46:33 9491ba7d738528f168657adb43a198238abde19e"
          114  +#define SQLITE_VERSION        "3.13.0"
          115  +#define SQLITE_VERSION_NUMBER 3013000
          116  +#define SQLITE_SOURCE_ID      "2016-05-18 10:57:30 fc49f556e48970561d7ab6a2f24fdd7d9eb81ff2"
   113    117   
   114    118   /*
   115    119   ** CAPI3REF: Run-Time Library Version Numbers
   116    120   ** KEYWORDS: sqlite3_version, sqlite3_sourceid
   117    121   **
   118    122   ** These interfaces provide the same information as the [SQLITE_VERSION],
   119    123   ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
   120    124   ** but are associated with the library instead of the header file.  ^(Cautious
   121    125   ** programmers might include assert() statements in their application to
   122    126   ** verify that values returned by these interfaces match the macros in
   123         -** the header, and thus insure that the application is
          127  +** the header, and thus ensure that the application is
   124    128   ** compiled with matching library and header files.
   125    129   **
   126    130   ** <blockquote><pre>
   127    131   ** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
   128    132   ** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
   129    133   ** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
   130    134   ** </pre></blockquote>)^
................................................................................
   138    142   ** [SQLITE_VERSION_NUMBER].  ^The sqlite3_sourceid() function returns 
   139    143   ** a pointer to a string constant whose value is the same as the 
   140    144   ** [SQLITE_SOURCE_ID] C preprocessor macro.
   141    145   **
   142    146   ** See also: [sqlite_version()] and [sqlite_source_id()].
   143    147   */
   144    148   SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
   145         -SQLITE_API const char *sqlite3_libversion(void);
   146         -SQLITE_API const char *sqlite3_sourceid(void);
   147         -SQLITE_API int sqlite3_libversion_number(void);
          149  +SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void);
          150  +SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void);
          151  +SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void);
   148    152   
   149    153   /*
   150    154   ** CAPI3REF: Run-Time Library Compilation Options Diagnostics
   151    155   **
   152    156   ** ^The sqlite3_compileoption_used() function returns 0 or 1 
   153    157   ** indicating whether the specified option was defined at 
   154    158   ** compile time.  ^The SQLITE_ prefix may be omitted from the 
................................................................................
   165    169   ** and sqlite3_compileoption_get() may be omitted by specifying the 
   166    170   ** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time.
   167    171   **
   168    172   ** See also: SQL functions [sqlite_compileoption_used()] and
   169    173   ** [sqlite_compileoption_get()] and the [compile_options pragma].
   170    174   */
   171    175   #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
   172         -SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
   173         -SQLITE_API const char *sqlite3_compileoption_get(int N);
          176  +SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName);
          177  +SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N);
   174    178   #endif
   175    179   
   176    180   /*
   177    181   ** CAPI3REF: Test To See If The Library Is Threadsafe
   178    182   **
   179    183   ** ^The sqlite3_threadsafe() function returns zero if and only if
   180    184   ** SQLite was compiled with mutexing code omitted due to the
................................................................................
   197    201   ** the desired setting of the [SQLITE_THREADSAFE] macro.
   198    202   **
   199    203   ** This interface only reports on the compile-time mutex setting
   200    204   ** of the [SQLITE_THREADSAFE] flag.  If SQLite is compiled with
   201    205   ** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
   202    206   ** can be fully or partially disabled using a call to [sqlite3_config()]
   203    207   ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
   204         -** or [SQLITE_CONFIG_MUTEX].  ^(The return value of the
          208  +** or [SQLITE_CONFIG_SERIALIZED].  ^(The return value of the
   205    209   ** sqlite3_threadsafe() function shows only the compile-time setting of
   206    210   ** thread safety, not any run-time changes to that setting made by
   207    211   ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
   208    212   ** is unchanged by calls to sqlite3_config().)^
   209    213   **
   210    214   ** See the [threading mode] documentation for additional information.
   211    215   */
   212         -SQLITE_API int sqlite3_threadsafe(void);
          216  +SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void);
   213    217   
   214    218   /*
   215    219   ** CAPI3REF: Database Connection Handle
   216    220   ** KEYWORDS: {database connection} {database connections}
   217    221   **
   218    222   ** Each open SQLite database is represented by a pointer to an instance of
   219    223   ** the opaque structure named "sqlite3".  It is useful to think of an sqlite3
................................................................................
   262    266   */
   263    267   #ifdef SQLITE_OMIT_FLOATING_POINT
   264    268   # define double sqlite3_int64
   265    269   #endif
   266    270   
   267    271   /*
   268    272   ** CAPI3REF: Closing A Database Connection
          273  +** DESTRUCTOR: sqlite3
   269    274   **
   270    275   ** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors
   271    276   ** for the [sqlite3] object.
   272    277   ** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if
   273    278   ** the [sqlite3] object is successfully destroyed and all associated
   274    279   ** resources are deallocated.
   275    280   **
................................................................................
   301    306   ** must be either a NULL
   302    307   ** pointer or an [sqlite3] object pointer obtained
   303    308   ** from [sqlite3_open()], [sqlite3_open16()], or
   304    309   ** [sqlite3_open_v2()], and not previously closed.
   305    310   ** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
   306    311   ** argument is a harmless no-op.
   307    312   */
   308         -SQLITE_API int sqlite3_close(sqlite3*);
   309         -SQLITE_API int sqlite3_close_v2(sqlite3*);
          313  +SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3*);
          314  +SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3*);
   310    315   
   311    316   /*
   312    317   ** The type for a callback function.
   313    318   ** This is legacy and deprecated.  It is included for historical
   314    319   ** compatibility and is not documented.
   315    320   */
   316    321   typedef int (*sqlite3_callback)(void*,int,char**, char**);
   317    322   
   318    323   /*
   319    324   ** CAPI3REF: One-Step Query Execution Interface
          325  +** METHOD: sqlite3
   320    326   **
   321    327   ** The sqlite3_exec() interface is a convenience wrapper around
   322    328   ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
   323    329   ** that allows an application to run multiple statements of SQL
   324    330   ** without having to use a lot of C code. 
   325    331   **
   326    332   ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
................................................................................
   337    343   ** ^If an error occurs while evaluating the SQL statements passed into
   338    344   ** sqlite3_exec(), then execution of the current statement stops and
   339    345   ** subsequent statements are skipped.  ^If the 5th parameter to sqlite3_exec()
   340    346   ** is not NULL then any error message is written into memory obtained
   341    347   ** from [sqlite3_malloc()] and passed back through the 5th parameter.
   342    348   ** To avoid memory leaks, the application should invoke [sqlite3_free()]
   343    349   ** on error message strings returned through the 5th parameter of
   344         -** of sqlite3_exec() after the error message string is no longer needed.
          350  +** sqlite3_exec() after the error message string is no longer needed.
   345    351   ** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors
   346    352   ** occur, then sqlite3_exec() sets the pointer in its 5th parameter to
   347    353   ** NULL before returning.
   348    354   **
   349    355   ** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()
   350    356   ** routine returns SQLITE_ABORT without invoking the callback again and
   351    357   ** without running any subsequent SQL statements.
................................................................................
   364    370   ** to an empty string, or a pointer that contains only whitespace and/or 
   365    371   ** SQL comments, then no SQL statements are evaluated and the database
   366    372   ** is not changed.
   367    373   **
   368    374   ** Restrictions:
   369    375   **
   370    376   ** <ul>
   371         -** <li> The application must insure that the 1st parameter to sqlite3_exec()
          377  +** <li> The application must ensure that the 1st parameter to sqlite3_exec()
   372    378   **      is a valid and open [database connection].
   373    379   ** <li> The application must not close the [database connection] specified by
   374    380   **      the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
   375    381   ** <li> The application must not modify the SQL statement text passed into
   376    382   **      the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
   377    383   ** </ul>
   378    384   */
   379         -SQLITE_API int sqlite3_exec(
          385  +SQLITE_API int SQLITE_STDCALL sqlite3_exec(
   380    386     sqlite3*,                                  /* An open database */
   381    387     const char *sql,                           /* SQL to be evaluated */
   382    388     int (*callback)(void*,int,char**,char**),  /* Callback function */
   383    389     void *,                                    /* 1st argument to callback */
   384    390     char **errmsg                              /* Error msg written here */
   385    391   );
   386    392   
................................................................................
   467    473   #define SQLITE_IOERR_SHMLOCK           (SQLITE_IOERR | (20<<8))
   468    474   #define SQLITE_IOERR_SHMMAP            (SQLITE_IOERR | (21<<8))
   469    475   #define SQLITE_IOERR_SEEK              (SQLITE_IOERR | (22<<8))
   470    476   #define SQLITE_IOERR_DELETE_NOENT      (SQLITE_IOERR | (23<<8))
   471    477   #define SQLITE_IOERR_MMAP              (SQLITE_IOERR | (24<<8))
   472    478   #define SQLITE_IOERR_GETTEMPPATH       (SQLITE_IOERR | (25<<8))
   473    479   #define SQLITE_IOERR_CONVPATH          (SQLITE_IOERR | (26<<8))
          480  +#define SQLITE_IOERR_VNODE             (SQLITE_IOERR | (27<<8))
          481  +#define SQLITE_IOERR_AUTH              (SQLITE_IOERR | (28<<8))
   474    482   #define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))
   475    483   #define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))
   476    484   #define SQLITE_BUSY_SNAPSHOT           (SQLITE_BUSY   |  (2<<8))
   477    485   #define SQLITE_CANTOPEN_NOTEMPDIR      (SQLITE_CANTOPEN | (1<<8))
   478    486   #define SQLITE_CANTOPEN_ISDIR          (SQLITE_CANTOPEN | (2<<8))
   479    487   #define SQLITE_CANTOPEN_FULLPATH       (SQLITE_CANTOPEN | (3<<8))
   480    488   #define SQLITE_CANTOPEN_CONVPATH       (SQLITE_CANTOPEN | (4<<8))
................................................................................
   493    501   #define SQLITE_CONSTRAINT_TRIGGER      (SQLITE_CONSTRAINT | (7<<8))
   494    502   #define SQLITE_CONSTRAINT_UNIQUE       (SQLITE_CONSTRAINT | (8<<8))
   495    503   #define SQLITE_CONSTRAINT_VTAB         (SQLITE_CONSTRAINT | (9<<8))
   496    504   #define SQLITE_CONSTRAINT_ROWID        (SQLITE_CONSTRAINT |(10<<8))
   497    505   #define SQLITE_NOTICE_RECOVER_WAL      (SQLITE_NOTICE | (1<<8))
   498    506   #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
   499    507   #define SQLITE_WARNING_AUTOINDEX       (SQLITE_WARNING | (1<<8))
          508  +#define SQLITE_AUTH_USER               (SQLITE_AUTH | (1<<8))
   500    509   
   501    510   /*
   502    511   ** CAPI3REF: Flags For File Open Operations
   503    512   **
   504    513   ** These bit values are intended for use in the
   505    514   ** 3rd parameter to the [sqlite3_open_v2()] interface and
   506    515   ** in the 4th parameter to the [sqlite3_vfs.xOpen] method.
................................................................................
   751    760   ** CAPI3REF: Standard File Control Opcodes
   752    761   ** KEYWORDS: {file control opcodes} {file control opcode}
   753    762   **
   754    763   ** These integer constants are opcodes for the xFileControl method
   755    764   ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
   756    765   ** interface.
   757    766   **
          767  +** <ul>
          768  +** <li>[[SQLITE_FCNTL_LOCKSTATE]]
   758    769   ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging.  This
   759    770   ** opcode causes the xFileControl method to write the current state of
   760    771   ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
   761    772   ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
   762    773   ** into an integer that the pArg argument points to. This capability
   763         -** is used during testing and only needs to be supported when SQLITE_TEST
   764         -** is defined.
   765         -** <ul>
          774  +** is used during testing and is only available when the SQLITE_TEST
          775  +** compile-time option is used.
          776  +**
   766    777   ** <li>[[SQLITE_FCNTL_SIZE_HINT]]
   767    778   ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
   768    779   ** layer a hint of how large the database file will grow to be during the
   769    780   ** current transaction.  This hint is not guaranteed to be accurate but it
   770    781   ** is often close.  The underlying VFS might choose to preallocate database
   771    782   ** file space based on this hint in order to help writes to the database
   772    783   ** file run faster.
................................................................................
   779    790   ** for the nominated database. Allocating database file space in large
   780    791   ** chunks (say 1MB at a time), may reduce file-system fragmentation and
   781    792   ** improve performance on some systems.
   782    793   **
   783    794   ** <li>[[SQLITE_FCNTL_FILE_POINTER]]
   784    795   ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer
   785    796   ** to the [sqlite3_file] object associated with a particular database
   786         -** connection.  See the [sqlite3_file_control()] documentation for
   787         -** additional information.
          797  +** connection.  See also [SQLITE_FCNTL_JOURNAL_POINTER].
          798  +**
          799  +** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]]
          800  +** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer
          801  +** to the [sqlite3_file] object associated with the journal file (either
          802  +** the [rollback journal] or the [write-ahead log]) for a particular database
          803  +** connection.  See also [SQLITE_FCNTL_FILE_POINTER].
   788    804   **
   789    805   ** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]
   790    806   ** No longer in use.
   791    807   **
   792    808   ** <li>[[SQLITE_FCNTL_SYNC]]
   793    809   ** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and
   794    810   ** sent to the VFS immediately before the xSync method is invoked on a
................................................................................
   866    882   ** [sqlite3_malloc()] and the result is stored in the char* variable
   867    883   ** that the fourth parameter of [sqlite3_file_control()] points to.
   868    884   ** The caller is responsible for freeing the memory when done.  As with
   869    885   ** all file-control actions, there is no guarantee that this will actually
   870    886   ** do anything.  Callers should initialize the char* variable to a NULL
   871    887   ** pointer in case this file-control is not implemented.  This file-control
   872    888   ** is intended for diagnostic use only.
          889  +**
          890  +** <li>[[SQLITE_FCNTL_VFS_POINTER]]
          891  +** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level
          892  +** [VFSes] currently in use.  ^(The argument X in
          893  +** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be
          894  +** of type "[sqlite3_vfs] **".  This opcodes will set *X
          895  +** to a pointer to the top-level VFS.)^
          896  +** ^When there are multiple VFS shims in the stack, this opcode finds the
          897  +** upper-most shim only.
   873    898   **
   874    899   ** <li>[[SQLITE_FCNTL_PRAGMA]]
   875    900   ** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] 
   876    901   ** file control is sent to the open [sqlite3_file] object corresponding
   877    902   ** to the database file to which the pragma statement refers. ^The argument
   878    903   ** to the [SQLITE_FCNTL_PRAGMA] file control is an array of
   879    904   ** pointers to strings (char**) in which the second element of the array
................................................................................
   883    908   ** of the char** argument point to a string obtained from [sqlite3_mprintf()]
   884    909   ** or the equivalent and that string will become the result of the pragma or
   885    910   ** the error message if the pragma fails. ^If the
   886    911   ** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal 
   887    912   ** [PRAGMA] processing continues.  ^If the [SQLITE_FCNTL_PRAGMA]
   888    913   ** file control returns [SQLITE_OK], then the parser assumes that the
   889    914   ** VFS has handled the PRAGMA itself and the parser generates a no-op
   890         -** prepared statement.  ^If the [SQLITE_FCNTL_PRAGMA] file control returns
          915  +** prepared statement if result string is NULL, or that returns a copy
          916  +** of the result string if the string is non-NULL.
          917  +** ^If the [SQLITE_FCNTL_PRAGMA] file control returns
   891    918   ** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
   892    919   ** that the VFS encountered an error while handling the [PRAGMA] and the
   893    920   ** compilation of the PRAGMA fails with an error.  ^The [SQLITE_FCNTL_PRAGMA]
   894    921   ** file control occurs at the beginning of pragma statement analysis and so
   895    922   ** it is able to override built-in [PRAGMA] statements.
   896    923   **
   897    924   ** <li>[[SQLITE_FCNTL_BUSYHANDLER]]
................................................................................
   941    968   **
   942    969   ** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]
   943    970   ** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging.  This
   944    971   ** opcode causes the xFileControl method to swap the file handle with the one
   945    972   ** pointed to by the pArg argument.  This capability is used during testing
   946    973   ** and only needs to be supported when SQLITE_TEST is defined.
   947    974   **
          975  +** <li>[[SQLITE_FCNTL_WAL_BLOCK]]
          976  +** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might
          977  +** be advantageous to block on the next WAL lock if the lock is not immediately
          978  +** available.  The WAL subsystem issues this signal during rare
          979  +** circumstances in order to fix a problem with priority inversion.
          980  +** Applications should <em>not</em> use this file-control.
          981  +**
          982  +** <li>[[SQLITE_FCNTL_ZIPVFS]]
          983  +** The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other
          984  +** VFS should return SQLITE_NOTFOUND for this opcode.
          985  +**
          986  +** <li>[[SQLITE_FCNTL_RBU]]
          987  +** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by
          988  +** the RBU extension only.  All other VFS should return SQLITE_NOTFOUND for
          989  +** this opcode.  
   948    990   ** </ul>
   949    991   */
   950    992   #define SQLITE_FCNTL_LOCKSTATE               1
   951         -#define SQLITE_GET_LOCKPROXYFILE             2
   952         -#define SQLITE_SET_LOCKPROXYFILE             3
   953         -#define SQLITE_LAST_ERRNO                    4
          993  +#define SQLITE_FCNTL_GET_LOCKPROXYFILE       2
          994  +#define SQLITE_FCNTL_SET_LOCKPROXYFILE       3
          995  +#define SQLITE_FCNTL_LAST_ERRNO              4
   954    996   #define SQLITE_FCNTL_SIZE_HINT               5
   955    997   #define SQLITE_FCNTL_CHUNK_SIZE              6
   956    998   #define SQLITE_FCNTL_FILE_POINTER            7
   957    999   #define SQLITE_FCNTL_SYNC_OMITTED            8
   958   1000   #define SQLITE_FCNTL_WIN32_AV_RETRY          9
   959   1001   #define SQLITE_FCNTL_PERSIST_WAL            10
   960   1002   #define SQLITE_FCNTL_OVERWRITE              11
................................................................................
   965   1007   #define SQLITE_FCNTL_TEMPFILENAME           16
   966   1008   #define SQLITE_FCNTL_MMAP_SIZE              18
   967   1009   #define SQLITE_FCNTL_TRACE                  19
   968   1010   #define SQLITE_FCNTL_HAS_MOVED              20
   969   1011   #define SQLITE_FCNTL_SYNC                   21
   970   1012   #define SQLITE_FCNTL_COMMIT_PHASETWO        22
   971   1013   #define SQLITE_FCNTL_WIN32_SET_HANDLE       23
         1014  +#define SQLITE_FCNTL_WAL_BLOCK              24
         1015  +#define SQLITE_FCNTL_ZIPVFS                 25
         1016  +#define SQLITE_FCNTL_RBU                    26
         1017  +#define SQLITE_FCNTL_VFS_POINTER            27
         1018  +#define SQLITE_FCNTL_JOURNAL_POINTER        28
         1019  +
         1020  +/* deprecated names */
         1021  +#define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE
         1022  +#define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE
         1023  +#define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO
         1024  +
   972   1025   
   973   1026   /*
   974   1027   ** CAPI3REF: Mutex Handle
   975   1028   **
   976   1029   ** The mutex module within SQLite defines [sqlite3_mutex] to be an
   977   1030   ** abstract type for a mutex object.  The SQLite core never looks
   978   1031   ** at the internal representation of an [sqlite3_mutex].  It only
................................................................................
  1171   1224     ** Those below are for version 3 and greater.
  1172   1225     */
  1173   1226     int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr);
  1174   1227     sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName);
  1175   1228     const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);
  1176   1229     /*
  1177   1230     ** The methods above are in versions 1 through 3 of the sqlite_vfs object.
  1178         -  ** New fields may be appended in figure versions.  The iVersion
         1231  +  ** New fields may be appended in future versions.  The iVersion
  1179   1232     ** value will increment whenever this happens. 
  1180   1233     */
  1181   1234   };
  1182   1235   
  1183   1236   /*
  1184   1237   ** CAPI3REF: Flags for the xAccess VFS method
  1185   1238   **
................................................................................
  1216   1269   ** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_SHARED
  1217   1270   ** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE
  1218   1271   ** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED
  1219   1272   ** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE
  1220   1273   ** </ul>
  1221   1274   **
  1222   1275   ** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as
  1223         -** was given no the corresponding lock.  
         1276  +** was given on the corresponding lock.  
  1224   1277   **
  1225   1278   ** The xShmLock method can transition between unlocked and SHARED or
  1226   1279   ** between unlocked and EXCLUSIVE.  It cannot transition between SHARED
  1227   1280   ** and EXCLUSIVE.
  1228   1281   */
  1229   1282   #define SQLITE_SHM_UNLOCK       1
  1230   1283   #define SQLITE_SHM_LOCK         2
................................................................................
  1313   1366   ** (using the [SQLITE_OS_OTHER=1] compile-time
  1314   1367   ** option) the application must supply a suitable implementation for
  1315   1368   ** sqlite3_os_init() and sqlite3_os_end().  An application-supplied
  1316   1369   ** implementation of sqlite3_os_init() or sqlite3_os_end()
  1317   1370   ** must return [SQLITE_OK] on success and some other [error code] upon
  1318   1371   ** failure.
  1319   1372   */
  1320         -SQLITE_API int sqlite3_initialize(void);
  1321         -SQLITE_API int sqlite3_shutdown(void);
  1322         -SQLITE_API int sqlite3_os_init(void);
  1323         -SQLITE_API int sqlite3_os_end(void);
         1373  +SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void);
         1374  +SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void);
         1375  +SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void);
         1376  +SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void);
  1324   1377   
  1325   1378   /*
  1326   1379   ** CAPI3REF: Configuring The SQLite Library
  1327   1380   **
  1328   1381   ** The sqlite3_config() interface is used to make global configuration
  1329   1382   ** changes to SQLite in order to tune SQLite to the specific needs of
  1330   1383   ** the application.  The default configuration is recommended for most
  1331   1384   ** applications and so this routine is usually not necessary.  It is
  1332   1385   ** provided to support rare applications with unusual needs.
  1333   1386   **
  1334         -** The sqlite3_config() interface is not threadsafe.  The application
  1335         -** must insure that no other SQLite interfaces are invoked by other
  1336         -** threads while sqlite3_config() is running.  Furthermore, sqlite3_config()
         1387  +** <b>The sqlite3_config() interface is not threadsafe. The application
         1388  +** must ensure that no other SQLite interfaces are invoked by other
         1389  +** threads while sqlite3_config() is running.</b>
         1390  +**
         1391  +** The sqlite3_config() interface
  1337   1392   ** may only be invoked prior to library initialization using
  1338   1393   ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
  1339   1394   ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
  1340   1395   ** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.
  1341   1396   ** Note, however, that ^sqlite3_config() can be called as part of the
  1342   1397   ** implementation of an application-defined [sqlite3_os_init()].
  1343   1398   **
................................................................................
  1347   1402   ** vary depending on the [configuration option]
  1348   1403   ** in the first argument.
  1349   1404   **
  1350   1405   ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
  1351   1406   ** ^If the option is unknown or SQLite is unable to set the option
  1352   1407   ** then this routine returns a non-zero [error code].
  1353   1408   */
  1354         -SQLITE_API int sqlite3_config(int, ...);
         1409  +SQLITE_API int SQLITE_CDECL sqlite3_config(int, ...);
  1355   1410   
  1356   1411   /*
  1357   1412   ** CAPI3REF: Configure database connections
         1413  +** METHOD: sqlite3
  1358   1414   **
  1359   1415   ** The sqlite3_db_config() interface is used to make configuration
  1360   1416   ** changes to a [database connection].  The interface is similar to
  1361   1417   ** [sqlite3_config()] except that the changes apply to a single
  1362   1418   ** [database connection] (specified in the first argument).
  1363   1419   **
  1364   1420   ** The second argument to sqlite3_db_config(D,V,...)  is the
................................................................................
  1365   1421   ** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code 
  1366   1422   ** that indicates what aspect of the [database connection] is being configured.
  1367   1423   ** Subsequent arguments vary depending on the configuration verb.
  1368   1424   **
  1369   1425   ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
  1370   1426   ** the call is considered successful.
  1371   1427   */
  1372         -SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
         1428  +SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3*, int op, ...);
  1373   1429   
  1374   1430   /*
  1375   1431   ** CAPI3REF: Memory Allocation Routines
  1376   1432   **
  1377   1433   ** An instance of this object defines the interface between SQLite
  1378   1434   ** and low-level memory allocation routines.
  1379   1435   **
................................................................................
  1499   1555   ** ^If SQLite is compiled with
  1500   1556   ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
  1501   1557   ** it is not possible to set the Serialized [threading mode] and
  1502   1558   ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
  1503   1559   ** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
  1504   1560   **
  1505   1561   ** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>
  1506         -** <dd> ^(This option takes a single argument which is a pointer to an
  1507         -** instance of the [sqlite3_mem_methods] structure.  The argument specifies
         1562  +** <dd> ^(The SQLITE_CONFIG_MALLOC option takes a single argument which is 
         1563  +** a pointer to an instance of the [sqlite3_mem_methods] structure.
         1564  +** The argument specifies
  1508   1565   ** alternative low-level memory allocation routines to be used in place of
  1509   1566   ** the memory allocation routines built into SQLite.)^ ^SQLite makes
  1510   1567   ** its own private copy of the content of the [sqlite3_mem_methods] structure
  1511   1568   ** before the [sqlite3_config()] call returns.</dd>
  1512   1569   **
  1513   1570   ** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>
  1514         -** <dd> ^(This option takes a single argument which is a pointer to an
  1515         -** instance of the [sqlite3_mem_methods] structure.  The [sqlite3_mem_methods]
         1571  +** <dd> ^(The SQLITE_CONFIG_GETMALLOC option takes a single argument which
         1572  +** is a pointer to an instance of the [sqlite3_mem_methods] structure.
         1573  +** The [sqlite3_mem_methods]
  1516   1574   ** structure is filled with the currently defined memory allocation routines.)^
  1517   1575   ** This option can be used to overload the default memory allocation
  1518   1576   ** routines with a wrapper that simulations memory allocation failure or
  1519   1577   ** tracks memory usage, for example. </dd>
  1520   1578   **
  1521   1579   ** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>
  1522         -** <dd> ^This option takes single argument of type int, interpreted as a 
  1523         -** boolean, which enables or disables the collection of memory allocation 
  1524         -** statistics. ^(When memory allocation statistics are disabled, the 
  1525         -** following SQLite interfaces become non-operational:
         1580  +** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,
         1581  +** interpreted as a boolean, which enables or disables the collection of
         1582  +** memory allocation statistics. ^(When memory allocation statistics are
         1583  +** disabled, the following SQLite interfaces become non-operational:
  1526   1584   **   <ul>
  1527   1585   **   <li> [sqlite3_memory_used()]
  1528   1586   **   <li> [sqlite3_memory_highwater()]
  1529   1587   **   <li> [sqlite3_soft_heap_limit64()]
  1530         -**   <li> [sqlite3_status()]
         1588  +**   <li> [sqlite3_status64()]
  1531   1589   **   </ul>)^
  1532   1590   ** ^Memory allocation statistics are enabled by default unless SQLite is
  1533   1591   ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
  1534   1592   ** allocation statistics are disabled by default.
  1535   1593   ** </dd>
  1536   1594   **
  1537   1595   ** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt>
  1538         -** <dd> ^This option specifies a static memory buffer that SQLite can use for
  1539         -** scratch memory.  There are three arguments:  A pointer an 8-byte
         1596  +** <dd> ^The SQLITE_CONFIG_SCRATCH option specifies a static memory buffer
         1597  +** that SQLite can use for scratch memory.  ^(There are three arguments
         1598  +** to SQLITE_CONFIG_SCRATCH:  A pointer an 8-byte
  1540   1599   ** aligned memory buffer from which the scratch allocations will be
  1541   1600   ** drawn, the size of each scratch allocation (sz),
  1542         -** and the maximum number of scratch allocations (N).  The sz
  1543         -** argument must be a multiple of 16.
         1601  +** and the maximum number of scratch allocations (N).)^
  1544   1602   ** The first argument must be a pointer to an 8-byte aligned buffer
  1545   1603   ** of at least sz*N bytes of memory.
  1546         -** ^SQLite will use no more than two scratch buffers per thread.  So
  1547         -** N should be set to twice the expected maximum number of threads.
  1548         -** ^SQLite will never require a scratch buffer that is more than 6
  1549         -** times the database page size. ^If SQLite needs needs additional
         1604  +** ^SQLite will not use more than one scratch buffers per thread.
         1605  +** ^SQLite will never request a scratch buffer that is more than 6
         1606  +** times the database page size.
         1607  +** ^If SQLite needs needs additional
  1550   1608   ** scratch memory beyond what is provided by this configuration option, then 
  1551         -** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
         1609  +** [sqlite3_malloc()] will be used to obtain the memory needed.<p>
         1610  +** ^When the application provides any amount of scratch memory using
         1611  +** SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary large
         1612  +** [sqlite3_malloc|heap allocations].
         1613  +** This can help [Robson proof|prevent memory allocation failures] due to heap
         1614  +** fragmentation in low-memory embedded systems.
         1615  +** </dd>
  1552   1616   **
  1553   1617   ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
  1554         -** <dd> ^This option specifies a static memory buffer that SQLite can use for
  1555         -** the database page cache with the default page cache implementation.  
  1556         -** This configuration should not be used if an application-define page
  1557         -** cache implementation is loaded using the SQLITE_CONFIG_PCACHE2 option.
  1558         -** There are three arguments to this option: A pointer to 8-byte aligned
  1559         -** memory, the size of each page buffer (sz), and the number of pages (N).
         1618  +** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool
         1619  +** that SQLite can use for the database page cache with the default page
         1620  +** cache implementation.  
         1621  +** This configuration option is a no-op if an application-define page
         1622  +** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2].
         1623  +** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to
         1624  +** 8-byte aligned memory (pMem), the size of each page cache line (sz),
         1625  +** and the number of cache lines (N).
  1560   1626   ** The sz argument should be the size of the largest database page
  1561         -** (a power of two between 512 and 32768) plus a little extra for each
  1562         -** page header.  ^The page header size is 20 to 40 bytes depending on
  1563         -** the host architecture.  ^It is harmless, apart from the wasted memory,
  1564         -** to make sz a little too large.  The first
  1565         -** argument should point to an allocation of at least sz*N bytes of memory.
  1566         -** ^SQLite will use the memory provided by the first argument to satisfy its
  1567         -** memory needs for the first N pages that it adds to cache.  ^If additional
  1568         -** page cache memory is needed beyond what is provided by this option, then
  1569         -** SQLite goes to [sqlite3_malloc()] for the additional storage space.
  1570         -** The pointer in the first argument must
  1571         -** be aligned to an 8-byte boundary or subsequent behavior of SQLite
  1572         -** will be undefined.</dd>
         1627  +** (a power of two between 512 and 65536) plus some extra bytes for each
         1628  +** page header.  ^The number of extra bytes needed by the page header
         1629  +** can be determined using [SQLITE_CONFIG_PCACHE_HDRSZ].
         1630  +** ^It is harmless, apart from the wasted memory,
         1631  +** for the sz parameter to be larger than necessary.  The pMem
         1632  +** argument must be either a NULL pointer or a pointer to an 8-byte
         1633  +** aligned block of memory of at least sz*N bytes, otherwise
         1634  +** subsequent behavior is undefined.
         1635  +** ^When pMem is not NULL, SQLite will strive to use the memory provided
         1636  +** to satisfy page cache needs, falling back to [sqlite3_malloc()] if
         1637  +** a page cache line is larger than sz bytes or if all of the pMem buffer
         1638  +** is exhausted.
         1639  +** ^If pMem is NULL and N is non-zero, then each database connection
         1640  +** does an initial bulk allocation for page cache memory
         1641  +** from [sqlite3_malloc()] sufficient for N cache lines if N is positive or
         1642  +** of -1024*N bytes if N is negative, . ^If additional
         1643  +** page cache memory is needed beyond what is provided by the initial
         1644  +** allocation, then SQLite goes to [sqlite3_malloc()] separately for each
         1645  +** additional cache line. </dd>
  1573   1646   **
  1574   1647   ** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>
  1575         -** <dd> ^This option specifies a static memory buffer that SQLite will use
  1576         -** for all of its dynamic memory allocation needs beyond those provided
  1577         -** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
  1578         -** There are three arguments: An 8-byte aligned pointer to the memory,
         1648  +** <dd> ^The SQLITE_CONFIG_HEAP option specifies a static memory buffer 
         1649  +** that SQLite will use for all of its dynamic memory allocation needs
         1650  +** beyond those provided for by [SQLITE_CONFIG_SCRATCH] and
         1651  +** [SQLITE_CONFIG_PAGECACHE].
         1652  +** ^The SQLITE_CONFIG_HEAP option is only available if SQLite is compiled
         1653  +** with either [SQLITE_ENABLE_MEMSYS3] or [SQLITE_ENABLE_MEMSYS5] and returns
         1654  +** [SQLITE_ERROR] if invoked otherwise.
         1655  +** ^There are three arguments to SQLITE_CONFIG_HEAP:
         1656  +** An 8-byte aligned pointer to the memory,
  1579   1657   ** the number of bytes in the memory buffer, and the minimum allocation size.
  1580   1658   ** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts
  1581   1659   ** to using its default memory allocator (the system malloc() implementation),
  1582   1660   ** undoing any prior invocation of [SQLITE_CONFIG_MALLOC].  ^If the
  1583         -** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or
  1584         -** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
         1661  +** memory pointer is not NULL then the alternative memory
  1585   1662   ** allocator is engaged to handle all of SQLites memory allocation needs.
  1586   1663   ** The first pointer (the memory pointer) must be aligned to an 8-byte
  1587   1664   ** boundary or subsequent behavior of SQLite will be undefined.
  1588   1665   ** The minimum allocation size is capped at 2**12. Reasonable values
  1589   1666   ** for the minimum allocation size are 2**5 through 2**8.</dd>
  1590   1667   **
  1591   1668   ** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>
  1592         -** <dd> ^(This option takes a single argument which is a pointer to an
  1593         -** instance of the [sqlite3_mutex_methods] structure.  The argument specifies
  1594         -** alternative low-level mutex routines to be used in place
  1595         -** the mutex routines built into SQLite.)^  ^SQLite makes a copy of the
  1596         -** content of the [sqlite3_mutex_methods] structure before the call to
         1669  +** <dd> ^(The SQLITE_CONFIG_MUTEX option takes a single argument which is a
         1670  +** pointer to an instance of the [sqlite3_mutex_methods] structure.
         1671  +** The argument specifies alternative low-level mutex routines to be used
         1672  +** in place the mutex routines built into SQLite.)^  ^SQLite makes a copy of
         1673  +** the content of the [sqlite3_mutex_methods] structure before the call to
  1597   1674   ** [sqlite3_config()] returns. ^If SQLite is compiled with
  1598   1675   ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
  1599   1676   ** the entire mutexing subsystem is omitted from the build and hence calls to
  1600   1677   ** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will
  1601   1678   ** return [SQLITE_ERROR].</dd>
  1602   1679   **
  1603   1680   ** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt>
  1604         -** <dd> ^(This option takes a single argument which is a pointer to an
  1605         -** instance of the [sqlite3_mutex_methods] structure.  The
         1681  +** <dd> ^(The SQLITE_CONFIG_GETMUTEX option takes a single argument which
         1682  +** is a pointer to an instance of the [sqlite3_mutex_methods] structure.  The
  1606   1683   ** [sqlite3_mutex_methods]
  1607   1684   ** structure is filled with the currently defined mutex routines.)^
  1608   1685   ** This option can be used to overload the default mutex allocation
  1609   1686   ** routines with a wrapper used to track mutex usage for performance
  1610   1687   ** profiling or testing, for example.   ^If SQLite is compiled with
  1611   1688   ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
  1612   1689   ** the entire mutexing subsystem is omitted from the build and hence calls to
  1613   1690   ** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will
  1614   1691   ** return [SQLITE_ERROR].</dd>
  1615   1692   **
  1616   1693   ** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>
  1617         -** <dd> ^(This option takes two arguments that determine the default
  1618         -** memory allocation for the lookaside memory allocator on each
  1619         -** [database connection].  The first argument is the
         1694  +** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine
         1695  +** the default size of lookaside memory on each [database connection].
         1696  +** The first argument is the
  1620   1697   ** size of each lookaside buffer slot and the second is the number of
  1621         -** slots allocated to each database connection.)^  ^(This option sets the
  1622         -** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
  1623         -** verb to [sqlite3_db_config()] can be used to change the lookaside
         1698  +** slots allocated to each database connection.)^  ^(SQLITE_CONFIG_LOOKASIDE
         1699  +** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
         1700  +** option to [sqlite3_db_config()] can be used to change the lookaside
  1624   1701   ** configuration on individual connections.)^ </dd>
  1625   1702   **
  1626   1703   ** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>
  1627         -** <dd> ^(This option takes a single argument which is a pointer to
  1628         -** an [sqlite3_pcache_methods2] object.  This object specifies the interface
  1629         -** to a custom page cache implementation.)^  ^SQLite makes a copy of the
  1630         -** object and uses it for page cache memory allocations.</dd>
         1704  +** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is 
         1705  +** a pointer to an [sqlite3_pcache_methods2] object.  This object specifies
         1706  +** the interface to a custom page cache implementation.)^
         1707  +** ^SQLite makes a copy of the [sqlite3_pcache_methods2] object.</dd>
  1631   1708   **
  1632   1709   ** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>
  1633         -** <dd> ^(This option takes a single argument which is a pointer to an
  1634         -** [sqlite3_pcache_methods2] object.  SQLite copies of the current
  1635         -** page cache implementation into that object.)^ </dd>
         1710  +** <dd> ^(The SQLITE_CONFIG_GETPCACHE2 option takes a single argument which
         1711  +** is a pointer to an [sqlite3_pcache_methods2] object.  SQLite copies of
         1712  +** the current page cache implementation into that object.)^ </dd>
  1636   1713   **
  1637   1714   ** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>
  1638   1715   ** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite
  1639   1716   ** global [error log].
  1640   1717   ** (^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a
  1641   1718   ** function with a call signature of void(*)(void*,int,const char*), 
  1642   1719   ** and a pointer to void. ^If the function pointer is not NULL, it is
................................................................................
  1651   1728   ** log message after formatting via [sqlite3_snprintf()].
  1652   1729   ** The SQLite logging interface is not reentrant; the logger function
  1653   1730   ** supplied by the application must not invoke any SQLite interface.
  1654   1731   ** In a multi-threaded application, the application-defined logger
  1655   1732   ** function must be threadsafe. </dd>
  1656   1733   **
  1657   1734   ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
  1658         -** <dd>^(This option takes a single argument of type int. If non-zero, then
  1659         -** URI handling is globally enabled. If the parameter is zero, then URI handling
  1660         -** is globally disabled.)^ ^If URI handling is globally enabled, all filenames
  1661         -** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
         1735  +** <dd>^(The SQLITE_CONFIG_URI option takes a single argument of type int.
         1736  +** If non-zero, then URI handling is globally enabled. If the parameter is zero,
         1737  +** then URI handling is globally disabled.)^ ^If URI handling is globally
         1738  +** enabled, all filenames passed to [sqlite3_open()], [sqlite3_open_v2()],
         1739  +** [sqlite3_open16()] or
  1662   1740   ** specified as part of [ATTACH] commands are interpreted as URIs, regardless
  1663   1741   ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
  1664   1742   ** connection is opened. ^If it is globally disabled, filenames are
  1665   1743   ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
  1666   1744   ** database connection is opened. ^(By default, URI handling is globally
  1667   1745   ** disabled. The default value may be changed by compiling with the
  1668   1746   ** [SQLITE_USE_URI] symbol defined.)^
  1669   1747   **
  1670   1748   ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
  1671         -** <dd>^This option takes a single integer argument which is interpreted as
  1672         -** a boolean in order to enable or disable the use of covering indices for
  1673         -** full table scans in the query optimizer.  ^The default setting is determined
         1749  +** <dd>^The SQLITE_CONFIG_COVERING_INDEX_SCAN option takes a single integer
         1750  +** argument which is interpreted as a boolean in order to enable or disable
         1751  +** the use of covering indices for full table scans in the query optimizer.
         1752  +** ^The default setting is determined
  1674   1753   ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
  1675   1754   ** if that compile-time option is omitted.
  1676   1755   ** The ability to disable the use of covering indices for full table scans
  1677   1756   ** is because some incorrectly coded legacy applications might malfunction
  1678   1757   ** when the optimization is enabled.  Providing the ability to
  1679   1758   ** disable the optimization allows the older, buggy application code to work
  1680   1759   ** without change even with newer versions of SQLite.
................................................................................
  1706   1785   ** <dt>SQLITE_CONFIG_MMAP_SIZE
  1707   1786   ** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
  1708   1787   ** that are the default mmap size limit (the default setting for
  1709   1788   ** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.
  1710   1789   ** ^The default setting can be overridden by each database connection using
  1711   1790   ** either the [PRAGMA mmap_size] command, or by using the
  1712   1791   ** [SQLITE_FCNTL_MMAP_SIZE] file control.  ^(The maximum allowed mmap size
  1713         -** cannot be changed at run-time.  Nor may the maximum allowed mmap size
  1714         -** exceed the compile-time maximum mmap size set by the
         1792  +** will be silently truncated if necessary so that it does not exceed the
         1793  +** compile-time maximum mmap size set by the
  1715   1794   ** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
  1716   1795   ** ^If either argument to this option is negative, then that argument is
  1717   1796   ** changed to its compile-time default.
  1718   1797   **
  1719   1798   ** [[SQLITE_CONFIG_WIN32_HEAPSIZE]]
  1720   1799   ** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
  1721         -** <dd>^This option is only available if SQLite is compiled for Windows
  1722         -** with the [SQLITE_WIN32_MALLOC] pre-processor macro defined.
  1723         -** SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
         1800  +** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is
         1801  +** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro
         1802  +** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
  1724   1803   ** that specifies the maximum size of the created heap.
         1804  +**
         1805  +** [[SQLITE_CONFIG_PCACHE_HDRSZ]]
         1806  +** <dt>SQLITE_CONFIG_PCACHE_HDRSZ
         1807  +** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which
         1808  +** is a pointer to an integer and writes into that integer the number of extra
         1809  +** bytes per page required for each page in [SQLITE_CONFIG_PAGECACHE].
         1810  +** The amount of extra space required can change depending on the compiler,
         1811  +** target platform, and SQLite version.
         1812  +**
         1813  +** [[SQLITE_CONFIG_PMASZ]]
         1814  +** <dt>SQLITE_CONFIG_PMASZ
         1815  +** <dd>^The SQLITE_CONFIG_PMASZ option takes a single parameter which
         1816  +** is an unsigned integer and sets the "Minimum PMA Size" for the multithreaded
         1817  +** sorter to that integer.  The default minimum PMA Size is set by the
         1818  +** [SQLITE_SORTER_PMASZ] compile-time option.  New threads are launched
         1819  +** to help with sort operations when multithreaded sorting
         1820  +** is enabled (using the [PRAGMA threads] command) and the amount of content
         1821  +** to be sorted exceeds the page size times the minimum of the
         1822  +** [PRAGMA cache_size] setting and this value.
         1823  +**
         1824  +** [[SQLITE_CONFIG_STMTJRNL_SPILL]]
         1825  +** <dt>SQLITE_CONFIG_STMTJRNL_SPILL
         1826  +** <dd>^The SQLITE_CONFIG_STMTJRNL_SPILL option takes a single parameter which
         1827  +** becomes the [statement journal] spill-to-disk threshold.  
         1828  +** [Statement journals] are held in memory until their size (in bytes)
         1829  +** exceeds this threshold, at which point they are written to disk.
         1830  +** Or if the threshold is -1, statement journals are always held
         1831  +** exclusively in memory.
         1832  +** Since many statement journals never become large, setting the spill
         1833  +** threshold to a value such as 64KiB can greatly reduce the amount of
         1834  +** I/O required to support statement rollback.
         1835  +** The default value for this setting is controlled by the
         1836  +** [SQLITE_STMTJRNL_SPILL] compile-time option.
  1725   1837   ** </dl>
  1726   1838   */
  1727   1839   #define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */
  1728   1840   #define SQLITE_CONFIG_MULTITHREAD   2  /* nil */
  1729   1841   #define SQLITE_CONFIG_SERIALIZED    3  /* nil */
  1730   1842   #define SQLITE_CONFIG_MALLOC        4  /* sqlite3_mem_methods* */
  1731   1843   #define SQLITE_CONFIG_GETMALLOC     5  /* sqlite3_mem_methods* */
................................................................................
  1743   1855   #define SQLITE_CONFIG_URI          17  /* int */
  1744   1856   #define SQLITE_CONFIG_PCACHE2      18  /* sqlite3_pcache_methods2* */
  1745   1857   #define SQLITE_CONFIG_GETPCACHE2   19  /* sqlite3_pcache_methods2* */
  1746   1858   #define SQLITE_CONFIG_COVERING_INDEX_SCAN 20  /* int */
  1747   1859   #define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */
  1748   1860   #define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */
  1749   1861   #define SQLITE_CONFIG_WIN32_HEAPSIZE      23  /* int nByte */
         1862  +#define SQLITE_CONFIG_PCACHE_HDRSZ        24  /* int *psz */
         1863  +#define SQLITE_CONFIG_PMASZ               25  /* unsigned int szPma */
         1864  +#define SQLITE_CONFIG_STMTJRNL_SPILL      26  /* int nByte */
  1750   1865   
  1751   1866   /*
  1752   1867   ** CAPI3REF: Database Connection Configuration Options
  1753   1868   **
  1754   1869   ** These constants are the available integer configuration options that
  1755   1870   ** can be passed as the second argument to the [sqlite3_db_config()] interface.
  1756   1871   **
................................................................................
  1800   1915   ** The first argument is an integer which is 0 to disable triggers,
  1801   1916   ** positive to enable triggers or negative to leave the setting unchanged.
  1802   1917   ** The second parameter is a pointer to an integer into which
  1803   1918   ** is written 0 or 1 to indicate whether triggers are disabled or enabled
  1804   1919   ** following this call.  The second parameter may be a NULL pointer, in
  1805   1920   ** which case the trigger setting is not reported back. </dd>
  1806   1921   **
         1922  +** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
         1923  +** <dd> ^This option is used to enable or disable the two-argument
         1924  +** version of the [fts3_tokenizer()] function which is part of the
         1925  +** [FTS3] full-text search engine extension.
         1926  +** There should be two additional arguments.
         1927  +** The first argument is an integer which is 0 to disable fts3_tokenizer() or
         1928  +** positive to enable fts3_tokenizer() or negative to leave the setting
         1929  +** unchanged.
         1930  +** The second parameter is a pointer to an integer into which
         1931  +** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
         1932  +** following this call.  The second parameter may be a NULL pointer, in
         1933  +** which case the new setting is not reported back. </dd>
         1934  +**
         1935  +** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>
         1936  +** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]
         1937  +** interface independently of the [load_extension()] SQL function.
         1938  +** The [sqlite3_enable_load_extension()] API enables or disables both the
         1939  +** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
         1940  +** There should be two additional arguments.
         1941  +** When the first argument to this interface is 1, then only the C-API is
         1942  +** enabled and the SQL function remains disabled.  If the first argment to
         1943  +** this interface is 0, then both the C-API and the SQL function are disabled.
         1944  +** If the first argument is -1, then no changes are made to state of either the
         1945  +** C-API or the SQL function.
         1946  +** The second parameter is a pointer to an integer into which
         1947  +** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface
         1948  +** is disabled or enabled following this call.  The second parameter may
         1949  +** be a NULL pointer, in which case the new setting is not reported back.
         1950  +** </dd>
         1951  +**
  1807   1952   ** </dl>
  1808   1953   */
  1809         -#define SQLITE_DBCONFIG_LOOKASIDE       1001  /* void* int int */
  1810         -#define SQLITE_DBCONFIG_ENABLE_FKEY     1002  /* int int* */
  1811         -#define SQLITE_DBCONFIG_ENABLE_TRIGGER  1003  /* int int* */
         1954  +#define SQLITE_DBCONFIG_LOOKASIDE             1001 /* void* int int */
         1955  +#define SQLITE_DBCONFIG_ENABLE_FKEY           1002 /* int int* */
         1956  +#define SQLITE_DBCONFIG_ENABLE_TRIGGER        1003 /* int int* */
         1957  +#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
         1958  +#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
  1812   1959   
  1813   1960   
  1814   1961   /*
  1815   1962   ** CAPI3REF: Enable Or Disable Extended Result Codes
         1963  +** METHOD: sqlite3
  1816   1964   **
  1817   1965   ** ^The sqlite3_extended_result_codes() routine enables or disables the
  1818   1966   ** [extended result codes] feature of SQLite. ^The extended result
  1819   1967   ** codes are disabled by default for historical compatibility.
  1820   1968   */
  1821         -SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
         1969  +SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3*, int onoff);
  1822   1970   
  1823   1971   /*
  1824   1972   ** CAPI3REF: Last Insert Rowid
         1973  +** METHOD: sqlite3
  1825   1974   **
  1826   1975   ** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
  1827   1976   ** has a unique 64-bit signed
  1828   1977   ** integer key called the [ROWID | "rowid"]. ^The rowid is always available
  1829   1978   ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
  1830   1979   ** names are not also used by explicitly declared columns. ^If
  1831   1980   ** the table has a column of type [INTEGER PRIMARY KEY] then that column
................................................................................
  1865   2014   ** If a separate thread performs a new [INSERT] on the same
  1866   2015   ** database connection while the [sqlite3_last_insert_rowid()]
  1867   2016   ** function is running and thus changes the last insert [rowid],
  1868   2017   ** then the value returned by [sqlite3_last_insert_rowid()] is
  1869   2018   ** unpredictable and might not equal either the old or the new
  1870   2019   ** last insert [rowid].
  1871   2020   */
  1872         -SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
         2021  +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3*);
  1873   2022   
  1874   2023   /*
  1875   2024   ** CAPI3REF: Count The Number Of Rows Modified
  1876         -**
  1877         -** ^This function returns the number of database rows that were changed
  1878         -** or inserted or deleted by the most recently completed SQL statement
  1879         -** on the [database connection] specified by the first parameter.
  1880         -** ^(Only changes that are directly specified by the [INSERT], [UPDATE],
  1881         -** or [DELETE] statement are counted.  Auxiliary changes caused by
  1882         -** triggers or [foreign key actions] are not counted.)^ Use the
  1883         -** [sqlite3_total_changes()] function to find the total number of changes
  1884         -** including changes caused by triggers and foreign key actions.
  1885         -**
  1886         -** ^Changes to a view that are simulated by an [INSTEAD OF trigger]
  1887         -** are not counted.  Only real table changes are counted.
  1888         -**
  1889         -** ^(A "row change" is a change to a single row of a single table
  1890         -** caused by an INSERT, DELETE, or UPDATE statement.  Rows that
  1891         -** are changed as side effects of [REPLACE] constraint resolution,
  1892         -** rollback, ABORT processing, [DROP TABLE], or by any other
  1893         -** mechanisms do not count as direct row changes.)^
  1894         -**
  1895         -** A "trigger context" is a scope of execution that begins and
  1896         -** ends with the script of a [CREATE TRIGGER | trigger]. 
  1897         -** Most SQL statements are
  1898         -** evaluated outside of any trigger.  This is the "top level"
  1899         -** trigger context.  If a trigger fires from the top level, a
  1900         -** new trigger context is entered for the duration of that one
  1901         -** trigger.  Subtriggers create subcontexts for their duration.
  1902         -**
  1903         -** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
  1904         -** not create a new trigger context.
  1905         -**
  1906         -** ^This function returns the number of direct row changes in the
  1907         -** most recent INSERT, UPDATE, or DELETE statement within the same
  1908         -** trigger context.
  1909         -**
  1910         -** ^Thus, when called from the top level, this function returns the
  1911         -** number of changes in the most recent INSERT, UPDATE, or DELETE
  1912         -** that also occurred at the top level.  ^(Within the body of a trigger,
  1913         -** the sqlite3_changes() interface can be called to find the number of
  1914         -** changes in the most recently completed INSERT, UPDATE, or DELETE
  1915         -** statement within the body of the same trigger.
  1916         -** However, the number returned does not include changes
  1917         -** caused by subtriggers since those have their own context.)^
         2025  +** METHOD: sqlite3
         2026  +**
         2027  +** ^This function returns the number of rows modified, inserted or
         2028  +** deleted by the most recently completed INSERT, UPDATE or DELETE
         2029  +** statement on the database connection specified by the only parameter.
         2030  +** ^Executing any other type of SQL statement does not modify the value
         2031  +** returned by this function.
         2032  +**
         2033  +** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are
         2034  +** considered - auxiliary changes caused by [CREATE TRIGGER | triggers], 
         2035  +** [foreign key actions] or [REPLACE] constraint resolution are not counted.
         2036  +** 
         2037  +** Changes to a view that are intercepted by 
         2038  +** [INSTEAD OF trigger | INSTEAD OF triggers] are not counted. ^The value 
         2039  +** returned by sqlite3_changes() immediately after an INSERT, UPDATE or 
         2040  +** DELETE statement run on a view is always zero. Only changes made to real 
         2041  +** tables are counted.
         2042  +**
         2043  +** Things are more complicated if the sqlite3_changes() function is
         2044  +** executed while a trigger program is running. This may happen if the
         2045  +** program uses the [changes() SQL function], or if some other callback
         2046  +** function invokes sqlite3_changes() directly. Essentially:
         2047  +** 
         2048  +** <ul>
         2049  +**   <li> ^(Before entering a trigger program the value returned by
         2050  +**        sqlite3_changes() function is saved. After the trigger program 
         2051  +**        has finished, the original value is restored.)^
         2052  +** 
         2053  +**   <li> ^(Within a trigger program each INSERT, UPDATE and DELETE 
         2054  +**        statement sets the value returned by sqlite3_changes() 
         2055  +**        upon completion as normal. Of course, this value will not include 
         2056  +**        any changes performed by sub-triggers, as the sqlite3_changes() 
         2057  +**        value will be saved and restored after each sub-trigger has run.)^
         2058  +** </ul>
         2059  +** 
         2060  +** ^This means that if the changes() SQL function (or similar) is used
         2061  +** by the first INSERT, UPDATE or DELETE statement within a trigger, it 
         2062  +** returns the value as set when the calling statement began executing.
         2063  +** ^If it is used by the second or subsequent such statement within a trigger 
         2064  +** program, the value returned reflects the number of rows modified by the 
         2065  +** previous INSERT, UPDATE or DELETE statement within the same trigger.
  1918   2066   **
  1919   2067   ** See also the [sqlite3_total_changes()] interface, the
  1920   2068   ** [count_changes pragma], and the [changes() SQL function].
  1921   2069   **
  1922   2070   ** If a separate thread makes changes on the same database connection
  1923   2071   ** while [sqlite3_changes()] is running then the value returned
  1924   2072   ** is unpredictable and not meaningful.
  1925   2073   */
  1926         -SQLITE_API int sqlite3_changes(sqlite3*);
         2074  +SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3*);
  1927   2075   
  1928   2076   /*
  1929   2077   ** CAPI3REF: Total Number Of Rows Modified
         2078  +** METHOD: sqlite3
  1930   2079   **
  1931         -** ^This function returns the number of row changes caused by [INSERT],
  1932         -** [UPDATE] or [DELETE] statements since the [database connection] was opened.
  1933         -** ^(The count returned by sqlite3_total_changes() includes all changes
  1934         -** from all [CREATE TRIGGER | trigger] contexts and changes made by
  1935         -** [foreign key actions]. However,
  1936         -** the count does not include changes used to implement [REPLACE] constraints,
  1937         -** do rollbacks or ABORT processing, or [DROP TABLE] processing.  The
  1938         -** count does not include rows of views that fire an [INSTEAD OF trigger],
  1939         -** though if the INSTEAD OF trigger makes changes of its own, those changes 
  1940         -** are counted.)^
  1941         -** ^The sqlite3_total_changes() function counts the changes as soon as
  1942         -** the statement that makes them is completed (when the statement handle
  1943         -** is passed to [sqlite3_reset()] or [sqlite3_finalize()]).
  1944         -**
         2080  +** ^This function returns the total number of rows inserted, modified or
         2081  +** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
         2082  +** since the database connection was opened, including those executed as
         2083  +** part of trigger programs. ^Executing any other type of SQL statement
         2084  +** does not affect the value returned by sqlite3_total_changes().
         2085  +** 
         2086  +** ^Changes made as part of [foreign key actions] are included in the
         2087  +** count, but those made as part of REPLACE constraint resolution are
         2088  +** not. ^Changes to a view that are intercepted by INSTEAD OF triggers 
         2089  +** are not counted.
         2090  +** 
  1945   2091   ** See also the [sqlite3_changes()] interface, the
  1946   2092   ** [count_changes pragma], and the [total_changes() SQL function].
  1947   2093   **
  1948   2094   ** If a separate thread makes changes on the same database connection
  1949   2095   ** while [sqlite3_total_changes()] is running then the value
  1950   2096   ** returned is unpredictable and not meaningful.
  1951   2097   */
  1952         -SQLITE_API int sqlite3_total_changes(sqlite3*);
         2098  +SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3*);
  1953   2099   
  1954   2100   /*
  1955   2101   ** CAPI3REF: Interrupt A Long-Running Query
         2102  +** METHOD: sqlite3
  1956   2103   **
  1957   2104   ** ^This function causes any pending database operation to abort and
  1958   2105   ** return at its earliest opportunity. This routine is typically
  1959   2106   ** called in response to a user action such as pressing "Cancel"
  1960   2107   ** or Ctrl-C where the user wants a long query operation to halt
  1961   2108   ** immediately.
  1962   2109   **
................................................................................
  1984   2131   ** ^A call to sqlite3_interrupt(D) that occurs when there are no running
  1985   2132   ** SQL statements is a no-op and has no effect on SQL statements
  1986   2133   ** that are started after the sqlite3_interrupt() call returns.
  1987   2134   **
  1988   2135   ** If the database connection closes while [sqlite3_interrupt()]
  1989   2136   ** is running then bad things will likely happen.
  1990   2137   */
  1991         -SQLITE_API void sqlite3_interrupt(sqlite3*);
         2138  +SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3*);
  1992   2139   
  1993   2140   /*
  1994   2141   ** CAPI3REF: Determine If An SQL Statement Is Complete
  1995   2142   **
  1996   2143   ** These routines are useful during command-line input to determine if the
  1997   2144   ** currently entered text seems to form a complete SQL statement or
  1998   2145   ** if additional input is needed before sending the text into
................................................................................
  2019   2166   **
  2020   2167   ** The input to [sqlite3_complete()] must be a zero-terminated
  2021   2168   ** UTF-8 string.
  2022   2169   **
  2023   2170   ** The input to [sqlite3_complete16()] must be a zero-terminated
  2024   2171   ** UTF-16 string in native byte order.
  2025   2172   */
  2026         -SQLITE_API int sqlite3_complete(const char *sql);
  2027         -SQLITE_API int sqlite3_complete16(const void *sql);
         2173  +SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *sql);
         2174  +SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *sql);
  2028   2175   
  2029   2176   /*
  2030   2177   ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
         2178  +** KEYWORDS: {busy-handler callback} {busy handler}
         2179  +** METHOD: sqlite3
  2031   2180   **
  2032   2181   ** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X
  2033   2182   ** that might be invoked with argument P whenever
  2034   2183   ** an attempt is made to access a database table associated with
  2035   2184   ** [database connection] D when another thread
  2036   2185   ** or process has the table locked.
  2037   2186   ** The sqlite3_busy_handler() interface is used to implement
................................................................................
  2040   2189   ** ^If the busy callback is NULL, then [SQLITE_BUSY]
  2041   2190   ** is returned immediately upon encountering the lock.  ^If the busy callback
  2042   2191   ** is not NULL, then the callback might be invoked with two arguments.
  2043   2192   **
  2044   2193   ** ^The first argument to the busy handler is a copy of the void* pointer which
  2045   2194   ** is the third argument to sqlite3_busy_handler().  ^The second argument to
  2046   2195   ** the busy handler callback is the number of times that the busy handler has
  2047         -** been invoked for the same locking event.  ^If the
         2196  +** been invoked previously for the same locking event.  ^If the
  2048   2197   ** busy callback returns 0, then no additional attempts are made to
  2049   2198   ** access the database and [SQLITE_BUSY] is returned
  2050   2199   ** to the application.
  2051   2200   ** ^If the callback returns non-zero, then another attempt
  2052   2201   ** is made to access the database and the cycle repeats.
  2053   2202   **
  2054   2203   ** The presence of a busy handler does not guarantee that it will be invoked
................................................................................
  2079   2228   ** database connection that invoked the busy handler.  In other words,
  2080   2229   ** the busy handler is not reentrant.  Any such actions
  2081   2230   ** result in undefined behavior.
  2082   2231   ** 
  2083   2232   ** A busy handler must not close the database connection
  2084   2233   ** or [prepared statement] that invoked the busy handler.
  2085   2234   */
  2086         -SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
         2235  +SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
  2087   2236   
  2088   2237   /*
  2089   2238   ** CAPI3REF: Set A Busy Timeout
         2239  +** METHOD: sqlite3
  2090   2240   **
  2091   2241   ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
  2092   2242   ** for a specified amount of time when a table is locked.  ^The handler
  2093   2243   ** will sleep multiple times until at least "ms" milliseconds of sleeping
  2094   2244   ** have accumulated.  ^After at least "ms" milliseconds of sleeping,
  2095   2245   ** the handler returns 0 which causes [sqlite3_step()] to return
  2096   2246   ** [SQLITE_BUSY].
  2097   2247   **
  2098   2248   ** ^Calling this routine with an argument less than or equal to zero
  2099   2249   ** turns off all busy handlers.
  2100   2250   **
  2101   2251   ** ^(There can only be a single busy handler for a particular
  2102         -** [database connection] any any given moment.  If another busy handler
         2252  +** [database connection] at any given moment.  If another busy handler
  2103   2253   ** was defined  (using [sqlite3_busy_handler()]) prior to calling
  2104   2254   ** this routine, that other busy handler is cleared.)^
  2105   2255   **
  2106   2256   ** See also:  [PRAGMA busy_timeout]
  2107   2257   */
  2108         -SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
         2258  +SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3*, int ms);
  2109   2259   
  2110   2260   /*
  2111   2261   ** CAPI3REF: Convenience Routines For Running Queries
         2262  +** METHOD: sqlite3
  2112   2263   **
  2113   2264   ** This is a legacy interface that is preserved for backwards compatibility.
  2114   2265   ** Use of this interface is not recommended.
  2115   2266   **
  2116   2267   ** Definition: A <b>result table</b> is memory data structure created by the
  2117   2268   ** [sqlite3_get_table()] interface.  A result table records the
  2118   2269   ** complete query results from one or more queries.
................................................................................
  2175   2326   ** [sqlite3_exec()].  The sqlite3_get_table() routine does not have access
  2176   2327   ** to any internal data structures of SQLite.  It uses only the public
  2177   2328   ** interface defined here.  As a consequence, errors that occur in the
  2178   2329   ** wrapper layer outside of the internal [sqlite3_exec()] call are not
  2179   2330   ** reflected in subsequent calls to [sqlite3_errcode()] or
  2180   2331   ** [sqlite3_errmsg()].
  2181   2332   */
  2182         -SQLITE_API int sqlite3_get_table(
         2333  +SQLITE_API int SQLITE_STDCALL sqlite3_get_table(
  2183   2334     sqlite3 *db,          /* An open database */
  2184   2335     const char *zSql,     /* SQL to be evaluated */
  2185   2336     char ***pazResult,    /* Results of the query */
  2186   2337     int *pnRow,           /* Number of result rows written here */
  2187   2338     int *pnColumn,        /* Number of result columns written here */
  2188   2339     char **pzErrmsg       /* Error msg written here */
  2189   2340   );
  2190         -SQLITE_API void sqlite3_free_table(char **result);
         2341  +SQLITE_API void SQLITE_STDCALL sqlite3_free_table(char **result);
  2191   2342   
  2192   2343   /*
  2193   2344   ** CAPI3REF: Formatted String Printing Functions
  2194   2345   **
  2195   2346   ** These routines are work-alikes of the "printf()" family of functions
  2196   2347   ** from the standard C library.
         2348  +** These routines understand most of the common K&R formatting options,
         2349  +** plus some additional non-standard formats, detailed below.
         2350  +** Note that some of the more obscure formatting options from recent
         2351  +** C-library standards are omitted from this implementation.
  2197   2352   **
  2198   2353   ** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
  2199   2354   ** results into memory obtained from [sqlite3_malloc()].
  2200   2355   ** The strings returned by these two routines should be
  2201   2356   ** released by [sqlite3_free()].  ^Both routines return a
  2202   2357   ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough
  2203   2358   ** memory to hold the resulting string.
................................................................................
  2222   2377   ** written will be n-1 characters.
  2223   2378   **
  2224   2379   ** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf().
  2225   2380   **
  2226   2381   ** These routines all implement some additional formatting
  2227   2382   ** options that are useful for constructing SQL statements.
  2228   2383   ** All of the usual printf() formatting options apply.  In addition, there
  2229         -** is are "%q", "%Q", and "%z" options.
         2384  +** is are "%q", "%Q", "%w" and "%z" options.
  2230   2385   **
  2231   2386   ** ^(The %q option works like %s in that it substitutes a nul-terminated
  2232   2387   ** string from the argument list.  But %q also doubles every '\'' character.
  2233   2388   ** %q is designed for use inside a string literal.)^  By doubling each '\''
  2234   2389   ** character it escapes that character and allows it to be inserted into
  2235   2390   ** the string.
  2236   2391   **
................................................................................
  2274   2429   **  char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
  2275   2430   **  sqlite3_exec(db, zSQL, 0, 0, 0);
  2276   2431   **  sqlite3_free(zSQL);
  2277   2432   ** </pre></blockquote>
  2278   2433   **
  2279   2434   ** The code above will render a correct SQL statement in the zSQL
  2280   2435   ** variable even if the zText variable is a NULL pointer.
         2436  +**
         2437  +** ^(The "%w" formatting option is like "%q" except that it expects to
         2438  +** be contained within double-quotes instead of single quotes, and it
         2439  +** escapes the double-quote character instead of the single-quote
         2440  +** character.)^  The "%w" formatting option is intended for safely inserting
         2441  +** table and column names into a constructed SQL statement.
  2281   2442   **
  2282   2443   ** ^(The "%z" formatting option works like "%s" but with the
  2283   2444   ** addition that after the string has been read and copied into
  2284   2445   ** the result, [sqlite3_free()] is called on the input string.)^
  2285   2446   */
  2286         -SQLITE_API char *sqlite3_mprintf(const char*,...);
  2287         -SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
  2288         -SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
  2289         -SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
         2447  +SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char*,...);
         2448  +SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char*, va_list);
         2449  +SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int,char*,const char*, ...);
         2450  +SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int,char*,const char*, va_list);
  2290   2451   
  2291   2452   /*
  2292   2453   ** CAPI3REF: Memory Allocation Subsystem
  2293   2454   **
  2294   2455   ** The SQLite core uses these three routines for all of its own
  2295   2456   ** internal memory allocation needs. "Core" in the previous sentence
  2296   2457   ** does not include operating-system specific VFS implementation.  The
................................................................................
  2298   2459   **
  2299   2460   ** ^The sqlite3_malloc() routine returns a pointer to a block
  2300   2461   ** of memory at least N bytes in length, where N is the parameter.
  2301   2462   ** ^If sqlite3_malloc() is unable to obtain sufficient free
  2302   2463   ** memory, it returns a NULL pointer.  ^If the parameter N to
  2303   2464   ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns
  2304   2465   ** a NULL pointer.
         2466  +**
         2467  +** ^The sqlite3_malloc64(N) routine works just like
         2468  +** sqlite3_malloc(N) except that N is an unsigned 64-bit integer instead
         2469  +** of a signed 32-bit integer.
  2305   2470   **
  2306   2471   ** ^Calling sqlite3_free() with a pointer previously returned
  2307   2472   ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so
  2308   2473   ** that it might be reused.  ^The sqlite3_free() routine is
  2309   2474   ** a no-op if is called with a NULL pointer.  Passing a NULL pointer
  2310   2475   ** to sqlite3_free() is harmless.  After being freed, memory
  2311   2476   ** should neither be read nor written.  Even reading previously freed
  2312   2477   ** memory might result in a segmentation fault or other severe error.
  2313   2478   ** Memory corruption, a segmentation fault, or other severe error
  2314   2479   ** might result if sqlite3_free() is called with a non-NULL pointer that
  2315   2480   ** was not obtained from sqlite3_malloc() or sqlite3_realloc().
  2316   2481   **
  2317         -** ^(The sqlite3_realloc() interface attempts to resize a
  2318         -** prior memory allocation to be at least N bytes, where N is the
  2319         -** second parameter.  The memory allocation to be resized is the first
  2320         -** parameter.)^ ^ If the first parameter to sqlite3_realloc()
         2482  +** ^The sqlite3_realloc(X,N) interface attempts to resize a
         2483  +** prior memory allocation X to be at least N bytes.
         2484  +** ^If the X parameter to sqlite3_realloc(X,N)
  2321   2485   ** is a NULL pointer then its behavior is identical to calling
  2322         -** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc().
  2323         -** ^If the second parameter to sqlite3_realloc() is zero or
         2486  +** sqlite3_malloc(N).
         2487  +** ^If the N parameter to sqlite3_realloc(X,N) is zero or
  2324   2488   ** negative then the behavior is exactly the same as calling
  2325         -** sqlite3_free(P) where P is the first parameter to sqlite3_realloc().
  2326         -** ^sqlite3_realloc() returns a pointer to a memory allocation
  2327         -** of at least N bytes in size or NULL if sufficient memory is unavailable.
         2489  +** sqlite3_free(X).
         2490  +** ^sqlite3_realloc(X,N) returns a pointer to a memory allocation
         2491  +** of at least N bytes in size or NULL if insufficient memory is available.
  2328   2492   ** ^If M is the size of the prior allocation, then min(N,M) bytes
  2329   2493   ** of the prior allocation are copied into the beginning of buffer returned
  2330         -** by sqlite3_realloc() and the prior allocation is freed.
  2331         -** ^If sqlite3_realloc() returns NULL, then the prior allocation
  2332         -** is not freed.
         2494  +** by sqlite3_realloc(X,N) and the prior allocation is freed.
         2495  +** ^If sqlite3_realloc(X,N) returns NULL and N is positive, then the
         2496  +** prior allocation is not freed.
  2333   2497   **
  2334         -** ^The memory returned by sqlite3_malloc() and sqlite3_realloc()
         2498  +** ^The sqlite3_realloc64(X,N) interfaces works the same as
         2499  +** sqlite3_realloc(X,N) except that N is a 64-bit unsigned integer instead
         2500  +** of a 32-bit signed integer.
         2501  +**
         2502  +** ^If X is a memory allocation previously obtained from sqlite3_malloc(),
         2503  +** sqlite3_malloc64(), sqlite3_realloc(), or sqlite3_realloc64(), then
         2504  +** sqlite3_msize(X) returns the size of that memory allocation in bytes.
         2505  +** ^The value returned by sqlite3_msize(X) might be larger than the number
         2506  +** of bytes requested when X was allocated.  ^If X is a NULL pointer then
         2507  +** sqlite3_msize(X) returns zero.  If X points to something that is not
         2508  +** the beginning of memory allocation, or if it points to a formerly
         2509  +** valid memory allocation that has now been freed, then the behavior
         2510  +** of sqlite3_msize(X) is undefined and possibly harmful.
         2511  +**
         2512  +** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(),
         2513  +** sqlite3_malloc64(), and sqlite3_realloc64()
  2335   2514   ** is always aligned to at least an 8 byte boundary, or to a
  2336   2515   ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time
  2337   2516   ** option is used.
  2338   2517   **
  2339   2518   ** In SQLite version 3.5.0 and 3.5.1, it was possible to define
  2340   2519   ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in
  2341   2520   ** implementation of these routines to be omitted.  That capability
................................................................................
  2354   2533   ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
  2355   2534   ** not yet been released.
  2356   2535   **
  2357   2536   ** The application must not read or write any part of
  2358   2537   ** a block of memory after it has been released using
  2359   2538   ** [sqlite3_free()] or [sqlite3_realloc()].
  2360   2539   */
  2361         -SQLITE_API void *sqlite3_malloc(int);
  2362         -SQLITE_API void *sqlite3_realloc(void*, int);
  2363         -SQLITE_API void sqlite3_free(void*);
         2540  +SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int);
         2541  +SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64);
         2542  +SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void*, int);
         2543  +SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void*, sqlite3_uint64);
         2544  +SQLITE_API void SQLITE_STDCALL sqlite3_free(void*);
         2545  +SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void*);
  2364   2546   
  2365   2547   /*
  2366   2548   ** CAPI3REF: Memory Allocator Statistics
  2367   2549   **
  2368   2550   ** SQLite provides these two interfaces for reporting on the status
  2369   2551   ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()]
  2370   2552   ** routines, which form the built-in memory allocation subsystem.
................................................................................
  2381   2563   **
  2382   2564   ** ^The memory high-water mark is reset to the current value of
  2383   2565   ** [sqlite3_memory_used()] if and only if the parameter to
  2384   2566   ** [sqlite3_memory_highwater()] is true.  ^The value returned
  2385   2567   ** by [sqlite3_memory_highwater(1)] is the high-water mark
  2386   2568   ** prior to the reset.
  2387   2569   */
  2388         -SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
  2389         -SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
         2570  +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void);
         2571  +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag);
  2390   2572   
  2391   2573   /*
  2392   2574   ** CAPI3REF: Pseudo-Random Number Generator
  2393   2575   **
  2394   2576   ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
  2395   2577   ** select random [ROWID | ROWIDs] when inserting new records into a table that
  2396   2578   ** already uses the largest possible [ROWID].  The PRNG is also used for
  2397   2579   ** the build-in random() and randomblob() SQL functions.  This interface allows
  2398   2580   ** applications to access the same PRNG for other purposes.
  2399   2581   **
  2400   2582   ** ^A call to this routine stores N bytes of randomness into buffer P.
  2401         -** ^If N is less than one, then P can be a NULL pointer.
         2583  +** ^The P parameter can be a NULL pointer.
  2402   2584   **
  2403   2585   ** ^If this routine has not been previously called or if the previous
  2404         -** call had N less than one, then the PRNG is seeded using randomness
  2405         -** obtained from the xRandomness method of the default [sqlite3_vfs] object.
  2406         -** ^If the previous call to this routine had an N of 1 or more then
  2407         -** the pseudo-randomness is generated
         2586  +** call had N less than one or a NULL pointer for P, then the PRNG is
         2587  +** seeded using randomness obtained from the xRandomness method of
         2588  +** the default [sqlite3_vfs] object.
         2589  +** ^If the previous call to this routine had an N of 1 or more and a
         2590  +** non-NULL P then the pseudo-randomness is generated
  2408   2591   ** internally and without recourse to the [sqlite3_vfs] xRandomness
  2409   2592   ** method.
  2410   2593   */
  2411         -SQLITE_API void sqlite3_randomness(int N, void *P);
         2594  +SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *P);
  2412   2595   
  2413   2596   /*
  2414   2597   ** CAPI3REF: Compile-Time Authorization Callbacks
         2598  +** METHOD: sqlite3
  2415   2599   **
  2416   2600   ** ^This routine registers an authorizer callback with a particular
  2417   2601   ** [database connection], supplied in the first argument.
  2418   2602   ** ^The authorizer callback is invoked as SQL statements are being compiled
  2419   2603   ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
  2420   2604   ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()].  ^At various
  2421   2605   ** points during the compilation process, as logic is being created
................................................................................
  2486   2670   **
  2487   2671   ** ^Note that the authorizer callback is invoked only during
  2488   2672   ** [sqlite3_prepare()] or its variants.  Authorization is not
  2489   2673   ** performed during statement evaluation in [sqlite3_step()], unless
  2490   2674   ** as stated in the previous paragraph, sqlite3_step() invokes
  2491   2675   ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
  2492   2676   */
  2493         -SQLITE_API int sqlite3_set_authorizer(
         2677  +SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
  2494   2678     sqlite3*,
  2495   2679     int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
  2496   2680     void *pUserData
  2497   2681   );
  2498   2682   
  2499   2683   /*
  2500   2684   ** CAPI3REF: Authorizer Return Codes
................................................................................
  2564   2748   #define SQLITE_FUNCTION             31   /* NULL            Function Name   */
  2565   2749   #define SQLITE_SAVEPOINT            32   /* Operation       Savepoint Name  */
  2566   2750   #define SQLITE_COPY                  0   /* No longer used */
  2567   2751   #define SQLITE_RECURSIVE            33   /* NULL            NULL            */
  2568   2752   
  2569   2753   /*
  2570   2754   ** CAPI3REF: Tracing And Profiling Functions
         2755  +** METHOD: sqlite3
  2571   2756   **
  2572   2757   ** These routines register callback functions that can be used for
  2573   2758   ** tracing and profiling the execution of SQL statements.
  2574   2759   **
  2575   2760   ** ^The callback function registered by sqlite3_trace() is invoked at
  2576   2761   ** various times when an SQL statement is being run by [sqlite3_step()].
  2577   2762   ** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the
................................................................................
  2590   2775   ** time is in units of nanoseconds, however the current implementation
  2591   2776   ** is only capable of millisecond resolution so the six least significant
  2592   2777   ** digits in the time are meaningless.  Future versions of SQLite
  2593   2778   ** might provide greater resolution on the profiler callback.  The
  2594   2779   ** sqlite3_profile() function is considered experimental and is
  2595   2780   ** subject to change in future versions of SQLite.
  2596   2781   */
  2597         -SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
  2598         -SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
         2782  +SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
         2783  +SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
  2599   2784      void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
  2600   2785   
  2601   2786   /*
  2602   2787   ** CAPI3REF: Query Progress Callbacks
         2788  +** METHOD: sqlite3
  2603   2789   **
  2604   2790   ** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback
  2605   2791   ** function X to be invoked periodically during long running calls to
  2606   2792   ** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for
  2607   2793   ** database connection D.  An example use for this
  2608   2794   ** interface is to keep a GUI updated during a large query.
  2609   2795   **
................................................................................
  2625   2811   **
  2626   2812   ** The progress handler callback must not do anything that will modify
  2627   2813   ** the database connection that invoked the progress handler.
  2628   2814   ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
  2629   2815   ** database connections for the meaning of "modify" in this paragraph.
  2630   2816   **
  2631   2817   */
  2632         -SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
         2818  +SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
  2633   2819   
  2634   2820   /*
  2635   2821   ** CAPI3REF: Opening A New Database Connection
         2822  +** CONSTRUCTOR: sqlite3
  2636   2823   **
  2637   2824   ** ^These routines open an SQLite database file as specified by the 
  2638   2825   ** filename argument. ^The filename argument is interpreted as UTF-8 for
  2639   2826   ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
  2640   2827   ** order for sqlite3_open16(). ^(A [database connection] handle is usually
  2641   2828   ** returned in *ppDb, even if an error occurs.  The only exception is that
  2642   2829   ** if SQLite is unable to allocate memory to hold the [sqlite3] object,
................................................................................
  2643   2830   ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]
  2644   2831   ** object.)^ ^(If the database is opened (and/or created) successfully, then
  2645   2832   ** [SQLITE_OK] is returned.  Otherwise an [error code] is returned.)^ ^The
  2646   2833   ** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain
  2647   2834   ** an English language description of the error following a failure of any
  2648   2835   ** of the sqlite3_open() routines.
  2649   2836   **
  2650         -** ^The default encoding for the database will be UTF-8 if
  2651         -** sqlite3_open() or sqlite3_open_v2() is called and
  2652         -** UTF-16 in the native byte order if sqlite3_open16() is used.
         2837  +** ^The default encoding will be UTF-8 for databases created using
         2838  +** sqlite3_open() or sqlite3_open_v2().  ^The default encoding for databases
         2839  +** created using sqlite3_open16() will be UTF-16 in the native byte order.
  2653   2840   **
  2654   2841   ** Whether or not an error occurs when it is opened, resources
  2655   2842   ** associated with the [database connection] handle should be released by
  2656   2843   ** passing it to [sqlite3_close()] when it is no longer required.
  2657   2844   **
  2658   2845   ** The sqlite3_open_v2() interface works like sqlite3_open()
  2659   2846   ** except that it accepts two additional parameters for additional control
................................................................................
  2733   2920   ** present, is ignored.
  2734   2921   **
  2735   2922   ** ^SQLite uses the path component of the URI as the name of the disk file
  2736   2923   ** which contains the database. ^If the path begins with a '/' character, 
  2737   2924   ** then it is interpreted as an absolute path. ^If the path does not begin 
  2738   2925   ** with a '/' (meaning that the authority section is omitted from the URI)
  2739   2926   ** then the path is interpreted as a relative path. 
  2740         -** ^On windows, the first component of an absolute path 
  2741         -** is a drive specification (e.g. "C:").
         2927  +** ^(On windows, the first component of an absolute path 
         2928  +** is a drive specification (e.g. "C:").)^
  2742   2929   **
  2743   2930   ** [[core URI query parameters]]
  2744   2931   ** The query component of a URI may contain parameters that are interpreted
  2745   2932   ** either by SQLite itself, or by a [VFS | custom VFS implementation].
  2746         -** SQLite interprets the following three query parameters:
         2933  +** SQLite and its built-in [VFSes] interpret the
         2934  +** following query parameters:
  2747   2935   **
  2748   2936   ** <ul>
  2749   2937   **   <li> <b>vfs</b>: ^The "vfs" parameter may be used to specify the name of
  2750   2938   **     a VFS object that provides the operating system interface that should
  2751   2939   **     be used to access the database file on disk. ^If this option is set to
  2752   2940   **     an empty string the default VFS object is used. ^Specifying an unknown
  2753   2941   **     VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is
................................................................................
  2774   2962   **     SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to
  2775   2963   **     sqlite3_open_v2(). ^Setting the cache parameter to "private" is 
  2776   2964   **     equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit.
  2777   2965   **     ^If sqlite3_open_v2() is used and the "cache" parameter is present in
  2778   2966   **     a URI filename, its value overrides any behavior requested by setting
  2779   2967   **     SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag.
  2780   2968   **
  2781         -**  <li> <b>psow</b>: ^The psow parameter may be "true" (or "on" or "yes" or
  2782         -**     "1") or "false" (or "off" or "no" or "0") to indicate that the
         2969  +**  <li> <b>psow</b>: ^The psow parameter indicates whether or not the
  2783   2970   **     [powersafe overwrite] property does or does not apply to the
  2784         -**     storage media on which the database file resides.  ^The psow query
  2785         -**     parameter only works for the built-in unix and Windows VFSes.
         2971  +**     storage media on which the database file resides.
  2786   2972   **
  2787   2973   **  <li> <b>nolock</b>: ^The nolock parameter is a boolean query parameter
  2788   2974   **     which if set disables file locking in rollback journal modes.  This
  2789   2975   **     is useful for accessing a database on a filesystem that does not
  2790   2976   **     support locking.  Caution:  Database corruption might result if two
  2791   2977   **     or more processes write to the same database and any one of those
  2792   2978   **     processes uses nolock=1.
................................................................................
  2854   3040   **
  2855   3041   ** <b>Note to Windows Runtime users:</b>  The temporary directory must be set
  2856   3042   ** prior to calling sqlite3_open() or sqlite3_open_v2().  Otherwise, various
  2857   3043   ** features that require the use of temporary files may fail.
  2858   3044   **
  2859   3045   ** See also: [sqlite3_temp_directory]
  2860   3046   */
  2861         -SQLITE_API int sqlite3_open(
         3047  +SQLITE_API int SQLITE_STDCALL sqlite3_open(
  2862   3048     const char *filename,   /* Database filename (UTF-8) */
  2863   3049     sqlite3 **ppDb          /* OUT: SQLite db handle */
  2864   3050   );
  2865         -SQLITE_API int sqlite3_open16(
         3051  +SQLITE_API int SQLITE_STDCALL sqlite3_open16(
  2866   3052     const void *filename,   /* Database filename (UTF-16) */
  2867   3053     sqlite3 **ppDb          /* OUT: SQLite db handle */
  2868   3054   );
  2869         -SQLITE_API int sqlite3_open_v2(
         3055  +SQLITE_API int SQLITE_STDCALL sqlite3_open_v2(
  2870   3056     const char *filename,   /* Database filename (UTF-8) */
  2871   3057     sqlite3 **ppDb,         /* OUT: SQLite db handle */
  2872   3058     int flags,              /* Flags */
  2873   3059     const char *zVfs        /* Name of VFS module to use */
  2874   3060   );
  2875   3061   
  2876   3062   /*
................................................................................
  2908   3094   ** 
  2909   3095   ** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and
  2910   3096   ** sqlite3_uri_boolean(F,P,B) returns B.  If F is not a NULL pointer and
  2911   3097   ** is not a database file pathname pointer that SQLite passed into the xOpen
  2912   3098   ** VFS method, then the behavior of this routine is undefined and probably
  2913   3099   ** undesirable.
  2914   3100   */
  2915         -SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
  2916         -SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
  2917         -SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
         3101  +SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam);
         3102  +SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
         3103  +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
  2918   3104   
  2919   3105   
  2920   3106   /*
  2921   3107   ** CAPI3REF: Error Codes And Messages
         3108  +** METHOD: sqlite3
  2922   3109   **
  2923         -** ^The sqlite3_errcode() interface returns the numeric [result code] or
  2924         -** [extended result code] for the most recent failed sqlite3_* API call
  2925         -** associated with a [database connection]. If a prior API call failed
  2926         -** but the most recent API call succeeded, the return value from
  2927         -** sqlite3_errcode() is undefined.  ^The sqlite3_extended_errcode()
         3110  +** ^If the most recent sqlite3_* API call associated with 
         3111  +** [database connection] D failed, then the sqlite3_errcode(D) interface
         3112  +** returns the numeric [result code] or [extended result code] for that
         3113  +** API call.
         3114  +** If the most recent API call was successful,
         3115  +** then the return value from sqlite3_errcode() is undefined.
         3116  +** ^The sqlite3_extended_errcode()
  2928   3117   ** interface is the same except that it always returns the 
  2929   3118   ** [extended result code] even when extended result codes are
  2930   3119   ** disabled.
  2931   3120   **
  2932   3121   ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
  2933   3122   ** text that describes the error, as either UTF-8 or UTF-16 respectively.
  2934   3123   ** ^(Memory to hold the error message string is managed internally.
................................................................................
  2951   3140   ** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after
  2952   3141   ** all calls to the interfaces listed here are completed.
  2953   3142   **
  2954   3143   ** If an interface fails with SQLITE_MISUSE, that means the interface
  2955   3144   ** was invoked incorrectly by the application.  In that case, the
  2956   3145   ** error code and message may or may not be set.
  2957   3146   */
  2958         -SQLITE_API int sqlite3_errcode(sqlite3 *db);
  2959         -SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
  2960         -SQLITE_API const char *sqlite3_errmsg(sqlite3*);
  2961         -SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
  2962         -SQLITE_API const char *sqlite3_errstr(int);
         3147  +SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db);
         3148  +SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db);
         3149  +SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3*);
         3150  +SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3*);
         3151  +SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int);
  2963   3152   
  2964   3153   /*
  2965         -** CAPI3REF: SQL Statement Object
         3154  +** CAPI3REF: Prepared Statement Object
  2966   3155   ** KEYWORDS: {prepared statement} {prepared statements}
  2967   3156   **
  2968         -** An instance of this object represents a single SQL statement.
  2969         -** This object is variously known as a "prepared statement" or a
  2970         -** "compiled SQL statement" or simply as a "statement".
         3157  +** An instance of this object represents a single SQL statement that
         3158  +** has been compiled into binary form and is ready to be evaluated.
  2971   3159   **
  2972         -** The life of a statement object goes something like this:
         3160  +** Think of each SQL statement as a separate computer program.  The
         3161  +** original SQL text is source code.  A prepared statement object 
         3162  +** is the compiled object code.  All SQL must be converted into a
         3163  +** prepared statement before it can be run.
         3164  +**
         3165  +** The life-cycle of a prepared statement object usually goes like this:
  2973   3166   **
  2974   3167   ** <ol>
  2975         -** <li> Create the object using [sqlite3_prepare_v2()] or a related
  2976         -**      function.
  2977         -** <li> Bind values to [host parameters] using the sqlite3_bind_*()
         3168  +** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
         3169  +** <li> Bind values to [parameters] using the sqlite3_bind_*()
  2978   3170   **      interfaces.
  2979   3171   ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
  2980         -** <li> Reset the statement using [sqlite3_reset()] then go back
         3172  +** <li> Reset the prepared statement using [sqlite3_reset()] then go back
  2981   3173   **      to step 2.  Do this zero or more times.
  2982   3174   ** <li> Destroy the object using [sqlite3_finalize()].
  2983   3175   ** </ol>
  2984         -**
  2985         -** Refer to documentation on individual methods above for additional
  2986         -** information.
  2987   3176   */
  2988   3177   typedef struct sqlite3_stmt sqlite3_stmt;
  2989   3178   
  2990   3179   /*
  2991   3180   ** CAPI3REF: Run-time Limits
         3181  +** METHOD: sqlite3
  2992   3182   **
  2993   3183   ** ^(This interface allows the size of various constructs to be limited
  2994   3184   ** on a connection by connection basis.  The first parameter is the
  2995   3185   ** [database connection] whose limit is to be set or queried.  The
  2996   3186   ** second parameter is one of the [limit categories] that define a
  2997   3187   ** class of constructs to be size limited.  The third parameter is the
  2998   3188   ** new limit for that construct.)^
................................................................................
  3022   3212   ** attack.  Developers might also want to use the [sqlite3_set_authorizer()]
  3023   3213   ** interface to further control untrusted SQL.  The size of the database
  3024   3214   ** created by an untrusted script can be contained using the
  3025   3215   ** [max_page_count] [PRAGMA].
  3026   3216   **
  3027   3217   ** New run-time limit categories may be added in future releases.
  3028   3218   */
  3029         -SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
         3219  +SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3*, int id, int newVal);
  3030   3220   
  3031   3221   /*
  3032   3222   ** CAPI3REF: Run-Time Limit Categories
  3033   3223   ** KEYWORDS: {limit category} {*limit categories}
  3034   3224   **
  3035   3225   ** These constants define various performance limits
  3036   3226   ** that can be lowered at run-time using [sqlite3_limit()].
................................................................................
  3074   3264   **
  3075   3265   ** [[SQLITE_LIMIT_VARIABLE_NUMBER]]
  3076   3266   ** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
  3077   3267   ** <dd>The maximum index number of any [parameter] in an SQL statement.)^
  3078   3268   **
  3079   3269   ** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
  3080   3270   ** <dd>The maximum depth of recursion for triggers.</dd>)^
         3271  +**
         3272  +** [[SQLITE_LIMIT_WORKER_THREADS]] ^(<dt>SQLITE_LIMIT_WORKER_THREADS</dt>
         3273  +** <dd>The maximum number of auxiliary worker threads that a single
         3274  +** [prepared statement] may start.</dd>)^
  3081   3275   ** </dl>
  3082   3276   */
  3083   3277   #define SQLITE_LIMIT_LENGTH                    0
  3084   3278   #define SQLITE_LIMIT_SQL_LENGTH                1
  3085   3279   #define SQLITE_LIMIT_COLUMN                    2
  3086   3280   #define SQLITE_LIMIT_EXPR_DEPTH                3
  3087   3281   #define SQLITE_LIMIT_COMPOUND_SELECT           4
  3088   3282   #define SQLITE_LIMIT_VDBE_OP                   5
  3089   3283   #define SQLITE_LIMIT_FUNCTION_ARG              6
  3090   3284   #define SQLITE_LIMIT_ATTACHED                  7
  3091   3285   #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH       8
  3092   3286   #define SQLITE_LIMIT_VARIABLE_NUMBER           9
  3093   3287   #define SQLITE_LIMIT_TRIGGER_DEPTH            10
         3288  +#define SQLITE_LIMIT_WORKER_THREADS           11
  3094   3289   
  3095   3290   /*
  3096   3291   ** CAPI3REF: Compiling An SQL Statement
  3097   3292   ** KEYWORDS: {SQL statement compiler}
         3293  +** METHOD: sqlite3
         3294  +** CONSTRUCTOR: sqlite3_stmt
  3098   3295   **
  3099   3296   ** To execute an SQL query, it must first be compiled into a byte-code
  3100   3297   ** program using one of these routines.
  3101   3298   **
  3102   3299   ** The first argument, "db", is a [database connection] obtained from a
  3103   3300   ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
  3104   3301   ** [sqlite3_open16()].  The database connection must not have been closed.
  3105   3302   **
  3106   3303   ** The second argument, "zSql", is the statement to be compiled, encoded
  3107   3304   ** as either UTF-8 or UTF-16.  The sqlite3_prepare() and sqlite3_prepare_v2()
  3108   3305   ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
  3109   3306   ** use UTF-16.
  3110   3307   **
  3111         -** ^If the nByte argument is less than zero, then zSql is read up to the
  3112         -** first zero terminator. ^If nByte is non-negative, then it is the maximum
  3113         -** number of  bytes read from zSql.  ^When nByte is non-negative, the
  3114         -** zSql string ends at either the first '\000' or '\u0000' character or
  3115         -** the nByte-th byte, whichever comes first. If the caller knows
  3116         -** that the supplied string is nul-terminated, then there is a small
  3117         -** performance advantage to be gained by passing an nByte parameter that
  3118         -** is equal to the number of bytes in the input string <i>including</i>
  3119         -** the nul-terminator bytes as this saves SQLite from having to
  3120         -** make a copy of the input string.
         3308  +** ^If the nByte argument is negative, then zSql is read up to the
         3309  +** first zero terminator. ^If nByte is positive, then it is the
         3310  +** number of bytes read from zSql.  ^If nByte is zero, then no prepared
         3311  +** statement is generated.
         3312  +** If the caller knows that the supplied string is nul-terminated, then
         3313  +** there is a small performance advantage to passing an nByte parameter that
         3314  +** is the number of bytes in the input string <i>including</i>
         3315  +** the nul-terminator.
  3121   3316   **
  3122   3317   ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
  3123   3318   ** past the end of the first SQL statement in zSql.  These routines only
  3124   3319   ** compile the first statement in zSql, so *pzTail is left pointing to
  3125   3320   ** what remains uncompiled.
  3126   3321   **
  3127   3322   ** ^*ppStmt is left pointing to a compiled [prepared statement] that can be
................................................................................
  3169   3364   ** ^The specific value of WHERE-clause [parameter] might influence the 
  3170   3365   ** choice of query plan if the parameter is the left-hand side of a [LIKE]
  3171   3366   ** or [GLOB] operator or if the parameter is compared to an indexed column
  3172   3367   ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
  3173   3368   ** </li>
  3174   3369   ** </ol>
  3175   3370   */
  3176         -SQLITE_API int sqlite3_prepare(
         3371  +SQLITE_API int SQLITE_STDCALL sqlite3_prepare(
  3177   3372     sqlite3 *db,            /* Database handle */
  3178   3373     const char *zSql,       /* SQL statement, UTF-8 encoded */
  3179   3374     int nByte,              /* Maximum length of zSql in bytes. */
  3180   3375     sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  3181   3376     const char **pzTail     /* OUT: Pointer to unused portion of zSql */
  3182   3377   );
  3183         -SQLITE_API int sqlite3_prepare_v2(
         3378  +SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2(
  3184   3379     sqlite3 *db,            /* Database handle */
  3185   3380     const char *zSql,       /* SQL statement, UTF-8 encoded */
  3186   3381     int nByte,              /* Maximum length of zSql in bytes. */
  3187   3382     sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  3188   3383     const char **pzTail     /* OUT: Pointer to unused portion of zSql */
  3189   3384   );
  3190         -SQLITE_API int sqlite3_prepare16(
         3385  +SQLITE_API int SQLITE_STDCALL sqlite3_prepare16(
  3191   3386     sqlite3 *db,            /* Database handle */
  3192   3387     const void *zSql,       /* SQL statement, UTF-16 encoded */
  3193   3388     int nByte,              /* Maximum length of zSql in bytes. */
  3194   3389     sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  3195   3390     const void **pzTail     /* OUT: Pointer to unused portion of zSql */
  3196   3391   );
  3197         -SQLITE_API int sqlite3_prepare16_v2(
         3392  +SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
  3198   3393     sqlite3 *db,            /* Database handle */
  3199   3394     const void *zSql,       /* SQL statement, UTF-16 encoded */
  3200   3395     int nByte,              /* Maximum length of zSql in bytes. */
  3201   3396     sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  3202   3397     const void **pzTail     /* OUT: Pointer to unused portion of zSql */
  3203   3398   );
  3204   3399   
  3205   3400   /*
  3206   3401   ** CAPI3REF: Retrieving Statement SQL
         3402  +** METHOD: sqlite3_stmt
  3207   3403   **
  3208   3404   ** ^This interface can be used to retrieve a saved copy of the original
  3209   3405   ** SQL text used to create a [prepared statement] if that statement was
  3210   3406   ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
  3211   3407   */
  3212         -SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
         3408  +SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
  3213   3409   
  3214   3410   /*
  3215   3411   ** CAPI3REF: Determine If An SQL Statement Writes The Database
         3412  +** METHOD: sqlite3_stmt
  3216   3413   **
  3217   3414   ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
  3218   3415   ** and only if the [prepared statement] X makes no direct changes to
  3219   3416   ** the content of the database file.
  3220   3417   **
  3221   3418   ** Note that [application-defined SQL functions] or
  3222   3419   ** [virtual tables] might change the database indirectly as a side effect.  
................................................................................
  3236   3433   ** since the statements themselves do not actually modify the database but
  3237   3434   ** rather they control the timing of when other statements modify the 
  3238   3435   ** database.  ^The [ATTACH] and [DETACH] statements also cause
  3239   3436   ** sqlite3_stmt_readonly() to return true since, while those statements
  3240   3437   ** change the configuration of a database connection, they do not make 
  3241   3438   ** changes to the content of the database files on disk.
  3242   3439   */
  3243         -SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
         3440  +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
  3244   3441   
  3245   3442   /*
  3246   3443   ** CAPI3REF: Determine If A Prepared Statement Has Been Reset
         3444  +** METHOD: sqlite3_stmt
  3247   3445   **
  3248   3446   ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
  3249   3447   ** [prepared statement] S has been stepped at least once using 
  3250         -** [sqlite3_step(S)] but has not run to completion and/or has not 
         3448  +** [sqlite3_step(S)] but has neither run to completion (returned
         3449  +** [SQLITE_DONE] from [sqlite3_step(S)]) nor
  3251   3450   ** been reset using [sqlite3_reset(S)].  ^The sqlite3_stmt_busy(S)
  3252   3451   ** interface returns false if S is a NULL pointer.  If S is not a 
  3253   3452   ** NULL pointer and is not a pointer to a valid [prepared statement]
  3254   3453   ** object, then the behavior is undefined and probably undesirable.
  3255   3454   **
  3256   3455   ** This interface can be used in combination [sqlite3_next_stmt()]
  3257   3456   ** to locate all prepared statements associated with a database 
  3258   3457   ** connection that are in need of being reset.  This can be used,
  3259   3458   ** for example, in diagnostic routines to search for prepared 
  3260   3459   ** statements that are holding a transaction open.
  3261   3460   */
  3262         -SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
         3461  +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt*);
  3263   3462   
  3264   3463   /*
  3265   3464   ** CAPI3REF: Dynamically Typed Value Object
  3266   3465   ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
  3267   3466   **
  3268   3467   ** SQLite uses the sqlite3_value object to represent all values
  3269   3468   ** that can be stored in a database table. SQLite uses dynamic typing
................................................................................
  3270   3469   ** for the values it stores.  ^Values stored in sqlite3_value objects
  3271   3470   ** can be integers, floating point values, strings, BLOBs, or NULL.
  3272   3471   **
  3273   3472   ** An sqlite3_value object may be either "protected" or "unprotected".
  3274   3473   ** Some interfaces require a protected sqlite3_value.  Other interfaces
  3275   3474   ** will accept either a protected or an unprotected sqlite3_value.
  3276   3475   ** Every interface that accepts sqlite3_value arguments specifies
  3277         -** whether or not it requires a protected sqlite3_value.
         3476  +** whether or not it requires a protected sqlite3_value.  The
         3477  +** [sqlite3_value_dup()] interface can be used to construct a new 
         3478  +** protected sqlite3_value from an unprotected sqlite3_value.
  3278   3479   **
  3279   3480   ** The terms "protected" and "unprotected" refer to whether or not
  3280   3481   ** a mutex is held.  An internal mutex is held for a protected
  3281   3482   ** sqlite3_value object but no mutex is held for an unprotected
  3282   3483   ** sqlite3_value object.  If SQLite is compiled to be single-threaded
  3283   3484   ** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0)
  3284   3485   ** or if SQLite is run in one of reduced mutex modes 
................................................................................
  3314   3515   */
  3315   3516   typedef struct sqlite3_context sqlite3_context;
  3316   3517   
  3317   3518   /*
  3318   3519   ** CAPI3REF: Binding Values To Prepared Statements
  3319   3520   ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
  3320   3521   ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
         3522  +** METHOD: sqlite3_stmt
  3321   3523   **
  3322   3524   ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
  3323   3525   ** literals may be replaced by a [parameter] that matches one of following
  3324   3526   ** templates:
  3325   3527   **
  3326   3528   ** <ul>
  3327   3529   ** <li>  ?
................................................................................
  3360   3562   ** number of <u>bytes</u> in the value, not the number of characters.)^
  3361   3563   ** ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16()
  3362   3564   ** is negative, then the length of the string is
  3363   3565   ** the number of bytes up to the first zero terminator.
  3364   3566   ** If the fourth parameter to sqlite3_bind_blob() is negative, then
  3365   3567   ** the behavior is undefined.
  3366   3568   ** If a non-negative fourth parameter is provided to sqlite3_bind_text()
  3367         -** or sqlite3_bind_text16() then that parameter must be the byte offset
         3569  +** or sqlite3_bind_text16() or sqlite3_bind_text64() then
         3570  +** that parameter must be the byte offset
  3368   3571   ** where the NUL terminator would occur assuming the string were NUL
  3369   3572   ** terminated.  If any NUL characters occur at byte offsets less than 
  3370   3573   ** the value of the fourth parameter then the resulting string value will
  3371   3574   ** contain embedded NULs.  The result of expressions involving strings
  3372   3575   ** with embedded NULs is undefined.
  3373   3576   **
  3374         -** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
  3375         -** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
         3577  +** ^The fifth argument to the BLOB and string binding interfaces
         3578  +** is a destructor used to dispose of the BLOB or
  3376   3579   ** string after SQLite has finished with it.  ^The destructor is called
  3377         -** to dispose of the BLOB or string even if the call to sqlite3_bind_blob(),
  3378         -** sqlite3_bind_text(), or sqlite3_bind_text16() fails.  
         3580  +** to dispose of the BLOB or string even if the call to bind API fails.
  3379   3581   ** ^If the fifth argument is
  3380   3582   ** the special value [SQLITE_STATIC], then SQLite assumes that the
  3381   3583   ** information is in static, unmanaged space and does not need to be freed.
  3382   3584   ** ^If the fifth argument has the value [SQLITE_TRANSIENT], then
  3383   3585   ** SQLite makes its own private copy of the data immediately, before
  3384   3586   ** the sqlite3_bind_*() routine returns.
         3587  +**
         3588  +** ^The sixth argument to sqlite3_bind_text64() must be one of
         3589  +** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]
         3590  +** to specify the encoding of the text in the third parameter.  If
         3591  +** the sixth argument to sqlite3_bind_text64() is not one of the
         3592  +** allowed values shown above, or if the text encoding is different
         3593  +** from the encoding specified by the sixth parameter, then the behavior
         3594  +** is undefined.
  3385   3595   **
  3386   3596   ** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
  3387   3597   ** is filled with zeroes.  ^A zeroblob uses a fixed amount of memory
  3388   3598   ** (just an integer to hold its size) while it is being processed.
  3389   3599   ** Zeroblobs are intended to serve as placeholders for BLOBs whose
  3390   3600   ** content is later written using
  3391   3601   ** [sqlite3_blob_open | incremental BLOB I/O] routines.
................................................................................
  3399   3609   ** result is undefined and probably harmful.
  3400   3610   **
  3401   3611   ** ^Bindings are not cleared by the [sqlite3_reset()] routine.
  3402   3612   ** ^Unbound parameters are interpreted as NULL.
  3403   3613   **
  3404   3614   ** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an
  3405   3615   ** [error code] if anything goes wrong.
         3616  +** ^[SQLITE_TOOBIG] might be returned if the size of a string or BLOB
         3617  +** exceeds limits imposed by [sqlite3_limit]([SQLITE_LIMIT_LENGTH]) or
         3618  +** [SQLITE_MAX_LENGTH].
  3406   3619   ** ^[SQLITE_RANGE] is returned if the parameter
  3407   3620   ** index is out of range.  ^[SQLITE_NOMEM] is returned if malloc() fails.
  3408   3621   **
  3409   3622   ** See also: [sqlite3_bind_parameter_count()],
  3410   3623   ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
  3411   3624   */
  3412         -SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
  3413         -SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
  3414         -SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
  3415         -SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
  3416         -SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
  3417         -SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));
  3418         -SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
  3419         -SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
  3420         -SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
         3625  +SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
         3626  +SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
         3627  +                        void(*)(void*));
         3628  +SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt*, int, double);
         3629  +SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt*, int, int);
         3630  +SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
         3631  +SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt*, int);
         3632  +SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
         3633  +SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
         3634  +SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
         3635  +                         void(*)(void*), unsigned char encoding);
         3636  +SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
         3637  +SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
         3638  +SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
  3421   3639   
  3422   3640   /*
  3423   3641   ** CAPI3REF: Number Of SQL Parameters
         3642  +** METHOD: sqlite3_stmt
  3424   3643   **
  3425   3644   ** ^This routine can be used to find the number of [SQL parameters]
  3426   3645   ** in a [prepared statement].  SQL parameters are tokens of the
  3427   3646   ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
  3428   3647   ** placeholders for values that are [sqlite3_bind_blob | bound]
  3429   3648   ** to the parameters at a later time.
  3430   3649   **
................................................................................
  3433   3652   ** number of unique parameters.  If parameters of the ?NNN form are used,
  3434   3653   ** there may be gaps in the list.)^
  3435   3654   **
  3436   3655   ** See also: [sqlite3_bind_blob|sqlite3_bind()],
  3437   3656   ** [sqlite3_bind_parameter_name()], and
  3438   3657   ** [sqlite3_bind_parameter_index()].
  3439   3658   */
  3440         -SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
         3659  +SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt*);
  3441   3660   
  3442   3661   /*
  3443   3662   ** CAPI3REF: Name Of A Host Parameter
         3663  +** METHOD: sqlite3_stmt
  3444   3664   **
  3445   3665   ** ^The sqlite3_bind_parameter_name(P,N) interface returns
  3446   3666   ** the name of the N-th [SQL parameter] in the [prepared statement] P.
  3447   3667   ** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
  3448   3668   ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
  3449   3669   ** respectively.
  3450   3670   ** In other words, the initial ":" or "$" or "@" or "?"
................................................................................
  3460   3680   ** originally specified as UTF-16 in [sqlite3_prepare16()] or
  3461   3681   ** [sqlite3_prepare16_v2()].
  3462   3682   **
  3463   3683   ** See also: [sqlite3_bind_blob|sqlite3_bind()],
  3464   3684   ** [sqlite3_bind_parameter_count()], and
  3465   3685   ** [sqlite3_bind_parameter_index()].
  3466   3686   */
  3467         -SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
         3687  +SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt*, int);
  3468   3688   
  3469   3689   /*
  3470   3690   ** CAPI3REF: Index Of A Parameter With A Given Name
         3691  +** METHOD: sqlite3_stmt
  3471   3692   **
  3472   3693   ** ^Return the index of an SQL parameter given its name.  ^The
  3473   3694   ** index value returned is suitable for use as the second
  3474   3695   ** parameter to [sqlite3_bind_blob|sqlite3_bind()].  ^A zero
  3475   3696   ** is returned if no matching parameter is found.  ^The parameter
  3476   3697   ** name must be given in UTF-8 even if the original statement
  3477   3698   ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
  3478   3699   **
  3479   3700   ** See also: [sqlite3_bind_blob|sqlite3_bind()],
  3480   3701   ** [sqlite3_bind_parameter_count()], and
  3481         -** [sqlite3_bind_parameter_index()].
         3702  +** [sqlite3_bind_parameter_name()].
  3482   3703   */
  3483         -SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
         3704  +SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
  3484   3705   
  3485   3706   /*
  3486   3707   ** CAPI3REF: Reset All Bindings On A Prepared Statement
         3708  +** METHOD: sqlite3_stmt
  3487   3709   **
  3488   3710   ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
  3489   3711   ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
  3490   3712   ** ^Use this routine to reset all host parameters to NULL.
  3491   3713   */
  3492         -SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
         3714  +SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt*);
  3493   3715   
  3494   3716   /*
  3495   3717   ** CAPI3REF: Number Of Columns In A Result Set
         3718  +** METHOD: sqlite3_stmt
  3496   3719   **
  3497   3720   ** ^Return the number of columns in the result set returned by the
  3498   3721   ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
  3499   3722   ** statement that does not return data (for example an [UPDATE]).
  3500   3723   **
  3501   3724   ** See also: [sqlite3_data_count()]
  3502   3725   */
  3503         -SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
         3726  +SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt);
  3504   3727   
  3505   3728   /*
  3506   3729   ** CAPI3REF: Column Names In A Result Set
         3730  +** METHOD: sqlite3_stmt
  3507   3731   **
  3508   3732   ** ^These routines return the name assigned to a particular column
  3509   3733   ** in the result set of a [SELECT] statement.  ^The sqlite3_column_name()
  3510   3734   ** interface returns a pointer to a zero-terminated UTF-8 string
  3511   3735   ** and sqlite3_column_name16() returns a pointer to a zero-terminated
  3512   3736   ** UTF-16 string.  ^The first parameter is the [prepared statement]
  3513   3737   ** that implements the [SELECT] statement. ^The second parameter is the
................................................................................
  3524   3748   ** NULL pointer is returned.
  3525   3749   **
  3526   3750   ** ^The name of a result column is the value of the "AS" clause for
  3527   3751   ** that column, if there is an AS clause.  If there is no AS clause
  3528   3752   ** then the name of the column is unspecified and may change from
  3529   3753   ** one release of SQLite to the next.
  3530   3754   */
  3531         -SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
  3532         -SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
         3755  +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt*, int N);
         3756  +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt*, int N);
  3533   3757   
  3534   3758   /*
  3535   3759   ** CAPI3REF: Source Of Data In A Query Result
         3760  +** METHOD: sqlite3_stmt
  3536   3761   **
  3537   3762   ** ^These routines provide a means to determine the database, table, and
  3538   3763   ** table column that is the origin of a particular result column in
  3539   3764   ** [SELECT] statement.
  3540   3765   ** ^The name of the database or table or column can be returned as
  3541   3766   ** either a UTF-8 or UTF-16 string.  ^The _database_ routines return
  3542   3767   ** the database name, the _table_ routines return the table name, and
................................................................................
  3572   3797   ** undefined.
  3573   3798   **
  3574   3799   ** If two or more threads call one or more
  3575   3800   ** [sqlite3_column_database_name | column metadata interfaces]
  3576   3801   ** for the same [prepared statement] and result column
  3577   3802   ** at the same time then the results are undefined.
  3578   3803   */
  3579         -SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);
  3580         -SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
  3581         -SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);
  3582         -SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
  3583         -SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
  3584         -SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
         3804  +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt*,int);
         3805  +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt*,int);
         3806  +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt*,int);
         3807  +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt*,int);
         3808  +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt*,int);
         3809  +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt*,int);
  3585   3810   
  3586   3811   /*
  3587   3812   ** CAPI3REF: Declared Datatype Of A Query Result
         3813  +** METHOD: sqlite3_stmt
  3588   3814   **
  3589   3815   ** ^(The first parameter is a [prepared statement].
  3590   3816   ** If this statement is a [SELECT] statement and the Nth column of the
  3591   3817   ** returned result set of that [SELECT] is a table column (not an
  3592   3818   ** expression or subquery) then the declared type of the table
  3593   3819   ** column is returned.)^  ^If the Nth column of the result set is an
  3594   3820   ** expression or subquery, then a NULL pointer is returned.
................................................................................
  3608   3834   ** ^SQLite uses dynamic run-time typing.  ^So just because a column
  3609   3835   ** is declared to contain a particular type does not mean that the
  3610   3836   ** data stored in that column is of the declared type.  SQLite is
  3611   3837   ** strongly typed, but the typing is dynamic not static.  ^Type
  3612   3838   ** is associated with individual values, not with the containers
  3613   3839   ** used to hold those values.
  3614   3840   */
  3615         -SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
  3616         -SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
         3841  +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt*,int);
         3842  +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt*,int);
  3617   3843   
  3618   3844   /*
  3619   3845   ** CAPI3REF: Evaluate An SQL Statement
         3846  +** METHOD: sqlite3_stmt
  3620   3847   **
  3621   3848   ** After a [prepared statement] has been prepared using either
  3622   3849   ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
  3623   3850   ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
  3624   3851   ** must be called one or more times to evaluate the statement.
  3625   3852   **
  3626   3853   ** The details of the behavior of the sqlite3_step() interface depend
................................................................................
  3688   3915   ** We admit that this is a goofy design.  The problem has been fixed
  3689   3916   ** with the "v2" interface.  If you prepare all of your SQL statements
  3690   3917   ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
  3691   3918   ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
  3692   3919   ** then the more specific [error codes] are returned directly
  3693   3920   ** by sqlite3_step().  The use of the "v2" interface is recommended.
  3694   3921   */
  3695         -SQLITE_API int sqlite3_step(sqlite3_stmt*);
         3922  +SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt*);
  3696   3923   
  3697   3924   /*
  3698   3925   ** CAPI3REF: Number of columns in a result set
         3926  +** METHOD: sqlite3_stmt
  3699   3927   **
  3700   3928   ** ^The sqlite3_data_count(P) interface returns the number of columns in the
  3701   3929   ** current row of the result set of [prepared statement] P.
  3702   3930   ** ^If prepared statement P does not have results ready to return
  3703   3931   ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
  3704   3932   ** interfaces) then sqlite3_data_count(P) returns 0.
  3705   3933   ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.
................................................................................
  3708   3936   ** will return non-zero if previous call to [sqlite3_step](P) returned
  3709   3937   ** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum]
  3710   3938   ** where it always returns zero since each step of that multi-step
  3711   3939   ** pragma returns 0 columns of data.
  3712   3940   **
  3713   3941   ** See also: [sqlite3_column_count()]
  3714   3942   */
  3715         -SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
         3943  +SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt);
  3716   3944   
  3717   3945   /*
  3718   3946   ** CAPI3REF: Fundamental Datatypes
  3719   3947   ** KEYWORDS: SQLITE_TEXT
  3720   3948   **
  3721   3949   ** ^(Every value in SQLite has one of five fundamental datatypes:
  3722   3950   **
................................................................................
  3745   3973   # define SQLITE_TEXT     3
  3746   3974   #endif
  3747   3975   #define SQLITE3_TEXT     3
  3748   3976   
  3749   3977   /*
  3750   3978   ** CAPI3REF: Result Values From A Query
  3751   3979   ** KEYWORDS: {column access functions}
  3752         -**
  3753         -** These routines form the "result set" interface.
         3980  +** METHOD: sqlite3_stmt
  3754   3981   **
  3755   3982   ** ^These routines return information about a single column of the current
  3756   3983   ** result row of a query.  ^In every case the first argument is a pointer
  3757   3984   ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
  3758   3985   ** that was returned from [sqlite3_prepare_v2()] or one of its variants)
  3759   3986   ** and the second argument is the index of the column for which information
  3760   3987   ** should be returned. ^The leftmost column of the result set has the index 0.
................................................................................
  3807   4034   ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of
  3808   4035   ** bytes in the string, not the number of characters.
  3809   4036   **
  3810   4037   ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
  3811   4038   ** even empty strings, are always zero-terminated.  ^The return
  3812   4039   ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
  3813   4040   **
  3814         -** ^The object returned by [sqlite3_column_value()] is an
  3815         -** [unprotected sqlite3_value] object.  An unprotected sqlite3_value object
  3816         -** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
         4041  +** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
         4042  +** [unprotected sqlite3_value] object.  In a multithreaded environment,
         4043  +** an unprotected sqlite3_value object may only be used safely with
         4044  +** [sqlite3_bind_value()] and [sqlite3_result_value()].
  3817   4045   ** If the [unprotected sqlite3_value] object returned by
  3818   4046   ** [sqlite3_column_value()] is used in any other way, including calls
  3819   4047   ** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
  3820         -** or [sqlite3_value_bytes()], then the behavior is undefined.
         4048  +** or [sqlite3_value_bytes()], the behavior is not threadsafe.
  3821   4049   **
  3822   4050   ** These routines attempt to convert the value where appropriate.  ^For
  3823   4051   ** example, if the internal representation is FLOAT and a text result
  3824   4052   ** is requested, [sqlite3_snprintf()] is used internally to perform the
  3825   4053   ** conversion automatically.  ^(The following table details the conversions
  3826   4054   ** that are applied:
  3827   4055   **
................................................................................
  3844   4072   ** <tr><td>  TEXT    <td>   BLOB    <td> No change
  3845   4073   ** <tr><td>  BLOB    <td> INTEGER   <td> [CAST] to INTEGER
  3846   4074   ** <tr><td>  BLOB    <td>  FLOAT    <td> [CAST] to REAL
  3847   4075   ** <tr><td>  BLOB    <td>   TEXT    <td> Add a zero terminator if needed
  3848   4076   ** </table>
  3849   4077   ** </blockquote>)^
  3850   4078   **
  3851         -** The table above makes reference to standard C library functions atoi()
  3852         -** and atof().  SQLite does not really use these functions.  It has its
  3853         -** own equivalent internal routines.  The atoi() and atof() names are
  3854         -** used in the table for brevity and because they are familiar to most
  3855         -** C programmers.
  3856         -**
  3857   4079   ** Note that when type conversions occur, pointers returned by prior
  3858   4080   ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
  3859   4081   ** sqlite3_column_text16() may be invalidated.
  3860   4082   ** Type conversions and pointer invalidations might occur
  3861   4083   ** in the following cases:
  3862   4084   **
  3863   4085   ** <ul>
................................................................................
  3874   4096   **
  3875   4097   ** ^Conversions between UTF-16be and UTF-16le are always done in place and do
  3876   4098   ** not invalidate a prior pointer, though of course the content of the buffer
  3877   4099   ** that the prior pointer references will have been modified.  Other kinds
  3878   4100   ** of conversion are done in place when it is possible, but sometimes they
  3879   4101   ** are not possible and in those cases prior pointers are invalidated.
  3880   4102   **
  3881         -** The safest and easiest to remember policy is to invoke these routines
         4103  +** The safest policy is to invoke these routines
  3882   4104   ** in one of the following ways:
  3883   4105   **
  3884   4106   ** <ul>
  3885   4107   **  <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>
  3886   4108   **  <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>
  3887   4109   **  <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>
  3888   4110   ** </ul>
................................................................................
  3894   4116   ** to sqlite3_column_text() or sqlite3_column_blob() with calls to
  3895   4117   ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()
  3896   4118   ** with calls to sqlite3_column_bytes().
  3897   4119   **
  3898   4120   ** ^The pointers returned are valid until a type conversion occurs as
  3899   4121   ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
  3900   4122   ** [sqlite3_finalize()] is called.  ^The memory space used to hold strings
  3901         -** and BLOBs is freed automatically.  Do <b>not</b> pass the pointers returned
         4123  +** and BLOBs is freed automatically.  Do <em>not</em> pass the pointers returned
  3902   4124   ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
  3903   4125   ** [sqlite3_free()].
  3904   4126   **
  3905   4127   ** ^(If a memory allocation error occurs during the evaluation of any
  3906   4128   ** of these routines, a default value is returned.  The default value
  3907   4129   ** is either the integer 0, the floating point number 0.0, or a NULL
  3908   4130   ** pointer.  Subsequent calls to [sqlite3_errcode()] will return
  3909   4131   ** [SQLITE_NOMEM].)^
  3910   4132   */
  3911         -SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
  3912         -SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
  3913         -SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
  3914         -SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
  3915         -SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
  3916         -SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
  3917         -SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
  3918         -SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
  3919         -SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
  3920         -SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
         4133  +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt*, int iCol);
         4134  +SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt*, int iCol);
         4135  +SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
         4136  +SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt*, int iCol);
         4137  +SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt*, int iCol);
         4138  +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt*, int iCol);
         4139  +SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt*, int iCol);
         4140  +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt*, int iCol);
         4141  +SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt*, int iCol);
         4142  +SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt*, int iCol);
  3921   4143   
  3922   4144   /*
  3923   4145   ** CAPI3REF: Destroy A Prepared Statement Object
         4146  +** DESTRUCTOR: sqlite3_stmt
  3924   4147   **
  3925   4148   ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
  3926   4149   ** ^If the most recent evaluation of the statement encountered no errors
  3927   4150   ** or if the statement is never been evaluated, then sqlite3_finalize() returns
  3928   4151   ** SQLITE_OK.  ^If the most recent evaluation of statement S failed, then
  3929   4152   ** sqlite3_finalize(S) returns the appropriate [error code] or
  3930   4153   ** [extended error code].
................................................................................
  3940   4163   **
  3941   4164   ** The application must finalize every [prepared statement] in order to avoid
  3942   4165   ** resource leaks.  It is a grievous error for the application to try to use
  3943   4166   ** a prepared statement after it has been finalized.  Any use of a prepared
  3944   4167   ** statement after it has been finalized can result in undefined and
  3945   4168   ** undesirable behavior such as segfaults and heap corruption.
  3946   4169   */
  3947         -SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
         4170  +SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt);
  3948   4171   
  3949   4172   /*
  3950   4173   ** CAPI3REF: Reset A Prepared Statement Object
         4174  +** METHOD: sqlite3_stmt
  3951   4175   **
  3952   4176   ** The sqlite3_reset() function is called to reset a [prepared statement]
  3953   4177   ** object back to its initial state, ready to be re-executed.
  3954   4178   ** ^Any SQL statement variables that had values bound to them using
  3955   4179   ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
  3956   4180   ** Use [sqlite3_clear_bindings()] to reset the bindings.
  3957   4181   **
................................................................................
  3966   4190   ** ^If the most recent call to [sqlite3_step(S)] for the
  3967   4191   ** [prepared statement] S indicated an error, then
  3968   4192   ** [sqlite3_reset(S)] returns an appropriate [error code].
  3969   4193   **
  3970   4194   ** ^The [sqlite3_reset(S)] interface does not change the values
  3971   4195   ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
  3972   4196   */
  3973         -SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
         4197  +SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt);
  3974   4198   
  3975   4199   /*
  3976   4200   ** CAPI3REF: Create Or Redefine SQL Functions
  3977   4201   ** KEYWORDS: {function creation routines}
  3978   4202   ** KEYWORDS: {application-defined SQL function}
  3979   4203   ** KEYWORDS: {application-defined SQL functions}
         4204  +** METHOD: sqlite3
  3980   4205   **
  3981   4206   ** ^These functions (collectively known as "function creation routines")
  3982   4207   ** are used to add SQL functions or aggregates or to redefine the behavior
  3983   4208   ** of existing SQL functions or aggregates.  The only differences between
  3984   4209   ** these routines are the text encoding expected for
  3985   4210   ** the second parameter (the name of the function being created)
  3986   4211   ** and the presence or absence of a destructor callback for
................................................................................
  4065   4290   ** ^Built-in functions may be overloaded by new application-defined functions.
  4066   4291   **
  4067   4292   ** ^An application-defined function is permitted to call other
  4068   4293   ** SQLite interfaces.  However, such calls must not
  4069   4294   ** close the database connection nor finalize or reset the prepared
  4070   4295   ** statement in which the function is running.
  4071   4296   */
  4072         -SQLITE_API int sqlite3_create_function(
         4297  +SQLITE_API int SQLITE_STDCALL sqlite3_create_function(
  4073   4298     sqlite3 *db,
  4074   4299     const char *zFunctionName,
  4075   4300     int nArg,
  4076   4301     int eTextRep,
  4077   4302     void *pApp,
  4078   4303     void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
  4079   4304     void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  4080   4305     void (*xFinal)(sqlite3_context*)
  4081   4306   );
  4082         -SQLITE_API int sqlite3_create_function16(
         4307  +SQLITE_API int SQLITE_STDCALL sqlite3_create_function16(
  4083   4308     sqlite3 *db,
  4084   4309     const void *zFunctionName,
  4085   4310     int nArg,
  4086   4311     int eTextRep,
  4087   4312     void *pApp,
  4088   4313     void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
  4089   4314     void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  4090   4315     void (*xFinal)(sqlite3_context*)
  4091   4316   );
  4092         -SQLITE_API int sqlite3_create_function_v2(
         4317  +SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2(
  4093   4318     sqlite3 *db,
  4094   4319     const char *zFunctionName,
  4095   4320     int nArg,
  4096   4321     int eTextRep,
  4097   4322     void *pApp,
  4098   4323     void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
  4099   4324     void (*xStep)(sqlite3_context*,int,sqlite3_value**),
................................................................................
  4103   4328   
  4104   4329   /*
  4105   4330   ** CAPI3REF: Text Encodings
  4106   4331   **
  4107   4332   ** These constant define integer codes that represent the various
  4108   4333   ** text encodings supported by SQLite.
  4109   4334   */
  4110         -#define SQLITE_UTF8           1
  4111         -#define SQLITE_UTF16LE        2
  4112         -#define SQLITE_UTF16BE        3
         4335  +#define SQLITE_UTF8           1    /* IMP: R-37514-35566 */
         4336  +#define SQLITE_UTF16LE        2    /* IMP: R-03371-37637 */
         4337  +#define SQLITE_UTF16BE        3    /* IMP: R-51971-34154 */
  4113   4338   #define SQLITE_UTF16          4    /* Use native byte order */
  4114   4339   #define SQLITE_ANY            5    /* Deprecated */
  4115   4340   #define SQLITE_UTF16_ALIGNED  8    /* sqlite3_create_collation only */
  4116   4341   
  4117   4342   /*
  4118   4343   ** CAPI3REF: Function Flags
  4119   4344   **
................................................................................
  4127   4352   /*
  4128   4353   ** CAPI3REF: Deprecated Functions
  4129   4354   ** DEPRECATED
  4130   4355   **
  4131   4356   ** These functions are [deprecated].  In order to maintain
  4132   4357   ** backwards compatibility with older code, these functions continue 
  4133   4358   ** to be supported.  However, new applications should avoid
  4134         -** the use of these functions.  To help encourage people to avoid
  4135         -** using these functions, we are not going to tell you what they do.
         4359  +** the use of these functions.  To encourage programmers to avoid
         4360  +** these functions, we will not explain what they do.
  4136   4361   */
  4137   4362   #ifndef SQLITE_OMIT_DEPRECATED
  4138         -SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
  4139         -SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
  4140         -SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
  4141         -SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
  4142         -SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
  4143         -SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
         4363  +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context*);
         4364  +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt*);
         4365  +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
         4366  +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_global_recover(void);
         4367  +SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_thread_cleanup(void);
         4368  +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
  4144   4369                         void*,sqlite3_int64);
  4145   4370   #endif
  4146   4371   
  4147   4372   /*
  4148         -** CAPI3REF: Obtaining SQL Function Parameter Values
         4373  +** CAPI3REF: Obtaining SQL Values
         4374  +** METHOD: sqlite3_value
  4149   4375   **
  4150   4376   ** The C-language implementation of SQL functions and aggregates uses
  4151   4377   ** this set of interface routines to access the parameter values on
  4152         -** the function or aggregate.
         4378  +** the function or aggregate.  
  4153   4379   **
  4154   4380   ** The xFunc (for scalar functions) or xStep (for aggregates) parameters
  4155   4381   ** to [sqlite3_create_function()] and [sqlite3_create_function16()]
  4156   4382   ** define callbacks that implement the SQL functions and aggregates.
  4157   4383   ** The 3rd parameter to these callbacks is an array of pointers to
  4158   4384   ** [protected sqlite3_value] objects.  There is one [sqlite3_value] object for
  4159   4385   ** each parameter to the SQL function.  These routines are used to
................................................................................
  4160   4386   ** extract values from the [sqlite3_value] objects.
  4161   4387   **
  4162   4388   ** These routines work only with [protected sqlite3_value] objects.
  4163   4389   ** Any attempt to use these routines on an [unprotected sqlite3_value]
  4164   4390   ** object results in undefined behavior.
  4165   4391   **
  4166   4392   ** ^These routines work just like the corresponding [column access functions]
  4167         -** except that  these routines take a single [protected sqlite3_value] object
         4393  +** except that these routines take a single [protected sqlite3_value] object
  4168   4394   ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
  4169   4395   **
  4170   4396   ** ^The sqlite3_value_text16() interface extracts a UTF-16 string
  4171   4397   ** in the native byte-order of the host machine.  ^The
  4172   4398   ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
  4173   4399   ** extract UTF-16 strings as big-endian and little-endian respectively.
  4174   4400   **
................................................................................
  4185   4411   ** [sqlite3_value_text16()] can be invalidated by a subsequent call to
  4186   4412   ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
  4187   4413   ** or [sqlite3_value_text16()].
  4188   4414   **
  4189   4415   ** These routines must be called from the same thread as
  4190   4416   ** the SQL function that supplied the [sqlite3_value*] parameters.
  4191   4417   */
  4192         -SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
  4193         -SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
  4194         -SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
  4195         -SQLITE_API double sqlite3_value_double(sqlite3_value*);
  4196         -SQLITE_API int sqlite3_value_int(sqlite3_value*);
  4197         -SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
  4198         -SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
  4199         -SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
  4200         -SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
  4201         -SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
  4202         -SQLITE_API int sqlite3_value_type(sqlite3_value*);
  4203         -SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
         4418  +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value*);
         4419  +SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value*);
         4420  +SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value*);
         4421  +SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value*);
         4422  +SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value*);
         4423  +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value*);
         4424  +SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value*);
         4425  +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value*);
         4426  +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value*);
         4427  +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value*);
         4428  +SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value*);
         4429  +SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value*);
         4430  +
         4431  +/*
         4432  +** CAPI3REF: Finding The Subtype Of SQL Values
         4433  +** METHOD: sqlite3_value
         4434  +**
         4435  +** The sqlite3_value_subtype(V) function returns the subtype for
         4436  +** an [application-defined SQL function] argument V.  The subtype
         4437  +** information can be used to pass a limited amount of context from
         4438  +** one SQL function to another.  Use the [sqlite3_result_subtype()]
         4439  +** routine to set the subtype for the return value of an SQL function.
         4440  +**
         4441  +** SQLite makes no use of subtype itself.  It merely passes the subtype
         4442  +** from the result of one [application-defined SQL function] into the
         4443  +** input of another.
         4444  +*/
         4445  +SQLITE_API unsigned int SQLITE_STDCALL sqlite3_value_subtype(sqlite3_value*);
         4446  +
         4447  +/*
         4448  +** CAPI3REF: Copy And Free SQL Values
         4449  +** METHOD: sqlite3_value
         4450  +**
         4451  +** ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value]
         4452  +** object D and returns a pointer to that copy.  ^The [sqlite3_value] returned
         4453  +** is a [protected sqlite3_value] object even if the input is not.
         4454  +** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a
         4455  +** memory allocation fails.
         4456  +**
         4457  +** ^The sqlite3_value_free(V) interface frees an [sqlite3_value] object
         4458  +** previously obtained from [sqlite3_value_dup()].  ^If V is a NULL pointer
         4459  +** then sqlite3_value_free(V) is a harmless no-op.
         4460  +*/
         4461  +SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_value_dup(const sqlite3_value*);
         4462  +SQLITE_API void SQLITE_STDCALL sqlite3_value_free(sqlite3_value*);
  4204   4463   
  4205   4464   /*
  4206   4465   ** CAPI3REF: Obtain Aggregate Function Context
         4466  +** METHOD: sqlite3_context
  4207   4467   **
  4208   4468   ** Implementations of aggregate SQL functions use this
  4209   4469   ** routine to allocate memory for storing their state.
  4210   4470   **
  4211   4471   ** ^The first time the sqlite3_aggregate_context(C,N) routine is called 
  4212   4472   ** for a particular aggregate function, SQLite
  4213   4473   ** allocates N of memory, zeroes out that memory, and returns a pointer
................................................................................
  4240   4500   ** [sqlite3_context | SQL function context] that is the first parameter
  4241   4501   ** to the xStep or xFinal callback routine that implements the aggregate
  4242   4502   ** function.
  4243   4503   **
  4244   4504   ** This routine must be called from the same thread in which
  4245   4505   ** the aggregate SQL function is running.
  4246   4506   */
  4247         -SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
         4507  +SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context*, int nBytes);
  4248   4508   
  4249   4509   /*
  4250   4510   ** CAPI3REF: User Data For Functions
         4511  +** METHOD: sqlite3_context
  4251   4512   **
  4252   4513   ** ^The sqlite3_user_data() interface returns a copy of
  4253   4514   ** the pointer that was the pUserData parameter (the 5th parameter)
  4254   4515   ** of the [sqlite3_create_function()]
  4255   4516   ** and [sqlite3_create_function16()] routines that originally
  4256   4517   ** registered the application defined function.
  4257   4518   **
  4258   4519   ** This routine must be called from the same thread in which
  4259   4520   ** the application-defined function is running.
  4260   4521   */
  4261         -SQLITE_API void *sqlite3_user_data(sqlite3_context*);
         4522  +SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context*);
  4262   4523   
  4263   4524   /*
  4264   4525   ** CAPI3REF: Database Connection For Functions
         4526  +** METHOD: sqlite3_context
  4265   4527   **
  4266   4528   ** ^The sqlite3_context_db_handle() interface returns a copy of
  4267   4529   ** the pointer to the [database connection] (the 1st parameter)
  4268   4530   ** of the [sqlite3_create_function()]
  4269   4531   ** and [sqlite3_create_function16()] routines that originally
  4270   4532   ** registered the application defined function.
  4271   4533   */
  4272         -SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
         4534  +SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context*);
  4273   4535   
  4274   4536   /*
  4275   4537   ** CAPI3REF: Function Auxiliary Data
         4538  +** METHOD: sqlite3_context
  4276   4539   **
  4277   4540   ** These functions may be used by (non-aggregate) SQL functions to
  4278   4541   ** associate metadata with argument values. If the same value is passed to
  4279   4542   ** multiple invocations of the same SQL function during query execution, under
  4280   4543   ** some circumstances the associated metadata may be preserved.  An example
  4281   4544   ** of where this might be useful is in a regular-expression matching
  4282   4545   ** function. The compiled version of the regular expression can be stored as
................................................................................
  4317   4580   ** ^(In practice, metadata is preserved between function calls for
  4318   4581   ** function parameters that are compile-time constants, including literal
  4319   4582   ** values and [parameters] and expressions composed from the same.)^
  4320   4583   **
  4321   4584   ** These routines must be called from the same thread in which
  4322   4585   ** the SQL function is running.
  4323   4586   */
  4324         -SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
  4325         -SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
         4587  +SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context*, int N);
         4588  +SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
  4326   4589   
  4327   4590   
  4328   4591   /*
  4329   4592   ** CAPI3REF: Constants Defining Special Destructor Behavior
  4330   4593   **
  4331   4594   ** These are special values for the destructor that is passed in as the
  4332   4595   ** final argument to routines like [sqlite3_result_blob()].  ^If the destructor
................................................................................
  4341   4604   */
  4342   4605   typedef void (*sqlite3_destructor_type)(void*);
  4343   4606   #define SQLITE_STATIC      ((sqlite3_destructor_type)0)
  4344   4607   #define SQLITE_TRANSIENT   ((sqlite3_destructor_type)-1)
  4345   4608   
  4346   4609   /*
  4347   4610   ** CAPI3REF: Setting The Result Of An SQL Function
         4611  +** METHOD: sqlite3_context
  4348   4612   **
  4349   4613   ** These routines are used by the xFunc or xFinal callbacks that
  4350   4614   ** implement SQL functions and aggregates.  See
  4351   4615   ** [sqlite3_create_function()] and [sqlite3_create_function16()]
  4352   4616   ** for additional information.
  4353   4617   **
  4354   4618   ** These functions work very much like the [parameter binding] family of
................................................................................
  4356   4620   ** Refer to the [SQL parameter] documentation for additional information.
  4357   4621   **
  4358   4622   ** ^The sqlite3_result_blob() interface sets the result from
  4359   4623   ** an application-defined function to be the BLOB whose content is pointed
  4360   4624   ** to by the second parameter and which is N bytes long where N is the
  4361   4625   ** third parameter.
  4362   4626   **
  4363         -** ^The sqlite3_result_zeroblob() interfaces set the result of
  4364         -** the application-defined function to be a BLOB containing all zero
  4365         -** bytes and N bytes in size, where N is the value of the 2nd parameter.
         4627  +** ^The sqlite3_result_zeroblob(C,N) and sqlite3_result_zeroblob64(C,N)
         4628  +** interfaces set the result of the application-defined function to be
         4629  +** a BLOB containing all zero bytes and N bytes in size.
  4366   4630   **
  4367   4631   ** ^The sqlite3_result_double() interface sets the result from
  4368   4632   ** an application-defined function to be a floating point value specified
  4369   4633   ** by its 2nd argument.
  4370   4634   **
  4371   4635   ** ^The sqlite3_result_error() and sqlite3_result_error16() functions
  4372   4636   ** cause the implemented SQL function to throw an exception.
................................................................................
  4407   4671   ** of the application-defined function to be NULL.
  4408   4672   **
  4409   4673   ** ^The sqlite3_result_text(), sqlite3_result_text16(),
  4410   4674   ** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces
  4411   4675   ** set the return value of the application-defined function to be
  4412   4676   ** a text string which is represented as UTF-8, UTF-16 native byte order,
  4413   4677   ** UTF-16 little endian, or UTF-16 big endian, respectively.
         4678  +** ^The sqlite3_result_text64() interface sets the return value of an
         4679  +** application-defined function to be a text string in an encoding
         4680  +** specified by the fifth (and last) parameter, which must be one
         4681  +** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].
  4414   4682   ** ^SQLite takes the text result from the application from
  4415   4683   ** the 2nd parameter of the sqlite3_result_text* interfaces.
  4416   4684   ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
  4417   4685   ** is negative, then SQLite takes result text from the 2nd parameter
  4418   4686   ** through the first zero character.
  4419   4687   ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
  4420   4688   ** is non-negative, then as many bytes (not characters) of the text
................................................................................
  4436   4704   ** when it has finished using that result.
  4437   4705   ** ^If the 4th parameter to the sqlite3_result_text* interfaces
  4438   4706   ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
  4439   4707   ** then SQLite makes a copy of the result into space obtained from
  4440   4708   ** from [sqlite3_malloc()] before it returns.
  4441   4709   **
  4442   4710   ** ^The sqlite3_result_value() interface sets the result of
  4443         -** the application-defined function to be a copy the
         4711  +** the application-defined function to be a copy of the
  4444   4712   ** [unprotected sqlite3_value] object specified by the 2nd parameter.  ^The
  4445   4713   ** sqlite3_result_value() interface makes a copy of the [sqlite3_value]
  4446   4714   ** so that the [sqlite3_value] specified in the parameter may change or
  4447   4715   ** be deallocated after sqlite3_result_value() returns without harm.
  4448   4716   ** ^A [protected sqlite3_value] object may always be used where an
  4449   4717   ** [unprotected sqlite3_value] object is required, so either
  4450   4718   ** kind of [sqlite3_value] object can be used with this interface.
  4451   4719   **
  4452   4720   ** If these routines are called from within the different thread
  4453   4721   ** than the one containing the application-defined function that received
  4454   4722   ** the [sqlite3_context] pointer, the results are undefined.
  4455   4723   */
  4456         -SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
  4457         -SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
  4458         -SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
  4459         -SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
  4460         -SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);
  4461         -SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);
  4462         -SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);
  4463         -SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
  4464         -SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
  4465         -SQLITE_API void sqlite3_result_null(sqlite3_context*);
  4466         -SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
  4467         -SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
  4468         -SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
  4469         -SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
  4470         -SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
  4471         -SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
         4724  +SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
         4725  +SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(sqlite3_context*,const void*,
         4726  +                           sqlite3_uint64,void(*)(void*));
         4727  +SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context*, double);
         4728  +SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context*, const char*, int);
         4729  +SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context*, const void*, int);
         4730  +SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context*);
         4731  +SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context*);
         4732  +SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context*, int);
         4733  +SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context*, int);
         4734  +SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
         4735  +SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context*);
         4736  +SQLITE_API void SQLITE_STDCALL sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
         4737  +SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
         4738  +                           void(*)(void*), unsigned char encoding);
         4739  +SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
         4740  +SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
         4741  +SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
         4742  +SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context*, sqlite3_value*);
         4743  +SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context*, int n);
         4744  +SQLITE_API int SQLITE_STDCALL sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
         4745  +
         4746  +
         4747  +/*
         4748  +** CAPI3REF: Setting The Subtype Of An SQL Function
         4749  +** METHOD: sqlite3_context
         4750  +**
         4751  +** The sqlite3_result_subtype(C,T) function causes the subtype of
         4752  +** the result from the [application-defined SQL function] with 
         4753  +** [sqlite3_context] C to be the value T.  Only the lower 8 bits 
         4754  +** of the subtype T are preserved in current versions of SQLite;
         4755  +** higher order bits are discarded.
         4756  +** The number of subtype bytes preserved by SQLite might increase
         4757  +** in future releases of SQLite.
         4758  +*/
         4759  +SQLITE_API void SQLITE_STDCALL sqlite3_result_subtype(sqlite3_context*,unsigned int);
  4472   4760   
  4473   4761   /*
  4474   4762   ** CAPI3REF: Define New Collating Sequences
         4763  +** METHOD: sqlite3
  4475   4764   **
  4476   4765   ** ^These functions add, remove, or modify a [collation] associated
  4477   4766   ** with the [database connection] specified as the first argument.
  4478   4767   **
  4479   4768   ** ^The name of the collation is a UTF-8 string
  4480   4769   ** for sqlite3_create_collation() and sqlite3_create_collation_v2()
  4481   4770   ** and a UTF-16 string in native byte order for sqlite3_create_collation16().
................................................................................
  4545   4834   ** themselves rather than expecting SQLite to deal with it for them.
  4546   4835   ** This is different from every other SQLite interface.  The inconsistency 
  4547   4836   ** is unfortunate but cannot be changed without breaking backwards 
  4548   4837   ** compatibility.
  4549   4838   **
  4550   4839   ** See also:  [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
  4551   4840   */
  4552         -SQLITE_API int sqlite3_create_collation(
         4841  +SQLITE_API int SQLITE_STDCALL sqlite3_create_collation(
  4553   4842     sqlite3*, 
  4554   4843     const char *zName, 
  4555   4844     int eTextRep, 
  4556   4845     void *pArg,
  4557   4846     int(*xCompare)(void*,int,const void*,int,const void*)
  4558   4847   );
  4559         -SQLITE_API int sqlite3_create_collation_v2(
         4848  +SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2(
  4560   4849     sqlite3*, 
  4561   4850     const char *zName, 
  4562   4851     int eTextRep, 
  4563   4852     void *pArg,
  4564   4853     int(*xCompare)(void*,int,const void*,int,const void*),
  4565   4854     void(*xDestroy)(void*)
  4566   4855   );
  4567         -SQLITE_API int sqlite3_create_collation16(
         4856  +SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16(
  4568   4857     sqlite3*, 
  4569   4858     const void *zName,
  4570   4859     int eTextRep, 
  4571   4860     void *pArg,
  4572   4861     int(*xCompare)(void*,int,const void*,int,const void*)
  4573   4862   );
  4574   4863   
  4575   4864   /*
  4576   4865   ** CAPI3REF: Collation Needed Callbacks
         4866  +** METHOD: sqlite3
  4577   4867   **
  4578   4868   ** ^To avoid having to register all collation sequences before a database
  4579   4869   ** can be used, a single callback function may be registered with the
  4580   4870   ** [database connection] to be invoked whenever an undefined collation
  4581   4871   ** sequence is required.
  4582   4872   **
  4583   4873   ** ^If the function is registered using the sqlite3_collation_needed() API,
................................................................................
  4594   4884   ** sequence function required.  The fourth parameter is the name of the
  4595   4885   ** required collation sequence.)^
  4596   4886   **
  4597   4887   ** The callback function should register the desired collation using
  4598   4888   ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
  4599   4889   ** [sqlite3_create_collation_v2()].
  4600   4890   */
  4601         -SQLITE_API int sqlite3_collation_needed(
         4891  +SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed(
  4602   4892     sqlite3*, 
  4603   4893     void*, 
  4604   4894     void(*)(void*,sqlite3*,int eTextRep,const char*)
  4605   4895   );
  4606         -SQLITE_API int sqlite3_collation_needed16(
         4896  +SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16(
  4607   4897     sqlite3*, 
  4608   4898     void*,
  4609   4899     void(*)(void*,sqlite3*,int eTextRep,const void*)
  4610   4900   );
  4611   4901   
  4612   4902   #ifdef SQLITE_HAS_CODEC
  4613   4903   /*
  4614   4904   ** Specify the key for an encrypted database.  This routine should be
  4615   4905   ** called right after sqlite3_open().
  4616   4906   **
  4617   4907   ** The code to implement this API is not available in the public release
  4618   4908   ** of SQLite.
  4619   4909   */
  4620         -SQLITE_API int sqlite3_key(
         4910  +SQLITE_API int SQLITE_STDCALL sqlite3_key(
  4621   4911     sqlite3 *db,                   /* Database to be rekeyed */
  4622   4912     const void *pKey, int nKey     /* The key */
  4623   4913   );
  4624         -SQLITE_API int sqlite3_key_v2(
         4914  +SQLITE_API int SQLITE_STDCALL sqlite3_key_v2(
  4625   4915     sqlite3 *db,                   /* Database to be rekeyed */
  4626   4916     const char *zDbName,           /* Name of the database */
  4627   4917     const void *pKey, int nKey     /* The key */
  4628   4918   );
  4629   4919   
  4630   4920   /*
  4631   4921   ** Change the key on an open database.  If the current database is not
  4632   4922   ** encrypted, this routine will encrypt it.  If pNew==0 or nNew==0, the
  4633   4923   ** database is decrypted.
  4634   4924   **
  4635   4925   ** The code to implement this API is not available in the public release
  4636   4926   ** of SQLite.
  4637   4927   */
  4638         -SQLITE_API int sqlite3_rekey(
         4928  +SQLITE_API int SQLITE_STDCALL sqlite3_rekey(
  4639   4929     sqlite3 *db,                   /* Database to be rekeyed */
  4640   4930     const void *pKey, int nKey     /* The new key */
  4641   4931   );
  4642         -SQLITE_API int sqlite3_rekey_v2(
         4932  +SQLITE_API int SQLITE_STDCALL sqlite3_rekey_v2(
  4643   4933     sqlite3 *db,                   /* Database to be rekeyed */
  4644   4934     const char *zDbName,           /* Name of the database */
  4645   4935     const void *pKey, int nKey     /* The new key */
  4646   4936   );
  4647   4937   
  4648   4938   /*
  4649   4939   ** Specify the activation key for a SEE database.  Unless 
  4650   4940   ** activated, none of the SEE routines will work.
  4651   4941   */
  4652         -SQLITE_API void sqlite3_activate_see(
         4942  +SQLITE_API void SQLITE_STDCALL sqlite3_activate_see(
  4653   4943     const char *zPassPhrase        /* Activation phrase */
  4654   4944   );
  4655   4945   #endif
  4656   4946   
  4657   4947   #ifdef SQLITE_ENABLE_CEROD
  4658   4948   /*
  4659   4949   ** Specify the activation key for a CEROD database.  Unless 
  4660   4950   ** activated, none of the CEROD routines will work.
  4661   4951   */
  4662         -SQLITE_API void sqlite3_activate_cerod(
         4952  +SQLITE_API void SQLITE_STDCALL sqlite3_activate_cerod(
  4663   4953     const char *zPassPhrase        /* Activation phrase */
  4664   4954   );
  4665   4955   #endif
  4666   4956   
  4667   4957   /*
  4668   4958   ** CAPI3REF: Suspend Execution For A Short Time
  4669   4959   **
................................................................................
  4677   4967   **
  4678   4968   ** ^SQLite implements this interface by calling the xSleep()
  4679   4969   ** method of the default [sqlite3_vfs] object.  If the xSleep() method
  4680   4970   ** of the default VFS is not implemented correctly, or not implemented at
  4681   4971   ** all, then the behavior of sqlite3_sleep() may deviate from the description
  4682   4972   ** in the previous paragraphs.
  4683   4973   */
  4684         -SQLITE_API int sqlite3_sleep(int);
         4974  +SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int);
  4685   4975   
  4686   4976   /*
  4687   4977   ** CAPI3REF: Name Of The Folder Holding Temporary Files
  4688   4978   **
  4689   4979   ** ^(If this global variable is made to point to a string which is
  4690   4980   ** the name of a folder (a.k.a. directory), then all temporary files
  4691   4981   ** created by SQLite when using a built-in [sqlite3_vfs | VFS]
................................................................................
  4777   5067   ** or else the use of the [data_store_directory pragma] should be avoided.
  4778   5068   */
  4779   5069   SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory;
  4780   5070   
  4781   5071   /*
  4782   5072   ** CAPI3REF: Test For Auto-Commit Mode
  4783   5073   ** KEYWORDS: {autocommit mode}
         5074  +** METHOD: sqlite3
  4784   5075   **
  4785   5076   ** ^The sqlite3_get_autocommit() interface returns non-zero or
  4786   5077   ** zero if the given database connection is or is not in autocommit mode,
  4787   5078   ** respectively.  ^Autocommit mode is on by default.
  4788   5079   ** ^Autocommit mode is disabled by a [BEGIN] statement.
  4789   5080   ** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].
  4790   5081   **
................................................................................
  4795   5086   ** find out whether SQLite automatically rolled back the transaction after
  4796   5087   ** an error is to use this function.
  4797   5088   **
  4798   5089   ** If another thread changes the autocommit status of the database
  4799   5090   ** connection while this routine is running, then the return value
  4800   5091   ** is undefined.
  4801   5092   */
  4802         -SQLITE_API int sqlite3_get_autocommit(sqlite3*);
         5093  +SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3*);
  4803   5094   
  4804   5095   /*
  4805   5096   ** CAPI3REF: Find The Database Handle Of A Prepared Statement
         5097  +** METHOD: sqlite3_stmt
  4806   5098   **
  4807   5099   ** ^The sqlite3_db_handle interface returns the [database connection] handle
  4808   5100   ** to which a [prepared statement] belongs.  ^The [database connection]
  4809   5101   ** returned by sqlite3_db_handle is the same [database connection]
  4810   5102   ** that was the first argument
  4811   5103   ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
  4812   5104   ** create the statement in the first place.
  4813   5105   */
  4814         -SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
         5106  +SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt*);
  4815   5107   
  4816   5108   /*
  4817   5109   ** CAPI3REF: Return The Filename For A Database Connection
         5110  +** METHOD: sqlite3
  4818   5111   **
  4819   5112   ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
  4820   5113   ** associated with database N of connection D.  ^The main database file
  4821   5114   ** has the name "main".  If there is no attached database N on the database
  4822   5115   ** connection D, or if database N is a temporary or in-memory database, then
  4823   5116   ** a NULL pointer is returned.
  4824   5117   **
  4825   5118   ** ^The filename returned by this function is the output of the
  4826   5119   ** xFullPathname method of the [VFS].  ^In other words, the filename
  4827   5120   ** will be an absolute pathname, even if the filename used
  4828   5121   ** to open the database originally was a URI or relative pathname.
  4829   5122   */
  4830         -SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
         5123  +SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName);
  4831   5124   
  4832   5125   /*
  4833   5126   ** CAPI3REF: Determine if a database is read-only
         5127  +** METHOD: sqlite3
  4834   5128   **
  4835   5129   ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
  4836   5130   ** of connection D is read-only, 0 if it is read/write, or -1 if N is not
  4837   5131   ** the name of a database on connection D.
  4838   5132   */
  4839         -SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
         5133  +SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
  4840   5134   
  4841   5135   /*
  4842   5136   ** CAPI3REF: Find the next prepared statement
         5137  +** METHOD: sqlite3
  4843   5138   **
  4844   5139   ** ^This interface returns a pointer to the next [prepared statement] after
  4845   5140   ** pStmt associated with the [database connection] pDb.  ^If pStmt is NULL
  4846   5141   ** then this interface returns a pointer to the first prepared statement
  4847   5142   ** associated with the database connection pDb.  ^If no prepared statement
  4848   5143   ** satisfies the conditions of this routine, it returns NULL.
  4849   5144   **
  4850   5145   ** The [database connection] pointer D in a call to
  4851   5146   ** [sqlite3_next_stmt(D,S)] must refer to an open database
  4852   5147   ** connection and in particular must not be a NULL pointer.
  4853   5148   */
  4854         -SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
         5149  +SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
  4855   5150   
  4856   5151   /*
  4857   5152   ** CAPI3REF: Commit And Rollback Notification Callbacks
         5153  +** METHOD: sqlite3
  4858   5154   **
  4859   5155   ** ^The sqlite3_commit_hook() interface registers a callback
  4860   5156   ** function to be invoked whenever a transaction is [COMMIT | committed].
  4861   5157   ** ^Any callback set by a previous call to sqlite3_commit_hook()
  4862   5158   ** for the same database connection is overridden.
  4863   5159   ** ^The sqlite3_rollback_hook() interface registers a callback
  4864   5160   ** function to be invoked whenever a transaction is [ROLLBACK | rolled back].
................................................................................
  4895   5191   ** rolled back if an explicit "ROLLBACK" statement is executed, or
  4896   5192   ** an error or constraint causes an implicit rollback to occur.
  4897   5193   ** ^The rollback callback is not invoked if a transaction is
  4898   5194   ** automatically rolled back because the database connection is closed.
  4899   5195   **
  4900   5196   ** See also the [sqlite3_update_hook()] interface.
  4901   5197   */
  4902         -SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
  4903         -SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
         5198  +SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
         5199  +SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
  4904   5200   
  4905   5201   /*
  4906   5202   ** CAPI3REF: Data Change Notification Callbacks
         5203  +** METHOD: sqlite3
  4907   5204   **
  4908   5205   ** ^The sqlite3_update_hook() interface registers a callback function
  4909   5206   ** with the [database connection] identified by the first argument
  4910   5207   ** to be invoked whenever a row is updated, inserted or deleted in
  4911         -** a rowid table.
         5208  +** a [rowid table].
  4912   5209   ** ^Any callback set by a previous call to this function
  4913   5210   ** for the same database connection is overridden.
  4914   5211   **
  4915   5212   ** ^The second argument is a pointer to the function to invoke when a
  4916   5213   ** row is updated, inserted or deleted in a rowid table.
  4917   5214   ** ^The first argument to the callback is a copy of the third argument
  4918   5215   ** to sqlite3_update_hook().
................................................................................
  4943   5240   ** database connections for the meaning of "modify" in this paragraph.
  4944   5241   **
  4945   5242   ** ^The sqlite3_update_hook(D,C,P) function
  4946   5243   ** returns the P argument from the previous call
  4947   5244   ** on the same [database connection] D, or NULL for
  4948   5245   ** the first call on D.
  4949   5246   **
  4950         -** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
  4951         -** interfaces.
         5247  +** See also the [sqlite3_commit_hook()], [sqlite3_rollback_hook()],
         5248  +** and [sqlite3_preupdate_hook()] interfaces.
  4952   5249   */
  4953         -SQLITE_API void *sqlite3_update_hook(
         5250  +SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
  4954   5251     sqlite3*, 
  4955   5252     void(*)(void *,int ,char const *,char const *,sqlite3_int64),
  4956   5253     void*
  4957   5254   );
  4958   5255   
  4959   5256   /*
  4960   5257   ** CAPI3REF: Enable Or Disable Shared Pager Cache
................................................................................
  4975   5272   **
  4976   5273   ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled
  4977   5274   ** successfully.  An [error code] is returned otherwise.)^
  4978   5275   **
  4979   5276   ** ^Shared cache is disabled by default. But this might change in
  4980   5277   ** future releases of SQLite.  Applications that care about shared
  4981   5278   ** cache setting should set it explicitly.
         5279  +**
         5280  +** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0
         5281  +** and will always return SQLITE_MISUSE. On those systems, 
         5282  +** shared cache mode should be enabled per-database connection via 
         5283  +** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE].
  4982   5284   **
  4983   5285   ** This interface is threadsafe on processors where writing a
  4984   5286   ** 32-bit integer is atomic.
  4985   5287   **
  4986   5288   ** See Also:  [SQLite Shared-Cache Mode]
  4987   5289   */
  4988         -SQLITE_API int sqlite3_enable_shared_cache(int);
         5290  +SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int);
  4989   5291   
  4990   5292   /*
  4991   5293   ** CAPI3REF: Attempt To Free Heap Memory
  4992   5294   **
  4993   5295   ** ^The sqlite3_release_memory() interface attempts to free N bytes
  4994   5296   ** of heap memory by deallocating non-essential memory allocations
  4995   5297   ** held by the database library.   Memory used to cache database
................................................................................
  4997   5299   ** ^sqlite3_release_memory() returns the number of bytes actually freed,
  4998   5300   ** which might be more or less than the amount requested.
  4999   5301   ** ^The sqlite3_release_memory() routine is a no-op returning zero
  5000   5302   ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
  5001   5303   **
  5002   5304   ** See also: [sqlite3_db_release_memory()]
  5003   5305   */
  5004         -SQLITE_API int sqlite3_release_memory(int);
         5306  +SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int);
  5005   5307   
  5006   5308   /*
  5007   5309   ** CAPI3REF: Free Memory Used By A Database Connection
         5310  +** METHOD: sqlite3
  5008   5311   **
  5009   5312   ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
  5010   5313   ** memory as possible from database connection D. Unlike the
  5011   5314   ** [sqlite3_release_memory()] interface, this interface is in effect even
  5012   5315   ** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
  5013   5316   ** omitted.
  5014   5317   **
  5015   5318   ** See also: [sqlite3_release_memory()]
  5016   5319   */
  5017         -SQLITE_API int sqlite3_db_release_memory(sqlite3*);
         5320  +SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3*);
  5018   5321   
  5019   5322   /*
  5020   5323   ** CAPI3REF: Impose A Limit On Heap Size
  5021   5324   **
  5022   5325   ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
  5023   5326   ** soft limit on the amount of heap memory that may be allocated by SQLite.
  5024   5327   ** ^SQLite strives to keep heap memory utilization below the soft heap
................................................................................
  5062   5365   ** the page cache is the predominate memory user in SQLite, most
  5063   5366   ** applications will achieve adequate soft heap limit enforcement without
  5064   5367   ** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
  5065   5368   **
  5066   5369   ** The circumstances under which SQLite will enforce the soft heap limit may
  5067   5370   ** changes in future releases of SQLite.
  5068   5371   */
  5069         -SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
         5372  +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 N);
  5070   5373   
  5071   5374   /*
  5072   5375   ** CAPI3REF: Deprecated Soft Heap Limit Interface
  5073   5376   ** DEPRECATED
  5074   5377   **
  5075   5378   ** This is a deprecated version of the [sqlite3_soft_heap_limit64()]
  5076   5379   ** interface.  This routine is provided for historical compatibility
  5077   5380   ** only.  All new applications should use the
  5078   5381   ** [sqlite3_soft_heap_limit64()] interface rather than this one.
  5079   5382   */
  5080         -SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
         5383  +SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_soft_heap_limit(int N);
  5081   5384   
  5082   5385   
  5083   5386   /*
  5084   5387   ** CAPI3REF: Extract Metadata About A Column Of A Table
         5388  +** METHOD: sqlite3
  5085   5389   **
  5086         -** ^This routine returns metadata about a specific column of a specific
  5087         -** database table accessible using the [database connection] handle
  5088         -** passed as the first function argument.
         5390  +** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
         5391  +** information about column C of table T in database D
         5392  +** on [database connection] X.)^  ^The sqlite3_table_column_metadata()
         5393  +** interface returns SQLITE_OK and fills in the non-NULL pointers in
         5394  +** the final five arguments with appropriate values if the specified
         5395  +** column exists.  ^The sqlite3_table_column_metadata() interface returns
         5396  +** SQLITE_ERROR and if the specified column does not exist.
         5397  +** ^If the column-name parameter to sqlite3_table_column_metadata() is a
         5398  +** NULL pointer, then this routine simply checks for the existance of the
         5399  +** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
         5400  +** does not.
  5089   5401   **
  5090   5402   ** ^The column is identified by the second, third and fourth parameters to
  5091         -** this function. ^The second parameter is either the name of the database
         5403  +** this function. ^(The second parameter is either the name of the database
  5092   5404   ** (i.e. "main", "temp", or an attached database) containing the specified
  5093         -** table or NULL. ^If it is NULL, then all attached databases are searched
         5405  +** table or NULL.)^ ^If it is NULL, then all attached databases are searched
  5094   5406   ** for the table using the same algorithm used by the database engine to
  5095   5407   ** resolve unqualified table references.
  5096   5408   **
  5097   5409   ** ^The third and fourth parameters to this function are the table and column
  5098         -** name of the desired column, respectively. Neither of these parameters
  5099         -** may be NULL.
         5410  +** name of the desired column, respectively.
  5100   5411   **
  5101   5412   ** ^Metadata is returned by writing to the memory locations passed as the 5th
  5102   5413   ** and subsequent parameters to this function. ^Any of these arguments may be
  5103   5414   ** NULL, in which case the corresponding element of metadata is omitted.
  5104   5415   **
  5105   5416   ** ^(<blockquote>
  5106   5417   ** <table border="1">
................................................................................
  5111   5422   ** <tr><td> 7th <td> int         <td> True if column has a NOT NULL constraint
  5112   5423   ** <tr><td> 8th <td> int         <td> True if column is part of the PRIMARY KEY
  5113   5424   ** <tr><td> 9th <td> int         <td> True if column is [AUTOINCREMENT]
  5114   5425   ** </table>
  5115   5426   ** </blockquote>)^
  5116   5427   **
  5117   5428   ** ^The memory pointed to by the character pointers returned for the
  5118         -** declaration type and collation sequence is valid only until the next
         5429  +** declaration type and collation sequence is valid until the next
  5119   5430   ** call to any SQLite API function.
  5120   5431   **
  5121   5432   ** ^If the specified table is actually a view, an [error code] is returned.
  5122   5433   **
  5123         -** ^If the specified column is "rowid", "oid" or "_rowid_" and an
         5434  +** ^If the specified column is "rowid", "oid" or "_rowid_" and the table 
         5435  +** is not a [WITHOUT ROWID] table and an
  5124   5436   ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
  5125   5437   ** parameters are set for the explicitly declared column. ^(If there is no
  5126         -** explicitly declared [INTEGER PRIMARY KEY] column, then the output
  5127         -** parameters are set as follows:
         5438  +** [INTEGER PRIMARY KEY] column, then the outputs
         5439  +** for the [rowid] are set as follows:
  5128   5440   **
  5129   5441   ** <pre>
  5130   5442   **     data type: "INTEGER"
  5131   5443   **     collation sequence: "BINARY"
  5132   5444   **     not null: 0
  5133   5445   **     primary key: 1
  5134   5446   **     auto increment: 0
  5135   5447   ** </pre>)^
  5136   5448   **
  5137         -** ^(This function may load one or more schemas from database files. If an
  5138         -** error occurs during this process, or if the requested table or column
  5139         -** cannot be found, an [error code] is returned and an error message left
  5140         -** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
  5141         -**
  5142         -** ^This API is only available if the library was compiled with the
  5143         -** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
         5449  +** ^This function causes all database schemas to be read from disk and
         5450  +** parsed, if that has not already been done, and returns an error if
         5451  +** any errors are encountered while loading the schema.
  5144   5452   */
  5145         -SQLITE_API int sqlite3_table_column_metadata(
         5453  +SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
  5146   5454     sqlite3 *db,                /* Connection handle */
  5147   5455     const char *zDbName,        /* Database name or NULL */
  5148   5456     const char *zTableName,     /* Table name */
  5149   5457     const char *zColumnName,    /* Column name */
  5150   5458     char const **pzDataType,    /* OUTPUT: Declared data type */
  5151   5459     char const **pzCollSeq,     /* OUTPUT: Collation sequence name */
  5152   5460     int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */
  5153   5461     int *pPrimaryKey,           /* OUTPUT: True if column part of PK */
  5154   5462     int *pAutoinc               /* OUTPUT: True if column is auto-increment */
  5155   5463   );
  5156   5464   
  5157   5465   /*
  5158   5466   ** CAPI3REF: Load An Extension
         5467  +** METHOD: sqlite3
  5159   5468   **
  5160   5469   ** ^This interface loads an SQLite extension library from the named file.
  5161   5470   **
  5162   5471   ** ^The sqlite3_load_extension() interface attempts to load an
  5163   5472   ** [SQLite extension] library contained in the file zFile.  If
  5164   5473   ** the file cannot be loaded directly, attempts are made to load
  5165   5474   ** with various operating-system specific extensions added.
................................................................................
  5179   5488   ** ^If an error occurs and pzErrMsg is not 0, then the
  5180   5489   ** [sqlite3_load_extension()] interface shall attempt to
  5181   5490   ** fill *pzErrMsg with error message text stored in memory
  5182   5491   ** obtained from [sqlite3_malloc()]. The calling function
  5183   5492   ** should free this memory by calling [sqlite3_free()].
  5184   5493   **
  5185   5494   ** ^Extension loading must be enabled using
  5186         -** [sqlite3_enable_load_extension()] prior to calling this API,
         5495  +** [sqlite3_enable_load_extension()] or
         5496  +** [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],1,NULL)
         5497  +** prior to calling this API,
  5187   5498   ** otherwise an error will be returned.
         5499  +**
         5500  +** <b>Security warning:</b> It is recommended that the 
         5501  +** [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method be used to enable only this
         5502  +** interface.  The use of the [sqlite3_enable_load_extension()] interface
         5503  +** should be avoided.  This will keep the SQL function [load_extension()]
         5504  +** disabled and prevent SQL injections from giving attackers
         5505  +** access to extension loading capabilities.
  5188   5506   **
  5189   5507   ** See also the [load_extension() SQL function].
  5190   5508   */
  5191         -SQLITE_API int sqlite3_load_extension(
         5509  +SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
  5192   5510     sqlite3 *db,          /* Load the extension into this database connection */
  5193   5511     const char *zFile,    /* Name of the shared library containing extension */
  5194   5512     const char *zProc,    /* Entry point.  Derived from zFile if 0 */
  5195   5513     char **pzErrMsg       /* Put error message here if not 0 */
  5196   5514   );
  5197   5515   
  5198   5516   /*
  5199   5517   ** CAPI3REF: Enable Or Disable Extension Loading
         5518  +** METHOD: sqlite3
  5200   5519   **
  5201   5520   ** ^So as not to open security holes in older applications that are
  5202   5521   ** unprepared to deal with [extension loading], and as a means of disabling
  5203   5522   ** [extension loading] while evaluating user-entered SQL, the following API
  5204   5523   ** is provided to turn the [sqlite3_load_extension()] mechanism on and off.
  5205   5524   **
  5206   5525   ** ^Extension loading is off by default.
  5207   5526   ** ^Call the sqlite3_enable_load_extension() routine with onoff==1
  5208   5527   ** to turn extension loading on and call it with onoff==0 to turn
  5209   5528   ** it back off again.
         5529  +**
         5530  +** ^This interface enables or disables both the C-API
         5531  +** [sqlite3_load_extension()] and the SQL function [load_extension()].
         5532  +** Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)
         5533  +** to enable or disable only the C-API.
         5534  +**
         5535  +** <b>Security warning:</b> It is recommended that extension loading
         5536  +** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method
         5537  +** rather than this interface, so the [load_extension()] SQL function
         5538  +** remains disabled. This will prevent SQL injections from giving attackers
         5539  +** access to extension loading capabilities.
  5210   5540   */
  5211         -SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
         5541  +SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff);
  5212   5542   
  5213   5543   /*
  5214   5544   ** CAPI3REF: Automatically Load Statically Linked Extensions
  5215   5545   **
  5216   5546   ** ^This interface causes the xEntryPoint() function to be invoked for
  5217   5547   ** each new [database connection] that is created.  The idea here is that
  5218   5548   ** xEntryPoint() is the entry point for a statically linked [SQLite extension]
................................................................................
  5242   5572   ** ^Calling sqlite3_auto_extension(X) with an entry point X that is already
  5243   5573   ** on the list of automatic extensions is a harmless no-op. ^No entry point
  5244   5574   ** will be called more than once for each database connection that is opened.
  5245   5575   **
  5246   5576   ** See also: [sqlite3_reset_auto_extension()]
  5247   5577   ** and [sqlite3_cancel_auto_extension()]
  5248   5578   */
  5249         -SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
         5579  +SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
  5250   5580   
  5251   5581   /*
  5252   5582   ** CAPI3REF: Cancel Automatic Extension Loading
  5253   5583   **
  5254   5584   ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
  5255   5585   ** initialization routine X that was registered using a prior call to
  5256   5586   ** [sqlite3_auto_extension(X)].  ^The [sqlite3_cancel_auto_extension(X)]
  5257   5587   ** routine returns 1 if initialization routine X was successfully 
  5258   5588   ** unregistered and it returns 0 if X was not on the list of initialization
  5259   5589   ** routines.
  5260   5590   */
  5261         -SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
         5591  +SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
  5262   5592   
  5263   5593   /*
  5264   5594   ** CAPI3REF: Reset Automatic Extension Loading
  5265   5595   **
  5266   5596   ** ^This interface disables all automatic extensions previously
  5267   5597   ** registered using [sqlite3_auto_extension()].
  5268   5598   */
  5269         -SQLITE_API void sqlite3_reset_auto_extension(void);
         5599  +SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void);
  5270   5600   
  5271   5601   /*
  5272   5602   ** The interface to the virtual-table mechanism is currently considered
  5273   5603   ** to be experimental.  The interface might change in incompatible ways.
  5274   5604   ** If this is a problem for you, do not use the interface at this time.
  5275   5605   **
  5276   5606   ** When the virtual-table mechanism stabilizes, we will declare the
................................................................................
  5363   5693   ** and makes other simplifications to the WHERE clause in an attempt to
  5364   5694   ** get as many WHERE clause terms into the form shown above as possible.
  5365   5695   ** ^The aConstraint[] array only reports WHERE clause terms that are
  5366   5696   ** relevant to the particular virtual table being queried.
  5367   5697   **
  5368   5698   ** ^Information about the ORDER BY clause is stored in aOrderBy[].
  5369   5699   ** ^Each term of aOrderBy records a column of the ORDER BY clause.
         5700  +**
         5701  +** The colUsed field indicates which columns of the virtual table may be
         5702  +** required by the current scan. Virtual table columns are numbered from
         5703  +** zero in the order in which they appear within the CREATE TABLE statement
         5704  +** passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62),
         5705  +** the corresponding bit is set within the colUsed mask if the column may be
         5706  +** required by SQLite. If the table has at least 64 columns and any column
         5707  +** to the right of the first 63 is required, then bit 63 of colUsed is also
         5708  +** set. In other words, column iCol may be required if the expression
         5709  +** (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to 
         5710  +** non-zero.
  5370   5711   **
  5371   5712   ** The [xBestIndex] method must fill aConstraintUsage[] with information
  5372   5713   ** about what parameters to pass to xFilter.  ^If argvIndex>0 then
  5373   5714   ** the right-hand side of the corresponding aConstraint[] is evaluated
  5374   5715   ** and becomes the argvIndex-th entry in argv.  ^(If aConstraintUsage[].omit
  5375   5716   ** is true, then the constraint is assumed to be fully handled by the
  5376   5717   ** virtual table and is not checked again by SQLite.)^
................................................................................
  5388   5729   ** strategy. A cost of N indicates that the cost of the strategy is similar
  5389   5730   ** to a linear scan of an SQLite table with N rows. A cost of log(N) 
  5390   5731   ** indicates that the expense of the operation is similar to that of a
  5391   5732   ** binary search on a unique indexed field of an SQLite table with N rows.
  5392   5733   **
  5393   5734   ** ^The estimatedRows value is an estimate of the number of rows that
  5394   5735   ** will be returned by the strategy.
         5736  +**
         5737  +** The xBestIndex method may optionally populate the idxFlags field with a 
         5738  +** mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag -
         5739  +** SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite
         5740  +** assumes that the strategy may visit at most one row. 
         5741  +**
         5742  +** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then
         5743  +** SQLite also assumes that if a call to the xUpdate() method is made as
         5744  +** part of the same statement to delete or update a virtual table row and the
         5745  +** implementation returns SQLITE_CONSTRAINT, then there is no need to rollback
         5746  +** any database changes. In other words, if the xUpdate() returns
         5747  +** SQLITE_CONSTRAINT, the database contents must be exactly as they were
         5748  +** before xUpdate was called. By contrast, if SQLITE_INDEX_SCAN_UNIQUE is not
         5749  +** set and xUpdate returns SQLITE_CONSTRAINT, any database changes made by
         5750  +** the xUpdate method are automatically rolled back by SQLite.
  5395   5751   **
  5396   5752   ** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info
  5397   5753   ** structure for SQLite version 3.8.2. If a virtual table extension is
  5398   5754   ** used with an SQLite version earlier than 3.8.2, the results of attempting 
  5399   5755   ** to read or write the estimatedRows field are undefined (but are likely 
  5400   5756   ** to included crashing the application). The estimatedRows field should
  5401   5757   ** therefore only be used if [sqlite3_libversion_number()] returns a
  5402         -** value greater than or equal to 3008002.
         5758  +** value greater than or equal to 3008002. Similarly, the idxFlags field
         5759  +** was added for version 3.9.0. It may therefore only be used if
         5760  +** sqlite3_libversion_number() returns a value greater than or equal to
         5761  +** 3009000.
  5403   5762   */
  5404   5763   struct sqlite3_index_info {
  5405   5764     /* Inputs */
  5406   5765     int nConstraint;           /* Number of entries in aConstraint */
  5407   5766     struct sqlite3_index_constraint {
  5408         -     int iColumn;              /* Column on left-hand side of constraint */
         5767  +     int iColumn;              /* Column constrained.  -1 for ROWID */
  5409   5768        unsigned char op;         /* Constraint operator */
  5410   5769        unsigned char usable;     /* True if this constraint is usable */
  5411   5770        int iTermOffset;          /* Used internally - xBestIndex should ignore */
  5412   5771     } *aConstraint;            /* Table of WHERE clause constraints */
  5413   5772     int nOrderBy;              /* Number of terms in the ORDER BY clause */
  5414   5773     struct sqlite3_index_orderby {
  5415   5774        int iColumn;              /* Column number */
................................................................................
  5423   5782     int idxNum;                /* Number used to identify the index */
  5424   5783     char *idxStr;              /* String, possibly obtained from sqlite3_malloc */
  5425   5784     int needToFreeIdxStr;      /* Free idxStr using sqlite3_free() if true */
  5426   5785     int orderByConsumed;       /* True if output is already ordered */
  5427   5786     double estimatedCost;           /* Estimated cost of using this index */
  5428   5787     /* Fields below are only available in SQLite 3.8.2 and later */
  5429   5788     sqlite3_int64 estimatedRows;    /* Estimated number of rows returned */
         5789  +  /* Fields below are only available in SQLite 3.9.0 and later */
         5790  +  int idxFlags;              /* Mask of SQLITE_INDEX_SCAN_* flags */
         5791  +  /* Fields below are only available in SQLite 3.10.0 and later */
         5792  +  sqlite3_uint64 colUsed;    /* Input: Mask of columns used by statement */
  5430   5793   };
  5431   5794   
         5795  +/*
         5796  +** CAPI3REF: Virtual Table Scan Flags
         5797  +*/
         5798  +#define SQLITE_INDEX_SCAN_UNIQUE      1     /* Scan visits at most 1 row */
         5799  +
  5432   5800   /*
  5433   5801   ** CAPI3REF: Virtual Table Constraint Operator Codes
  5434   5802   **
  5435   5803   ** These macros defined the allowed values for the
  5436   5804   ** [sqlite3_index_info].aConstraint[].op field.  Each value represents
  5437   5805   ** an operator that is part of a constraint term in the wHERE clause of
  5438   5806   ** a query that uses a [virtual table].
  5439   5807   */
  5440         -#define SQLITE_INDEX_CONSTRAINT_EQ    2
  5441         -#define SQLITE_INDEX_CONSTRAINT_GT    4
  5442         -#define SQLITE_INDEX_CONSTRAINT_LE    8
  5443         -#define SQLITE_INDEX_CONSTRAINT_LT    16
  5444         -#define SQLITE_INDEX_CONSTRAINT_GE    32
  5445         -#define SQLITE_INDEX_CONSTRAINT_MATCH 64
         5808  +#define SQLITE_INDEX_CONSTRAINT_EQ      2
         5809  +#define SQLITE_INDEX_CONSTRAINT_GT      4
         5810  +#define SQLITE_INDEX_CONSTRAINT_LE      8
         5811  +#define SQLITE_INDEX_CONSTRAINT_LT     16
         5812  +#define SQLITE_INDEX_CONSTRAINT_GE     32
         5813  +#define SQLITE_INDEX_CONSTRAINT_MATCH  64
         5814  +#define SQLITE_INDEX_CONSTRAINT_LIKE   65
         5815  +#define SQLITE_INDEX_CONSTRAINT_GLOB   66
         5816  +#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
  5446   5817   
  5447   5818   /*
  5448   5819   ** CAPI3REF: Register A Virtual Table Implementation
         5820  +** METHOD: sqlite3
  5449   5821   **
  5450   5822   ** ^These routines are used to register a new [virtual table module] name.
  5451   5823   ** ^Module names must be registered before
  5452   5824   ** creating a new [virtual table] using the module and before using a
  5453   5825   ** preexisting [virtual table] for the module.
  5454   5826   **
  5455   5827   ** ^The module name is registered on the [database connection] specified
................................................................................
  5465   5837   ** invoke the destructor function (if it is not NULL) when SQLite
  5466   5838   ** no longer needs the pClientData pointer.  ^The destructor will also
  5467   5839   ** be invoked if the call to sqlite3_create_module_v2() fails.
  5468   5840   ** ^The sqlite3_create_module()
  5469   5841   ** interface is equivalent to sqlite3_create_module_v2() with a NULL
  5470   5842   ** destructor.
  5471   5843   */
  5472         -SQLITE_API int sqlite3_create_module(
         5844  +SQLITE_API int SQLITE_STDCALL sqlite3_create_module(
  5473   5845     sqlite3 *db,               /* SQLite connection to register module with */
  5474   5846     const char *zName,         /* Name of the module */
  5475   5847     const sqlite3_module *p,   /* Methods for the module */
  5476   5848     void *pClientData          /* Client data for xCreate/xConnect */
  5477   5849   );
  5478         -SQLITE_API int sqlite3_create_module_v2(
         5850  +SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2(
  5479   5851     sqlite3 *db,               /* SQLite connection to register module with */
  5480   5852     const char *zName,         /* Name of the module */
  5481   5853     const sqlite3_module *p,   /* Methods for the module */
  5482   5854     void *pClientData,         /* Client data for xCreate/xConnect */
  5483   5855     void(*xDestroy)(void*)     /* Module destructor function */
  5484   5856   );
  5485   5857   
................................................................................
  5499   5871   ** take care that any prior string is freed by a call to [sqlite3_free()]
  5500   5872   ** prior to assigning a new string to zErrMsg.  ^After the error message
  5501   5873   ** is delivered up to the client application, the string will be automatically
  5502   5874   ** freed by sqlite3_free() and the zErrMsg field will be zeroed.
  5503   5875   */
  5504   5876   struct sqlite3_vtab {
  5505   5877     const sqlite3_module *pModule;  /* The module for this virtual table */
  5506         -  int nRef;                       /* NO LONGER USED */
         5878  +  int nRef;                       /* Number of open cursors */
  5507   5879     char *zErrMsg;                  /* Error message from sqlite3_mprintf() */
  5508   5880     /* Virtual table implementations will typically add additional fields */
  5509   5881   };
  5510   5882   
  5511   5883   /*
  5512   5884   ** CAPI3REF: Virtual Table Cursor Object
  5513   5885   ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}
................................................................................
  5534   5906   ** CAPI3REF: Declare The Schema Of A Virtual Table
  5535   5907   **
  5536   5908   ** ^The [xCreate] and [xConnect] methods of a
  5537   5909   ** [virtual table module] call this interface
  5538   5910   ** to declare the format (the names and datatypes of the columns) of
  5539   5911   ** the virtual tables they implement.
  5540   5912   */
  5541         -SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
         5913  +SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3*, const char *zSQL);
  5542   5914   
  5543   5915   /*
  5544   5916   ** CAPI3REF: Overload A Function For A Virtual Table
         5917  +** METHOD: sqlite3
  5545   5918   **
  5546   5919   ** ^(Virtual tables can provide alternative implementations of functions
  5547   5920   ** using the [xFindFunction] method of the [virtual table module].  
  5548   5921   ** But global versions of those functions
  5549   5922   ** must exist in order to be overloaded.)^
  5550   5923   **
  5551   5924   ** ^(This API makes sure a global version of a function with a particular
................................................................................
  5552   5925   ** name and number of parameters exists.  If no such function exists
  5553   5926   ** before this API is called, a new function is created.)^  ^The implementation
  5554   5927   ** of the new function always causes an exception to be thrown.  So
  5555   5928   ** the new function is not good for anything by itself.  Its only
  5556   5929   ** purpose is to be a placeholder function that can be overloaded
  5557   5930   ** by a [virtual table].
  5558   5931   */
  5559         -SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
         5932  +SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
  5560   5933   
  5561   5934   /*
  5562   5935   ** The interface to the virtual-table mechanism defined above (back up
  5563   5936   ** to a comment remarkably similar to this one) is currently considered
  5564   5937   ** to be experimental.  The interface might change in incompatible ways.
  5565   5938   ** If this is a problem for you, do not use the interface at this time.
  5566   5939   **
................................................................................
  5580   5953   ** can be used to read or write small subsections of the BLOB.
  5581   5954   ** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.
  5582   5955   */
  5583   5956   typedef struct sqlite3_blob sqlite3_blob;
  5584   5957   
  5585   5958   /*
  5586   5959   ** CAPI3REF: Open A BLOB For Incremental I/O
         5960  +** METHOD: sqlite3
         5961  +** CONSTRUCTOR: sqlite3_blob
  5587   5962   **
  5588   5963   ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located
  5589   5964   ** in row iRow, column zColumn, table zTable in database zDb;
  5590   5965   ** in other words, the same BLOB that would be selected by:
  5591   5966   **
  5592   5967   ** <pre>
  5593   5968   **     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
  5594   5969   ** </pre>)^
         5970  +**
         5971  +** ^(Parameter zDb is not the filename that contains the database, but 
         5972  +** rather the symbolic name of the database. For attached databases, this is
         5973  +** the name that appears after the AS keyword in the [ATTACH] statement.
         5974  +** For the main database file, the database name is "main". For TEMP
         5975  +** tables, the database name is "temp".)^
  5595   5976   **
  5596   5977   ** ^If the flags parameter is non-zero, then the BLOB is opened for read
  5597         -** and write access. ^If it is zero, the BLOB is opened for read access.
  5598         -** ^It is not possible to open a column that is part of an index or primary 
  5599         -** key for writing. ^If [foreign key constraints] are enabled, it is 
  5600         -** not possible to open a column that is part of a [child key] for writing.
  5601         -**
  5602         -** ^Note that the database name is not the filename that contains
  5603         -** the database but rather the symbolic name of the database that
  5604         -** appears after the AS keyword when the database is connected using [ATTACH].
  5605         -** ^For the main database file, the database name is "main".
  5606         -** ^For TEMP tables, the database name is "temp".
  5607         -**
  5608         -** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written
  5609         -** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set
  5610         -** to be a null pointer.)^
  5611         -** ^This function sets the [database connection] error code and message
  5612         -** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related
  5613         -** functions. ^Note that the *ppBlob variable is always initialized in a
  5614         -** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob
  5615         -** regardless of the success or failure of this routine.
         5978  +** and write access. ^If the flags parameter is zero, the BLOB is opened for
         5979  +** read-only access.
         5980  +**
         5981  +** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is stored
         5982  +** in *ppBlob. Otherwise an [error code] is returned and, unless the error
         5983  +** code is SQLITE_MISUSE, *ppBlob is set to NULL.)^ ^This means that, provided
         5984  +** the API is not misused, it is always safe to call [sqlite3_blob_close()] 
         5985  +** on *ppBlob after this function it returns.
         5986  +**
         5987  +** This function fails with SQLITE_ERROR if any of the following are true:
         5988  +** <ul>
         5989  +**   <li> ^(Database zDb does not exist)^, 
         5990  +**   <li> ^(Table zTable does not exist within database zDb)^, 
         5991  +**   <li> ^(Table zTable is a WITHOUT ROWID table)^, 
         5992  +**   <li> ^(Column zColumn does not exist)^,
         5993  +**   <li> ^(Row iRow is not present in the table)^,
         5994  +**   <li> ^(The specified column of row iRow contains a value that is not
         5995  +**         a TEXT or BLOB value)^,
         5996  +**   <li> ^(Column zColumn is part of an index, PRIMARY KEY or UNIQUE 
         5997  +**         constraint and the blob is being opened for read/write access)^,
         5998  +**   <li> ^([foreign key constraints | Foreign key constraints] are enabled, 
         5999  +**         column zColumn is part of a [child key] definition and the blob is
         6000  +**         being opened for read/write access)^.
         6001  +** </ul>
         6002  +**
         6003  +** ^Unless it returns SQLITE_MISUSE, this function sets the 
         6004  +** [database connection] error code and message accessible via 
         6005  +** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. 
         6006  +**
  5616   6007   **
  5617   6008   ** ^(If the row that a BLOB handle points to is modified by an
  5618   6009   ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects
  5619   6010   ** then the BLOB handle is marked as "expired".
  5620   6011   ** This is true if any column of the row is changed, even a column
  5621   6012   ** other than the one the BLOB handle is open on.)^
  5622   6013   ** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for
................................................................................
  5626   6017   ** commit if the transaction continues to completion.)^
  5627   6018   **
  5628   6019   ** ^Use the [sqlite3_blob_bytes()] interface to determine the size of
  5629   6020   ** the opened blob.  ^The size of a blob may not be changed by this
  5630   6021   ** interface.  Use the [UPDATE] SQL command to change the size of a
  5631   6022   ** blob.
  5632   6023   **
  5633         -** ^The [sqlite3_blob_open()] interface will fail for a [WITHOUT ROWID]
  5634         -** table.  Incremental BLOB I/O is not possible on [WITHOUT ROWID] tables.
  5635         -**
  5636   6024   ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
  5637         -** and the built-in [zeroblob] SQL function can be used, if desired,
  5638         -** to create an empty, zero-filled blob in which to read or write using
  5639         -** this interface.
         6025  +** and the built-in [zeroblob] SQL function may be used to create a 
         6026  +** zero-filled blob to read or write using the incremental-blob interface.
  5640   6027   **
  5641   6028   ** To avoid a resource leak, every open [BLOB handle] should eventually
  5642   6029   ** be released by a call to [sqlite3_blob_close()].
  5643   6030   */
  5644         -SQLITE_API int sqlite3_blob_open(
         6031  +SQLITE_API int SQLITE_STDCALL sqlite3_blob_open(
  5645   6032     sqlite3*,
  5646   6033     const char *zDb,
  5647   6034     const char *zTable,
  5648   6035     const char *zColumn,
  5649   6036     sqlite3_int64 iRow,
  5650   6037     int flags,
  5651   6038     sqlite3_blob **ppBlob
  5652   6039   );
  5653   6040   
  5654   6041   /*
  5655   6042   ** CAPI3REF: Move a BLOB Handle to a New Row
         6043  +** METHOD: sqlite3_blob
  5656   6044   **
  5657   6045   ** ^This function is used to move an existing blob handle so that it points
  5658   6046   ** to a different row of the same database table. ^The new row is identified
  5659   6047   ** by the rowid value passed as the second argument. Only the row can be
  5660   6048   ** changed. ^The database, table and column on which the blob handle is open
  5661   6049   ** remain the same. Moving an existing blob handle to a new row can be
  5662   6050   ** faster than closing the existing handle and opening a new one.
................................................................................
  5669   6057   ** ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or
  5670   6058   ** [sqlite3_blob_reopen()] on an aborted blob handle immediately return
  5671   6059   ** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle
  5672   6060   ** always returns zero.
  5673   6061   **
  5674   6062   ** ^This function sets the database handle error code and message.
  5675   6063   */
  5676         -SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
         6064  +SQLITE_API int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
  5677   6065   
  5678   6066   /*
  5679   6067   ** CAPI3REF: Close A BLOB Handle
  5680         -**
  5681         -** ^Closes an open [BLOB handle].
  5682         -**
  5683         -** ^Closing a BLOB shall cause the current transaction to commit
  5684         -** if there are no other BLOBs, no pending prepared statements, and the
  5685         -** database connection is in [autocommit mode].
  5686         -** ^If any writes were made to the BLOB, they might be held in cache
  5687         -** until the close operation if they will fit.
  5688         -**
  5689         -** ^(Closing the BLOB often forces the changes
  5690         -** out to disk and so if any I/O errors occur, they will likely occur
  5691         -** at the time when the BLOB is closed.  Any errors that occur during
  5692         -** closing are reported as a non-zero return value.)^
  5693         -**
  5694         -** ^(The BLOB is closed unconditionally.  Even if this routine returns
  5695         -** an error code, the BLOB is still closed.)^
  5696         -**
  5697         -** ^Calling this routine with a null pointer (such as would be returned
  5698         -** by a failed call to [sqlite3_blob_open()]) is a harmless no-op.
  5699         -*/
  5700         -SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
         6068  +** DESTRUCTOR: sqlite3_blob
         6069  +**
         6070  +** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed
         6071  +** unconditionally.  Even if this routine returns an error code, the 
         6072  +** handle is still closed.)^
         6073  +**
         6074  +** ^If the blob handle being closed was opened for read-write access, and if
         6075  +** the database is in auto-commit mode and there are no other open read-write
         6076  +** blob handles or active write statements, the current transaction is
         6077  +** committed. ^If an error occurs while committing the transaction, an error
         6078  +** code is returned and the transaction rolled back.
         6079  +**
         6080  +** Calling this function with an argument that is not a NULL pointer or an
         6081  +** open blob handle results in undefined behaviour. ^Calling this routine 
         6082  +** with a null pointer (such as would be returned by a failed call to 
         6083  +** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
         6084  +** is passed a valid open blob handle, the values returned by the 
         6085  +** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
         6086  +*/
         6087  +SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *);
  5701   6088   
  5702   6089   /*
  5703   6090   ** CAPI3REF: Return The Size Of An Open BLOB
         6091  +** METHOD: sqlite3_blob
  5704   6092   **
  5705   6093   ** ^Returns the size in bytes of the BLOB accessible via the 
  5706   6094   ** successfully opened [BLOB handle] in its only argument.  ^The
  5707   6095   ** incremental blob I/O routines can only read or overwriting existing
  5708   6096   ** blob content; they cannot change the size of a blob.
  5709   6097   **
  5710   6098   ** This routine only works on a [BLOB handle] which has been created
  5711   6099   ** by a prior successful call to [sqlite3_blob_open()] and which has not
  5712   6100   ** been closed by [sqlite3_blob_close()].  Passing any other pointer in
  5713   6101   ** to this routine results in undefined and probably undesirable behavior.
  5714   6102   */
  5715         -SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
         6103  +SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *);
  5716   6104   
  5717   6105   /*
  5718   6106   ** CAPI3REF: Read Data From A BLOB Incrementally
         6107  +** METHOD: sqlite3_blob
  5719   6108   **
  5720   6109   ** ^(This function is used to read data from an open [BLOB handle] into a
  5721   6110   ** caller-supplied buffer. N bytes of data are copied into buffer Z
  5722   6111   ** from the open BLOB, starting at offset iOffset.)^
  5723   6112   **
  5724   6113   ** ^If offset iOffset is less than N bytes from the end of the BLOB,
  5725   6114   ** [SQLITE_ERROR] is returned and no data is read.  ^If N or iOffset is
................................................................................
  5736   6125   ** This routine only works on a [BLOB handle] which has been created
  5737   6126   ** by a prior successful call to [sqlite3_blob_open()] and which has not
  5738   6127   ** been closed by [sqlite3_blob_close()].  Passing any other pointer in
  5739   6128   ** to this routine results in undefined and probably undesirable behavior.
  5740   6129   **
  5741   6130   ** See also: [sqlite3_blob_write()].
  5742   6131   */
  5743         -SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
         6132  +SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
  5744   6133   
  5745   6134   /*
  5746   6135   ** CAPI3REF: Write Data Into A BLOB Incrementally
         6136  +** METHOD: sqlite3_blob
  5747   6137   **
  5748         -** ^This function is used to write data into an open [BLOB handle] from a
  5749         -** caller-supplied buffer. ^N bytes of data are copied from the buffer Z
  5750         -** into the open BLOB, starting at offset iOffset.
         6138  +** ^(This function is used to write data into an open [BLOB handle] from a
         6139  +** caller-supplied buffer. N bytes of data are copied from the buffer Z
         6140  +** into the open BLOB, starting at offset iOffset.)^
         6141  +**
         6142  +** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
         6143  +** Otherwise, an  [error code] or an [extended error code] is returned.)^
         6144  +** ^Unless SQLITE_MISUSE is returned, this function sets the 
         6145  +** [database connection] error code and message accessible via 
         6146  +** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. 
  5751   6147   **
  5752   6148   ** ^If the [BLOB handle] passed as the first argument was not opened for
  5753   6149   ** writing (the flags parameter to [sqlite3_blob_open()] was zero),
  5754   6150   ** this function returns [SQLITE_READONLY].
  5755   6151   **
  5756         -** ^This function may only modify the contents of the BLOB; it is
         6152  +** This function may only modify the contents of the BLOB; it is
  5757   6153   ** not possible to increase the size of a BLOB using this API.
  5758   6154   ** ^If offset iOffset is less than N bytes from the end of the BLOB,
  5759         -** [SQLITE_ERROR] is returned and no data is written.  ^If N is
  5760         -** less than zero [SQLITE_ERROR] is returned and no data is written.
  5761         -** The size of the BLOB (and hence the maximum value of N+iOffset)
  5762         -** can be determined using the [sqlite3_blob_bytes()] interface.
         6155  +** [SQLITE_ERROR] is returned and no data is written. The size of the 
         6156  +** BLOB (and hence the maximum value of N+iOffset) can be determined 
         6157  +** using the [sqlite3_blob_bytes()] interface. ^If N or iOffset are less 
         6158  +** than zero [SQLITE_ERROR] is returned and no data is written.
  5763   6159   **
  5764   6160   ** ^An attempt to write to an expired [BLOB handle] fails with an
  5765   6161   ** error code of [SQLITE_ABORT].  ^Writes to the BLOB that occurred
  5766   6162   ** before the [BLOB handle] expired are not rolled back by the
  5767   6163   ** expiration of the handle, though of course those changes might
  5768   6164   ** have been overwritten by the statement that expired the BLOB handle
  5769   6165   ** or by other independent statements.
  5770   6166   **
  5771         -** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
  5772         -** Otherwise, an  [error code] or an [extended error code] is returned.)^
  5773         -**
  5774   6167   ** This routine only works on a [BLOB handle] which has been created
  5775   6168   ** by a prior successful call to [sqlite3_blob_open()] and which has not
  5776   6169   ** been closed by [sqlite3_blob_close()].  Passing any other pointer in
  5777   6170   ** to this routine results in undefined and probably undesirable behavior.
  5778   6171   **
  5779   6172   ** See also: [sqlite3_blob_read()].
  5780   6173   */
  5781         -SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
         6174  +SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
  5782   6175   
  5783   6176   /*
  5784   6177   ** CAPI3REF: Virtual File System Objects
  5785   6178   **
  5786   6179   ** A virtual filesystem (VFS) is an [sqlite3_vfs] object
  5787   6180   ** that SQLite uses to interact
  5788   6181   ** with the underlying operating system.  Most SQLite builds come with a
................................................................................
  5805   6198   ** VFS is registered with a name that is NULL or an empty string,
  5806   6199   ** then the behavior is undefined.
  5807   6200   **
  5808   6201   ** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
  5809   6202   ** ^(If the default VFS is unregistered, another VFS is chosen as
  5810   6203   ** the default.  The choice for the new VFS is arbitrary.)^
  5811   6204   */
  5812         -SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
  5813         -SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
  5814         -SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
         6205  +SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfsName);
         6206  +SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
         6207  +SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs*);
  5815   6208   
  5816   6209   /*
  5817   6210   ** CAPI3REF: Mutexes
  5818   6211   **
  5819   6212   ** The SQLite core uses these routines for thread
  5820   6213   ** synchronization. Though they are intended for internal
  5821   6214   ** use by SQLite, code that links against SQLite is
  5822   6215   ** permitted to use any of these routines.
  5823   6216   **
  5824   6217   ** The SQLite source code contains multiple implementations
  5825   6218   ** of these mutex routines.  An appropriate implementation
  5826         -** is selected automatically at compile-time.  ^(The following
         6219  +** is selected automatically at compile-time.  The following
  5827   6220   ** implementations are available in the SQLite core:
  5828   6221   **
  5829   6222   ** <ul>
  5830   6223   ** <li>   SQLITE_MUTEX_PTHREADS
  5831   6224   ** <li>   SQLITE_MUTEX_W32
  5832   6225   ** <li>   SQLITE_MUTEX_NOOP
  5833         -** </ul>)^
         6226  +** </ul>
  5834   6227   **
  5835         -** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
         6228  +** The SQLITE_MUTEX_NOOP implementation is a set of routines
  5836   6229   ** that does no real locking and is appropriate for use in
  5837         -** a single-threaded application.  ^The SQLITE_MUTEX_PTHREADS and
         6230  +** a single-threaded application.  The SQLITE_MUTEX_PTHREADS and
  5838   6231   ** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix
  5839   6232   ** and Windows.
  5840   6233   **
  5841         -** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
         6234  +** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
  5842   6235   ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
  5843   6236   ** implementation is included with the library. In this case the
  5844   6237   ** application must supply a custom mutex implementation using the
  5845   6238   ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function
  5846   6239   ** before calling sqlite3_initialize() or any other public sqlite3_
  5847         -** function that calls sqlite3_initialize().)^
         6240  +** function that calls sqlite3_initialize().
  5848   6241   **
  5849   6242   ** ^The sqlite3_mutex_alloc() routine allocates a new
  5850         -** mutex and returns a pointer to it. ^If it returns NULL
  5851         -** that means that a mutex could not be allocated.  ^SQLite
  5852         -** will unwind its stack and return an error.  ^(The argument
  5853         -** to sqlite3_mutex_alloc() is one of these integer constants:
         6243  +** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()
         6244  +** routine returns NULL if it is unable to allocate the requested
         6245  +** mutex.  The argument to sqlite3_mutex_alloc() must one of these
         6246  +** integer constants:
  5854   6247   **
  5855   6248   ** <ul>
  5856   6249   ** <li>  SQLITE_MUTEX_FAST
  5857   6250   ** <li>  SQLITE_MUTEX_RECURSIVE
  5858   6251   ** <li>  SQLITE_MUTEX_STATIC_MASTER
  5859   6252   ** <li>  SQLITE_MUTEX_STATIC_MEM
  5860   6253   ** <li>  SQLITE_MUTEX_STATIC_OPEN
  5861   6254   ** <li>  SQLITE_MUTEX_STATIC_PRNG
  5862   6255   ** <li>  SQLITE_MUTEX_STATIC_LRU
  5863   6256   ** <li>  SQLITE_MUTEX_STATIC_PMEM
  5864   6257   ** <li>  SQLITE_MUTEX_STATIC_APP1
  5865   6258   ** <li>  SQLITE_MUTEX_STATIC_APP2
  5866         -** </ul>)^
         6259  +** <li>  SQLITE_MUTEX_STATIC_APP3
         6260  +** <li>  SQLITE_MUTEX_STATIC_VFS1
         6261  +** <li>  SQLITE_MUTEX_STATIC_VFS2
         6262  +** <li>  SQLITE_MUTEX_STATIC_VFS3
         6263  +** </ul>
  5867   6264   **
  5868   6265   ** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)
  5869   6266   ** cause sqlite3_mutex_alloc() to create
  5870   6267   ** a new mutex.  ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
  5871   6268   ** is used but not necessarily so when SQLITE_MUTEX_FAST is used.
  5872   6269   ** The mutex implementation does not need to make a distinction
  5873   6270   ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
  5874         -** not want to.  ^SQLite will only request a recursive mutex in
  5875         -** cases where it really needs one.  ^If a faster non-recursive mutex
         6271  +** not want to.  SQLite will only request a recursive mutex in
         6272  +** cases where it really needs one.  If a faster non-recursive mutex
  5876   6273   ** implementation is available on the host platform, the mutex subsystem
  5877   6274   ** might return such a mutex in response to SQLITE_MUTEX_FAST.
  5878   6275   **
  5879   6276   ** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other
  5880   6277   ** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return
  5881         -** a pointer to a static preexisting mutex.  ^Six static mutexes are
         6278  +** a pointer to a static preexisting mutex.  ^Nine static mutexes are
  5882   6279   ** used by the current version of SQLite.  Future versions of SQLite
  5883   6280   ** may add additional static mutexes.  Static mutexes are for internal
  5884   6281   ** use by SQLite only.  Applications that use SQLite mutexes should
  5885   6282   ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or
  5886   6283   ** SQLITE_MUTEX_RECURSIVE.
  5887   6284   **
  5888   6285   ** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
  5889   6286   ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()
  5890         -** returns a different mutex on every call.  ^But for the static
         6287  +** returns a different mutex on every call.  ^For the static
  5891   6288   ** mutex types, the same mutex is returned on every call that has
  5892   6289   ** the same type number.
  5893   6290   **
  5894   6291   ** ^The sqlite3_mutex_free() routine deallocates a previously
  5895         -** allocated dynamic mutex.  ^SQLite is careful to deallocate every
  5896         -** dynamic mutex that it allocates.  The dynamic mutexes must not be in
  5897         -** use when they are deallocated.  Attempting to deallocate a static
  5898         -** mutex results in undefined behavior.  ^SQLite never deallocates
  5899         -** a static mutex.
         6292  +** allocated dynamic mutex.  Attempting to deallocate a static
         6293  +** mutex results in undefined behavior.
  5900   6294   **
  5901   6295   ** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
  5902   6296   ** to enter a mutex.  ^If another thread is already within the mutex,
  5903   6297   ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return
  5904   6298   ** SQLITE_BUSY.  ^The sqlite3_mutex_try() interface returns [SQLITE_OK]
  5905   6299   ** upon successful entry.  ^(Mutexes created using
  5906   6300   ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.
  5907         -** In such cases the,
         6301  +** In such cases, the
  5908   6302   ** mutex must be exited an equal number of times before another thread
  5909         -** can enter.)^  ^(If the same thread tries to enter any other
  5910         -** kind of mutex more than once, the behavior is undefined.
  5911         -** SQLite will never exhibit
  5912         -** such behavior in its own use of mutexes.)^
         6303  +** can enter.)^  If the same thread tries to enter any mutex other
         6304  +** than an SQLITE_MUTEX_RECURSIVE more than once, the behavior is undefined.
  5913   6305   **
  5914   6306   ** ^(Some systems (for example, Windows 95) do not support the operation
  5915   6307   ** implemented by sqlite3_mutex_try().  On those systems, sqlite3_mutex_try()
  5916         -** will always return SQLITE_BUSY.  The SQLite core only ever uses
  5917         -** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^
         6308  +** will always return SQLITE_BUSY. The SQLite core only ever uses
         6309  +** sqlite3_mutex_try() as an optimization so this is acceptable 
         6310  +** behavior.)^
  5918   6311   **
  5919   6312   ** ^The sqlite3_mutex_leave() routine exits a mutex that was
  5920         -** previously entered by the same thread.   ^(The behavior
         6313  +** previously entered by the same thread.   The behavior
  5921   6314   ** is undefined if the mutex is not currently entered by the
  5922         -** calling thread or is not currently allocated.  SQLite will
  5923         -** never do either.)^
         6315  +** calling thread or is not currently allocated.
  5924   6316   **
  5925   6317   ** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
  5926   6318   ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
  5927   6319   ** behave as no-ops.
  5928   6320   **
  5929   6321   ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
  5930   6322   */
  5931         -SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);
  5932         -SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);
  5933         -SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
  5934         -SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
  5935         -SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
         6323  +SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int);
         6324  +SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex*);
         6325  +SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex*);
         6326  +SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex*);
         6327  +SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex*);
  5936   6328   
  5937   6329   /*
  5938   6330   ** CAPI3REF: Mutex Methods Object
  5939   6331   **
  5940   6332   ** An instance of this structure defines the low-level routines
  5941   6333   ** used to allocate and use mutexes.
  5942   6334   **
  5943   6335   ** Usually, the default mutex implementations provided by SQLite are
  5944         -** sufficient, however the user has the option of substituting a custom
         6336  +** sufficient, however the application has the option of substituting a custom
  5945   6337   ** implementation for specialized deployments or systems for which SQLite
  5946         -** does not provide a suitable implementation. In this case, the user
         6338  +** does not provide a suitable implementation. In this case, the application
  5947   6339   ** creates and populates an instance of this structure to pass
  5948   6340   ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.
  5949   6341   ** Additionally, an instance of this structure can be used as an
  5950   6342   ** output variable when querying the system for the current mutex
  5951   6343   ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option.
  5952   6344   **
  5953   6345   ** ^The xMutexInit method defined by this structure is invoked as
................................................................................
  5980   6372   ** above silently ignore any invocations that pass a NULL pointer instead
  5981   6373   ** of a valid mutex handle. The implementations of the methods defined
  5982   6374   ** by this structure are not required to handle this case, the results
  5983   6375   ** of passing a NULL pointer instead of a valid mutex handle are undefined
  5984   6376   ** (i.e. it is acceptable to provide an implementation that segfaults if
  5985   6377   ** it is passed a NULL pointer).
  5986   6378   **
  5987         -** The xMutexInit() method must be threadsafe.  ^It must be harmless to
         6379  +** The xMutexInit() method must be threadsafe.  It must be harmless to
  5988   6380   ** invoke xMutexInit() multiple times within the same process and without
  5989   6381   ** intervening calls to xMutexEnd().  Second and subsequent calls to
  5990   6382   ** xMutexInit() must be no-ops.
  5991   6383   **
  5992         -** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
  5993         -** and its associates).  ^Similarly, xMutexAlloc() must not use SQLite memory
         6384  +** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
         6385  +** and its associates).  Similarly, xMutexAlloc() must not use SQLite memory
  5994   6386   ** allocation for a static mutex.  ^However xMutexAlloc() may use SQLite
  5995   6387   ** memory allocation for a fast or recursive mutex.
  5996   6388   **
  5997   6389   ** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is
  5998   6390   ** called, but only if the prior call to xMutexInit returned SQLITE_OK.
  5999   6391   ** If xMutexInit fails in any way, it is expected to clean up after itself
  6000   6392   ** prior to returning.
................................................................................
  6012   6404     int (*xMutexNotheld)(sqlite3_mutex *);
  6013   6405   };
  6014   6406   
  6015   6407   /*
  6016   6408   ** CAPI3REF: Mutex Verification Routines
  6017   6409   **
  6018   6410   ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines
  6019         -** are intended for use inside assert() statements.  ^The SQLite core
         6411  +** are intended for use inside assert() statements.  The SQLite core
  6020   6412   ** never uses these routines except inside an assert() and applications
  6021         -** are advised to follow the lead of the core.  ^The SQLite core only
         6413  +** are advised to follow the lead of the core.  The SQLite core only
  6022   6414   ** provides implementations for these routines when it is compiled
  6023         -** with the SQLITE_DEBUG flag.  ^External mutex implementations
         6415  +** with the SQLITE_DEBUG flag.  External mutex implementations
  6024   6416   ** are only required to provide these routines if SQLITE_DEBUG is
  6025   6417   ** defined and if NDEBUG is not defined.
  6026   6418   **
  6027         -** ^These routines should return true if the mutex in their argument
         6419  +** These routines should return true if the mutex in their argument
  6028   6420   ** is held or not held, respectively, by the calling thread.
  6029   6421   **
  6030         -** ^The implementation is not required to provide versions of these
         6422  +** The implementation is not required to provide versions of these
  6031   6423   ** routines that actually work. If the implementation does not provide working
  6032   6424   ** versions of these routines, it should at least provide stubs that always
  6033   6425   ** return true so that one does not get spurious assertion failures.
  6034   6426   **
  6035         -** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
         6427  +** If the argument to sqlite3_mutex_held() is a NULL pointer then
  6036   6428   ** the routine should return 1.   This seems counter-intuitive since
  6037   6429   ** clearly the mutex cannot be held if it does not exist.  But
  6038   6430   ** the reason the mutex does not exist is because the build is not
  6039   6431   ** using mutexes.  And we do not want the assert() containing the
  6040   6432   ** call to sqlite3_mutex_held() to fail, so a non-zero return is
  6041         -** the appropriate thing to do.  ^The sqlite3_mutex_notheld()
         6433  +** the appropriate thing to do.  The sqlite3_mutex_notheld()
  6042   6434   ** interface should also return 1 when given a NULL pointer.
  6043   6435   */
  6044   6436   #ifndef NDEBUG
  6045         -SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
  6046         -SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
         6437  +SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex*);
         6438  +SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex*);
  6047   6439   #endif
  6048   6440   
  6049   6441   /*
  6050   6442   ** CAPI3REF: Mutex Types
  6051   6443   **
  6052   6444   ** The [sqlite3_mutex_alloc()] interface takes a single argument
  6053   6445   ** which is one of these integer constants.
................................................................................
  6065   6457   #define SQLITE_MUTEX_STATIC_PRNG      5  /* sqlite3_random() */
  6066   6458   #define SQLITE_MUTEX_STATIC_LRU       6  /* lru page list */
  6067   6459   #define SQLITE_MUTEX_STATIC_LRU2      7  /* NOT USED */
  6068   6460   #define SQLITE_MUTEX_STATIC_PMEM      7  /* sqlite3PageMalloc() */
  6069   6461   #define SQLITE_MUTEX_STATIC_APP1      8  /* For use by application */
  6070   6462   #define SQLITE_MUTEX_STATIC_APP2      9  /* For use by application */
  6071   6463   #define SQLITE_MUTEX_STATIC_APP3     10  /* For use by application */
         6464  +#define SQLITE_MUTEX_STATIC_VFS1     11  /* For use by built-in VFS */
         6465  +#define SQLITE_MUTEX_STATIC_VFS2     12  /* For use by extension VFS */
         6466  +#define SQLITE_MUTEX_STATIC_VFS3     13  /* For use by application VFS */
  6072   6467   
  6073   6468   /*
  6074   6469   ** CAPI3REF: Retrieve the mutex for a database connection
         6470  +** METHOD: sqlite3
  6075   6471   **
  6076   6472   ** ^This interface returns a pointer the [sqlite3_mutex] object that 
  6077   6473   ** serializes access to the [database connection] given in the argument
  6078   6474   ** when the [threading mode] is Serialized.
  6079   6475   ** ^If the [threading mode] is Single-thread or Multi-thread then this
  6080   6476   ** routine returns a NULL pointer.
  6081   6477   */
  6082         -SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
         6478  +SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3*);
  6083   6479   
  6084   6480   /*
  6085   6481   ** CAPI3REF: Low-Level Control Of Database Files
         6482  +** METHOD: sqlite3
  6086   6483   **
  6087   6484   ** ^The [sqlite3_file_control()] interface makes a direct call to the
  6088   6485   ** xFileControl method for the [sqlite3_io_methods] object associated
  6089   6486   ** with a particular database identified by the second argument. ^The
  6090   6487   ** name of the database is "main" for the main database or "temp" for the
  6091   6488   ** TEMP database, or the name that appears after the AS keyword for
  6092   6489   ** databases that are added using the [ATTACH] SQL command.
................................................................................
  6109   6506   ** or [sqlite3_errmsg()].  The underlying xFileControl method might
  6110   6507   ** also return SQLITE_ERROR.  There is no way to distinguish between
  6111   6508   ** an incorrect zDbName and an SQLITE_ERROR return from the underlying
  6112   6509   ** xFileControl method.
  6113   6510   **
  6114   6511   ** See also: [SQLITE_FCNTL_LOCKSTATE]
  6115   6512   */
  6116         -SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
         6513  +SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
  6117   6514   
  6118   6515   /*
  6119   6516   ** CAPI3REF: Testing Interface
  6120   6517   **
  6121   6518   ** ^The sqlite3_test_control() interface is used to read out internal
  6122   6519   ** state of SQLite and to inject faults into SQLite for testing
  6123   6520   ** purposes.  ^The first parameter is an operation code that determines
................................................................................
  6128   6525   ** on how the SQLite library is compiled, this interface might not exist.
  6129   6526   **
  6130   6527   ** The details of the operation codes, their meanings, the parameters
  6131   6528   ** they take, and what they do are all subject to change without notice.
  6132   6529   ** Unlike most of the SQLite API, this function is not guaranteed to
  6133   6530   ** operate consistently from one release to the next.
  6134   6531   */
  6135         -SQLITE_API int sqlite3_test_control(int op, ...);
         6532  +SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...);
  6136   6533   
  6137   6534   /*
  6138   6535   ** CAPI3REF: Testing Interface Operation Codes
  6139   6536   **
  6140   6537   ** These constants are the valid operation code parameters used
  6141   6538   ** as the first argument to [sqlite3_test_control()].
  6142   6539   **
................................................................................
  6156   6553   #define SQLITE_TESTCTRL_ASSERT                  12
  6157   6554   #define SQLITE_TESTCTRL_ALWAYS                  13
  6158   6555   #define SQLITE_TESTCTRL_RESERVE                 14
  6159   6556   #define SQLITE_TESTCTRL_OPTIMIZATIONS           15
  6160   6557   #define SQLITE_TESTCTRL_ISKEYWORD               16
  6161   6558   #define SQLITE_TESTCTRL_SCRATCHMALLOC           17
  6162   6559   #define SQLITE_TESTCTRL_LOCALTIME_FAULT         18
  6163         -#define SQLITE_TESTCTRL_EXPLAIN_STMT            19
         6560  +#define SQLITE_TESTCTRL_EXPLAIN_STMT            19  /* NOT USED */
  6164   6561   #define SQLITE_TESTCTRL_NEVER_CORRUPT           20
  6165   6562   #define SQLITE_TESTCTRL_VDBE_COVERAGE           21
  6166   6563   #define SQLITE_TESTCTRL_BYTEORDER               22
  6167   6564   #define SQLITE_TESTCTRL_ISINIT                  23
  6168         -#define SQLITE_TESTCTRL_LAST                    23
         6565  +#define SQLITE_TESTCTRL_SORTER_MMAP             24
         6566  +#define SQLITE_TESTCTRL_IMPOSTER                25
         6567  +#define SQLITE_TESTCTRL_LAST                    25
  6169   6568   
  6170   6569   /*
  6171   6570   ** CAPI3REF: SQLite Runtime Status
  6172   6571   **
  6173         -** ^This interface is used to retrieve runtime status information
         6572  +** ^These interfaces are used to retrieve runtime status information
  6174   6573   ** about the performance of SQLite, and optionally to reset various
  6175   6574   ** highwater marks.  ^The first argument is an integer code for
  6176   6575   ** the specific parameter to measure.  ^(Recognized integer codes
  6177   6576   ** are of the form [status parameters | SQLITE_STATUS_...].)^
  6178   6577   ** ^The current value of the parameter is returned into *pCurrent.
  6179   6578   ** ^The highest recorded value is returned in *pHighwater.  ^If the
  6180   6579   ** resetFlag is true, then the highest record value is reset after
  6181   6580   ** *pHighwater is written.  ^(Some parameters do not record the highest
  6182   6581   ** value.  For those parameters
  6183   6582   ** nothing is written into *pHighwater and the resetFlag is ignored.)^
  6184   6583   ** ^(Other parameters record only the highwater mark and not the current
  6185   6584   ** value.  For these latter parameters nothing is written into *pCurrent.)^
  6186   6585   **
  6187         -** ^The sqlite3_status() routine returns SQLITE_OK on success and a
  6188         -** non-zero [error code] on failure.
         6586  +** ^The sqlite3_status() and sqlite3_status64() routines return
         6587  +** SQLITE_OK on success and a non-zero [error code] on failure.
  6189   6588   **
  6190         -** This routine is threadsafe but is not atomic.  This routine can be
  6191         -** called while other threads are running the same or different SQLite
  6192         -** interfaces.  However the values returned in *pCurrent and
  6193         -** *pHighwater reflect the status of SQLite at different points in time
  6194         -** and it is possible that another thread might change the parameter
  6195         -** in between the times when *pCurrent and *pHighwater are written.
         6589  +** If either the current value or the highwater mark is too large to
         6590  +** be represented by a 32-bit integer, then the values returned by
         6591  +** sqlite3_status() are undefined.
  6196   6592   **
  6197   6593   ** See also: [sqlite3_db_status()]
  6198   6594   */
  6199         -SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
         6595  +SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
         6596  +SQLITE_API int SQLITE_STDCALL sqlite3_status64(
         6597  +  int op,
         6598  +  sqlite3_int64 *pCurrent,
         6599  +  sqlite3_int64 *pHighwater,
         6600  +  int resetFlag
         6601  +);
  6200   6602   
  6201   6603   
  6202   6604   /*
  6203   6605   ** CAPI3REF: Status Parameters
  6204   6606   ** KEYWORDS: {status parameters}
  6205   6607   **
  6206   6608   ** These integer constants designate various run-time status parameters
................................................................................
  6271   6673   ** [[SQLITE_STATUS_SCRATCH_SIZE]] ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
  6272   6674   ** <dd>This parameter records the largest memory allocation request
  6273   6675   ** handed to [scratch memory allocator].  Only the value returned in the
  6274   6676   ** *pHighwater parameter to [sqlite3_status()] is of interest.  
  6275   6677   ** The value written into the *pCurrent parameter is undefined.</dd>)^
  6276   6678   **
  6277   6679   ** [[SQLITE_STATUS_PARSER_STACK]] ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>
  6278         -** <dd>This parameter records the deepest parser stack.  It is only
         6680  +** <dd>The *pHighwater parameter records the deepest parser stack. 
         6681  +** The *pCurrent value is undefined.  The *pHighwater value is only
  6279   6682   ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^
  6280   6683   ** </dl>
  6281   6684   **
  6282   6685   ** New status parameters may be added from time to time.
  6283   6686   */
  6284   6687   #define SQLITE_STATUS_MEMORY_USED          0
  6285   6688   #define SQLITE_STATUS_PAGECACHE_USED       1
................................................................................
  6290   6693   #define SQLITE_STATUS_PARSER_STACK         6
  6291   6694   #define SQLITE_STATUS_PAGECACHE_SIZE       7
  6292   6695   #define SQLITE_STATUS_SCRATCH_SIZE         8
  6293   6696   #define SQLITE_STATUS_MALLOC_COUNT         9
  6294   6697   
  6295   6698   /*
  6296   6699   ** CAPI3REF: Database Connection Status
         6700  +** METHOD: sqlite3
  6297   6701   **
  6298   6702   ** ^This interface is used to retrieve runtime status information 
  6299   6703   ** about a single [database connection].  ^The first argument is the
  6300   6704   ** database connection object to be interrogated.  ^The second argument
  6301   6705   ** is an integer constant, taken from the set of
  6302   6706   ** [SQLITE_DBSTATUS options], that
  6303   6707   ** determines the parameter to interrogate.  The set of 
................................................................................
  6310   6714   ** reset back down to the current value.
  6311   6715   **
  6312   6716   ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
  6313   6717   ** non-zero [error code] on failure.
  6314   6718   **
  6315   6719   ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
  6316   6720   */
  6317         -SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
         6721  +SQLITE_API int SQLITE_STDCALL sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
  6318   6722   
  6319   6723   /*
  6320   6724   ** CAPI3REF: Status Parameters for database connections
  6321   6725   ** KEYWORDS: {SQLITE_DBSTATUS options}
  6322   6726   **
  6323   6727   ** These constants are the available integer "verbs" that can be passed as
  6324   6728   ** the second argument to the [sqlite3_db_status()] interface.
................................................................................
  6352   6756   ** <dd>This parameter returns the number malloc attempts that might have
  6353   6757   ** been satisfied using lookaside memory but failed due to all lookaside
  6354   6758   ** memory already being in use.
  6355   6759   ** Only the high-water value is meaningful;
  6356   6760   ** the current value is always zero.)^
  6357   6761   **
  6358   6762   ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
  6359         -** <dd>This parameter returns the approximate number of of bytes of heap
         6763  +** <dd>This parameter returns the approximate number of bytes of heap
  6360   6764   ** memory used by all pager caches associated with the database connection.)^
  6361   6765   ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
  6362   6766   **
  6363   6767   ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
  6364         -** <dd>This parameter returns the approximate number of of bytes of heap
         6768  +** <dd>This parameter returns the approximate number of bytes of heap
  6365   6769   ** memory used to store the schema for all databases associated
  6366   6770   ** with the connection - main, temp, and any [ATTACH]-ed databases.)^ 
  6367   6771   ** ^The full amount of memory used by the schemas is reported, even if the
  6368   6772   ** schema memory is shared with other database connections due to
  6369   6773   ** [shared cache mode] being enabled.
  6370   6774   ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.
  6371   6775   **
  6372   6776   ** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>
  6373         -** <dd>This parameter returns the approximate number of of bytes of heap
         6777  +** <dd>This parameter returns the approximate number of bytes of heap
  6374   6778   ** and lookaside memory used by all prepared statements associated with
  6375   6779   ** the database connection.)^
  6376   6780   ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0.
  6377   6781   ** </dd>
  6378   6782   **
  6379   6783   ** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(<dt>SQLITE_DBSTATUS_CACHE_HIT</dt>
  6380   6784   ** <dd>This parameter returns the number of pager cache hits that have
................................................................................
  6418   6822   #define SQLITE_DBSTATUS_CACHE_WRITE          9
  6419   6823   #define SQLITE_DBSTATUS_DEFERRED_FKS        10
  6420   6824   #define SQLITE_DBSTATUS_MAX                 10   /* Largest defined DBSTATUS */
  6421   6825   
  6422   6826   
  6423   6827   /*
  6424   6828   ** CAPI3REF: Prepared Statement Status
         6829  +** METHOD: sqlite3_stmt
  6425   6830   **
  6426   6831   ** ^(Each prepared statement maintains various
  6427   6832   ** [SQLITE_STMTSTATUS counters] that measure the number
  6428   6833   ** of times it has performed specific operations.)^  These counters can
  6429   6834   ** be used to monitor the performance characteristics of the prepared
  6430   6835   ** statements.  For example, if the number of table steps greatly exceeds
  6431   6836   ** the number of table searches or result rows, that would tend to indicate
................................................................................
  6439   6844   ** to be interrogated.)^
  6440   6845   ** ^The current value of the requested counter is returned.
  6441   6846   ** ^If the resetFlg is true, then the counter is reset to zero after this
  6442   6847   ** interface call returns.
  6443   6848   **
  6444   6849   ** See also: [sqlite3_status()] and [sqlite3_db_status()].
  6445   6850   */
  6446         -SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
         6851  +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
  6447   6852   
  6448   6853   /*
  6449   6854   ** CAPI3REF: Status Parameters for prepared statements
  6450   6855   ** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}
  6451   6856   **
  6452   6857   ** These preprocessor macros define integer codes that name counter
  6453   6858   ** values associated with the [sqlite3_stmt_status()] interface.
................................................................................
  6765   7170   ** an [ATTACH] statement for an attached database.
  6766   7171   ** ^The S and M arguments passed to 
  6767   7172   ** sqlite3_backup_init(D,N,S,M) identify the [database connection]
  6768   7173   ** and database name of the source database, respectively.
  6769   7174   ** ^The source and destination [database connections] (parameters S and D)
  6770   7175   ** must be different or else sqlite3_backup_init(D,N,S,M) will fail with
  6771   7176   ** an error.
         7177  +**
         7178  +** ^A call to sqlite3_backup_init() will fail, returning NULL, if 
         7179  +** there is already a read or read-write transaction open on the 
         7180  +** destination database.
  6772   7181   **
  6773   7182   ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is
  6774   7183   ** returned and an error code and error message are stored in the
  6775   7184   ** destination [database connection] D.
  6776   7185   ** ^The error code and message for the failed call to sqlite3_backup_init()
  6777   7186   ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or
  6778   7187   ** [sqlite3_errmsg16()] functions.
................................................................................
  6858   7267   ** sqlite3_backup_step() call on the same [sqlite3_backup] object, then
  6859   7268   ** sqlite3_backup_finish() returns the corresponding [error code].
  6860   7269   **
  6861   7270   ** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()
  6862   7271   ** is not a permanent error and does not affect the return value of
  6863   7272   ** sqlite3_backup_finish().
  6864   7273   **
  6865         -** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]]
         7274  +** [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]]
  6866   7275   ** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>
  6867   7276   **
  6868         -** ^Each call to sqlite3_backup_step() sets two values inside
  6869         -** the [sqlite3_backup] object: the number of pages still to be backed
  6870         -** up and the total number of pages in the source database file.
  6871         -** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces
  6872         -** retrieve these two values, respectively.
  6873         -**
  6874         -** ^The values returned by these functions are only updated by
  6875         -** sqlite3_backup_step(). ^If the source database is modified during a backup
  6876         -** operation, then the values are not updated to account for any extra
  6877         -** pages that need to be updated or the size of the source database file
  6878         -** changing.
         7277  +** ^The sqlite3_backup_remaining() routine returns the number of pages still
         7278  +** to be backed up at the conclusion of the most recent sqlite3_backup_step().
         7279  +** ^The sqlite3_backup_pagecount() routine returns the total number of pages
         7280  +** in the source database at the conclusion of the most recent
         7281  +** sqlite3_backup_step().
         7282  +** ^(The values returned by these functions are only updated by
         7283  +** sqlite3_backup_step(). If the source database is modified in a way that
         7284  +** changes the size of the source database or the number of pages remaining,
         7285  +** those changes are not reflected in the output of sqlite3_backup_pagecount()
         7286  +** and sqlite3_backup_remaining() until after the next
         7287  +** sqlite3_backup_step().)^
  6879   7288   **
  6880   7289   ** <b>Concurrent Usage of Database Handles</b>
  6881   7290   **
  6882   7291   ** ^The source [database connection] may be used by the application for other
  6883   7292   ** purposes while a backup operation is underway or being initialized.
  6884   7293   ** ^If SQLite is compiled and configured to support threadsafe database
  6885   7294   ** connections, then the source database connection may be used concurrently
................................................................................
  6904   7313   ** The [sqlite3_backup] object itself is partially threadsafe. Multiple 
  6905   7314   ** threads may safely make multiple concurrent calls to sqlite3_backup_step().
  6906   7315   ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
  6907   7316   ** APIs are not strictly speaking threadsafe. If they are invoked at the
  6908   7317   ** same time as another thread is invoking sqlite3_backup_step() it is
  6909   7318   ** possible that they return invalid values.
  6910   7319   */
  6911         -SQLITE_API sqlite3_backup *sqlite3_backup_init(
         7320  +SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init(
  6912   7321     sqlite3 *pDest,                        /* Destination database handle */
  6913   7322     const char *zDestName,                 /* Destination database name */
  6914   7323     sqlite3 *pSource,                      /* Source database handle */
  6915   7324     const char *zSourceName                /* Source database name */
  6916   7325   );
  6917         -SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);
  6918         -SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);
  6919         -SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);
  6920         -SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
         7326  +SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage);
         7327  +SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p);
         7328  +SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p);
         7329  +SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p);
  6921   7330   
  6922   7331   /*
  6923   7332   ** CAPI3REF: Unlock Notification
         7333  +** METHOD: sqlite3
  6924   7334   **
  6925   7335   ** ^When running in shared-cache mode, a database operation may fail with
  6926   7336   ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
  6927   7337   ** individual tables within the shared-cache cannot be obtained. See
  6928   7338   ** [SQLite Shared-Cache Mode] for a description of shared-cache locking. 
  6929   7339   ** ^This API may be used to register a callback that SQLite will invoke 
  6930   7340   ** when the connection currently holding the required lock relinquishes it.
................................................................................
  7029   7439   **
  7030   7440   ** One way around this problem is to check the extended error code returned
  7031   7441   ** by an sqlite3_step() call. ^(If there is a blocking connection, then the
  7032   7442   ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
  7033   7443   ** the special "DROP TABLE/INDEX" case, the extended error code is just 
  7034   7444   ** SQLITE_LOCKED.)^
  7035   7445   */
  7036         -SQLITE_API int sqlite3_unlock_notify(
         7446  +SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify(
  7037   7447     sqlite3 *pBlocked,                          /* Waiting connection */
  7038   7448     void (*xNotify)(void **apArg, int nArg),    /* Callback function to invoke */
  7039   7449     void *pNotifyArg                            /* Argument to pass to xNotify */
  7040   7450   );
  7041   7451   
  7042   7452   
  7043   7453   /*
................................................................................
  7044   7454   ** CAPI3REF: String Comparison
  7045   7455   **
  7046   7456   ** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications
  7047   7457   ** and extensions to compare the contents of two buffers containing UTF-8
  7048   7458   ** strings in a case-independent fashion, using the same definition of "case
  7049   7459   ** independence" that SQLite uses internally when comparing identifiers.
  7050   7460   */
  7051         -SQLITE_API int sqlite3_stricmp(const char *, const char *);
  7052         -SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
         7461  +SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *, const char *);
         7462  +SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *, const char *, int);
  7053   7463   
  7054   7464   /*
  7055   7465   ** CAPI3REF: String Globbing
  7056   7466   *
  7057         -** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches
  7058         -** the glob pattern P, and it returns non-zero if string X does not match
  7059         -** the glob pattern P.  ^The definition of glob pattern matching used in
         7467  +** ^The [sqlite3_strglob(P,X)] interface returns zero if and only if
         7468  +** string X matches the [GLOB] pattern P.
         7469  +** ^The definition of [GLOB] pattern matching used in
  7060   7470   ** [sqlite3_strglob(P,X)] is the same as for the "X GLOB P" operator in the
  7061         -** SQL dialect used by SQLite.  ^The sqlite3_strglob(P,X) function is case
  7062         -** sensitive.
         7471  +** SQL dialect understood by SQLite.  ^The [sqlite3_strglob(P,X)] function
         7472  +** is case sensitive.
         7473  +**
         7474  +** Note that this routine returns zero on a match and non-zero if the strings
         7475  +** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
         7476  +**
         7477  +** See also: [sqlite3_strlike()].
         7478  +*/
         7479  +SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlob, const char *zStr);
         7480  +
         7481  +/*
         7482  +** CAPI3REF: String LIKE Matching
         7483  +*
         7484  +** ^The [sqlite3_strlike(P,X,E)] interface returns zero if and only if
         7485  +** string X matches the [LIKE] pattern P with escape character E.
         7486  +** ^The definition of [LIKE] pattern matching used in
         7487  +** [sqlite3_strlike(P,X,E)] is the same as for the "X LIKE P ESCAPE E"
         7488  +** operator in the SQL dialect understood by SQLite.  ^For "X LIKE P" without
         7489  +** the ESCAPE clause, set the E parameter of [sqlite3_strlike(P,X,E)] to 0.
         7490  +** ^As with the LIKE operator, the [sqlite3_strlike(P,X,E)] function is case
         7491  +** insensitive - equivalent upper and lower case ASCII characters match
         7492  +** one another.
         7493  +**
         7494  +** ^The [sqlite3_strlike(P,X,E)] function matches Unicode characters, though
         7495  +** only ASCII characters are case folded.
  7063   7496   **
  7064   7497   ** Note that this routine returns zero on a match and non-zero if the strings
  7065   7498   ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
         7499  +**
         7500  +** See also: [sqlite3_strglob()].
  7066   7501   */
  7067         -SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);
         7502  +SQLITE_API int SQLITE_STDCALL sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc);
  7068   7503   
  7069   7504   /*
  7070   7505   ** CAPI3REF: Error Logging Interface
  7071   7506   **
  7072   7507   ** ^The [sqlite3_log()] interface writes a message into the [error log]
  7073   7508   ** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()].
  7074   7509   ** ^If logging is enabled, the zFormat string and subsequent arguments are
................................................................................
  7083   7518   **
  7084   7519   ** To avoid deadlocks and other threading problems, the sqlite3_log() routine
  7085   7520   ** will not use dynamically allocated memory.  The log message is stored in
  7086   7521   ** a fixed-length buffer on the stack.  If the log message is longer than
  7087   7522   ** a few hundred characters, it will be truncated to the length of the
  7088   7523   ** buffer.
  7089   7524   */
  7090         -SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
         7525  +SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...);
  7091   7526   
  7092   7527   /*
  7093   7528   ** CAPI3REF: Write-Ahead Log Commit Hook
         7529  +** METHOD: sqlite3
  7094   7530   **
  7095   7531   ** ^The [sqlite3_wal_hook()] function is used to register a callback that
  7096         -** will be invoked each time a database connection commits data to a
  7097         -** [write-ahead log] (i.e. whenever a transaction is committed in
  7098         -** [journal_mode | journal_mode=WAL mode]). 
         7532  +** is invoked each time data is committed to a database in wal mode.
  7099   7533   **
  7100         -** ^The callback is invoked by SQLite after the commit has taken place and 
  7101         -** the associated write-lock on the database released, so the implementation 
         7534  +** ^(The callback is invoked by SQLite after the commit has taken place and 
         7535  +** the associated write-lock on the database released)^, so the implementation 
  7102   7536   ** may read, write or [checkpoint] the database as required.
  7103   7537   **
  7104   7538   ** ^The first parameter passed to the callback function when it is invoked
  7105   7539   ** is a copy of the third parameter passed to sqlite3_wal_hook() when
  7106   7540   ** registering the callback. ^The second is a copy of the database handle.
  7107   7541   ** ^The third parameter is the name of the database that was written to -
  7108   7542   ** either "main" or the name of an [ATTACH]-ed database. ^The fourth parameter
................................................................................
  7118   7552   ** are undefined.
  7119   7553   **
  7120   7554   ** A single database handle may have at most a single write-ahead log callback 
  7121   7555   ** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any
  7122   7556   ** previously registered write-ahead log callback. ^Note that the
  7123   7557   ** [sqlite3_wal_autocheckpoint()] interface and the
  7124   7558   ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
  7125         -** those overwrite any prior [sqlite3_wal_hook()] settings.
         7559  +** overwrite any prior [sqlite3_wal_hook()] settings.
  7126   7560   */
  7127         -SQLITE_API void *sqlite3_wal_hook(
         7561  +SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
  7128   7562     sqlite3*, 
  7129   7563     int(*)(void *,sqlite3*,const char*,int),
  7130   7564     void*
  7131   7565   );
  7132   7566   
  7133   7567   /*
  7134   7568   ** CAPI3REF: Configure an auto-checkpoint
         7569  +** METHOD: sqlite3
  7135   7570   **
  7136   7571   ** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around
  7137   7572   ** [sqlite3_wal_hook()] that causes any database on [database connection] D
  7138   7573   ** to automatically [checkpoint]
  7139   7574   ** after committing a transaction if there are N or
  7140   7575   ** more frames in the [write-ahead log] file.  ^Passing zero or 
  7141   7576   ** a negative value as the nFrame parameter disables automatic
................................................................................
  7154   7589   **
  7155   7590   ** ^Every new [database connection] defaults to having the auto-checkpoint
  7156   7591   ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]
  7157   7592   ** pages.  The use of this interface
  7158   7593   ** is only necessary if the default setting is found to be suboptimal
  7159   7594   ** for a particular application.
  7160   7595   */
  7161         -SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
         7596  +SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
  7162   7597   
  7163   7598   /*
  7164   7599   ** CAPI3REF: Checkpoint a database
         7600  +** METHOD: sqlite3
  7165   7601   **
  7166         -** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X
  7167         -** on [database connection] D to be [checkpointed].  ^If X is NULL or an
  7168         -** empty string, then a checkpoint is run on all databases of
  7169         -** connection D.  ^If the database connection D is not in
  7170         -** [WAL | write-ahead log mode] then this interface is a harmless no-op.
  7171         -** ^The [sqlite3_wal_checkpoint(D,X)] interface initiates a
  7172         -** [sqlite3_wal_checkpoint_v2|PASSIVE] checkpoint.
  7173         -** Use the [sqlite3_wal_checkpoint_v2()] interface to get a FULL
  7174         -** or RESET checkpoint.
         7602  +** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
         7603  +** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^
  7175   7604   **
  7176         -** ^The [wal_checkpoint pragma] can be used to invoke this interface
  7177         -** from SQL.  ^The [sqlite3_wal_autocheckpoint()] interface and the
  7178         -** [wal_autocheckpoint pragma] can be used to cause this interface to be
  7179         -** run whenever the WAL reaches a certain size threshold.
         7605  +** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the 
         7606  +** [write-ahead log] for database X on [database connection] D to be
         7607  +** transferred into the database file and for the write-ahead log to
         7608  +** be reset.  See the [checkpointing] documentation for addition
         7609  +** information.
  7180   7610   **
  7181         -** See also: [sqlite3_wal_checkpoint_v2()]
         7611  +** This interface used to be the only way to cause a checkpoint to
         7612  +** occur.  But then the newer and more powerful [sqlite3_wal_checkpoint_v2()]
         7613  +** interface was added.  This interface is retained for backwards
         7614  +** compatibility and as a convenience for applications that need to manually
         7615  +** start a callback but which do not need the full power (and corresponding
         7616  +** complication) of [sqlite3_wal_checkpoint_v2()].
  7182   7617   */
  7183         -SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
         7618  +SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
  7184   7619   
  7185   7620   /*
  7186   7621   ** CAPI3REF: Checkpoint a database
         7622  +** METHOD: sqlite3
  7187   7623   **
  7188         -** Run a checkpoint operation on WAL database zDb attached to database 
  7189         -** handle db. The specific operation is determined by the value of the 
  7190         -** eMode parameter:
         7624  +** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
         7625  +** operation on database X of [database connection] D in mode M.  Status
         7626  +** information is written back into integers pointed to by L and C.)^
         7627  +** ^(The M parameter must be a valid [checkpoint mode]:)^
  7191   7628   **
  7192   7629   ** <dl>
  7193   7630   ** <dt>SQLITE_CHECKPOINT_PASSIVE<dd>
  7194         -**   Checkpoint as many frames as possible without waiting for any database 
  7195         -**   readers or writers to finish. Sync the db file if all frames in the log
  7196         -**   are checkpointed. This mode is the same as calling 
  7197         -**   sqlite3_wal_checkpoint(). The [sqlite3_busy_handler|busy-handler callback]
  7198         -**   is never invoked.
         7631  +**   ^Checkpoint as many frames as possible without waiting for any database 
         7632  +**   readers or writers to finish, then sync the database file if all frames 
         7633  +**   in the log were checkpointed. ^The [busy-handler callback]
         7634  +**   is never invoked in the SQLITE_CHECKPOINT_PASSIVE mode.  
         7635  +**   ^On the other hand, passive mode might leave the checkpoint unfinished
         7636  +**   if there are concurrent readers or writers.
  7199   7637   **
  7200   7638   ** <dt>SQLITE_CHECKPOINT_FULL<dd>
  7201         -**   This mode blocks (it invokes the
         7639  +**   ^This mode blocks (it invokes the
  7202   7640   **   [sqlite3_busy_handler|busy-handler callback]) until there is no
  7203   7641   **   database writer and all readers are reading from the most recent database
  7204         -**   snapshot. It then checkpoints all frames in the log file and syncs the
  7205         -**   database file. This call blocks database writers while it is running,
  7206         -**   but not database readers.
         7642  +**   snapshot. ^It then checkpoints all frames in the log file and syncs the
         7643  +**   database file. ^This mode blocks new database writers while it is pending,
         7644  +**   but new database readers are allowed to continue unimpeded.
  7207   7645   **
  7208   7646   ** <dt>SQLITE_CHECKPOINT_RESTART<dd>
  7209         -**   This mode works the same way as SQLITE_CHECKPOINT_FULL, except after 
  7210         -**   checkpointing the log file it blocks (calls the 
  7211         -**   [sqlite3_busy_handler|busy-handler callback])
  7212         -**   until all readers are reading from the database file only. This ensures 
  7213         -**   that the next client to write to the database file restarts the log file 
  7214         -**   from the beginning. This call blocks database writers while it is running,
  7215         -**   but not database readers.
         7647  +**   ^This mode works the same way as SQLITE_CHECKPOINT_FULL with the addition
         7648  +**   that after checkpointing the log file it blocks (calls the 
         7649  +**   [busy-handler callback])
         7650  +**   until all readers are reading from the database file only. ^This ensures 
         7651  +**   that the next writer will restart the log file from the beginning.
         7652  +**   ^Like SQLITE_CHECKPOINT_FULL, this mode blocks new
         7653  +**   database writer attempts while it is pending, but does not impede readers.
         7654  +**
         7655  +** <dt>SQLITE_CHECKPOINT_TRUNCATE<dd>
         7656  +**   ^This mode works the same way as SQLITE_CHECKPOINT_RESTART with the
         7657  +**   addition that it also truncates the log file to zero bytes just prior
         7658  +**   to a successful return.
  7216   7659   ** </dl>
  7217   7660   **
  7218         -** If pnLog is not NULL, then *pnLog is set to the total number of frames in
  7219         -** the log file before returning. If pnCkpt is not NULL, then *pnCkpt is set to
  7220         -** the total number of checkpointed frames (including any that were already
  7221         -** checkpointed when this function is called). *pnLog and *pnCkpt may be
  7222         -** populated even if sqlite3_wal_checkpoint_v2() returns other than SQLITE_OK.
  7223         -** If no values are available because of an error, they are both set to -1
  7224         -** before returning to communicate this to the caller.
         7661  +** ^If pnLog is not NULL, then *pnLog is set to the total number of frames in
         7662  +** the log file or to -1 if the checkpoint could not run because
         7663  +** of an error or because the database is not in [WAL mode]. ^If pnCkpt is not
         7664  +** NULL,then *pnCkpt is set to the total number of checkpointed frames in the
         7665  +** log file (including any that were already checkpointed before the function
         7666  +** was called) or to -1 if the checkpoint could not run due to an error or
         7667  +** because the database is not in WAL mode. ^Note that upon successful
         7668  +** completion of an SQLITE_CHECKPOINT_TRUNCATE, the log file will have been
         7669  +** truncated to zero bytes and so both *pnLog and *pnCkpt will be set to zero.
  7225   7670   **
  7226         -** All calls obtain an exclusive "checkpoint" lock on the database file. If
         7671  +** ^All calls obtain an exclusive "checkpoint" lock on the database file. ^If
  7227   7672   ** any other process is running a checkpoint operation at the same time, the 
  7228         -** lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a 
         7673  +** lock cannot be obtained and SQLITE_BUSY is returned. ^Even if there is a 
  7229   7674   ** busy-handler configured, it will not be invoked in this case.
  7230   7675   **
  7231         -** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive 
  7232         -** "writer" lock on the database file. If the writer lock cannot be obtained
  7233         -** immediately, and a busy-handler is configured, it is invoked and the writer
  7234         -** lock retried until either the busy-handler returns 0 or the lock is
  7235         -** successfully obtained. The busy-handler is also invoked while waiting for
  7236         -** database readers as described above. If the busy-handler returns 0 before
         7676  +** ^The SQLITE_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the 
         7677  +** exclusive "writer" lock on the database file. ^If the writer lock cannot be
         7678  +** obtained immediately, and a busy-handler is configured, it is invoked and
         7679  +** the writer lock retried until either the busy-handler returns 0 or the lock
         7680  +** is successfully obtained. ^The busy-handler is also invoked while waiting for
         7681  +** database readers as described above. ^If the busy-handler returns 0 before
  7237   7682   ** the writer lock is obtained or while waiting for database readers, the
  7238   7683   ** checkpoint operation proceeds from that point in the same way as 
  7239   7684   ** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible 
  7240         -** without blocking any further. SQLITE_BUSY is returned in this case.
         7685  +** without blocking any further. ^SQLITE_BUSY is returned in this case.
  7241   7686   **
  7242         -** If parameter zDb is NULL or points to a zero length string, then the
  7243         -** specified operation is attempted on all WAL databases. In this case the
  7244         -** values written to output parameters *pnLog and *pnCkpt are undefined. If 
         7687  +** ^If parameter zDb is NULL or points to a zero length string, then the
         7688  +** specified operation is attempted on all WAL databases [attached] to 
         7689  +** [database connection] db.  In this case the
         7690  +** values written to output parameters *pnLog and *pnCkpt are undefined. ^If 
  7245   7691   ** an SQLITE_BUSY error is encountered when processing one or more of the 
  7246   7692   ** attached WAL databases, the operation is still attempted on any remaining 
  7247         -** attached databases and SQLITE_BUSY is returned to the caller. If any other 
         7693  +** attached databases and SQLITE_BUSY is returned at the end. ^If any other 
  7248   7694   ** error occurs while processing an attached database, processing is abandoned 
  7249         -** and the error code returned to the caller immediately. If no error 
         7695  +** and the error code is returned to the caller immediately. ^If no error 
  7250   7696   ** (SQLITE_BUSY or otherwise) is encountered while processing the attached 
  7251   7697   ** databases, SQLITE_OK is returned.
  7252   7698   **
  7253         -** If database zDb is the name of an attached database that is not in WAL
  7254         -** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. If
         7699  +** ^If database zDb is the name of an attached database that is not in WAL
         7700  +** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. ^If
  7255   7701   ** zDb is not NULL (or a zero length string) and is not the name of any
  7256   7702   ** attached database, SQLITE_ERROR is returned to the caller.
         7703  +**
         7704  +** ^Unless it returns SQLITE_MISUSE,
         7705  +** the sqlite3_wal_checkpoint_v2() interface
         7706  +** sets the error information that is queried by
         7707  +** [sqlite3_errcode()] and [sqlite3_errmsg()].
         7708  +**
         7709  +** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
         7710  +** from SQL.
  7257   7711   */
  7258         -SQLITE_API int sqlite3_wal_checkpoint_v2(
         7712  +SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
  7259   7713     sqlite3 *db,                    /* Database handle */
  7260   7714     const char *zDb,                /* Name of attached database (or NULL) */
  7261   7715     int eMode,                      /* SQLITE_CHECKPOINT_* value */
  7262   7716     int *pnLog,                     /* OUT: Size of WAL log in frames */
  7263   7717     int *pnCkpt                     /* OUT: Total number of frames checkpointed */
  7264   7718   );
  7265   7719   
  7266   7720   /*
  7267         -** CAPI3REF: Checkpoint operation parameters
         7721  +** CAPI3REF: Checkpoint Mode Values
         7722  +** KEYWORDS: {checkpoint mode}
  7268   7723   **
  7269         -** These constants can be used as the 3rd parameter to
  7270         -** [sqlite3_wal_checkpoint_v2()].  See the [sqlite3_wal_checkpoint_v2()]
  7271         -** documentation for additional information about the meaning and use of
  7272         -** each of these values.
         7724  +** These constants define all valid values for the "checkpoint mode" passed
         7725  +** as the third parameter to the [sqlite3_wal_checkpoint_v2()] interface.
         7726  +** See the [sqlite3_wal_checkpoint_v2()] documentation for details on the
         7727  +** meaning of each of these checkpoint modes.
  7273   7728   */
  7274         -#define SQLITE_CHECKPOINT_PASSIVE 0
  7275         -#define SQLITE_CHECKPOINT_FULL    1
  7276         -#define SQLITE_CHECKPOINT_RESTART 2
         7729  +#define SQLITE_CHECKPOINT_PASSIVE  0  /* Do as much as possible w/o blocking */
         7730  +#define SQLITE_CHECKPOINT_FULL     1  /* Wait for writers, then checkpoint */
         7731  +#define SQLITE_CHECKPOINT_RESTART  2  /* Like FULL but wait for for readers */
         7732  +#define SQLITE_CHECKPOINT_TRUNCATE 3  /* Like RESTART but also truncate WAL */
  7277   7733   
  7278   7734   /*
  7279   7735   ** CAPI3REF: Virtual Table Interface Configuration
  7280   7736   **
  7281   7737   ** This function may be called by either the [xConnect] or [xCreate] method
  7282   7738   ** of a [virtual table] implementation to configure
  7283   7739   ** various facets of the virtual table interface.
................................................................................
  7285   7741   ** If this interface is invoked outside the context of an xConnect or
  7286   7742   ** xCreate virtual table method then the behavior is undefined.
  7287   7743   **
  7288   7744   ** At present, there is only one option that may be configured using
  7289   7745   ** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].)  Further options
  7290   7746   ** may be added in the future.
  7291   7747   */
  7292         -SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
         7748  +SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3*, int op, ...);
  7293   7749   
  7294   7750   /*
  7295   7751   ** CAPI3REF: Virtual Table Configuration Options
  7296   7752   **
  7297   7753   ** These macros define the various options to the
  7298   7754   ** [sqlite3_vtab_config()] interface that [virtual table] implementations
  7299   7755   ** can use to customize and optimize their behavior.
................................................................................
  7338   7794   ** This function may only be called from within a call to the [xUpdate] method
  7339   7795   ** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The
  7340   7796   ** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],
  7341   7797   ** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode
  7342   7798   ** of the SQL statement that triggered the call to the [xUpdate] method of the
  7343   7799   ** [virtual table].
  7344   7800   */
  7345         -SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
         7801  +SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *);
  7346   7802   
  7347   7803   /*
  7348   7804   ** CAPI3REF: Conflict resolution modes
  7349   7805   ** KEYWORDS: {conflict resolution mode}
  7350   7806   **
  7351   7807   ** These constants are returned by [sqlite3_vtab_on_conflict()] to
  7352   7808   ** inform a [virtual table] implementation what the [ON CONFLICT] mode
................................................................................
  7358   7814   */
  7359   7815   #define SQLITE_ROLLBACK 1
  7360   7816   /* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */
  7361   7817   #define SQLITE_FAIL     3
  7362   7818   /* #define SQLITE_ABORT 4  // Also an error code */
  7363   7819   #define SQLITE_REPLACE  5
  7364   7820   
         7821  +/*
         7822  +** CAPI3REF: Prepared Statement Scan Status Opcodes
         7823  +** KEYWORDS: {scanstatus options}
         7824  +**
         7825  +** The following constants can be used for the T parameter to the
         7826  +** [sqlite3_stmt_scanstatus(S,X,T,V)] interface.  Each constant designates a
         7827  +** different metric for sqlite3_stmt_scanstatus() to return.
         7828  +**
         7829  +** When the value returned to V is a string, space to hold that string is
         7830  +** managed by the prepared statement S and will be automatically freed when
         7831  +** S is finalized.
         7832  +**
         7833  +** <dl>
         7834  +** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>
         7835  +** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be
         7836  +** set to the total number of times that the X-th loop has run.</dd>
         7837  +**
         7838  +** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt>
         7839  +** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set
         7840  +** to the total number of rows examined by all iterations of the X-th loop.</dd>
         7841  +**
         7842  +** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>
         7843  +** <dd>^The "double" variable pointed to by the T parameter will be set to the
         7844  +** query planner's estimate for the average number of rows output from each
         7845  +** iteration of the X-th loop.  If the query planner's estimates was accurate,
         7846  +** then this value will approximate the quotient NVISIT/NLOOP and the
         7847  +** product of this value for all prior loops with the same SELECTID will
         7848  +** be the NLOOP value for the current loop.
         7849  +**
         7850  +** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>
         7851  +** <dd>^The "const char *" variable pointed to by the T parameter will be set
         7852  +** to a zero-terminated UTF-8 string containing the name of the index or table
         7853  +** used for the X-th loop.
         7854  +**
         7855  +** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>
         7856  +** <dd>^The "const char *" variable pointed to by the T parameter will be set
         7857  +** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]
         7858  +** description for the X-th loop.
         7859  +**
         7860  +** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt>
         7861  +** <dd>^The "int" variable pointed to by the T parameter will be set to the
         7862  +** "select-id" for the X-th loop.  The select-id identifies which query or
         7863  +** subquery the loop is part of.  The main query has a select-id of zero.
         7864  +** The select-id is the same value as is output in the first column
         7865  +** of an [EXPLAIN QUERY PLAN] query.
         7866  +** </dl>
         7867  +*/
         7868  +#define SQLITE_SCANSTAT_NLOOP    0
         7869  +#define SQLITE_SCANSTAT_NVISIT   1
         7870  +#define SQLITE_SCANSTAT_EST      2
         7871  +#define SQLITE_SCANSTAT_NAME     3
         7872  +#define SQLITE_SCANSTAT_EXPLAIN  4
         7873  +#define SQLITE_SCANSTAT_SELECTID 5
  7365   7874   
         7875  +/*
         7876  +** CAPI3REF: Prepared Statement Scan Status
         7877  +** METHOD: sqlite3_stmt
         7878  +**
         7879  +** This interface returns information about the predicted and measured
         7880  +** performance for pStmt.  Advanced applications can use this
         7881  +** interface to compare the predicted and the measured performance and
         7882  +** issue warnings and/or rerun [ANALYZE] if discrepancies are found.
         7883  +**
         7884  +** Since this interface is expected to be rarely used, it is only
         7885  +** available if SQLite is compiled using the [SQLITE_ENABLE_STMT_SCANSTATUS]
         7886  +** compile-time option.
         7887  +**
         7888  +** The "iScanStatusOp" parameter determines which status information to return.
         7889  +** The "iScanStatusOp" must be one of the [scanstatus options] or the behavior
         7890  +** of this interface is undefined.
         7891  +** ^The requested measurement is written into a variable pointed to by
         7892  +** the "pOut" parameter.
         7893  +** Parameter "idx" identifies the specific loop to retrieve statistics for.
         7894  +** Loops are numbered starting from zero. ^If idx is out of range - less than
         7895  +** zero or greater than or equal to the total number of loops used to implement
         7896  +** the statement - a non-zero value is returned and the variable that pOut
         7897  +** points to is unchanged.
         7898  +**
         7899  +** ^Statistics might not be available for all loops in all statements. ^In cases
         7900  +** where there exist loops with no available statistics, this function behaves
         7901  +** as if the loop did not exist - it returns non-zero and leave the variable
         7902  +** that pOut points to unchanged.
         7903  +**
         7904  +** See also: [sqlite3_stmt_scanstatus_reset()]
         7905  +*/
         7906  +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_scanstatus(
         7907  +  sqlite3_stmt *pStmt,      /* Prepared statement for which info desired */
         7908  +  int idx,                  /* Index of loop to report on */
         7909  +  int iScanStatusOp,        /* Information desired.  SQLITE_SCANSTAT_* */
         7910  +  void *pOut                /* Result written here */
         7911  +);     
         7912  +
         7913  +/*
         7914  +** CAPI3REF: Zero Scan-Status Counters
         7915  +** METHOD: sqlite3_stmt
         7916  +**
         7917  +** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.
         7918  +**
         7919  +** This API is only available if the library is built with pre-processor
         7920  +** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.
         7921  +*/
         7922  +SQLITE_API void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
         7923  +
         7924  +/*
         7925  +** CAPI3REF: Flush caches to disk mid-transaction
         7926  +**
         7927  +** ^If a write-transaction is open on [database connection] D when the
         7928  +** [sqlite3_db_cacheflush(D)] interface invoked, any dirty
         7929  +** pages in the pager-cache that are not currently in use are written out 
         7930  +** to disk. A dirty page may be in use if a database cursor created by an
         7931  +** active SQL statement is reading from it, or if it is page 1 of a database
         7932  +** file (page 1 is always "in use").  ^The [sqlite3_db_cacheflush(D)]
         7933  +** interface flushes caches for all schemas - "main", "temp", and
         7934  +** any [attached] databases.
         7935  +**
         7936  +** ^If this function needs to obtain extra database locks before dirty pages 
         7937  +** can be flushed to disk, it does so. ^If those locks cannot be obtained 
         7938  +** immediately and there is a busy-handler callback configured, it is invoked
         7939  +** in the usual manner. ^If the required lock still cannot be obtained, then
         7940  +** the database is skipped and an attempt made to flush any dirty pages
         7941  +** belonging to the next (if any) database. ^If any databases are skipped
         7942  +** because locks cannot be obtained, but no other error occurs, this
         7943  +** function returns SQLITE_BUSY.
         7944  +**
         7945  +** ^If any other error occurs while flushing dirty pages to disk (for
         7946  +** example an IO error or out-of-memory condition), then processing is
         7947  +** abandoned and an SQLite [error code] is returned to the caller immediately.
         7948  +**
         7949  +** ^Otherwise, if no error occurs, [sqlite3_db_cacheflush()] returns SQLITE_OK.
         7950  +**
         7951  +** ^This function does not set the database handle error code or message
         7952  +** returned by the [sqlite3_errcode()] and [sqlite3_errmsg()] functions.
         7953  +*/
         7954  +SQLITE_API int SQLITE_STDCALL sqlite3_db_cacheflush(sqlite3*);
         7955  +
         7956  +/*
         7957  +** CAPI3REF: The pre-update hook.
         7958  +**
         7959  +** ^These interfaces are only available if SQLite is compiled using the
         7960  +** [SQLITE_ENABLE_PREUPDATE_HOOK] compile-time option.
         7961  +**
         7962  +** ^The [sqlite3_preupdate_hook()] interface registers a callback function
         7963  +** that is invoked prior to each [INSERT], [UPDATE], and [DELETE] operation
         7964  +** on a [rowid table].
         7965  +** ^At most one preupdate hook may be registered at a time on a single
         7966  +** [database connection]; each call to [sqlite3_preupdate_hook()] overrides
         7967  +** the previous setting.
         7968  +** ^The preupdate hook is disabled by invoking [sqlite3_preupdate_hook()]
         7969  +** with a NULL pointer as the second parameter.
         7970  +** ^The third parameter to [sqlite3_preupdate_hook()] is passed through as
         7971  +** the first parameter to callbacks.
         7972  +**
         7973  +** ^The preupdate hook only fires for changes to [rowid tables]; the preupdate
         7974  +** hook is not invoked for changes to [virtual tables] or [WITHOUT ROWID]
         7975  +** tables.
         7976  +**
         7977  +** ^The second parameter to the preupdate callback is a pointer to
         7978  +** the [database connection] that registered the preupdate hook.
         7979  +** ^The third parameter to the preupdate callback is one of the constants
         7980  +** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to indentify the
         7981  +** kind of update operation that is about to occur.
         7982  +** ^(The fourth parameter to the preupdate callback is the name of the
         7983  +** database within the database connection that is being modified.  This
         7984  +** will be "main" for the main database or "temp" for TEMP tables or 
         7985  +** the name given after the AS keyword in the [ATTACH] statement for attached
         7986  +** databases.)^
         7987  +** ^The fifth parameter to the preupdate callback is the name of the
         7988  +** table that is being modified.
         7989  +** ^The sixth parameter to the preupdate callback is the initial [rowid] of the
         7990  +** row being changes for SQLITE_UPDATE and SQLITE_DELETE changes and is
         7991  +** undefined for SQLITE_INSERT changes.
         7992  +** ^The seventh parameter to the preupdate callback is the final [rowid] of
         7993  +** the row being changed for SQLITE_UPDATE and SQLITE_INSERT changes and is
         7994  +** undefined for SQLITE_DELETE changes.
         7995  +**
         7996  +** The [sqlite3_preupdate_old()], [sqlite3_preupdate_new()],
         7997  +** [sqlite3_preupdate_count()], and [sqlite3_preupdate_depth()] interfaces
         7998  +** provide additional information about a preupdate event. These routines
         7999  +** may only be called from within a preupdate callback.  Invoking any of
         8000  +** these routines from outside of a preupdate callback or with a
         8001  +** [database connection] pointer that is different from the one supplied
         8002  +** to the preupdate callback results in undefined and probably undesirable
         8003  +** behavior.
         8004  +**
         8005  +** ^The [sqlite3_preupdate_count(D)] interface returns the number of columns
         8006  +** in the row that is being inserted, updated, or deleted.
         8007  +**
         8008  +** ^The [sqlite3_preupdate_old(D,N,P)] interface writes into P a pointer to
         8009  +** a [protected sqlite3_value] that contains the value of the Nth column of
         8010  +** the table row before it is updated.  The N parameter must be between 0
         8011  +** and one less than the number of columns or the behavior will be
         8012  +** undefined. This must only be used within SQLITE_UPDATE and SQLITE_DELETE
         8013  +** preupdate callbacks; if it is used by an SQLITE_INSERT callback then the
         8014  +** behavior is undefined.  The [sqlite3_value] that P points to
         8015  +** will be destroyed when the preupdate callback returns.
         8016  +**
         8017  +** ^The [sqlite3_preupdate_new(D,N,P)] interface writes into P a pointer to
         8018  +** a [protected sqlite3_value] that contains the value of the Nth column of
         8019  +** the table row after it is updated.  The N parameter must be between 0
         8020  +** and one less than the number of columns or the behavior will be
         8021  +** undefined. This must only be used within SQLITE_INSERT and SQLITE_UPDATE
         8022  +** preupdate callbacks; if it is used by an SQLITE_DELETE callback then the
         8023  +** behavior is undefined.  The [sqlite3_value] that P points to
         8024  +** will be destroyed when the preupdate callback returns.
         8025  +**
         8026  +** ^The [sqlite3_preupdate_depth(D)] interface returns 0 if the preupdate
         8027  +** callback was invoked as a result of a direct insert, update, or delete
         8028  +** operation; or 1 for inserts, updates, or deletes invoked by top-level 
         8029  +** triggers; or 2 for changes resulting from triggers called by top-level
         8030  +** triggers; and so forth.
         8031  +**
         8032  +** See also:  [sqlite3_update_hook()]
         8033  +*/
         8034  +SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_preupdate_hook(
         8035  +  sqlite3 *db,
         8036  +  void(*xPreUpdate)(
         8037  +    void *pCtx,                   /* Copy of third arg to preupdate_hook() */
         8038  +    sqlite3 *db,                  /* Database handle */
         8039  +    int op,                       /* SQLITE_UPDATE, DELETE or INSERT */
         8040  +    char const *zDb,              /* Database name */
         8041  +    char const *zName,            /* Table name */
         8042  +    sqlite3_int64 iKey1,          /* Rowid of row about to be deleted/updated */
         8043  +    sqlite3_int64 iKey2           /* New rowid value (for a rowid UPDATE) */
         8044  +  ),
         8045  +  void*
         8046  +);
         8047  +SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **);
         8048  +SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_preupdate_count(sqlite3 *);
         8049  +SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_preupdate_depth(sqlite3 *);
         8050  +SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **);
         8051  +
         8052  +/*
         8053  +** CAPI3REF: Low-level system error code
         8054  +**
         8055  +** ^Attempt to return the underlying operating system error code or error
         8056  +** number that caused the most recent I/O error or failure to open a file.
         8057  +** The return value is OS-dependent.  For example, on unix systems, after
         8058  +** [sqlite3_open_v2()] returns [SQLITE_CANTOPEN], this interface could be
         8059  +** called to get back the underlying "errno" that caused the problem, such
         8060  +** as ENOSPC, EAUTH, EISDIR, and so forth.  
         8061  +*/
         8062  +SQLITE_API int SQLITE_STDCALL sqlite3_system_errno(sqlite3*);
         8063  +
         8064  +/*
         8065  +** CAPI3REF: Database Snapshot
         8066  +** KEYWORDS: {snapshot}
         8067  +** EXPERIMENTAL
         8068  +**
         8069  +** An instance of the snapshot object records the state of a [WAL mode]
         8070  +** database for some specific point in history.
         8071  +**
         8072  +** In [WAL mode], multiple [database connections] that are open on the
         8073  +** same database file can each be reading a different historical version
         8074  +** of the database file.  When a [database connection] begins a read
         8075  +** transaction, that connection sees an unchanging copy of the database
         8076  +** as it existed for the point in time when the transaction first started.
         8077  +** Subsequent changes to the database from other connections are not seen
         8078  +** by the reader until a new read transaction is started.
         8079  +**
         8080  +** The sqlite3_snapshot object records state information about an historical
         8081  +** version of the database file so that it is possible to later open a new read
         8082  +** transaction that sees that historical version of the database rather than
         8083  +** the most recent version.
         8084  +**
         8085  +** The constructor for this object is [sqlite3_snapshot_get()].  The
         8086  +** [sqlite3_snapshot_open()] method causes a fresh read transaction to refer
         8087  +** to an historical snapshot (if possible).  The destructor for 
         8088  +** sqlite3_snapshot objects is [sqlite3_snapshot_free()].
         8089  +*/
         8090  +typedef struct sqlite3_snapshot sqlite3_snapshot;
         8091  +
         8092  +/*
         8093  +** CAPI3REF: Record A Database Snapshot
         8094  +** EXPERIMENTAL
         8095  +**
         8096  +** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a
         8097  +** new [sqlite3_snapshot] object that records the current state of
         8098  +** schema S in database connection D.  ^On success, the
         8099  +** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
         8100  +** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.
         8101  +** ^If schema S of [database connection] D is not a [WAL mode] database
         8102  +** that is in a read transaction, then [sqlite3_snapshot_get(D,S,P)]
         8103  +** leaves the *P value unchanged and returns an appropriate [error code].
         8104  +**
         8105  +** The [sqlite3_snapshot] object returned from a successful call to
         8106  +** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()]
         8107  +** to avoid a memory leak.
         8108  +**
         8109  +** The [sqlite3_snapshot_get()] interface is only available when the
         8110  +** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
         8111  +*/
         8112  +SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_snapshot_get(
         8113  +  sqlite3 *db,
         8114  +  const char *zSchema,
         8115  +  sqlite3_snapshot **ppSnapshot
         8116  +);
         8117  +
         8118  +/*
         8119  +** CAPI3REF: Start a read transaction on an historical snapshot
         8120  +** EXPERIMENTAL
         8121  +**
         8122  +** ^The [sqlite3_snapshot_open(D,S,P)] interface starts a
         8123  +** read transaction for schema S of
         8124  +** [database connection] D such that the read transaction
         8125  +** refers to historical [snapshot] P, rather than the most
         8126  +** recent change to the database.
         8127  +** ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK on success
         8128  +** or an appropriate [error code] if it fails.
         8129  +**
         8130  +** ^In order to succeed, a call to [sqlite3_snapshot_open(D,S,P)] must be
         8131  +** the first operation following the [BEGIN] that takes the schema S
         8132  +** out of [autocommit mode].
         8133  +** ^In other words, schema S must not currently be in
         8134  +** a transaction for [sqlite3_snapshot_open(D,S,P)] to work, but the
         8135  +** database connection D must be out of [autocommit mode].
         8136  +** ^A [snapshot] will fail to open if it has been overwritten by a
         8137  +** [checkpoint].
         8138  +** ^(A call to [sqlite3_snapshot_open(D,S,P)] will fail if the
         8139  +** database connection D does not know that the database file for
         8140  +** schema S is in [WAL mode].  A database connection might not know
         8141  +** that the database file is in [WAL mode] if there has been no prior
         8142  +** I/O on that database connection, or if the database entered [WAL mode] 
         8143  +** after the most recent I/O on the database connection.)^
         8144  +** (Hint: Run "[PRAGMA application_id]" against a newly opened
         8145  +** database connection in order to make it ready to use snapshots.)
         8146  +**
         8147  +** The [sqlite3_snapshot_open()] interface is only available when the
         8148  +** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
         8149  +*/
         8150  +SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_snapshot_open(
         8151  +  sqlite3 *db,
         8152  +  const char *zSchema,
         8153  +  sqlite3_snapshot *pSnapshot
         8154  +);
         8155  +
         8156  +/*
         8157  +** CAPI3REF: Destroy a snapshot
         8158  +** EXPERIMENTAL
         8159  +**
         8160  +** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.
         8161  +** The application must eventually free every [sqlite3_snapshot] object
         8162  +** using this routine to avoid a memory leak.
         8163  +**
         8164  +** The [sqlite3_snapshot_free()] interface is only available when the
         8165  +** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
         8166  +*/
         8167  +SQLITE_API SQLITE_EXPERIMENTAL void SQLITE_STDCALL sqlite3_snapshot_free(sqlite3_snapshot*);
         8168  +
         8169  +/*
         8170  +** CAPI3REF: Compare the ages of two snapshot handles.
         8171  +** EXPERIMENTAL
         8172  +**
         8173  +** The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages
         8174  +** of two valid snapshot handles. 
         8175  +**
         8176  +** If the two snapshot handles are not associated with the same database 
         8177  +** file, the result of the comparison is undefined. 
         8178  +**
         8179  +** Additionally, the result of the comparison is only valid if both of the
         8180  +** snapshot handles were obtained by calling sqlite3_snapshot_get() since the
         8181  +** last time the wal file was deleted. The wal file is deleted when the
         8182  +** database is changed back to rollback mode or when the number of database
         8183  +** clients drops to zero. If either snapshot handle was obtained before the 
         8184  +** wal file was last deleted, the value returned by this function 
         8185  +** is undefined.
         8186  +**
         8187  +** Otherwise, this API returns a negative value if P1 refers to an older
         8188  +** snapshot than P2, zero if the two handles refer to the same database
         8189  +** snapshot, and a positive value if P1 is a newer snapshot than P2.
         8190  +*/
         8191  +SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_snapshot_cmp(
         8192  +  sqlite3_snapshot *p1,
         8193  +  sqlite3_snapshot *p2
         8194  +);
  7366   8195   
  7367   8196   /*
  7368   8197   ** Undo the hack that converts floating point types to integer for
  7369   8198   ** builds on processors without floating point support.
  7370   8199   */
  7371   8200   #ifdef SQLITE_OMIT_FLOATING_POINT
  7372   8201   # undef double
................................................................................
  7373   8202   #endif
  7374   8203   
  7375   8204   #ifdef __cplusplus
  7376   8205   }  /* End of the 'extern "C"' block */
  7377   8206   #endif
  7378   8207   #endif /* _SQLITE3_H_ */
  7379   8208   
         8209  +/******** Begin file sqlite3rtree.h *********/
  7380   8210   /*
  7381   8211   ** 2010 August 30
  7382   8212   **
  7383   8213   ** The author disclaims copyright to this source code.  In place of
  7384   8214   ** a legal notice, here is a blessing:
  7385   8215   **
  7386   8216   **    May you do good and not evil.
................................................................................
  7412   8242   
  7413   8243   /*
  7414   8244   ** Register a geometry callback named zGeom that can be used as part of an
  7415   8245   ** R-Tree geometry query as follows:
  7416   8246   **
  7417   8247   **   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
  7418   8248   */
  7419         -SQLITE_API int sqlite3_rtree_geometry_callback(
         8249  +SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback(
  7420   8250     sqlite3 *db,
  7421   8251     const char *zGeom,
  7422   8252     int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),
  7423   8253     void *pContext
  7424   8254   );
  7425   8255   
  7426   8256   
................................................................................
  7438   8268   
  7439   8269   /*
  7440   8270   ** Register a 2nd-generation geometry callback named zScore that can be 
  7441   8271   ** used as part of an R-Tree geometry query as follows:
  7442   8272   **
  7443   8273   **   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)
  7444   8274   */
  7445         -SQLITE_API int sqlite3_rtree_query_callback(
         8275  +SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback(
  7446   8276     sqlite3 *db,
  7447   8277     const char *zQueryFunc,
  7448   8278     int (*xQueryFunc)(sqlite3_rtree_query_info*),
  7449   8279     void *pContext,
  7450   8280     void (*xDestructor)(void*)
  7451   8281   );
  7452   8282   
................................................................................
  7472   8302     int iLevel;                       /* Level of current node or entry */
  7473   8303     int mxLevel;                      /* The largest iLevel value in the tree */
  7474   8304     sqlite3_int64 iRowid;             /* Rowid for current entry */
  7475   8305     sqlite3_rtree_dbl rParentScore;   /* Score of parent node */
  7476   8306     int eParentWithin;                /* Visibility of parent node */
  7477   8307     int eWithin;                      /* OUT: Visiblity */
  7478   8308     sqlite3_rtree_dbl rScore;         /* OUT: Write the score here */
         8309  +  /* The following fields are only available in 3.8.11 and later */
         8310  +  sqlite3_value **apSqlParam;       /* Original SQL values of parameters */
  7479   8311   };
  7480   8312   
  7481   8313   /*
  7482   8314   ** Allowed values for sqlite3_rtree_query.eWithin and .eParentWithin.
  7483   8315   */
  7484   8316   #define NOT_WITHIN       0   /* Object completely outside of query region */
  7485   8317   #define PARTLY_WITHIN    1   /* Object partially overlaps query region */
................................................................................
  7488   8320   
  7489   8321   #ifdef __cplusplus
  7490   8322   }  /* end of the 'extern "C"' block */
  7491   8323   #endif
  7492   8324   
  7493   8325   #endif  /* ifndef _SQLITE3RTREE_H_ */
  7494   8326   
         8327  +/******** End of sqlite3rtree.h *********/
         8328  +/******** Begin file sqlite3session.h *********/
         8329  +
         8330  +#if !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION)
         8331  +#define __SQLITESESSION_H_ 1
         8332  +
         8333  +/*
         8334  +** Make sure we can call this stuff from C++.
         8335  +*/
         8336  +#ifdef __cplusplus
         8337  +extern "C" {
         8338  +#endif
         8339  +
         8340  +
         8341  +/*
         8342  +** CAPI3REF: Session Object Handle
         8343  +*/
         8344  +typedef struct sqlite3_session sqlite3_session;
         8345  +
         8346  +/*
         8347  +** CAPI3REF: Changeset Iterator Handle
         8348  +*/
         8349  +typedef struct sqlite3_changeset_iter sqlite3_changeset_iter;
         8350  +
         8351  +/*
         8352  +** CAPI3REF: Create A New Session Object
         8353  +**
         8354  +** Create a new session object attached to database handle db. If successful,
         8355  +** a pointer to the new object is written to *ppSession and SQLITE_OK is
         8356  +** returned. If an error occurs, *ppSession is set to NULL and an SQLite
         8357  +** error code (e.g. SQLITE_NOMEM) is returned.
         8358  +**
         8359  +** It is possible to create multiple session objects attached to a single
         8360  +** database handle.
         8361  +**
         8362  +** Session objects created using this function should be deleted using the
         8363  +** [sqlite3session_delete()] function before the database handle that they
         8364  +** are attached to is itself closed. If the database handle is closed before
         8365  +** the session object is deleted, then the results of calling any session
         8366  +** module function, including [sqlite3session_delete()] on the session object
         8367  +** are undefined.
         8368  +**
         8369  +** Because the session module uses the [sqlite3_preupdate_hook()] API, it
         8370  +** is not possible for an application to register a pre-update hook on a
         8371  +** database handle that has one or more session objects attached. Nor is
         8372  +** it possible to create a session object attached to a database handle for
         8373  +** which a pre-update hook is already defined. The results of attempting 
         8374  +** either of these things are undefined.
         8375  +**
         8376  +** The session object will be used to create changesets for tables in
         8377  +** database zDb, where zDb is either "main", or "temp", or the name of an
         8378  +** attached database. It is not an error if database zDb is not attached
         8379  +** to the database when the session object is created.
         8380  +*/
         8381  +int sqlite3session_create(
         8382  +  sqlite3 *db,                    /* Database handle */
         8383  +  const char *zDb,                /* Name of db (e.g. "main") */
         8384  +  sqlite3_session **ppSession     /* OUT: New session object */
         8385  +);
         8386  +
         8387  +/*
         8388  +** CAPI3REF: Delete A Session Object
         8389  +**
         8390  +** Delete a session object previously allocated using 
         8391  +** [sqlite3session_create()]. Once a session object has been deleted, the
         8392  +** results of attempting to use pSession with any other session module
         8393  +** function are undefined.
         8394  +**
         8395  +** Session objects must be deleted before the database handle to which they
         8396  +** are attached is closed. Refer to the documentation for 
         8397  +** [sqlite3session_create()] for details.
         8398  +*/
         8399  +void sqlite3session_delete(sqlite3_session *pSession);
         8400  +
         8401  +
         8402  +/*
         8403  +** CAPI3REF: Enable Or Disable A Session Object
         8404  +**
         8405  +** Enable or disable the recording of changes by a session object. When
         8406  +** enabled, a session object records changes made to the database. When
         8407  +** disabled - it does not. A newly created session object is enabled.
         8408  +** Refer to the documentation for [sqlite3session_changeset()] for further
         8409  +** details regarding how enabling and disabling a session object affects
         8410  +** the eventual changesets.
         8411  +**
         8412  +** Passing zero to this function disables the session. Passing a value
         8413  +** greater than zero enables it. Passing a value less than zero is a 
         8414  +** no-op, and may be used to query the current state of the session.
         8415  +**
         8416  +** The return value indicates the final state of the session object: 0 if 
         8417  +** the session is disabled, or 1 if it is enabled.
         8418  +*/
         8419  +int sqlite3session_enable(sqlite3_session *pSession, int bEnable);
         8420  +
         8421  +/*
         8422  +** CAPI3REF: Set Or Clear the Indirect Change Flag
         8423  +**
         8424  +** Each change recorded by a session object is marked as either direct or
         8425  +** indirect. A change is marked as indirect if either:
         8426  +**
         8427  +** <ul>
         8428  +**   <li> The session object "indirect" flag is set when the change is
         8429  +**        made, or
         8430  +**   <li> The change is made by an SQL trigger or foreign key action 
         8431  +**        instead of directly as a result of a users SQL statement.
         8432  +** </ul>
         8433  +**
         8434  +** If a single row is affected by more than one operation within a session,
         8435  +** then the change is considered indirect if all operations meet the criteria
         8436  +** for an indirect change above, or direct otherwise.
         8437  +**
         8438  +** This function is used to set, clear or query the session object indirect
         8439  +** flag.  If the second argument passed to this function is zero, then the
         8440  +** indirect flag is cleared. If it is greater than zero, the indirect flag
         8441  +** is set. Passing a value less than zero does not modify the current value
         8442  +** of the indirect flag, and may be used to query the current state of the 
         8443  +** indirect flag for the specified session object.
         8444  +**
         8445  +** The return value indicates the final state of the indirect flag: 0 if 
         8446  +** it is clear, or 1 if it is set.
         8447  +*/
         8448  +int sqlite3session_indirect(sqlite3_session *pSession, int bIndirect);
         8449  +
         8450  +/*
         8451  +** CAPI3REF: Attach A Table To A Session Object
         8452  +**
         8453  +** If argument zTab is not NULL, then it is the name of a table to attach
         8454  +** to the session object passed as the first argument. All subsequent changes 
         8455  +** made to the table while the session object is enabled will be recorded. See 
         8456  +** documentation for [sqlite3session_changeset()] for further details.
         8457  +**
         8458  +** Or, if argument zTab is NULL, then changes are recorded for all tables
         8459  +** in the database. If additional tables are added to the database (by 
         8460  +** executing "CREATE TABLE" statements) after this call is made, changes for 
         8461  +** the new tables are also recorded.
         8462  +**
         8463  +** Changes can only be recorded for tables that have a PRIMARY KEY explicitly
         8464  +** defined as part of their CREATE TABLE statement. It does not matter if the 
         8465  +** PRIMARY KEY is an "INTEGER PRIMARY KEY" (rowid alias) or not. The PRIMARY
         8466  +** KEY may consist of a single column, or may be a composite key.
         8467  +** 
         8468  +** It is not an error if the named table does not exist in the database. Nor
         8469  +** is it an error if the named table does not have a PRIMARY KEY. However,
         8470  +** no changes will be recorded in either of these scenarios.
         8471  +**
         8472  +** Changes are not recorded for individual rows that have NULL values stored
         8473  +** in one or more of their PRIMARY KEY columns.
         8474  +**
         8475  +** SQLITE_OK is returned if the call completes without error. Or, if an error 
         8476  +** occurs, an SQLite error code (e.g. SQLITE_NOMEM) is returned.
         8477  +*/
         8478  +int sqlite3session_attach(
         8479  +  sqlite3_session *pSession,      /* Session object */
         8480  +  const char *zTab                /* Table name */
         8481  +);
         8482  +
         8483  +/*
         8484  +** CAPI3REF: Set a table filter on a Session Object.
         8485  +**
         8486  +** The second argument (xFilter) is the "filter callback". For changes to rows 
         8487  +** in tables that are not attached to the Session oject, the filter is called
         8488  +** to determine whether changes to the table's rows should be tracked or not. 
         8489  +** If xFilter returns 0, changes is not tracked. Note that once a table is 
         8490  +** attached, xFilter will not be called again.
         8491  +*/
         8492  +void sqlite3session_table_filter(
         8493  +  sqlite3_session *pSession,      /* Session object */
         8494  +  int(*xFilter)(
         8495  +    void *pCtx,                   /* Copy of third arg to _filter_table() */
         8496  +    const char *zTab              /* Table name */
         8497  +  ),
         8498  +  void *pCtx                      /* First argument passed to xFilter */
         8499  +);
         8500  +
         8501  +/*
         8502  +** CAPI3REF: Generate A Changeset From A Session Object
         8503  +**
         8504  +** Obtain a changeset containing changes to the tables attached to the 
         8505  +** session object passed as the first argument. If successful, 
         8506  +** set *ppChangeset to point to a buffer containing the changeset 
         8507  +** and *pnChangeset to the size of the changeset in bytes before returning
         8508  +** SQLITE_OK. If an error occurs, set both *ppChangeset and *pnChangeset to
         8509  +** zero and return an SQLite error code.
         8510  +**
         8511  +** A changeset consists of zero or more INSERT, UPDATE and/or DELETE changes,
         8512  +** each representing a change to a single row of an attached table. An INSERT
         8513  +** change contains the values of each field of a new database row. A DELETE
         8514  +** contains the original values of each field of a deleted database row. An
         8515  +** UPDATE change contains the original values of each field of an updated
         8516  +** database row along with the updated values for each updated non-primary-key
         8517  +** column. It is not possible for an UPDATE change to represent a change that
         8518  +** modifies the values of primary key columns. If such a change is made, it
         8519  +** is represented in a changeset as a DELETE followed by an INSERT.
         8520  +**
         8521  +** Changes are not recorded for rows that have NULL values stored in one or 
         8522  +** more of their PRIMARY KEY columns. If such a row is inserted or deleted,
         8523  +** no corresponding change is present in the changesets returned by this
         8524  +** function. If an existing row with one or more NULL values stored in
         8525  +** PRIMARY KEY columns is updated so that all PRIMARY KEY columns are non-NULL,
         8526  +** only an INSERT is appears in the changeset. Similarly, if an existing row
         8527  +** with non-NULL PRIMARY KEY values is updated so that one or more of its
         8528  +** PRIMARY KEY columns are set to NULL, the resulting changeset contains a
         8529  +** DELETE change only.
         8530  +**
         8531  +** The contents of a changeset may be traversed using an iterator created
         8532  +** using the [sqlite3changeset_start()] API. A changeset may be applied to
         8533  +** a database with a compatible schema using the [sqlite3changeset_apply()]
         8534  +** API.
         8535  +**
         8536  +** Within a changeset generated by this function, all changes related to a
         8537  +** single table are grouped together. In other words, when iterating through
         8538  +** a changeset or when applying a changeset to a database, all changes related
         8539  +** to a single table are processed before moving on to the next table. Tables
         8540  +** are sorted in the same order in which they were attached (or auto-attached)
         8541  +** to the sqlite3_session object. The order in which the changes related to
         8542  +** a single table are stored is undefined.
         8543  +**
         8544  +** Following a successful call to this function, it is the responsibility of
         8545  +** the caller to eventually free the buffer that *ppChangeset points to using
         8546  +** [sqlite3_free()].
         8547  +**
         8548  +** <h3>Changeset Generation</h3>
         8549  +**
         8550  +** Once a table has been attached to a session object, the session object
         8551  +** records the primary key values of all new rows inserted into the table.
         8552  +** It also records the original primary key and other column values of any
         8553  +** deleted or updated rows. For each unique primary key value, data is only
         8554  +** recorded once - the first time a row with said primary key is inserted,
         8555  +** updated or deleted in the lifetime of the session.
         8556  +**
         8557  +** There is one exception to the previous paragraph: when a row is inserted,
         8558  +** updated or deleted, if one or more of its primary key columns contain a
         8559  +** NULL value, no record of the change is made.
         8560  +**
         8561  +** The session object therefore accumulates two types of records - those
         8562  +** that consist of primary key values only (created when the user inserts
         8563  +** a new record) and those that consist of the primary key values and the
         8564  +** original values of other table columns (created when the users deletes
         8565  +** or updates a record).
         8566  +**
         8567  +** When this function is called, the requested changeset is created using
         8568  +** both the accumulated records and the current contents of the database
         8569  +** file. Specifically:
         8570  +**
         8571  +** <ul>
         8572  +**   <li> For each record generated by an insert, the database is queried
         8573  +**        for a row with a matching primary key. If one is found, an INSERT
         8574  +**        change is added to the changeset. If no such row is found, no change 
         8575  +**        is added to the changeset.
         8576  +**
         8577  +**   <li> For each record generated by an update or delete, the database is 
         8578  +**        queried for a row with a matching primary key. If such a row is
         8579  +**        found and one or more of the non-primary key fields have been
         8580  +**        modified from their original values, an UPDATE change is added to 
         8581  +**        the changeset. Or, if no such row is found in the table, a DELETE 
         8582  +**        change is added to the changeset. If there is a row with a matching
         8583  +**        primary key in the database, but all fields contain their original
         8584  +**        values, no change is added to the changeset.
         8585  +** </ul>
         8586  +**
         8587  +** This means, amongst other things, that if a row is inserted and then later
         8588  +** deleted while a session object is active, neither the insert nor the delete
         8589  +** will be present in the changeset. Or if a row is deleted and then later a 
         8590  +** row with the same primary key values inserted while a session object is
         8591  +** active, the resulting changeset will contain an UPDATE change instead of
         8592  +** a DELETE and an INSERT.
         8593  +**
         8594  +** When a session object is disabled (see the [sqlite3session_enable()] API),
         8595  +** it does not accumulate records when rows are inserted, updated or deleted.
         8596  +** This may appear to have some counter-intuitive effects if a single row
         8597  +** is written to more than once during a session. For example, if a row
         8598  +** is inserted while a session object is enabled, then later deleted while 
         8599  +** the same session object is disabled, no INSERT record will appear in the
         8600  +** changeset, even though the delete took place while the session was disabled.
         8601  +** Or, if one field of a row is updated while a session is disabled, and 
         8602  +** another field of the same row is updated while the session is enabled, the
         8603  +** resulting changeset will contain an UPDATE change that updates both fields.
         8604  +*/
         8605  +int sqlite3session_changeset(
         8606  +  sqlite3_session *pSession,      /* Session object */
         8607  +  int *pnChangeset,               /* OUT: Size of buffer at *ppChangeset */
         8608  +  void **ppChangeset              /* OUT: Buffer containing changeset */
         8609  +);
         8610  +
         8611  +/*
         8612  +** CAPI3REF: Load The Difference Between Tables Into A Session 
         8613  +**
         8614  +** If it is not already attached to the session object passed as the first
         8615  +** argument, this function attaches table zTbl in the same manner as the
         8616  +** [sqlite3session_attach()] function. If zTbl does not exist, or if it
         8617  +** does not have a primary key, this function is a no-op (but does not return
         8618  +** an error).
         8619  +**
         8620  +** Argument zFromDb must be the name of a database ("main", "temp" etc.)
         8621  +** attached to the same database handle as the session object that contains 
         8622  +** a table compatible with the table attached to the session by this function.
         8623  +** A table is considered compatible if it:
         8624  +**
         8625  +** <ul>
         8626  +**   <li> Has the same name,
         8627  +**   <li> Has the same set of columns declared in the same order, and
         8628  +**   <li> Has the same PRIMARY KEY definition.
         8629  +** </ul>
         8630  +**
         8631  +** If the tables are not compatible, SQLITE_SCHEMA is returned. If the tables
         8632  +** are compatible but do not have any PRIMARY KEY columns, it is not an error
         8633  +** but no changes are added to the session object. As with other session
         8634  +** APIs, tables without PRIMARY KEYs are simply ignored.
         8635  +**
         8636  +** This function adds a set of changes to the session object that could be
         8637  +** used to update the table in database zFrom (call this the "from-table") 
         8638  +** so that its content is the same as the table attached to the session 
         8639  +** object (call this the "to-table"). Specifically:
         8640  +**
         8641  +** <ul>
         8642  +**   <li> For each row (primary key) that exists in the to-table but not in 
         8643  +**     the from-table, an INSERT record is added to the session object.
         8644  +**
         8645  +**   <li> For each row (primary key) that exists in the to-table but not in 
         8646  +**     the from-table, a DELETE record is added to the session object.
         8647  +**
         8648  +**   <li> For each row (primary key) that exists in both tables, but features 
         8649  +**     different in each, an UPDATE record is added to the session.
         8650  +** </ul>
         8651  +**
         8652  +** To clarify, if this function is called and then a changeset constructed
         8653  +** using [sqlite3session_changeset()], then after applying that changeset to 
         8654  +** database zFrom the contents of the two compatible tables would be 
         8655  +** identical.
         8656  +**
         8657  +** It an error if database zFrom does not exist or does not contain the
         8658  +** required compatible table.
         8659  +**
         8660  +** If the operation successful, SQLITE_OK is returned. Otherwise, an SQLite
         8661  +** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg
         8662  +** may be set to point to a buffer containing an English language error 
         8663  +** message. It is the responsibility of the caller to free this buffer using
         8664  +** sqlite3_free().
         8665  +*/
         8666  +int sqlite3session_diff(
         8667  +  sqlite3_session *pSession,
         8668  +  const char *zFromDb,
         8669  +  const char *zTbl,
         8670  +  char **pzErrMsg
         8671  +);
         8672  +
         8673  +
         8674  +/*
         8675  +** CAPI3REF: Generate A Patchset From A Session Object
         8676  +**
         8677  +** The differences between a patchset and a changeset are that:
         8678  +**
         8679  +** <ul>
         8680  +**   <li> DELETE records consist of the primary key fields only. The 
         8681  +**        original values of other fields are omitted.
         8682  +**   <li> The original values of any modified fields are omitted from 
         8683  +**        UPDATE records.
         8684  +** </ul>
         8685  +**
         8686  +** A patchset blob may be used with up to date versions of all 
         8687  +** sqlite3changeset_xxx API functions except for sqlite3changeset_invert(), 
         8688  +** which returns SQLITE_CORRUPT if it is passed a patchset. Similarly,
         8689  +** attempting to use a patchset blob with old versions of the
         8690  +** sqlite3changeset_xxx APIs also provokes an SQLITE_CORRUPT error. 
         8691  +**
         8692  +** Because the non-primary key "old.*" fields are omitted, no 
         8693  +** SQLITE_CHANGESET_DATA conflicts can be detected or reported if a patchset
         8694  +** is passed to the sqlite3changeset_apply() API. Other conflict types work
         8695  +** in the same way as for changesets.
         8696  +**
         8697  +** Changes within a patchset are ordered in the same way as for changesets
         8698  +** generated by the sqlite3session_changeset() function (i.e. all changes for
         8699  +** a single table are grouped together, tables appear in the order in which
         8700  +** they were attached to the session object).
         8701  +*/
         8702  +int sqlite3session_patchset(
         8703  +  sqlite3_session *pSession,      /* Session object */
         8704  +  int *pnPatchset,                /* OUT: Size of buffer at *ppChangeset */
         8705  +  void **ppPatchset               /* OUT: Buffer containing changeset */
         8706  +);
         8707  +
         8708  +/*
         8709  +** CAPI3REF: Test if a changeset has recorded any changes.
         8710  +**
         8711  +** Return non-zero if no changes to attached tables have been recorded by 
         8712  +** the session object passed as the first argument. Otherwise, if one or 
         8713  +** more changes have been recorded, return zero.
         8714  +**
         8715  +** Even if this function returns zero, it is possible that calling
         8716  +** [sqlite3session_changeset()] on the session handle may still return a
         8717  +** changeset that contains no changes. This can happen when a row in 
         8718  +** an attached table is modified and then later on the original values 
         8719  +** are restored. However, if this function returns non-zero, then it is
         8720  +** guaranteed that a call to sqlite3session_changeset() will return a 
         8721  +** changeset containing zero changes.
         8722  +*/
         8723  +int sqlite3session_isempty(sqlite3_session *pSession);
         8724  +
         8725  +/*
         8726  +** CAPI3REF: Create An Iterator To Traverse A Changeset 
         8727  +**
         8728  +** Create an iterator used to iterate through the contents of a changeset.
         8729  +** If successful, *pp is set to point to the iterator handle and SQLITE_OK
         8730  +** is returned. Otherwise, if an error occurs, *pp is set to zero and an
         8731  +** SQLite error code is returned.
         8732  +**
         8733  +** The following functions can be used to advance and query a changeset 
         8734  +** iterator created by this function:
         8735  +**
         8736  +** <ul>
         8737  +**   <li> [sqlite3changeset_next()]
         8738  +**   <li> [sqlite3changeset_op()]
         8739  +**   <li> [sqlite3changeset_new()]
         8740  +**   <li> [sqlite3changeset_old()]
         8741  +** </ul>
         8742  +**
         8743  +** It is the responsibility of the caller to eventually destroy the iterator
         8744  +** by passing it to [sqlite3changeset_finalize()]. The buffer containing the
         8745  +** changeset (pChangeset) must remain valid until after the iterator is
         8746  +** destroyed.
         8747  +**
         8748  +** Assuming the changeset blob was created by one of the
         8749  +** [sqlite3session_changeset()], [sqlite3changeset_concat()] or
         8750  +** [sqlite3changeset_invert()] functions, all changes within the changeset 
         8751  +** that apply to a single table are grouped together. This means that when 
         8752  +** an application iterates through a changeset using an iterator created by 
         8753  +** this function, all changes that relate to a single table are visted 
         8754  +** consecutively. There is no chance that the iterator will visit a change 
         8755  +** the applies to table X, then one for table Y, and then later on visit 
         8756  +** another change for table X.
         8757  +*/
         8758  +int sqlite3changeset_start(
         8759  +  sqlite3_changeset_iter **pp,    /* OUT: New changeset iterator handle */
         8760  +  int nChangeset,                 /* Size of changeset blob in bytes */
         8761  +  void *pChangeset                /* Pointer to blob containing changeset */
         8762  +);
         8763  +
         8764  +
         8765  +/*
         8766  +** CAPI3REF: Advance A Changeset Iterator
         8767  +**
         8768  +** This function may only be used with iterators created by function
         8769  +** [sqlite3changeset_start()]. If it is called on an iterator passed to
         8770  +** a conflict-handler callback by [sqlite3changeset_apply()], SQLITE_MISUSE
         8771  +** is returned and the call has no effect.
         8772  +**
         8773  +** Immediately after an iterator is created by sqlite3changeset_start(), it
         8774  +** does not point to any change in the changeset. Assuming the changeset
         8775  +** is not empty, the first call to this function advances the iterator to
         8776  +** point to the first change in the changeset. Each subsequent call advances
         8777  +** the iterator to point to the next change in the changeset (if any). If
         8778  +** no error occurs and the iterator points to a valid change after a call
         8779  +** to sqlite3changeset_next() has advanced it, SQLITE_ROW is returned. 
         8780  +** Otherwise, if all changes in the changeset have already been visited,
         8781  +** SQLITE_DONE is returned.
         8782  +**
         8783  +** If an error occurs, an SQLite error code is returned. Possible error 
         8784  +** codes include SQLITE_CORRUPT (if the changeset buffer is corrupt) or 
         8785  +** SQLITE_NOMEM.
         8786  +*/
         8787  +int sqlite3changeset_next(sqlite3_changeset_iter *pIter);
         8788  +
         8789  +/*
         8790  +** CAPI3REF: Obtain The Current Operation From A Changeset Iterator
         8791  +**
         8792  +** The pIter argument passed to this function may either be an iterator
         8793  +** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator
         8794  +** created by [sqlite3changeset_start()]. In the latter case, the most recent
         8795  +** call to [sqlite3changeset_next()] must have returned [SQLITE_ROW]. If this
         8796  +** is not the case, this function returns [SQLITE_MISUSE].
         8797  +**
         8798  +** If argument pzTab is not NULL, then *pzTab is set to point to a
         8799  +** nul-terminated utf-8 encoded string containing the name of the table
         8800  +** affected by the current change. The buffer remains valid until either
         8801  +** sqlite3changeset_next() is called on the iterator or until the 
         8802  +** conflict-handler function returns. If pnCol is not NULL, then *pnCol is 
         8803  +** set to the number of columns in the table affected by the change. If
         8804  +** pbIncorrect is not NULL, then *pbIndirect is set to true (1) if the change
         8805  +** is an indirect change, or false (0) otherwise. See the documentation for
         8806  +** [sqlite3session_indirect()] for a description of direct and indirect
         8807  +** changes. Finally, if pOp is not NULL, then *pOp is set to one of 
         8808  +** [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], depending on the 
         8809  +** type of change that the iterator currently points to.
         8810  +**
         8811  +** If no error occurs, SQLITE_OK is returned. If an error does occur, an
         8812  +** SQLite error code is returned. The values of the output variables may not
         8813  +** be trusted in this case.
         8814  +*/
         8815  +int sqlite3changeset_op(
         8816  +  sqlite3_changeset_iter *pIter,  /* Iterator object */
         8817  +  const char **pzTab,             /* OUT: Pointer to table name */
         8818  +  int *pnCol,                     /* OUT: Number of columns in table */
         8819  +  int *pOp,                       /* OUT: SQLITE_INSERT, DELETE or UPDATE */
         8820  +  int *pbIndirect                 /* OUT: True for an 'indirect' change */
         8821  +);
         8822  +
         8823  +/*
         8824  +** CAPI3REF: Obtain The Primary Key Definition Of A Table
         8825  +**
         8826  +** For each modified table, a changeset includes the following:
         8827  +**
         8828  +** <ul>
         8829  +**   <li> The number of columns in the table, and
         8830  +**   <li> Which of those columns make up the tables PRIMARY KEY.
         8831  +** </ul>
         8832  +**
         8833  +** This function is used to find which columns comprise the PRIMARY KEY of
         8834  +** the table modified by the change that iterator pIter currently points to.
         8835  +** If successful, *pabPK is set to point to an array of nCol entries, where
         8836  +** nCol is the number of columns in the table. Elements of *pabPK are set to
         8837  +** 0x01 if the corresponding column is part of the tables primary key, or
         8838  +** 0x00 if it is not.
         8839  +**
         8840  +** If argumet pnCol is not NULL, then *pnCol is set to the number of columns
         8841  +** in the table.
         8842  +**
         8843  +** If this function is called when the iterator does not point to a valid
         8844  +** entry, SQLITE_MISUSE is returned and the output variables zeroed. Otherwise,
         8845  +** SQLITE_OK is returned and the output variables populated as described
         8846  +** above.
         8847  +*/
         8848  +int sqlite3changeset_pk(
         8849  +  sqlite3_changeset_iter *pIter,  /* Iterator object */
         8850  +  unsigned char **pabPK,          /* OUT: Array of boolean - true for PK cols */
         8851  +  int *pnCol                      /* OUT: Number of entries in output array */
         8852  +);
         8853  +
         8854  +/*
         8855  +** CAPI3REF: Obtain old.* Values From A Changeset Iterator
         8856  +**
         8857  +** The pIter argument passed to this function may either be an iterator
         8858  +** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator
         8859  +** created by [sqlite3changeset_start()]. In the latter case, the most recent
         8860  +** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. 
         8861  +** Furthermore, it may only be called if the type of change that the iterator
         8862  +** currently points to is either [SQLITE_DELETE] or [SQLITE_UPDATE]. Otherwise,
         8863  +** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL.
         8864  +**
         8865  +** Argument iVal must be greater than or equal to 0, and less than the number
         8866  +** of columns in the table affected by the current change. Otherwise,
         8867  +** [SQLITE_RANGE] is returned and *ppValue is set to NULL.
         8868  +**
         8869  +** If successful, this function sets *ppValue to point to a protected
         8870  +** sqlite3_value object containing the iVal'th value from the vector of 
         8871  +** original row values stored as part of the UPDATE or DELETE change and
         8872  +** returns SQLITE_OK. The name of the function comes from the fact that this 
         8873  +** is similar to the "old.*" columns available to update or delete triggers.
         8874  +**
         8875  +** If some other error occurs (e.g. an OOM condition), an SQLite error code
         8876  +** is returned and *ppValue is set to NULL.
         8877  +*/
         8878  +int sqlite3changeset_old(
         8879  +  sqlite3_changeset_iter *pIter,  /* Changeset iterator */
         8880  +  int iVal,                       /* Column number */
         8881  +  sqlite3_value **ppValue         /* OUT: Old value (or NULL pointer) */
         8882  +);
         8883  +
         8884  +/*
         8885  +** CAPI3REF: Obtain new.* Values From A Changeset Iterator
         8886  +**
         8887  +** The pIter argument passed to this function may either be an iterator
         8888  +** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator
         8889  +** created by [sqlite3changeset_start()]. In the latter case, the most recent
         8890  +** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. 
         8891  +** Furthermore, it may only be called if the type of change that the iterator
         8892  +** currently points to is either [SQLITE_UPDATE] or [SQLITE_INSERT]. Otherwise,
         8893  +** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL.
         8894  +**
         8895  +** Argument iVal must be greater than or equal to 0, and less than the number
         8896  +** of columns in the table affected by the current change. Otherwise,
         8897  +** [SQLITE_RANGE] is returned and *ppValue is set to NULL.
         8898  +**
         8899  +** If successful, this function sets *ppValue to point to a protected
         8900  +** sqlite3_value object containing the iVal'th value from the vector of 
         8901  +** new row values stored as part of the UPDATE or INSERT change and
         8902  +** returns SQLITE_OK. If the change is an UPDATE and does not include
         8903  +** a new value for the requested column, *ppValue is set to NULL and 
         8904  +** SQLITE_OK returned. The name of the function comes from the fact that 
         8905  +** this is similar to the "new.*" columns available to update or delete 
         8906  +** triggers.
         8907  +**
         8908  +** If some other error occurs (e.g. an OOM condition), an SQLite error code
         8909  +** is returned and *ppValue is set to NULL.
         8910  +*/
         8911  +int sqlite3changeset_new(
         8912  +  sqlite3_changeset_iter *pIter,  /* Changeset iterator */
         8913  +  int iVal,                       /* Column number */
         8914  +  sqlite3_value **ppValue         /* OUT: New value (or NULL pointer) */
         8915  +);
         8916  +
         8917  +/*
         8918  +** CAPI3REF: Obtain Conflicting Row Values From A Changeset Iterator
         8919  +**
         8920  +** This function should only be used with iterator objects passed to a
         8921  +** conflict-handler callback by [sqlite3changeset_apply()] with either
         8922  +** [SQLITE_CHANGESET_DATA] or [SQLITE_CHANGESET_CONFLICT]. If this function
         8923  +** is called on any other iterator, [SQLITE_MISUSE] is returned and *ppValue
         8924  +** is set to NULL.
         8925  +**
         8926  +** Argument iVal must be greater than or equal to 0, and less than the number
         8927  +** of columns in the table affected by the current change. Otherwise,
         8928  +** [SQLITE_RANGE] is returned and *ppValue is set to NULL.
         8929  +**
         8930  +** If successful, this function sets *ppValue to point to a protected
         8931  +** sqlite3_value object containing the iVal'th value from the 
         8932  +** "conflicting row" associated with the current conflict-handler callback
         8933  +** and returns SQLITE_OK.
         8934  +**
         8935  +** If some other error occurs (e.g. an OOM condition), an SQLite error code
         8936  +** is returned and *ppValue is set to NULL.
         8937  +*/
         8938  +int sqlite3changeset_conflict(
         8939  +  sqlite3_changeset_iter *pIter,  /* Changeset iterator */
         8940  +  int iVal,                       /* Column number */
         8941  +  sqlite3_value **ppValue         /* OUT: Value from conflicting row */
         8942  +);
         8943  +
         8944  +/*
         8945  +** CAPI3REF: Determine The Number Of Foreign Key Constraint Violations
         8946  +**
         8947  +** This function may only be called with an iterator passed to an
         8948  +** SQLITE_CHANGESET_FOREIGN_KEY conflict handler callback. In this case
         8949  +** it sets the output variable to the total number of known foreign key
         8950  +** violations in the destination database and returns SQLITE_OK.
         8951  +**
         8952  +** In all other cases this function returns SQLITE_MISUSE.
         8953  +*/
         8954  +int sqlite3changeset_fk_conflicts(
         8955  +  sqlite3_changeset_iter *pIter,  /* Changeset iterator */
         8956  +  int *pnOut                      /* OUT: Number of FK violations */
         8957  +);
         8958  +
         8959  +
         8960  +/*
         8961  +** CAPI3REF: Finalize A Changeset Iterator
         8962  +**
         8963  +** This function is used to finalize an iterator allocated with
         8964  +** [sqlite3changeset_start()].
         8965  +**
         8966  +** This function should only be called on iterators created using the
         8967  +** [sqlite3changeset_start()] function. If an application calls this
         8968  +** function with an iterator passed to a conflict-handler by
         8969  +** [sqlite3changeset_apply()], [SQLITE_MISUSE] is immediately returned and the
         8970  +** call has no effect.
         8971  +**
         8972  +** If an error was encountered within a call to an sqlite3changeset_xxx()
         8973  +** function (for example an [SQLITE_CORRUPT] in [sqlite3changeset_next()] or an 
         8974  +** [SQLITE_NOMEM] in [sqlite3changeset_new()]) then an error code corresponding
         8975  +** to that error is returned by this function. Otherwise, SQLITE_OK is
         8976  +** returned. This is to allow the following pattern (pseudo-code):
         8977  +**
         8978  +**   sqlite3changeset_start();
         8979  +**   while( SQLITE_ROW==sqlite3changeset_next() ){
         8980  +**     // Do something with change.
         8981  +**   }
         8982  +**   rc = sqlite3changeset_finalize();
         8983  +**   if( rc!=SQLITE_OK ){
         8984  +**     // An error has occurred 
         8985  +**   }
         8986  +*/
         8987  +int sqlite3changeset_finalize(sqlite3_changeset_iter *pIter);
         8988  +
         8989  +/*
         8990  +** CAPI3REF: Invert A Changeset
         8991  +**
         8992  +** This function is used to "invert" a changeset object. Applying an inverted
         8993  +** changeset to a database reverses the effects of applying the uninverted
         8994  +** changeset. Specifically:
         8995  +**
         8996  +** <ul>
         8997  +**   <li> Each DELETE change is changed to an INSERT, and
         8998  +**   <li> Each INSERT change is changed to a DELETE, and
         8999  +**   <li> For each UPDATE change, the old.* and new.* values are exchanged.
         9000  +** </ul>
         9001  +**
         9002  +** This function does not change the order in which changes appear within
         9003  +** the changeset. It merely reverses the sense of each individual change.
         9004  +**
         9005  +** If successful, a pointer to a buffer containing the inverted changeset
         9006  +** is stored in *ppOut, the size of the same buffer is stored in *pnOut, and
         9007  +** SQLITE_OK is returned. If an error occurs, both *pnOut and *ppOut are
         9008  +** zeroed and an SQLite error code returned.
         9009  +**
         9010  +** It is the responsibility of the caller to eventually call sqlite3_free()
         9011  +** on the *ppOut pointer to free the buffer allocation following a successful 
         9012  +** call to this function.
         9013  +**
         9014  +** WARNING/TODO: This function currently assumes that the input is a valid
         9015  +** changeset. If it is not, the results are undefined.
         9016  +*/
         9017  +int sqlite3changeset_invert(
         9018  +  int nIn, const void *pIn,       /* Input changeset */
         9019  +  int *pnOut, void **ppOut        /* OUT: Inverse of input */
         9020  +);
         9021  +
         9022  +/*
         9023  +** CAPI3REF: Concatenate Two Changeset Objects
         9024  +**
         9025  +** This function is used to concatenate two changesets, A and B, into a 
         9026  +** single changeset. The result is a changeset equivalent to applying
         9027  +** changeset A followed by changeset B. 
         9028  +**
         9029  +** This function combines the two input changesets using an 
         9030  +** sqlite3_changegroup object. Calling it produces similar results as the
         9031  +** following code fragment:
         9032  +**
         9033  +**   sqlite3_changegroup *pGrp;
         9034  +**   rc = sqlite3_changegroup_new(&pGrp);
         9035  +**   if( rc==SQLITE_OK ) rc = sqlite3changegroup_add(pGrp, nA, pA);
         9036  +**   if( rc==SQLITE_OK ) rc = sqlite3changegroup_add(pGrp, nB, pB);
         9037  +**   if( rc==SQLITE_OK ){
         9038  +**     rc = sqlite3changegroup_output(pGrp, pnOut, ppOut);
         9039  +**   }else{
         9040  +**     *ppOut = 0;
         9041  +**     *pnOut = 0;
         9042  +**   }
         9043  +**
         9044  +** Refer to the sqlite3_changegroup documentation below for details.
         9045  +*/
         9046  +int sqlite3changeset_concat(
         9047  +  int nA,                         /* Number of bytes in buffer pA */
         9048  +  void *pA,                       /* Pointer to buffer containing changeset A */
         9049  +  int nB,                         /* Number of bytes in buffer pB */
         9050  +  void *pB,                       /* Pointer to buffer containing changeset B */
         9051  +  int *pnOut,                     /* OUT: Number of bytes in output changeset */
         9052  +  void **ppOut                    /* OUT: Buffer containing output changeset */
         9053  +);
         9054  +
         9055  +
         9056  +/*
         9057  +** Changegroup handle.
         9058  +*/
         9059  +typedef struct sqlite3_changegroup sqlite3_changegroup;
         9060  +
         9061  +/*
         9062  +** CAPI3REF: Combine two or more changesets into a single changeset.
         9063  +**
         9064  +** An sqlite3_changegroup object is used to combine two or more changesets
         9065  +** (or patchsets) into a single changeset (or patchset). A single changegroup
         9066  +** object may combine changesets or patchsets, but not both. The output is
         9067  +** always in the same format as the input.
         9068  +**
         9069  +** If successful, this function returns SQLITE_OK and populates (*pp) with
         9070  +** a pointer to a new sqlite3_changegroup object before returning. The caller
         9071  +** should eventually free the returned object using a call to 
         9072  +** sqlite3changegroup_delete(). If an error occurs, an SQLite error code
         9073  +** (i.e. SQLITE_NOMEM) is returned and *pp is set to NULL.
         9074  +**
         9075  +** The usual usage pattern for an sqlite3_changegroup object is as follows:
         9076  +**
         9077  +** <ul>
         9078  +**   <li> It is created using a call to sqlite3changegroup_new().
         9079  +**
         9080  +**   <li> Zero or more changesets (or patchsets) are added to the object
         9081  +**        by calling sqlite3changegroup_add().
         9082  +**
         9083  +**   <li> The result of combining all input changesets together is obtained 
         9084  +**        by the application via a call to sqlite3changegroup_output().
         9085  +**
         9086  +**   <li> The object is deleted using a call to sqlite3changegroup_delete().
         9087  +** </ul>
         9088  +**
         9089  +** Any number of calls to add() and output() may be made between the calls to
         9090  +** new() and delete(), and in any order.
         9091  +**
         9092  +** As well as the regular sqlite3changegroup_add() and 
         9093  +** sqlite3changegroup_output() functions, also available are the streaming
         9094  +** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().
         9095  +*/
         9096  +int sqlite3changegroup_new(sqlite3_changegroup **pp);
         9097  +
         9098  +/*
         9099  +** Add all changes within the changeset (or patchset) in buffer pData (size
         9100  +** nData bytes) to the changegroup. 
         9101  +**
         9102  +** If the buffer contains a patchset, then all prior calls to this function
         9103  +** on the same changegroup object must also have specified patchsets. Or, if
         9104  +** the buffer contains a changeset, so must have the earlier calls to this
         9105  +** function. Otherwise, SQLITE_ERROR is returned and no changes are added
         9106  +** to the changegroup.
         9107  +**
         9108  +** Rows within the changeset and changegroup are identified by the values in
         9109  +** their PRIMARY KEY columns. A change in the changeset is considered to
         9110  +** apply to the same row as a change already present in the changegroup if
         9111  +** the two rows have the same primary key.
         9112  +**
         9113  +** Changes to rows that that do not already appear in the changegroup are
         9114  +** simply copied into it. Or, if both the new changeset and the changegroup
         9115  +** contain changes that apply to a single row, the final contents of the
         9116  +** changegroup depends on the type of each change, as follows:
         9117  +**
         9118  +** <table border=1 style="margin-left:8ex;margin-right:8ex">
         9119  +**   <tr><th style="white-space:pre">Existing Change  </th>
         9120  +**       <th style="white-space:pre">New Change       </th>
         9121  +**       <th>Output Change
         9122  +**   <tr><td>INSERT <td>INSERT <td>
         9123  +**       The new change is ignored. This case does not occur if the new
         9124  +**       changeset was recorded immediately after the changesets already
         9125  +**       added to the changegroup.
         9126  +**   <tr><td>INSERT <td>UPDATE <td>
         9127  +**       The INSERT change remains in the changegroup. The values in the 
         9128  +**       INSERT change are modified as if the row was inserted by the
         9129  +**       existing change and then updated according to the new change.
         9130  +**   <tr><td>INSERT <td>DELETE <td>
         9131  +**       The existing INSERT is removed from the changegroup. The DELETE is
         9132  +**       not added.
         9133  +**   <tr><td>UPDATE <td>INSERT <td>
         9134  +**       The new change is ignored. This case does not occur if the new
         9135  +**       changeset was recorded immediately after the changesets already
         9136  +**       added to the changegroup.
         9137  +**   <tr><td>UPDATE <td>UPDATE <td>
         9138  +**       The existing UPDATE remains within the changegroup. It is amended 
         9139  +**       so that the accompanying values are as if the row was updated once 
         9140  +**       by the existing change and then again by the new change.
         9141  +**   <tr><td>UPDATE <td>DELETE <td>
         9142  +**       The existing UPDATE is replaced by the new DELETE within the
         9143  +**       changegroup.
         9144  +**   <tr><td>DELETE <td>INSERT <td>
         9145  +**       If one or more of the column values in the row inserted by the
         9146  +**       new change differ from those in the row deleted by the existing 
         9147  +**       change, the existing DELETE is replaced by an UPDATE within the
         9148  +**       changegroup. Otherwise, if the inserted row is exactly the same 
         9149  +**       as the deleted row, the existing DELETE is simply discarded.
         9150  +**   <tr><td>DELETE <td>UPDATE <td>
         9151  +**       The new change is ignored. This case does not occur if the new
         9152  +**       changeset was recorded immediately after the changesets already
         9153  +**       added to the changegroup.
         9154  +**   <tr><td>DELETE <td>DELETE <td>
         9155  +**       The new change is ignored. This case does not occur if the new
         9156  +**       changeset was recorded immediately after the changesets already
         9157  +**       added to the changegroup.
         9158  +** </table>
         9159  +**
         9160  +** If the new changeset contains changes to a table that is already present
         9161  +** in the changegroup, then the number of columns and the position of the
         9162  +** primary key columns for the table must be consistent. If this is not the
         9163  +** case, this function fails with SQLITE_SCHEMA. If the input changeset
         9164  +** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is
         9165  +** returned. Or, if an out-of-memory condition occurs during processing, this
         9166  +** function returns SQLITE_NOMEM. In all cases, if an error occurs the
         9167  +** final contents of the changegroup is undefined.
         9168  +**
         9169  +** If no error occurs, SQLITE_OK is returned.
         9170  +*/
         9171  +int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
         9172  +
         9173  +/*
         9174  +** Obtain a buffer containing a changeset (or patchset) representing the
         9175  +** current contents of the changegroup. If the inputs to the changegroup
         9176  +** were themselves changesets, the output is a changeset. Or, if the
         9177  +** inputs were patchsets, the output is also a patchset.
         9178  +**
         9179  +** As with the output of the sqlite3session_changeset() and
         9180  +** sqlite3session_patchset() functions, all changes related to a single
         9181  +** table are grouped together in the output of this function. Tables appear
         9182  +** in the same order as for the very first changeset added to the changegroup.
         9183  +** If the second or subsequent changesets added to the changegroup contain
         9184  +** changes for tables that do not appear in the first changeset, they are
         9185  +** appended onto the end of the output changeset, again in the order in
         9186  +** which they are first encountered.
         9187  +**
         9188  +** If an error occurs, an SQLite error code is returned and the output
         9189  +** variables (*pnData) and (*ppData) are set to 0. Otherwise, SQLITE_OK
         9190  +** is returned and the output variables are set to the size of and a 
         9191  +** pointer to the output buffer, respectively. In this case it is the
         9192  +** responsibility of the caller to eventually free the buffer using a
         9193  +** call to sqlite3_free().
         9194  +*/
         9195  +int sqlite3changegroup_output(
         9196  +  sqlite3_changegroup*,
         9197  +  int *pnData,                    /* OUT: Size of output buffer in bytes */
         9198  +  void **ppData                   /* OUT: Pointer to output buffer */
         9199  +);
         9200  +
         9201  +/*
         9202  +** Delete a changegroup object.
         9203  +*/
         9204  +void sqlite3changegroup_delete(sqlite3_changegroup*);
         9205  +
         9206  +/*
         9207  +** CAPI3REF: Apply A Changeset To A Database
         9208  +**
         9209  +** Apply a changeset to a database. This function attempts to update the
         9210  +** "main" database attached to handle db with the changes found in the
         9211  +** changeset passed via the second and third arguments.
         9212  +**
         9213  +** The fourth argument (xFilter) passed to this function is the "filter
         9214  +** callback". If it is not NULL, then for each table affected by at least one
         9215  +** change in the changeset, the filter callback is invoked with
         9216  +** the table name as the second argument, and a copy of the context pointer
         9217  +** passed as the sixth argument to this function as the first. If the "filter
         9218  +** callback" returns zero, then no attempt is made to apply any changes to 
         9219  +** the table. Otherwise, if the return value is non-zero or the xFilter
         9220  +** argument to this function is NULL, all changes related to the table are
         9221  +** attempted.
         9222  +**
         9223  +** For each table that is not excluded by the filter callback, this function 
         9224  +** tests that the target database contains a compatible table. A table is 
         9225  +** considered compatible if all of the following are true:
         9226  +**
         9227  +** <ul>
         9228  +**   <li> The table has the same name as the name recorded in the 
         9229  +**        changeset, and
         9230  +**   <li> The table has the same number of columns as recorded in the 
         9231  +**        changeset, and
         9232  +**   <li> The table has primary key columns in the same position as 
         9233  +**        recorded in the changeset.
         9234  +** </ul>
         9235  +**
         9236  +** If there is no compatible table, it is not an error, but none of the
         9237  +** changes associated with the table are applied. A warning message is issued
         9238  +** via the sqlite3_log() mechanism with the error code SQLITE_SCHEMA. At most
         9239  +** one such warning is issued for each table in the changeset.
         9240  +**
         9241  +** For each change for which there is a compatible table, an attempt is made 
         9242  +** to modify the table contents according to the UPDATE, INSERT or DELETE 
         9243  +** change. If a change cannot be applied cleanly, the conflict handler 
         9244  +** function passed as the fifth argument to sqlite3changeset_apply() may be 
         9245  +** invoked. A description of exactly when the conflict handler is invoked for 
         9246  +** each type of change is below.
         9247  +**
         9248  +** Unlike the xFilter argument, xConflict may not be passed NULL. The results
         9249  +** of passing anything other than a valid function pointer as the xConflict
         9250  +** argument are undefined.
         9251  +**
         9252  +** Each time the conflict handler function is invoked, it must return one
         9253  +** of [SQLITE_CHANGESET_OMIT], [SQLITE_CHANGESET_ABORT] or 
         9254  +** [SQLITE_CHANGESET_REPLACE]. SQLITE_CHANGESET_REPLACE may only be returned
         9255  +** if the second argument passed to the conflict handler is either
         9256  +** SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If the conflict-handler
         9257  +** returns an illegal value, any changes already made are rolled back and
         9258  +** the call to sqlite3changeset_apply() returns SQLITE_MISUSE. Different 
         9259  +** actions are taken by sqlite3changeset_apply() depending on the value
         9260  +** returned by each invocation of the conflict-handler function. Refer to
         9261  +** the documentation for the three 
         9262  +** [SQLITE_CHANGESET_OMIT|available return values] for details.
         9263  +**
         9264  +** <dl>
         9265  +** <dt>DELETE Changes<dd>
         9266  +**   For each DELETE change, this function checks if the target database 
         9267  +**   contains a row with the same primary key value (or values) as the 
         9268  +**   original row values stored in the changeset. If it does, and the values 
         9269  +**   stored in all non-primary key columns also match the values stored in 
         9270  +**   the changeset the row is deleted from the target database.
         9271  +**
         9272  +**   If a row with matching primary key values is found, but one or more of
         9273  +**   the non-primary key fields contains a value different from the original
         9274  +**   row value stored in the changeset, the conflict-handler function is
         9275  +**   invoked with [SQLITE_CHANGESET_DATA] as the second argument.
         9276  +**
         9277  +**   If no row with matching primary key values is found in the database,
         9278  +**   the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND]
         9279  +**   passed as the second argument.
         9280  +**
         9281  +**   If the DELETE operation is attempted, but SQLite returns SQLITE_CONSTRAINT
         9282  +**   (which can only happen if a foreign key constraint is violated), the
         9283  +**   conflict-handler function is invoked with [SQLITE_CHANGESET_CONSTRAINT]
         9284  +**   passed as the second argument. This includes the case where the DELETE
         9285  +**   operation is attempted because an earlier call to the conflict handler
         9286  +**   function returned [SQLITE_CHANGESET_REPLACE].
         9287  +**
         9288  +** <dt>INSERT Changes<dd>
         9289  +**   For each INSERT change, an attempt is made to insert the new row into
         9290  +**   the database.
         9291  +**
         9292  +**   If the attempt to insert the row fails because the database already 
         9293  +**   contains a row with the same primary key values, the conflict handler
         9294  +**   function is invoked with the second argument set to 
         9295  +**   [SQLITE_CHANGESET_CONFLICT].
         9296  +**
         9297  +**   If the attempt to insert the row fails because of some other constraint
         9298  +**   violation (e.g. NOT NULL or UNIQUE), the conflict handler function is 
         9299  +**   invoked with the second argument set to [SQLITE_CHANGESET_CONSTRAINT].
         9300  +**   This includes the case where the INSERT operation is re-attempted because 
         9301  +**   an earlier call to the conflict handler function returned 
         9302  +**   [SQLITE_CHANGESET_REPLACE].
         9303  +**
         9304  +** <dt>UPDATE Changes<dd>
         9305  +**   For each UPDATE change, this function checks if the target database 
         9306  +**   contains a row with the same primary key value (or values) as the 
         9307  +**   original row values stored in the changeset. If it does, and the values 
         9308  +**   stored in all non-primary key columns also match the values stored in 
         9309  +**   the changeset the row is updated within the target database.
         9310  +**
         9311  +**   If a row with matching primary key values is found, but one or more of
         9312  +**   the non-primary key fields contains a value different from an original
         9313  +**   row value stored in the changeset, the conflict-handler function is
         9314  +**   invoked with [SQLITE_CHANGESET_DATA] as the second argument. Since
         9315  +**   UPDATE changes only contain values for non-primary key fields that are
         9316  +**   to be modified, only those fields need to match the original values to
         9317  +**   avoid the SQLITE_CHANGESET_DATA conflict-handler callback.
         9318  +**
         9319  +**   If no row with matching primary key values is found in the database,
         9320  +**   the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND]
         9321  +**   passed as the second argument.
         9322  +**
         9323  +**   If the UPDATE operation is attempted, but SQLite returns 
         9324  +**   SQLITE_CONSTRAINT, the conflict-handler function is invoked with 
         9325  +**   [SQLITE_CHANGESET_CONSTRAINT] passed as the second argument.
         9326  +**   This includes the case where the UPDATE operation is attempted after 
         9327  +**   an earlier call to the conflict handler function returned
         9328  +**   [SQLITE_CHANGESET_REPLACE].  
         9329  +** </dl>
         9330  +**
         9331  +** It is safe to execute SQL statements, including those that write to the
         9332  +** table that the callback related to, from within the xConflict callback.
         9333  +** This can be used to further customize the applications conflict
         9334  +** resolution strategy.
         9335  +**
         9336  +** All changes made by this function are enclosed in a savepoint transaction.
         9337  +** If any other error (aside from a constraint failure when attempting to
         9338  +** write to the target database) occurs, then the savepoint transaction is
         9339  +** rolled back, restoring the target database to its original state, and an 
         9340  +** SQLite error code returned.
         9341  +*/
         9342  +int sqlite3changeset_apply(
         9343  +  sqlite3 *db,                    /* Apply change to "main" db of this handle */
         9344  +  int nChangeset,                 /* Size of changeset in bytes */
         9345  +  void *pChangeset,               /* Changeset blob */
         9346  +  int(*xFilter)(
         9347  +    void *pCtx,                   /* Copy of sixth arg to _apply() */
         9348  +    const char *zTab              /* Table name */
         9349  +  ),
         9350  +  int(*xConflict)(
         9351  +    void *pCtx,                   /* Copy of sixth arg to _apply() */
         9352  +    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
         9353  +    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
         9354  +  ),
         9355  +  void *pCtx                      /* First argument passed to xConflict */
         9356  +);
         9357  +
         9358  +/* 
         9359  +** CAPI3REF: Constants Passed To The Conflict Handler
         9360  +**
         9361  +** Values that may be passed as the second argument to a conflict-handler.
         9362  +**
         9363  +** <dl>
         9364  +** <dt>SQLITE_CHANGESET_DATA<dd>
         9365  +**   The conflict handler is invoked with CHANGESET_DATA as the second argument
         9366  +**   when processing a DELETE or UPDATE change if a row with the required
         9367  +**   PRIMARY KEY fields is present in the database, but one or more other 
         9368  +**   (non primary-key) fields modified by the update do not contain the 
         9369  +**   expected "before" values.
         9370  +** 
         9371  +**   The conflicting row, in this case, is the database row with the matching
         9372  +**   primary key.
         9373  +** 
         9374  +** <dt>SQLITE_CHANGESET_NOTFOUND<dd>
         9375  +**   The conflict handler is invoked with CHANGESET_NOTFOUND as the second
         9376  +**   argument when processing a DELETE or UPDATE change if a row with the
         9377  +**   required PRIMARY KEY fields is not present in the database.
         9378  +** 
         9379  +**   There is no conflicting row in this case. The results of invoking the
         9380  +**   sqlite3changeset_conflict() API are undefined.
         9381  +** 
         9382  +** <dt>SQLITE_CHANGESET_CONFLICT<dd>
         9383  +**   CHANGESET_CONFLICT is passed as the second argument to the conflict
         9384  +**   handler while processing an INSERT change if the operation would result 
         9385  +**   in duplicate primary key values.
         9386  +** 
         9387  +**   The conflicting row in this case is the database row with the matching
         9388  +**   primary key.
         9389  +**
         9390  +** <dt>SQLITE_CHANGESET_FOREIGN_KEY<dd>
         9391  +**   If foreign key handling is enabled, and applying a changeset leaves the
         9392  +**   database in a state containing foreign key violations, the conflict 
         9393  +**   handler is invoked with CHANGESET_FOREIGN_KEY as the second argument
         9394  +**   exactly once before the changeset is committed. If the conflict handler
         9395  +**   returns CHANGESET_OMIT, the changes, including those that caused the
         9396  +**   foreign key constraint violation, are committed. Or, if it returns
         9397  +**   CHANGESET_ABORT, the changeset is rolled back.
         9398  +**
         9399  +**   No current or conflicting row information is provided. The only function
         9400  +**   it is possible to call on the supplied sqlite3_changeset_iter handle
         9401  +**   is sqlite3changeset_fk_conflicts().
         9402  +** 
         9403  +** <dt>SQLITE_CHANGESET_CONSTRAINT<dd>
         9404  +**   If any other constraint violation occurs while applying a change (i.e. 
         9405  +**   a UNIQUE, CHECK or NOT NULL constraint), the conflict handler is 
         9406  +**   invoked with CHANGESET_CONSTRAINT as the second argument.
         9407  +** 
         9408  +**   There is no conflicting row in this case. The results of invoking the
         9409  +**   sqlite3changeset_conflict() API are undefined.
         9410  +**
         9411  +** </dl>
         9412  +*/
         9413  +#define SQLITE_CHANGESET_DATA        1
         9414  +#define SQLITE_CHANGESET_NOTFOUND    2
         9415  +#define SQLITE_CHANGESET_CONFLICT    3
         9416  +#define SQLITE_CHANGESET_CONSTRAINT  4
         9417  +#define SQLITE_CHANGESET_FOREIGN_KEY 5
         9418  +
         9419  +/* 
         9420  +** CAPI3REF: Constants Returned By The Conflict Handler
         9421  +**
         9422  +** A conflict handler callback must return one of the following three values.
         9423  +**
         9424  +** <dl>
         9425  +** <dt>SQLITE_CHANGESET_OMIT<dd>
         9426  +**   If a conflict handler returns this value no special action is taken. The
         9427  +**   change that caused the conflict is not applied. The session module 
         9428  +**   continues to the next change in the changeset.
         9429  +**
         9430  +** <dt>SQLITE_CHANGESET_REPLACE<dd>
         9431  +**   This value may only be returned if the second argument to the conflict
         9432  +**   handler was SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If this
         9433  +**   is not the case, any changes applied so far are rolled back and the 
         9434  +**   call to sqlite3changeset_apply() returns SQLITE_MISUSE.
         9435  +**
         9436  +**   If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_DATA conflict
         9437  +**   handler, then the conflicting row is either updated or deleted, depending
         9438  +**   on the type of change.
         9439  +**
         9440  +**   If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_CONFLICT conflict
         9441  +**   handler, then the conflicting row is removed from the database and a
         9442  +**   second attempt to apply the change is made. If this second attempt fails,
         9443  +**   the original row is restored to the database before continuing.
         9444  +**
         9445  +** <dt>SQLITE_CHANGESET_ABORT<dd>
         9446  +**   If this value is returned, any changes applied so far are rolled back 
         9447  +**   and the call to sqlite3changeset_apply() returns SQLITE_ABORT.
         9448  +** </dl>
         9449  +*/
         9450  +#define SQLITE_CHANGESET_OMIT       0
         9451  +#define SQLITE_CHANGESET_REPLACE    1
         9452  +#define SQLITE_CHANGESET_ABORT      2
         9453  +
         9454  +/*
         9455  +** CAPI3REF: Streaming Versions of API functions.
         9456  +**
         9457  +** The six streaming API xxx_strm() functions serve similar purposes to the 
         9458  +** corresponding non-streaming API functions:
         9459  +**
         9460  +** <table border=1 style="margin-left:8ex;margin-right:8ex">
         9461  +**   <tr><th>Streaming function<th>Non-streaming equivalent</th>
         9462  +**   <tr><td>sqlite3changeset_apply_str<td>[sqlite3changeset_apply] 
         9463  +**   <tr><td>sqlite3changeset_concat_str<td>[sqlite3changeset_concat] 
         9464  +**   <tr><td>sqlite3changeset_invert_str<td>[sqlite3changeset_invert] 
         9465  +**   <tr><td>sqlite3changeset_start_str<td>[sqlite3changeset_start] 
         9466  +**   <tr><td>sqlite3session_changeset_str<td>[sqlite3session_changeset] 
         9467  +**   <tr><td>sqlite3session_patchset_str<td>[sqlite3session_patchset] 
         9468  +** </table>
         9469  +**
         9470  +** Non-streaming functions that accept changesets (or patchsets) as input
         9471  +** require that the entire changeset be stored in a single buffer in memory. 
         9472  +** Similarly, those that return a changeset or patchset do so by returning 
         9473  +** a pointer to a single large buffer allocated using sqlite3_malloc(). 
         9474  +** Normally this is convenient. However, if an application running in a 
         9475  +** low-memory environment is required to handle very large changesets, the
         9476  +** large contiguous memory allocations required can become onerous.
         9477  +**
         9478  +** In order to avoid this problem, instead of a single large buffer, input
         9479  +** is passed to a streaming API functions by way of a callback function that
         9480  +** the sessions module invokes to incrementally request input data as it is
         9481  +** required. In all cases, a pair of API function parameters such as
         9482  +**
         9483  +**  <pre>
         9484  +**  &nbsp;     int nChangeset,
         9485  +**  &nbsp;     void *pChangeset,
         9486  +**  </pre>
         9487  +**
         9488  +** Is replaced by:
         9489  +**
         9490  +**  <pre>
         9491  +**  &nbsp;     int (*xInput)(void *pIn, void *pData, int *pnData),
         9492  +**  &nbsp;     void *pIn,
         9493  +**  </pre>
         9494  +**
         9495  +** Each time the xInput callback is invoked by the sessions module, the first
         9496  +** argument passed is a copy of the supplied pIn context pointer. The second 
         9497  +** argument, pData, points to a buffer (*pnData) bytes in size. Assuming no 
         9498  +** error occurs the xInput method should copy up to (*pnData) bytes of data 
         9499  +** into the buffer and set (*pnData) to the actual number of bytes copied 
         9500  +** before returning SQLITE_OK. If the input is completely exhausted, (*pnData) 
         9501  +** should be set to zero to indicate this. Or, if an error occurs, an SQLite 
         9502  +** error code should be returned. In all cases, if an xInput callback returns
         9503  +** an error, all processing is abandoned and the streaming API function
         9504  +** returns a copy of the error code to the caller.
         9505  +**
         9506  +** In the case of sqlite3changeset_start_strm(), the xInput callback may be
         9507  +** invoked by the sessions module at any point during the lifetime of the
         9508  +** iterator. If such an xInput callback returns an error, the iterator enters
         9509  +** an error state, whereby all subsequent calls to iterator functions 
         9510  +** immediately fail with the same error code as returned by xInput.
         9511  +**
         9512  +** Similarly, streaming API functions that return changesets (or patchsets)
         9513  +** return them in chunks by way of a callback function instead of via a
         9514  +** pointer to a single large buffer. In this case, a pair of parameters such
         9515  +** as:
         9516  +**
         9517  +**  <pre>
         9518  +**  &nbsp;     int *pnChangeset,
         9519  +**  &nbsp;     void **ppChangeset,
         9520  +**  </pre>
         9521  +**
         9522  +** Is replaced by:
         9523  +**
         9524  +**  <pre>
         9525  +**  &nbsp;     int (*xOutput)(void *pOut, const void *pData, int nData),
         9526  +**  &nbsp;     void *pOut
         9527  +**  </pre>
         9528  +**
         9529  +** The xOutput callback is invoked zero or more times to return data to
         9530  +** the application. The first parameter passed to each call is a copy of the
         9531  +** pOut pointer supplied by the application. The second parameter, pData,
         9532  +** points to a buffer nData bytes in size containing the chunk of output
         9533  +** data being returned. If the xOutput callback successfully processes the
         9534  +** supplied data, it should return SQLITE_OK to indicate success. Otherwise,
         9535  +** it should return some other SQLite error code. In this case processing
         9536  +** is immediately abandoned and the streaming API function returns a copy
         9537  +** of the xOutput error code to the application.
         9538  +**
         9539  +** The sessions module never invokes an xOutput callback with the third 
         9540  +** parameter set to a value less than or equal to zero. Other than this,
         9541  +** no guarantees are made as to the size of the chunks of data returned.
         9542  +*/
         9543  +int sqlite3changeset_apply_strm(
         9544  +  sqlite3 *db,                    /* Apply change to "main" db of this handle */
         9545  +  int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
         9546  +  void *pIn,                                          /* First arg for xInput */
         9547  +  int(*xFilter)(
         9548  +    void *pCtx,                   /* Copy of sixth arg to _apply() */
         9549  +    const char *zTab              /* Table name */
         9550  +  ),
         9551  +  int(*xConflict)(
         9552  +    void *pCtx,                   /* Copy of sixth arg to _apply() */
         9553  +    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
         9554  +    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
         9555  +  ),
         9556  +  void *pCtx                      /* First argument passed to xConflict */
         9557  +);
         9558  +int sqlite3changeset_concat_strm(
         9559  +  int (*xInputA)(void *pIn, void *pData, int *pnData),
         9560  +  void *pInA,
         9561  +  int (*xInputB)(void *pIn, void *pData, int *pnData),
         9562  +  void *pInB,
         9563  +  int (*xOutput)(void *pOut, const void *pData, int nData),
         9564  +  void *pOut
         9565  +);
         9566  +int sqlite3changeset_invert_strm(
         9567  +  int (*xInput)(void *pIn, void *pData, int *pnData),
         9568  +  void *pIn,
         9569  +  int (*xOutput)(void *pOut, const void *pData, int nData),
         9570  +  void *pOut
         9571  +);
         9572  +int sqlite3changeset_start_strm(
         9573  +  sqlite3_changeset_iter **pp,
         9574  +  int (*xInput)(void *pIn, void *pData, int *pnData),
         9575  +  void *pIn
         9576  +);
         9577  +int sqlite3session_changeset_strm(
         9578  +  sqlite3_session *pSession,
         9579  +  int (*xOutput)(void *pOut, const void *pData, int nData),
         9580  +  void *pOut
         9581  +);
         9582  +int sqlite3session_patchset_strm(
         9583  +  sqlite3_session *pSession,
         9584  +  int (*xOutput)(void *pOut, const void *pData, int nData),
         9585  +  void *pOut
         9586  +);
         9587  +int sqlite3changegroup_add_strm(sqlite3_changegroup*, 
         9588  +    int (*xInput)(void *pIn, void *pData, int *pnData),
         9589  +    void *pIn
         9590  +);
         9591  +int sqlite3changegroup_output_strm(sqlite3_changegroup*,
         9592  +    int (*xOutput)(void *pOut, const void *pData, int nData), 
         9593  +    void *pOut
         9594  +);
         9595  +
         9596  +
         9597  +/*
         9598  +** Make sure we can call this stuff from C++.
         9599  +*/
         9600  +#ifdef __cplusplus
         9601  +}
         9602  +#endif
         9603  +
         9604  +#endif  /* !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION) */
         9605  +
         9606  +/******** End of sqlite3session.h *********/
         9607  +/******** Begin file fts5.h *********/
         9608  +/*
         9609  +** 2014 May 31
         9610  +**
         9611  +** The author disclaims copyright to this source code.  In place of
         9612  +** a legal notice, here is a blessing:
         9613  +**
         9614  +**    May you do good and not evil.
         9615  +**    May you find forgiveness for yourself and forgive others.
         9616  +**    May you share freely, never taking more than you give.
         9617  +**
         9618  +******************************************************************************
         9619  +**
         9620  +** Interfaces to extend FTS5. Using the interfaces defined in this file, 
         9621  +** FTS5 may be extended with:
         9622  +**
         9623  +**     * custom tokenizers, and
         9624  +**     * custom auxiliary functions.
         9625  +*/
         9626  +
         9627  +
         9628  +#ifndef _FTS5_H
         9629  +#define _FTS5_H
         9630  +
         9631  +
         9632  +#ifdef __cplusplus
         9633  +extern "C" {
         9634  +#endif
         9635  +
         9636  +/*************************************************************************
         9637  +** CUSTOM AUXILIARY FUNCTIONS
         9638  +**
         9639  +** Virtual table implementations may overload SQL functions by implementing
         9640  +** the sqlite3_module.xFindFunction() method.
         9641  +*/
         9642  +
         9643  +typedef struct Fts5ExtensionApi Fts5ExtensionApi;
         9644  +typedef struct Fts5Context Fts5Context;
         9645  +typedef struct Fts5PhraseIter Fts5PhraseIter;
         9646  +
         9647  +typedef void (*fts5_extension_function)(
         9648  +  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */
         9649  +  Fts5Context *pFts,              /* First arg to pass to pApi functions */
         9650  +  sqlite3_context *pCtx,          /* Context for returning result/error */
         9651  +  int nVal,                       /* Number of values in apVal[] array */
         9652  +  sqlite3_value **apVal           /* Array of trailing arguments */
         9653  +);
         9654  +
         9655  +struct Fts5PhraseIter {
         9656  +  const unsigned char *a;
         9657  +  const unsigned char *b;
         9658  +};
         9659  +
         9660  +/*
         9661  +** EXTENSION API FUNCTIONS
         9662  +**
         9663  +** xUserData(pFts):
         9664  +**   Return a copy of the context pointer the extension function was 
         9665  +**   registered with.
         9666  +**
         9667  +** xColumnTotalSize(pFts, iCol, pnToken):
         9668  +**   If parameter iCol is less than zero, set output variable *pnToken
         9669  +**   to the total number of tokens in the FTS5 table. Or, if iCol is
         9670  +**   non-negative but less than the number of columns in the table, return
         9671  +**   the total number of tokens in column iCol, considering all rows in 
         9672  +**   the FTS5 table.
         9673  +**
         9674  +**   If parameter iCol is greater than or equal to the number of columns
         9675  +**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
         9676  +**   an OOM condition or IO error), an appropriate SQLite error code is 
         9677  +**   returned.
         9678  +**
         9679  +** xColumnCount(pFts):
         9680  +**   Return the number of columns in the table.
         9681  +**
         9682  +** xColumnSize(pFts, iCol, pnToken):
         9683  +**   If parameter iCol is less than zero, set output variable *pnToken
         9684  +**   to the total number of tokens in the current row. Or, if iCol is
         9685  +**   non-negative but less than the number of columns in the table, set
         9686  +**   *pnToken to the number of tokens in column iCol of the current row.
         9687  +**
         9688  +**   If parameter iCol is greater than or equal to the number of columns
         9689  +**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.
         9690  +**   an OOM condition or IO error), an appropriate SQLite error code is 
         9691  +**   returned.
         9692  +**
         9693  +**   This function may be quite inefficient if used with an FTS5 table
         9694  +**   created with the "columnsize=0" option.
         9695  +**
         9696  +** xColumnText:
         9697  +**   This function attempts to retrieve the text of column iCol of the
         9698  +**   current document. If successful, (*pz) is set to point to a buffer
         9699  +**   containing the text in utf-8 encoding, (*pn) is set to the size in bytes
         9700  +**   (not characters) of the buffer and SQLITE_OK is returned. Otherwise,
         9701  +**   if an error occurs, an SQLite error code is returned and the final values
         9702  +**   of (*pz) and (*pn) are undefined.
         9703  +**
         9704  +** xPhraseCount:
         9705  +**   Returns the number of phrases in the current query expression.
         9706  +**
         9707  +** xPhraseSize:
         9708  +**   Returns the number of tokens in phrase iPhrase of the query. Phrases
         9709  +**   are numbered starting from zero.
         9710  +**
         9711  +** xInstCount:
         9712  +**   Set *pnInst to the total number of occurrences of all phrases within
         9713  +**   the query within the current row. Return SQLITE_OK if successful, or
         9714  +**   an error code (i.e. SQLITE_NOMEM) if an error occurs.
         9715  +**
         9716  +**   This API can be quite slow if used with an FTS5 table created with the
         9717  +**   "detail=none" or "detail=column" option. If the FTS5 table is created 
         9718  +**   with either "detail=none" or "detail=column" and "content=" option 
         9719  +**   (i.e. if it is a contentless table), then this API always returns 0.
         9720  +**
         9721  +** xInst:
         9722  +**   Query for the details of phrase match iIdx within the current row.
         9723  +**   Phrase matches are numbered starting from zero, so the iIdx argument
         9724  +**   should be greater than or equal to zero and smaller than the value
         9725  +**   output by xInstCount().
         9726  +**
         9727  +**   Usually, output parameter *piPhrase is set to the phrase number, *piCol
         9728  +**   to the column in which it occurs and *piOff the token offset of the
         9729  +**   first token of the phrase. The exception is if the table was created
         9730  +**   with the offsets=0 option specified. In this case *piOff is always
         9731  +**   set to -1.
         9732  +**
         9733  +**   Returns SQLITE_OK if successful, or an error code (i.e. SQLITE_NOMEM) 
         9734  +**   if an error occurs.
         9735  +**
         9736  +**   This API can be quite slow if used with an FTS5 table created with the
         9737  +**   "detail=none" or "detail=column" option. 
         9738  +**
         9739  +** xRowid:
         9740  +**   Returns the rowid of the current row.
         9741  +**
         9742  +** xTokenize:
         9743  +**   Tokenize text using the tokenizer belonging to the FTS5 table.
         9744  +**
         9745  +** xQueryPhrase(pFts5, iPhrase, pUserData, xCallback):
         9746  +**   This API function is used to query the FTS table for phrase iPhrase
         9747  +**   of the current query. Specifically, a query equivalent to:
         9748  +**
         9749  +**       ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid
         9750  +**
         9751  +**   with $p set to a phrase equivalent to the phrase iPhrase of the
         9752  +**   current query is executed. Any column filter that applies to
         9753  +**   phrase iPhrase of the current query is included in $p. For each 
         9754  +**   row visited, the callback function passed as the fourth argument 
         9755  +**   is invoked. The context and API objects passed to the callback 
         9756  +**   function may be used to access the properties of each matched row.
         9757  +**   Invoking Api.xUserData() returns a copy of the pointer passed as 
         9758  +**   the third argument to pUserData.
         9759  +**
         9760  +**   If the callback function returns any value other than SQLITE_OK, the
         9761  +**   query is abandoned and the xQueryPhrase function returns immediately.
         9762  +**   If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK.
         9763  +**   Otherwise, the error code is propagated upwards.
         9764  +**
         9765  +**   If the query runs to completion without incident, SQLITE_OK is returned.
         9766  +**   Or, if some error occurs before the query completes or is aborted by
         9767  +**   the callback, an SQLite error code is returned.
         9768  +**
         9769  +**
         9770  +** xSetAuxdata(pFts5, pAux, xDelete)
         9771  +**
         9772  +**   Save the pointer passed as the second argument as the extension functions 
         9773  +**   "auxiliary data". The pointer may then be retrieved by the current or any
         9774  +**   future invocation of the same fts5 extension function made as part of
         9775  +**   of the same MATCH query using the xGetAuxdata() API.
         9776  +**
         9777  +**   Each extension function is allocated a single auxiliary data slot for
         9778  +**   each FTS query (MATCH expression). If the extension function is invoked 
         9779  +**   more than once for a single FTS query, then all invocations share a 
         9780  +**   single auxiliary data context.
         9781  +**
         9782  +**   If there is already an auxiliary data pointer when this function is
         9783  +**   invoked, then it is replaced by the new pointer. If an xDelete callback
         9784  +**   was specified along with the original pointer, it is invoked at this
         9785  +**   point.
         9786  +**
         9787  +**   The xDelete callback, if one is specified, is also invoked on the
         9788  +**   auxiliary data pointer after the FTS5 query has finished.
         9789  +**
         9790  +**   If an error (e.g. an OOM condition) occurs within this function, an
         9791  +**   the auxiliary data is set to NULL and an error code returned. If the
         9792  +**   xDelete parameter was not NULL, it is invoked on the auxiliary data
         9793  +**   pointer before returning.
         9794  +**
         9795  +**
         9796  +** xGetAuxdata(pFts5, bClear)
         9797  +**
         9798  +**   Returns the current auxiliary data pointer for the fts5 extension 
         9799  +**   function. See the xSetAuxdata() method for details.
         9800  +**
         9801  +**   If the bClear argument is non-zero, then the auxiliary data is cleared
         9802  +**   (set to NULL) before this function returns. In this case the xDelete,
         9803  +**   if any, is not invoked.
         9804  +**
         9805  +**
         9806  +** xRowCount(pFts5, pnRow)
         9807  +**
         9808  +**   This function is used to retrieve the total number of rows in the table.
         9809  +**   In other words, the same value that would be returned by:
         9810  +**
         9811  +**        SELECT count(*) FROM ftstable;
         9812  +**
         9813  +** xPhraseFirst()
         9814  +**   This function is used, along with type Fts5PhraseIter and the xPhraseNext
         9815  +**   method, to iterate through all instances of a single query phrase within
         9816  +**   the current row. This is the same information as is accessible via the
         9817  +**   xInstCount/xInst APIs. While the xInstCount/xInst APIs are more convenient
         9818  +**   to use, this API may be faster under some circumstances. To iterate 
         9819  +**   through instances of phrase iPhrase, use the following code:
         9820  +**
         9821  +**       Fts5PhraseIter iter;
         9822  +**       int iCol, iOff;
         9823  +**       for(pApi->xPhraseFirst(pFts, iPhrase, &iter, &iCol, &iOff);
         9824  +**           iCol>=0;
         9825  +**           pApi->xPhraseNext(pFts, &iter, &iCol, &iOff)
         9826  +**       ){
         9827  +**         // An instance of phrase iPhrase at offset iOff of column iCol
         9828  +**       }
         9829  +**
         9830  +**   The Fts5PhraseIter structure is defined above. Applications should not
         9831  +**   modify this structure directly - it should only be used as shown above
         9832  +**   with the xPhraseFirst() and xPhraseNext() API methods (and by
         9833  +**   xPhraseFirstColumn() and xPhraseNextColumn() as illustrated below).
         9834  +**
         9835  +**   This API can be quite slow if used with an FTS5 table created with the
         9836  +**   "detail=none" or "detail=column" option. If the FTS5 table is created 
         9837  +**   with either "detail=none" or "detail=column" and "content=" option 
         9838  +**   (i.e. if it is a contentless table), then this API always iterates
         9839  +**   through an empty set (all calls to xPhraseFirst() set iCol to -1).
         9840  +**
         9841  +** xPhraseNext()
         9842  +**   See xPhraseFirst above.
         9843  +**
         9844  +** xPhraseFirstColumn()
         9845  +**   This function and xPhraseNextColumn() are similar to the xPhraseFirst()
         9846  +**   and xPhraseNext() APIs described above. The difference is that instead
         9847  +**   of iterating through all instances of a phrase in the current row, these
         9848  +**   APIs are used to iterate through the set of columns in the current row
         9849  +**   that contain one or more instances of a specified phrase. For example:
         9850  +**
         9851  +**       Fts5PhraseIter iter;
         9852  +**       int iCol;
         9853  +**       for(pApi->xPhraseFirstColumn(pFts, iPhrase, &iter, &iCol);
         9854  +**           iCol>=0;
         9855  +**           pApi->xPhraseNextColumn(pFts, &iter, &iCol)
         9856  +**       ){
         9857  +**         // Column iCol contains at least one instance of phrase iPhrase
         9858  +**       }
         9859  +**
         9860  +**   This API can be quite slow if used with an FTS5 table created with the
         9861  +**   "detail=none" option. If the FTS5 table is created with either 
         9862  +**   "detail=none" "content=" option (i.e. if it is a contentless table), 
         9863  +**   then this API always iterates through an empty set (all calls to 
         9864  +**   xPhraseFirstColumn() set iCol to -1).
         9865  +**
         9866  +**   The information accessed using this API and its companion
         9867  +**   xPhraseFirstColumn() may also be obtained using xPhraseFirst/xPhraseNext
         9868  +**   (or xInst/xInstCount). The chief advantage of this API is that it is
         9869  +**   significantly more efficient than those alternatives when used with
         9870  +**   "detail=column" tables.  
         9871  +**
         9872  +** xPhraseNextColumn()
         9873  +**   See xPhraseFirstColumn above.
         9874  +*/
         9875  +struct Fts5ExtensionApi {
         9876  +  int iVersion;                   /* Currently always set to 3 */
         9877  +
         9878  +  void *(*xUserData)(Fts5Context*);
         9879  +
         9880  +  int (*xColumnCount)(Fts5Context*);
         9881  +  int (*xRowCount)(Fts5Context*, sqlite3_int64 *pnRow);
         9882  +  int (*xColumnTotalSize)(Fts5Context*, int iCol, sqlite3_int64 *pnToken);
         9883  +
         9884  +  int (*xTokenize)(Fts5Context*, 
         9885  +    const char *pText, int nText, /* Text to tokenize */
         9886  +    void *pCtx,                   /* Context passed to xToken() */
         9887  +    int (*xToken)(void*, int, const char*, int, int, int)       /* Callback */
         9888  +  );
         9889  +
         9890  +  int (*xPhraseCount)(Fts5Context*);
         9891  +  int (*xPhraseSize)(Fts5Context*, int iPhrase);
         9892  +
         9893  +  int (*xInstCount)(Fts5Context*, int *pnInst);
         9894  +  int (*xInst)(Fts5Context*, int iIdx, int *piPhrase, int *piCol, int *piOff);
         9895  +
         9896  +  sqlite3_int64 (*xRowid)(Fts5Context*);
         9897  +  int (*xColumnText)(Fts5Context*, int iCol, const char **pz, int *pn);
         9898  +  int (*xColumnSize)(Fts5Context*, int iCol, int *pnToken);
         9899  +
         9900  +  int (*xQueryPhrase)(Fts5Context*, int iPhrase, void *pUserData,
         9901  +    int(*)(const Fts5ExtensionApi*,Fts5Context*,void*)
         9902  +  );
         9903  +  int (*xSetAuxdata)(Fts5Context*, void *pAux, void(*xDelete)(void*));
         9904  +  void *(*xGetAuxdata)(Fts5Context*, int bClear);
         9905  +
         9906  +  int (*xPhraseFirst)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*, int*);
         9907  +  void (*xPhraseNext)(Fts5Context*, Fts5PhraseIter*, int *piCol, int *piOff);
         9908  +
         9909  +  int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*);
         9910  +  void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol);
         9911  +};
         9912  +
         9913  +/* 
         9914  +** CUSTOM AUXILIARY FUNCTIONS
         9915  +*************************************************************************/
         9916  +
         9917  +/*************************************************************************
         9918  +** CUSTOM TOKENIZERS
         9919  +**
         9920  +** Applications may also register custom tokenizer types. A tokenizer 
         9921  +** is registered by providing fts5 with a populated instance of the 
         9922  +** following structure. All structure methods must be defined, setting
         9923  +** any member of the fts5_tokenizer struct to NULL leads to undefined
         9924  +** behaviour. The structure methods are expected to function as follows:
         9925  +**
         9926  +** xCreate:
         9927  +**   This function is used to allocate and inititalize a tokenizer instance.
         9928  +**   A tokenizer instance is required to actually tokenize text.
         9929  +**
         9930  +**   The first argument passed to this function is a copy of the (void*)
         9931  +**   pointer provided by the application when the fts5_tokenizer object
         9932  +**   was registered with FTS5 (the third argument to xCreateTokenizer()). 
         9933  +**   The second and third arguments are an array of nul-terminated strings
         9934  +**   containing the tokenizer arguments, if any, specified following the
         9935  +**   tokenizer name as part of the CREATE VIRTUAL TABLE statement used
         9936  +**   to create the FTS5 table.
         9937  +**
         9938  +**   The final argument is an output variable. If successful, (*ppOut) 
         9939  +**   should be set to point to the new tokenizer handle and SQLITE_OK
         9940  +**   returned. If an error occurs, some value other than SQLITE_OK should
         9941  +**   be returned. In this case, fts5 assumes that the final value of *ppOut 
         9942  +**   is undefined.
         9943  +**
         9944  +** xDelete:
         9945  +**   This function is invoked to delete a tokenizer handle previously
         9946  +**   allocated using xCreate(). Fts5 guarantees that this function will
         9947  +**   be invoked exactly once for each successful call to xCreate().
         9948  +**
         9949  +** xTokenize:
         9950  +**   This function is expected to tokenize the nText byte string indicated 
         9951  +**   by argument pText. pText may or may not be nul-terminated. The first
         9952  +**   argument passed to this function is a pointer to an Fts5Tokenizer object
         9953  +**   returned by an earlier call to xCreate().
         9954  +**
         9955  +**   The second argument indicates the reason that FTS5 is requesting
         9956  +**   tokenization of the supplied text. This is always one of the following
         9957  +**   four values:
         9958  +**
         9959  +**   <ul><li> <b>FTS5_TOKENIZE_DOCUMENT</b> - A document is being inserted into
         9960  +**            or removed from the FTS table. The tokenizer is being invoked to
         9961  +**            determine the set of tokens to add to (or delete from) the
         9962  +**            FTS index.
         9963  +**
         9964  +**       <li> <b>FTS5_TOKENIZE_QUERY</b> - A MATCH query is being executed 
         9965  +**            against the FTS index. The tokenizer is being called to tokenize 
         9966  +**            a bareword or quoted string specified as part of the query.
         9967  +**
         9968  +**       <li> <b>(FTS5_TOKENIZE_QUERY | FTS5_TOKENIZE_PREFIX)</b> - Same as
         9969  +**            FTS5_TOKENIZE_QUERY, except that the bareword or quoted string is
         9970  +**            followed by a "*" character, indicating that the last token
         9971  +**            returned by the tokenizer will be treated as a token prefix.
         9972  +**
         9973  +**       <li> <b>FTS5_TOKENIZE_AUX</b> - The tokenizer is being invoked to 
         9974  +**            satisfy an fts5_api.xTokenize() request made by an auxiliary
         9975  +**            function. Or an fts5_api.xColumnSize() request made by the same
         9976  +**            on a columnsize=0 database.  
         9977  +**   </ul>
         9978  +**
         9979  +**   For each token in the input string, the supplied callback xToken() must
         9980  +**   be invoked. The first argument to it should be a copy of the pointer
         9981  +**   passed as the second argument to xTokenize(). The third and fourth
         9982  +**   arguments are a pointer to a buffer containing the token text, and the
         9983  +**   size of the token in bytes. The 4th and 5th arguments are the byte offsets
         9984  +**   of the first byte of and first byte immediately following the text from
         9985  +**   which the token is derived within the input.
         9986  +**
         9987  +**   The second argument passed to the xToken() callback ("tflags") should
         9988  +**   normally be set to 0. The exception is if the tokenizer supports 
         9989  +**   synonyms. In this case see the discussion below for details.
         9990  +**
         9991  +**   FTS5 assumes the xToken() callback is invoked for each token in the 
         9992  +**   order that they occur within the input text.
         9993  +**
         9994  +**   If an xToken() callback returns any value other than SQLITE_OK, then
         9995  +**   the tokenization should be abandoned and the xTokenize() method should
         9996  +**   immediately return a copy of the xToken() return value. Or, if the
         9997  +**   input buffer is exhausted, xTokenize() should return SQLITE_OK. Finally,
         9998  +**   if an error occurs with the xTokenize() implementation itself, it
         9999  +**   may abandon the tokenization and return any error code other than
        10000  +**   SQLITE_OK or SQLITE_DONE.
        10001  +**
        10002  +** SYNONYM SUPPORT
        10003  +**
        10004  +**   Custom tokenizers may also support synonyms. Consider a case in which a
        10005  +**   user wishes to query for a phrase such as "first place". Using the 
        10006  +**   built-in tokenizers, the FTS5 query 'first + place' will match instances
        10007  +**   of "first place" within the document set, but not alternative forms
        10008  +**   such as "1st place". In some applications, it would be better to match
        10009  +**   all instances of "first place" or "1st place" regardless of which form
        10010  +**   the user specified in the MATCH query text.
        10011  +**
        10012  +**   There are several ways to approach this in FTS5:
        10013  +**
        10014  +**   <ol><li> By mapping all synonyms to a single token. In this case, the 
        10015  +**            In the above example, this means that the tokenizer returns the
        10016  +**            same token for inputs "first" and "1st". Say that token is in
        10017  +**            fact "first", so that when the user inserts the document "I won
        10018  +**            1st place" entries are added to the index for tokens "i", "won",
        10019  +**            "first" and "place". If the user then queries for '1st + place',
        10020  +**            the tokenizer substitutes "first" for "1st" and the query works
        10021  +**            as expected.
        10022  +**
        10023  +**       <li> By adding multiple synonyms for a single term to the FTS index.
        10024  +**            In this case, when tokenizing query text, the tokenizer may 
        10025  +**            provide multiple synonyms for a single term within the document.
        10026  +**            FTS5 then queries the index for each synonym individually. For
        10027  +**            example, faced with the query:
        10028  +**
        10029  +**   <codeblock>
        10030  +**     ... MATCH 'first place'</codeblock>
        10031  +**
        10032  +**            the tokenizer offers both "1st" and "first" as synonyms for the
        10033  +**            first token in the MATCH query and FTS5 effectively runs a query 
        10034  +**            similar to:
        10035  +**
        10036  +**   <codeblock>
        10037  +**     ... MATCH '(first OR 1st) place'</codeblock>
        10038  +**
        10039  +**            except that, for the purposes of auxiliary functions, the query
        10040  +**            still appears to contain just two phrases - "(first OR 1st)" 
        10041  +**            being treated as a single phrase.
        10042  +**
        10043  +**       <li> By adding multiple synonyms for a single term to the FTS index.
        10044  +**            Using this method, when tokenizing document text, the tokenizer
        10045  +**            provides multiple synonyms for each token. So that when a 
        10046  +**            document such as "I won first place" is tokenized, entries are
        10047  +**            added to the FTS index for "i", "won", "first", "1st" and
        10048  +**            "place".
        10049  +**
        10050  +**            This way, even if the tokenizer does not provide synonyms
        10051  +**            when tokenizing query text (it should not - to do would be
        10052  +**            inefficient), it doesn't matter if the user queries for 
        10053  +**            'first + place' or '1st + place', as there are entires in the
        10054  +**            FTS index corresponding to both forms of the first token.
        10055  +**   </ol>
        10056  +**
        10057  +**   Whether it is parsing document or query text, any call to xToken that
        10058  +**   specifies a <i>tflags</i> argument with the FTS5_TOKEN_COLOCATED bit
        10059  +**   is considered to supply a synonym for the previous token. For example,
        10060  +**   when parsing the document "I won first place", a tokenizer that supports
        10061  +**   synonyms would call xToken() 5 times, as follows:
        10062  +**
        10063  +**   <codeblock>
        10064  +**       xToken(pCtx, 0, "i",                      1,  0,  1);
        10065  +**       xToken(pCtx, 0, "won",                    3,  2,  5);
        10066  +**       xToken(pCtx, 0, "first",                  5,  6, 11);
        10067  +**       xToken(pCtx, FTS5_TOKEN_COLOCATED, "1st", 3,  6, 11);
        10068  +**       xToken(pCtx, 0, "place",                  5, 12, 17);
        10069  +**</codeblock>
        10070  +**
        10071  +**   It is an error to specify the FTS5_TOKEN_COLOCATED flag the first time
        10072  +**   xToken() is called. Multiple synonyms may be specified for a single token
        10073  +**   by making multiple calls to xToken(FTS5_TOKEN_COLOCATED) in sequence. 
        10074  +**   There is no limit to the number of synonyms that may be provided for a
        10075  +**   single token.
        10076  +**
        10077  +**   In many cases, method (1) above is the best approach. It does not add 
        10078  +**   extra data to the FTS index or require FTS5 to query for multiple terms,
        10079  +**   so it is efficient in terms of disk space and query speed. However, it
        10080  +**   does not support prefix queries very well. If, as suggested above, the
        10081  +**   token "first" is subsituted for "1st" by the tokenizer, then the query:
        10082  +**
        10083  +**   <codeblock>
        10084  +**     ... MATCH '1s*'</codeblock>
        10085  +**
        10086  +**   will not match documents that contain the token "1st" (as the tokenizer
        10087  +**   will probably not map "1s" to any prefix of "first").
        10088  +**
        10089  +**   For full prefix support, method (3) may be preferred. In this case, 
        10090  +**   because the index contains entries for both "first" and "1st", prefix
        10091  +**   queries such as 'fi*' or '1s*' will match correctly. However, because
        10092  +**   extra entries are added to the FTS index, this method uses more space
        10093  +**   within the database.
        10094  +**
        10095  +**   Method (2) offers a midpoint between (1) and (3). Using this method,
        10096  +**   a query such as '1s*' will match documents that contain the literal 
        10097  +**   token "1st", but not "first" (assuming the tokenizer is not able to
        10098  +**   provide synonyms for prefixes). However, a non-prefix query like '1st'
        10099  +**   will match against "1st" and "first". This method does not require
        10100  +**   extra disk space, as no extra entries are added to the FTS index. 
        10101  +**   On the other hand, it may require more CPU cycles to run MATCH queries,
        10102  +**   as separate queries of the FTS index are required for each synonym.
        10103  +**
        10104  +**   When using methods (2) or (3), it is important that the tokenizer only
        10105  +**   provide synonyms when tokenizing document text (method (2)) or query
        10106  +**   text (method (3)), not both. Doing so will not cause any errors, but is
        10107  +**   inefficient.
        10108  +*/
        10109  +typedef struct Fts5Tokenizer Fts5Tokenizer;
        10110  +typedef struct fts5_tokenizer fts5_tokenizer;
        10111  +struct fts5_tokenizer {
        10112  +  int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut);
        10113  +  void (*xDelete)(Fts5Tokenizer*);
        10114  +  int (*xTokenize)(Fts5Tokenizer*, 
        10115  +      void *pCtx,
        10116  +      int flags,            /* Mask of FTS5_TOKENIZE_* flags */
        10117  +      const char *pText, int nText, 
        10118  +      int (*xToken)(
        10119  +        void *pCtx,         /* Copy of 2nd argument to xTokenize() */
        10120  +        int tflags,         /* Mask of FTS5_TOKEN_* flags */
        10121  +        const char *pToken, /* Pointer to buffer containing token */
        10122  +        int nToken,         /* Size of token in bytes */
        10123  +        int iStart,         /* Byte offset of token within input text */
        10124  +        int iEnd            /* Byte offset of end of token within input text */
        10125  +      )
        10126  +  );
        10127  +};
        10128  +
        10129  +/* Flags that may be passed as the third argument to xTokenize() */
        10130  +#define FTS5_TOKENIZE_QUERY     0x0001
        10131  +#define FTS5_TOKENIZE_PREFIX    0x0002
        10132  +#define FTS5_TOKENIZE_DOCUMENT  0x0004
        10133  +#define FTS5_TOKENIZE_AUX       0x0008
        10134  +
        10135  +/* Flags that may be passed by the tokenizer implementation back to FTS5
        10136  +** as the third argument to the supplied xToken callback. */
        10137  +#define FTS5_TOKEN_COLOCATED    0x0001      /* Same position as prev. token */
        10138  +
        10139  +/*
        10140  +** END OF CUSTOM TOKENIZERS
        10141  +*************************************************************************/
        10142  +
        10143  +/*************************************************************************
        10144  +** FTS5 EXTENSION REGISTRATION API
        10145  +*/
        10146  +typedef struct fts5_api fts5_api;
        10147  +struct fts5_api {
        10148  +  int iVersion;                   /* Currently always set to 2 */
        10149  +
        10150  +  /* Create a new tokenizer */
        10151  +  int (*xCreateTokenizer)(
        10152  +    fts5_api *pApi,
        10153  +    const char *zName,
        10154  +    void *pContext,
        10155  +    fts5_tokenizer *pTokenizer,
        10156  +    void (*xDestroy)(void*)
        10157  +  );
        10158  +
        10159  +  /* Find an existing tokenizer */
        10160  +  int (*xFindTokenizer)(
        10161  +    fts5_api *pApi,
        10162  +    const char *zName,
        10163  +    void **ppContext,
        10164  +    fts5_tokenizer *pTokenizer
        10165  +  );
        10166  +
        10167  +  /* Create a new auxiliary function */
        10168  +  int (*xCreateFunction)(
        10169  +    fts5_api *pApi,
        10170  +    const char *zName,
        10171  +    void *pContext,
        10172  +    fts5_extension_function xFunction,
        10173  +    void (*xDestroy)(void*)
        10174  +  );
        10175  +};
        10176  +
        10177  +/*
        10178  +** END OF REGISTRATION API
        10179  +*************************************************************************/
        10180  +
        10181  +#ifdef __cplusplus
        10182  +}  /* end of the 'extern "C"' block */
        10183  +#endif
        10184  +
        10185  +#endif /* _FTS5_H */
        10186  +
        10187  +
        10188  +/******** End of fts5.h *********/